Browse Source

Make a setter for defaultSave path in qbtsession and do some other optimizations to avoid potential pitfalls.

adaptive-webui-19844
sledgehammer999 12 years ago
parent
commit
3e979931d0
  1. 3
      src/addnewtorrentdialog.cpp
  2. 14
      src/qtlibtorrent/qbtsession.cpp
  3. 3
      src/qtlibtorrent/qbtsession.h

3
src/addnewtorrentdialog.cpp

@ -596,7 +596,6 @@ void AddNewTorrentDialog::on_buttonBox_accepted()
pref.useAdditionDialog(!ui->never_show_cb->isChecked()); pref.useAdditionDialog(!ui->never_show_cb->isChecked());
if (ui->default_save_path_cb->isChecked()) { if (ui->default_save_path_cb->isChecked()) {
pref.setSavePath(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString()); pref.setSavePath(ui->save_path_combo->itemData(ui->save_path_combo->currentIndex()).toString());
pref.sync(); QBtSession::instance()->setDefaultSavePath(pref.getSavePath());
QBtSession::instance()->configureSession();
} }
} }

14
src/qtlibtorrent/qbtsession.cpp

@ -1773,7 +1773,13 @@ void QBtSession::addTorrentsFromScanFolder(QStringList &pathList) {
} }
} }
void QBtSession::setDefaultTempPath(QString temppath) { void QBtSession::setDefaultSavePath(const QString &savepath) {
if (defaultSavePath == savepath || savepath.isEmpty())
return;
defaultSavePath = QDir::fromNativeSeparators(savepath);
}
void QBtSession::setDefaultTempPath(const QString &temppath) {
if (defaultTempPath == temppath) if (defaultTempPath == temppath)
return; return;
if (temppath.isEmpty()) { if (temppath.isEmpty()) {
@ -1799,13 +1805,13 @@ void QBtSession::setDefaultTempPath(QString temppath) {
QTorrentHandle h = QTorrentHandle(*torrentIT); QTorrentHandle h = QTorrentHandle(*torrentIT);
if (!h.is_valid()) continue; if (!h.is_valid()) continue;
if (!h.is_seed()) { if (!h.is_seed()) {
QString torrent_tmp_path = temppath.replace("\\", "/"); QString torrent_tmp_path = QDir::fromNativeSeparators(temppath);
qDebug("Moving torrent to its temp save path: %s", qPrintable(torrent_tmp_path)); qDebug("Moving torrent to its temp save path: %s", qPrintable(fsutils::toDisplayPath(torrent_tmp_path)));
h.move_storage(torrent_tmp_path); h.move_storage(torrent_tmp_path);
} }
} }
} }
defaultTempPath = temppath; defaultTempPath = QDir::fromNativeSeparators(temppath);
} }
void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) { void QBtSession::appendqBextensionToTorrent(const QTorrentHandle &h, bool append) {

3
src/qtlibtorrent/qbtsession.h

@ -147,7 +147,8 @@ public slots:
void setDHTPort(int dht_port); void setDHTPort(int dht_port);
void setProxySettings(libtorrent::proxy_settings proxySettings); void setProxySettings(libtorrent::proxy_settings proxySettings);
void setSessionSettings(const libtorrent::session_settings &sessionSettings); void setSessionSettings(const libtorrent::session_settings &sessionSettings);
void setDefaultTempPath(QString temppath); void setDefaultSavePath(const QString &savepath);
void setDefaultTempPath(const QString &temppath);
void setAppendLabelToSavePath(bool append); void setAppendLabelToSavePath(bool append);
void appendLabelToTorrentSavePath(const QTorrentHandle &h); void appendLabelToTorrentSavePath(const QTorrentHandle &h);
void changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label); void changeLabelInTorrentSavePath(const QTorrentHandle &h, QString old_label, QString new_label);

Loading…
Cancel
Save