Browse Source

Torrent addition dialog size/pos are now remembered correctly

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
cf65e4d77d
  1. 15
      src/bittorrent.cpp
  2. 19
      src/torrentadditiondlg.cpp
  3. 1
      src/torrentadditiondlg.h

15
src/bittorrent.cpp

@ -1065,6 +1065,21 @@ QTorrentHandle Bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
} }
return h; return h;
} }
// Check number of files
if(t->num_files() < 1) {
addConsoleMessage(tr("Error: The torrent %1 does not contain any file.").arg(misc::toQStringU(t->name())));
if(fromScanDir) {
// Delete torrent from scan dir
QFile::remove(file);
} else {
if(!from_url.isNull()) {
// If download from url, remove temp file
QFile::remove(file);
}
}
return h;
}
// Actually add the torrent
QString root_folder = misc::truncateRootFolder(t); QString root_folder = misc::truncateRootFolder(t);
add_torrent_params p; add_torrent_params p;
//Getting fast resume data if existing //Getting fast resume data if existing

19
src/torrentadditiondlg.cpp

@ -30,7 +30,7 @@
#include "torrentadditiondlg.h" #include "torrentadditiondlg.h"
torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession) : QDialog((QWidget*)parent), old_label("") { torrentAdditionDialog::torrentAdditionDialog(GUI *parent, Bittorrent* _BTSession) : QDialog((QWidget*)parent), old_label(""), hidden_height(0) {
setupUi(this); setupUi(this);
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&))); connect(this, SIGNAL(torrentPaused(QTorrentHandle&)), parent->getTransferList(), SLOT(pauseTorrent(QTorrentHandle&)));
@ -91,15 +91,17 @@ void torrentAdditionDialog::readSettings() {
} }
void torrentAdditionDialog::saveSettings() { void torrentAdditionDialog::saveSettings() {
if(is_magnet || t->num_files() <= 1) return;
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
QStringList contentColsWidths; if(!is_magnet && t->num_files() > 1) {
// -1 because we hid PROGRESS column QStringList contentColsWidths;
for(int i=0; i<PropListModel->columnCount()-1; ++i) { // -1 because we hid PROGRESS column
contentColsWidths << QString::number(torrentContentList->columnWidth(i)); for(int i=0; i<PropListModel->columnCount()-1; ++i) {
contentColsWidths << QString::number(torrentContentList->columnWidth(i));
}
settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), contentColsWidths);
} }
settings.setValue(QString::fromUtf8("TorrentAdditionDlg/filesColsWidth"), contentColsWidths); settings.setValue("TorrentAdditionDlg/size", size()+QSize(0, hidden_height));
settings.setValue("TorrentAdditionDlg/size", size()); qDebug("pos: (%d, %d)", pos().x(), pos().y());
settings.setValue("TorrentAdditionDlg/pos", pos()); settings.setValue("TorrentAdditionDlg/pos", pos());
} }
@ -110,7 +112,6 @@ void torrentAdditionDialog::renameTorrentNameInModel(QString file_path) {
} }
void torrentAdditionDialog::hideTorrentContent() { void torrentAdditionDialog::hideTorrentContent() {
int hidden_height = 0;
// Disable useless widgets // Disable useless widgets
hidden_height += torrentContentList->height(); hidden_height += torrentContentList->height();
torrentContentList->setVisible(false); torrentContentList->setVisible(false);

1
src/torrentadditiondlg.h

@ -102,6 +102,7 @@ private:
boost::intrusive_ptr<torrent_info> t; boost::intrusive_ptr<torrent_info> t;
QStringList files_path; QStringList files_path;
bool is_magnet; bool is_magnet;
int hidden_height;
}; };
#endif #endif

Loading…
Cancel
Save