diff --git a/src/app/application.cpp b/src/app/application.cpp index eedc9e170..a289c8e36 100644 --- a/src/app/application.cpp +++ b/src/app/application.cpp @@ -366,7 +366,7 @@ void Application::allTorrentsFinished() // do nothing & skip confirm } else { - if (!ShutdownConfirmDlg::askForConfirmation(action)) return; + if (!ShutdownConfirmDlg::askForConfirmation(m_window, action)) return; } #endif // DISABLE_GUI @@ -409,7 +409,7 @@ void Application::processParams(const QStringList ¶ms) param = param.trimmed(); // Process strings indicating options specified by the user. - + if (param.startsWith(QLatin1String("@savePath="))) { torrentParams.savePath = param.mid(10); continue; diff --git a/src/base/preferences.cpp b/src/base/preferences.cpp index 0c55373d6..0d4574a6f 100644 --- a/src/base/preferences.cpp +++ b/src/base/preferences.cpp @@ -1127,7 +1127,6 @@ void Preferences::setMainLastDir(const QString &path) setValue("MainWindowLastDir", path); } -#ifndef DISABLE_GUI QSize Preferences::getPrefSize(const QSize& defaultSize) const { return value("Preferences/State/size", defaultSize).toSize(); @@ -1137,17 +1136,6 @@ void Preferences::setPrefSize(const QSize &size) { setValue("Preferences/State/size", size); } -#endif - -QPoint Preferences::getPrefPos() const -{ - return value("Preferences/State/pos").toPoint(); -} - -void Preferences::setPrefPos(const QPoint &pos) -{ - setValue("Preferences/State/pos", pos); -} QStringList Preferences::getPrefHSplitterSizes() const { @@ -1219,14 +1207,14 @@ void Preferences::setPropTrackerListState(const QByteArray &state) setValue("TorrentProperties/Trackers/qt5/TrackerListState", state); } -QByteArray Preferences::getRssGeometry() const +QSize Preferences::getRssGeometrySize(const QSize &defaultSize) const { - return value("RssFeedDownloader/geometry").toByteArray(); + return value("RssFeedDownloader/geometrySize", defaultSize).toSize(); } -void Preferences::setRssGeometry(const QByteArray &geometry) +void Preferences::setRssGeometrySize(const QSize &geometry) { - setValue("RssFeedDownloader/geometry", geometry); + setValue("RssFeedDownloader/geometrySize", geometry); } QByteArray Preferences::getRssHSplitterSizes() const diff --git a/src/base/preferences.h b/src/base/preferences.h index 14eef4a38..0620f5f48 100644 --- a/src/base/preferences.h +++ b/src/base/preferences.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -274,12 +275,8 @@ public: void setMainVSplitterState(const QByteArray &state); QString getMainLastDir() const; void setMainLastDir(const QString &path); -#ifndef DISABLE_GUI QSize getPrefSize(const QSize &defaultSize) const; void setPrefSize(const QSize &size); -#endif - QPoint getPrefPos() const; - void setPrefPos(const QPoint &pos); QStringList getPrefHSplitterSizes() const; void setPrefHSplitterSizes(const QStringList &sizes); QByteArray getPeerListState() const; @@ -294,8 +291,8 @@ public: void setPropVisible(const bool visible); QByteArray getPropTrackerListState() const; void setPropTrackerListState(const QByteArray &state); - QByteArray getRssGeometry() const; - void setRssGeometry(const QByteArray &geometry); + QSize getRssGeometrySize(const QSize &defaultSize) const; + void setRssGeometrySize(const QSize &geometry); QByteArray getRssHSplitterSizes() const; void setRssHSplitterSizes(const QByteArray &sizes); QStringList getRssOpenFolders() const; diff --git a/src/base/utils/misc.cpp b/src/base/utils/misc.cpp index 79871e80b..48fad0147 100644 --- a/src/base/utils/misc.cpp +++ b/src/base/utils/misc.cpp @@ -219,21 +219,15 @@ void Utils::Misc::shutdownComputer(const ShutdownDialogAction &action) } #ifndef DISABLE_GUI -// Get screen center -QPoint Utils::Misc::screenCenter(QWidget *win) +QPoint Utils::Misc::screenCenter(const QWidget *w) { - int scrn = 0; - const QWidget *w = win->window(); + // Returns the QPoint which the widget will be placed center on screen (where parent resides) - if (w) - scrn = QApplication::desktop()->screenNumber(w); - else if (QApplication::desktop()->isVirtualDesktop()) - scrn = QApplication::desktop()->screenNumber(QCursor::pos()); - else - scrn = QApplication::desktop()->screenNumber(win); - - QRect desk(QApplication::desktop()->availableGeometry(scrn)); - return QPoint((desk.width() - win->frameGeometry().width()) / 2, (desk.height() - win->frameGeometry().height()) / 2); + QWidget *parent = w->parentWidget(); + QDesktopWidget *desktop = QApplication::desktop(); + int scrn = desktop->screenNumber(parent); // fallback to `primaryScreen` when parent is invalid + QRect r = desktop->availableGeometry(scrn); + return QPoint(r.x() + (r.width() - w->frameSize().width()) / 2, r.y() + (r.height() - w->frameSize().height()) / 2); } #endif diff --git a/src/base/utils/misc.h b/src/base/utils/misc.h index 856ca52b2..cf733e9a7 100644 --- a/src/base/utils/misc.h +++ b/src/base/utils/misc.h @@ -102,7 +102,7 @@ namespace Utils void openPath(const QString& absolutePath); void openFolderSelect(const QString& absolutePath); - QPoint screenCenter(QWidget *win); + QPoint screenCenter(const QWidget *w); QSize smallIconSize(); QSize largeIconSize(); #endif diff --git a/src/gui/addnewtorrentdialog.cpp b/src/gui/addnewtorrentdialog.cpp index 95b492dc7..e0dc803e7 100644 --- a/src/gui/addnewtorrentdialog.cpp +++ b/src/gui/addnewtorrentdialog.cpp @@ -63,7 +63,6 @@ const QString KEY_DEFAULTCATEGORY = SETTINGS_KEY("DefaultCategory"); const QString KEY_TREEHEADERSTATE = SETTINGS_KEY("TreeHeaderState"); const QString KEY_WIDTH = SETTINGS_KEY("Width"); const QString KEY_EXPANDED = SETTINGS_KEY("Expanded"); -const QString KEY_POSITION = SETTINGS_KEY("Position"); const QString KEY_TOPLEVEL = SETTINGS_KEY("TopLevel"); const QString KEY_SAVEPATHHISTORY = SETTINGS_KEY("SavePathHistory"); @@ -85,7 +84,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP , m_oldIndex(0) , m_torrentParams(inParams) { - // TODO: set dialog file properties using m_torrentParams.filePriorities + // TODO: set dialog file properties using m_torrentParams.filePriorities ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); ui->lblMetaLoading->setVisible(false); @@ -99,7 +98,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP ui->startTorrentCheckBox->setChecked(true); else ui->startTorrentCheckBox->setChecked(!session->isAddTorrentPaused()); - + ui->comboTTM->blockSignals(true); // the TreeView size isn't correct if the slot does it job at this point ui->comboTTM->setCurrentIndex(!session->isAutoTMMDisabledByDefault()); ui->comboTTM->blockSignals(false); @@ -114,7 +113,7 @@ AddNewTorrentDialog::AddNewTorrentDialog(const BitTorrent::AddTorrentParams &inP ui->createSubfolderCheckBox->setChecked(false); else ui->createSubfolderCheckBox->setChecked(session->isCreateTorrentSubfolder()); - + ui->skipCheckingCheckBox->setChecked(m_torrentParams.skipChecking); ui->doNotDeleteTorrentCheckBox->setVisible(TorrentFileGuard::autoDeleteMode() != TorrentFileGuard::Never); @@ -179,11 +178,10 @@ void AddNewTorrentDialog::loadState() { m_headerState = settings()->loadValue(KEY_TREEHEADERSTATE).toByteArray(); int width = settings()->loadValue(KEY_WIDTH, -1).toInt(); - if (width >= 0) { - QRect geo = geometry(); - geo.setWidth(width); - setGeometry(geo); - } + QSize geo = size(); + geo.setWidth(width); + resize(geo); + ui->adv_button->setChecked(settings()->loadValue(KEY_EXPANDED).toBool()); } @@ -191,7 +189,6 @@ void AddNewTorrentDialog::saveState() { if (m_contentModel) settings()->storeValue(KEY_TREEHEADERSTATE, ui->contentTreeView->header()->saveState()); - settings()->storeValue(KEY_POSITION, pos().y()); settings()->storeValue(KEY_WIDTH, width()); settings()->storeValue(KEY_EXPANDED, ui->adv_button->isChecked()); } @@ -235,13 +232,13 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) m_filePath = torrentPath; if (!QFile::exists(m_filePath)) { - MessageBoxRaised::critical(0, tr("I/O Error"), tr("The torrent file '%1' does not exist.").arg(Utils::Fs::toNativePath(m_filePath))); + MessageBoxRaised::critical(this, tr("I/O Error"), tr("The torrent file '%1' does not exist.").arg(Utils::Fs::toNativePath(m_filePath))); return false; } QFileInfo fileinfo(m_filePath); if (!fileinfo.isReadable()) { - MessageBoxRaised::critical(0, tr("I/O Error"), tr("The torrent file '%1' cannot be read from the disk. Probably you don't have enough permissions.").arg(Utils::Fs::toNativePath(m_filePath))); + MessageBoxRaised::critical(this, tr("I/O Error"), tr("The torrent file '%1' cannot be read from the disk. Probably you don't have enough permissions.").arg(Utils::Fs::toNativePath(m_filePath))); return false; } @@ -249,7 +246,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) QString error; m_torrentInfo = BitTorrent::TorrentInfo::loadFromFile(m_filePath, error); if (!m_torrentInfo.isValid()) { - MessageBoxRaised::critical(0, tr("Invalid torrent"), tr("Failed to load the torrent: %1.\nError: %2", "Don't remove the '\n' characters. They insert a newline.").arg(Utils::Fs::toNativePath(m_filePath)).arg(error)); + MessageBoxRaised::critical(this, tr("Invalid torrent"), tr("Failed to load the torrent: %1.\nError: %2", "Don't remove the '\n' characters. They insert a newline.").arg(Utils::Fs::toNativePath(m_filePath)).arg(error)); return false; } @@ -261,16 +258,16 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash); if (torrent) { if (torrent->isPrivate() || m_torrentInfo.isPrivate()) { - MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok); + MessageBoxRaised::critical(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok); } else { torrent->addTrackers(m_torrentInfo.trackers()); torrent->addUrlSeeds(m_torrentInfo.urlSeeds()); - MessageBoxRaised::information(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers were merged."), QMessageBox::Ok); + MessageBoxRaised::information(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers were merged."), QMessageBox::Ok); } } else { - MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding state."), QMessageBox::Ok); + MessageBoxRaised::critical(this, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding state."), QMessageBox::Ok); } return false; } @@ -284,7 +281,7 @@ bool AddNewTorrentDialog::loadTorrent(const QString &torrentPath) bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) { if (!magnetUri.isValid()) { - MessageBoxRaised::critical(0, tr("Invalid magnet link"), tr("This magnet link was not recognized")); + MessageBoxRaised::critical(this, tr("Invalid magnet link"), tr("This magnet link was not recognized")); return false; } @@ -295,16 +292,16 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) BitTorrent::TorrentHandle *const torrent = BitTorrent::Session::instance()->findTorrent(m_hash); if (torrent) { if (torrent->isPrivate()) { - MessageBoxRaised::critical(0, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok); + MessageBoxRaised::critical(this, tr("Already in download list"), tr("Torrent is already in download list. Trackers weren't merged because it is a private torrent."), QMessageBox::Ok); } else { torrent->addTrackers(magnetUri.trackers()); torrent->addUrlSeeds(magnetUri.urlSeeds()); - MessageBoxRaised::information(0, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok); + MessageBoxRaised::information(this, tr("Already in download list"), tr("Magnet link is already in download list. Trackers were merged."), QMessageBox::Ok); } } else { - MessageBoxRaised::critical(0, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok); + MessageBoxRaised::critical(this, tr("Cannot add torrent"), tr("Cannot add this torrent. Perhaps it is already in adding."), QMessageBox::Ok); } return false; } @@ -317,8 +314,6 @@ bool AddNewTorrentDialog::loadMagnet(const BitTorrent::MagnetUri &magnetUri) setupTreeview(); TMMChanged(ui->comboTTM->currentIndex()); - // Set dialog position - setdialogPosition(); BitTorrent::Session::instance()->loadMetadata(magnetUri); setMetadataProgressIndicator(true, tr("Retrieving metadata...")); @@ -575,28 +570,6 @@ void AddNewTorrentDialog::renameSelectedFile() } } -void AddNewTorrentDialog::setdialogPosition() -{ - // In macOS, AddNewTorrentDialog is a sheet, not a window. Moving it - // causes very bad things to happen, especially if AddNewTorrentDialog is - // on a secondary monitor. -#ifndef Q_OS_MAC - qApp->processEvents(); - QPoint center(Utils::Misc::screenCenter(this)); - // Adjust y - int y = settings()->loadValue(KEY_POSITION, -1).toInt(); - if (y >= 0) { - center.setY(y); - } - else { - center.ry() -= 120; - if (center.y() < 0) - center.setY(0); - } - move(center); -#endif -} - void AddNewTorrentDialog::populateSavePathComboBox() { QString defSavePath = BitTorrent::Session::instance()->defaultSavePath(); @@ -608,7 +581,7 @@ void AddNewTorrentDialog::populateSavePathComboBox() foreach (const QString &savePath, settings()->loadValue(KEY_SAVEPATHHISTORY).toStringList()) if (QDir(savePath) != defaultSaveDir) ui->savePathComboBox->addItem(Utils::Fs::toNativePath(savePath), savePath); - + if (!m_torrentParams.savePath.isEmpty()) setSavePath(m_torrentParams.savePath); } @@ -711,7 +684,7 @@ void AddNewTorrentDialog::updateMetadata(const BitTorrent::TorrentInfo &info) disconnect(this, SLOT(updateMetadata(BitTorrent::TorrentInfo))); if (!info.isValid()) { - MessageBoxRaised::critical(0, tr("I/O Error"), ("Invalid metadata.")); + MessageBoxRaised::critical(this, tr("I/O Error"), ("Invalid metadata.")); setMetadataProgressIndicator(false, tr("Invalid metadata")); return; } @@ -772,13 +745,11 @@ void AddNewTorrentDialog::setupTreeview() updateDiskSpaceLabel(); showAdvancedSettings(settings()->loadValue(KEY_EXPANDED, false).toBool()); - // Set dialog position - setdialogPosition(); } void AddNewTorrentDialog::handleDownloadFailed(const QString &url, const QString &reason) { - MessageBoxRaised::critical(0, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason)); + MessageBoxRaised::critical(this, tr("Download Error"), QString("Cannot download '%1': %2").arg(url).arg(reason)); this->deleteLater(); } diff --git a/src/gui/addnewtorrentdialog.h b/src/gui/addnewtorrentdialog.h index 35329b89e..7d9a153d2 100644 --- a/src/gui/addnewtorrentdialog.h +++ b/src/gui/addnewtorrentdialog.h @@ -75,7 +75,6 @@ private slots: void updateDiskSpaceLabel(); void onSavePathChanged(int); void renameSelectedFile(); - void setdialogPosition(); void updateMetadata(const BitTorrent::TorrentInfo &info); void browseButton_clicked(); void handleDownloadFailed(const QString &url, const QString &reason); diff --git a/src/gui/autoexpandabledialog.cpp b/src/gui/autoexpandabledialog.cpp index ed42eaa7c..1194e1ab7 100644 --- a/src/gui/autoexpandabledialog.cpp +++ b/src/gui/autoexpandabledialog.cpp @@ -72,7 +72,6 @@ void AutoExpandableDialog::showEvent(QShowEvent *e) { // NOTE: For some strange reason QFontMetrics gets more accurate // when called from showEvent. Only 6 symbols off instead of 11 symbols off. int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4; - int screenW = QApplication::desktop()->width() / 4; int wd = textW; if (!windowTitle().isEmpty()) { @@ -87,35 +86,9 @@ void AutoExpandableDialog::showEvent(QShowEvent *e) { wd = _w; } - // Now resize the dialog to fit the contents - // Maximum value is whichever is smaller: - // 1. screen width / 4 - // 2. max width of text from either of: label, title, textedit + // max width of text from either of: label, title, textedit // If the value is less than dialog default size default size is used - wd = textW < screenW ? textW : screenW; if (wd > width()) - resize(width() - ui->horizontalLayout->sizeHint().width() + wd, height()); - - // Use old dialog behavior: prohibit resizing the dialog - setFixedHeight(height()); - - // Update geometry: center on screen - QDesktopWidget *desk = QApplication::desktop(); - MainWindow *wnd = qobject_cast(QApplication::activeWindow()); - QPoint p = QCursor::pos(); - - int screenNum = 0; - if (wnd == 0) - screenNum = desk->screenNumber(p); - else if (!wnd->isHidden()) - screenNum = desk->screenNumber(wnd); - else - screenNum = desk->screenNumber(p); - - QRect screenRes = desk->screenGeometry(screenNum); - - QRect geom = geometry(); - geom.moveCenter(QPoint(screenRes.width() / 2, screenRes.height() / 2)); - setGeometry(geom); + resize(width() - ui->verticalLayout->sizeHint().width() + wd, height()); } diff --git a/src/gui/autoexpandabledialog.h b/src/gui/autoexpandabledialog.h index eab0e89fc..39950e45c 100644 --- a/src/gui/autoexpandabledialog.h +++ b/src/gui/autoexpandabledialog.h @@ -41,9 +41,9 @@ class AutoExpandableDialog; class AutoExpandableDialog : public QDialog { Q_OBJECT - + public: - explicit AutoExpandableDialog(QWidget *parent = 0); + explicit AutoExpandableDialog(QWidget *parent); ~AutoExpandableDialog(); static QString getText(QWidget *parent, const QString& title, const QString& label, @@ -52,7 +52,7 @@ public: protected: void showEvent(QShowEvent *e); - + private: Ui::AutoExpandableDialog *ui; }; diff --git a/src/gui/autoexpandabledialog.ui b/src/gui/autoexpandabledialog.ui index e70454216..43d7daa09 100644 --- a/src/gui/autoexpandabledialog.ui +++ b/src/gui/autoexpandabledialog.ui @@ -7,79 +7,23 @@ 0 0 222 - 94 + 105 - - - 0 - 0 - - - - Dialog - - - - Qt::Vertical - - - - 20 - 40 - - - + - - - - - - - - + - - - - - - + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - diff --git a/src/gui/bandwidth_limit.ui b/src/gui/bandwidth_limit.ui index 6fd700bef..b10bee62d 100644 --- a/src/gui/bandwidth_limit.ui +++ b/src/gui/bandwidth_limit.ui @@ -10,9 +10,6 @@ 83 - - Bandwidth allocation - @@ -25,9 +22,6 @@ - - - 65535 @@ -40,9 +34,6 @@ - - Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok diff --git a/src/gui/cookiesdialog.cpp b/src/gui/cookiesdialog.cpp index 1a1c03156..cec21f8f2 100644 --- a/src/gui/cookiesdialog.cpp +++ b/src/gui/cookiesdialog.cpp @@ -35,7 +35,7 @@ #include "ui_cookiesdialog.h" #define SETTINGS_KEY(name) "CookiesDialog/" name -const QString KEY_GEOMETRY = SETTINGS_KEY("Geometry"); +const QString KEY_SIZE = SETTINGS_KEY("Size"); const QString KEY_COOKIESVIEWSTATE = SETTINGS_KEY("CookiesViewState"); CookiesDialog::CookiesDialog(QWidget *parent) @@ -55,14 +55,14 @@ CookiesDialog::CookiesDialog(QWidget *parent) m_cookiesModel->index(0, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); - restoreGeometry(SettingsStorage::instance()->loadValue(KEY_GEOMETRY).toByteArray()); + resize(SettingsStorage::instance()->loadValue(KEY_SIZE, size()).toSize()); m_ui->treeView->header()->restoreState( SettingsStorage::instance()->loadValue(KEY_COOKIESVIEWSTATE).toByteArray()); } CookiesDialog::~CookiesDialog() { - SettingsStorage::instance()->storeValue(KEY_GEOMETRY, saveGeometry()); + SettingsStorage::instance()->storeValue(KEY_SIZE, size()); SettingsStorage::instance()->storeValue( KEY_COOKIESVIEWSTATE, m_ui->treeView->header()->saveState()); delete m_ui; diff --git a/src/gui/deletionconfirmationdlg.h b/src/gui/deletionconfirmationdlg.h index a6f21aa4d..37e7acde1 100644 --- a/src/gui/deletionconfirmationdlg.h +++ b/src/gui/deletionconfirmationdlg.h @@ -54,7 +54,6 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { lbl_warn->setFixedWidth(lbl_warn->height()); rememberBtn->setIcon(GuiIconProvider::instance()->getIcon("object-locked")); - move(Utils::Misc::screenCenter(this)); checkPermDelete->setChecked(defaultDeleteFiles || Preferences::instance()->deleteTorrentFilesAsDefault()); connect(checkPermDelete, SIGNAL(clicked()), this, SLOT(updateRememberButtonState())); buttonBox->button(QDialogButtonBox::Cancel)->setFocus(); @@ -64,8 +63,8 @@ class DeletionConfirmationDlg : public QDialog, private Ui::confirmDeletionDlg { return checkPermDelete->isChecked(); } - static bool askForDeletionConfirmation(bool& deleteLocalFiles, const int& size, const QString& name) { - DeletionConfirmationDlg dlg(NULL, size, name, deleteLocalFiles); + static bool askForDeletionConfirmation(QWidget *parent, bool& deleteLocalFiles, const int& size, const QString& name) { + DeletionConfirmationDlg dlg(parent, size, name, deleteLocalFiles); if (dlg.exec() == QDialog::Accepted) { deleteLocalFiles = dlg.shouldDeleteLocalFiles(); return true; diff --git a/src/gui/downloadfromurldlg.h b/src/gui/downloadfromurldlg.h index eb2f87616..cd05aeb17 100644 --- a/src/gui/downloadfromurldlg.h +++ b/src/gui/downloadfromurldlg.h @@ -47,7 +47,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ setupUi(this); setAttribute(Qt::WA_DeleteOnClose); setModal(true); - show(); + // Paste clipboard if there is an URL in it QString clip_txt = qApp->clipboard()->text(); QStringList clip_txt_list = clip_txt.split(QString::fromUtf8("\n")); @@ -71,6 +71,8 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ } if (clip_txt_list_cleaned.size() > 0) textUrls->setText(clip_txt_list_cleaned.join("\n")); + + show(); } ~downloadFromURL() {} @@ -93,7 +95,7 @@ class downloadFromURL : public QDialog, private Ui::downloadFromURL{ } } if (!url_list_cleaned.size()) { - QMessageBox::warning(0, tr("No URL entered"), tr("Please type at least one URL.")); + QMessageBox::warning(this, tr("No URL entered"), tr("Please type at least one URL.")); return; } emit urlsReadyToBeDownloaded(url_list_cleaned); diff --git a/src/gui/downloadfromurldlg.ui b/src/gui/downloadfromurldlg.ui index 1cf95097f..a701e7f99 100644 --- a/src/gui/downloadfromurldlg.ui +++ b/src/gui/downloadfromurldlg.ui @@ -15,21 +15,17 @@ - - - - - - 75 - true - - - - Add torrent links - - - - + + + + 75 + true + + + + Add torrent links + + @@ -43,19 +39,13 @@ - - - 16777215 - 17 - - true - One per line (HTTP links, Magnet links and info-hashes are supported) + One link per line (HTTP links, Magnet links and info-hashes are supported) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index 7af04034c..314d14455 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -385,7 +385,7 @@ MainWindow::MainWindow(QWidget *parent) qDebug("GUI Built"); #ifdef Q_OS_WIN if (!pref->neverCheckFileAssoc() && (!Preferences::isTorrentFileAssocSet() || !Preferences::isMagnetLinkAssocSet())) { - if (QMessageBox::question(0, tr("Torrent file association"), + if (QMessageBox::question(this, tr("Torrent file association"), tr("qBittorrent is not the default application to open torrent files or Magnet links.\nDo you want to associate qBittorrent to torrent files and Magnet links?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes) { Preferences::setTorrentFileAssoc(true); @@ -841,7 +841,7 @@ void MainWindow::askRecursiveTorrentDownloadConfirmation(BitTorrent::TorrentHand if (pref->recursiveDownloadDisabled()) return; // Get Torrent name QString torrentName = torrent->name(); - QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrentName)); + QMessageBox confirmBox(QMessageBox::Question, tr("Recursive download confirmation"), tr("The torrent '%1' contains torrent files, do you want to proceed with their download?").arg(torrentName), QMessageBox::NoButton, this); QPushButton *yes = confirmBox.addButton(tr("Yes"), QMessageBox::YesRole); /*QPushButton *no = */ confirmBox.addButton(tr("No"), QMessageBox::NoRole); QPushButton *never = confirmBox.addButton(tr("Never"), QMessageBox::NoRole); @@ -862,10 +862,12 @@ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const void MainWindow::on_actionSetGlobalUploadLimit_triggered() { qDebug() << Q_FUNC_INFO; + BitTorrent::Session *const session = BitTorrent::Session::instance(); bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); + this, &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); + if (ok) { qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.); session->setUploadSpeedLimit(newLimit); @@ -875,10 +877,12 @@ void MainWindow::on_actionSetGlobalUploadLimit_triggered() void MainWindow::on_actionSetGlobalDownloadLimit_triggered() { qDebug() << Q_FUNC_INFO; + BitTorrent::Session *const session = BitTorrent::Session::instance(); bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); + this, &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); + if (ok) { qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.); session->setDownloadSpeedLimit(newLimit); @@ -1164,8 +1168,9 @@ void MainWindow::on_actionOpen_triggered() // Open File Open Dialog // Note: it is possible to select more than one file const QStringList pathsList = - QFileDialog::getOpenFileNames(0, tr("Open Torrent Files"), pref->getMainLastDir(), + QFileDialog::getOpenFileNames(this, tr("Open Torrent Files"), pref->getMainLastDir(), tr("Torrent Files") + " (*.torrent)"); + const bool useTorrentAdditionDialog = AddNewTorrentDialog::isEnabled(); if (!pathsList.isEmpty()) { foreach (QString file, pathsList) { diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index 2c2ab35d8..c94f8be7d 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -52,7 +52,6 @@ class TransferListFiltersWidget; class PropertiesWidget; class StatusBar; class TorrentCreatorDlg; -class downloadFromURL; class LineEdit; class ExecutionLog; class PowerManagement; diff --git a/src/gui/optionsdlg.cpp b/src/gui/optionsdlg.cpp index d184d4736..ebef4073c 100644 --- a/src/gui/optionsdlg.cpp +++ b/src/gui/optionsdlg.cpp @@ -357,7 +357,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) m_ui->advPageLayout->addWidget(advancedSettings); connect(advancedSettings, SIGNAL(settingsChanged()), this, SLOT(enableApplyButton())); - // Adapt size show(); loadWindowState(); } @@ -404,14 +403,9 @@ void OptionsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previo void OptionsDialog::loadWindowState() { const Preferences* const pref = Preferences::instance(); - resize(pref->getPrefSize(sizeFittingScreen())); - QPoint p = pref->getPrefPos(); - QRect scr_rect = qApp->desktop()->screenGeometry(); - if (!p.isNull() && scr_rect.contains(p)) - move(p); - // Load slider size + + resize(pref->getPrefSize(this->size())); const QStringList sizes_str = pref->getPrefHSplitterSizes(); - // Splitter size QList sizes; if (sizes_str.size() == 2) { sizes << sizes_str.first().toInt(); @@ -427,8 +421,10 @@ void OptionsDialog::loadWindowState() void OptionsDialog::saveWindowState() const { Preferences* const pref = Preferences::instance(); + + // window size pref->setPrefSize(size()); - pref->setPrefPos(pos()); + // Splitter size QStringList sizes_str; sizes_str << QString::number(m_ui->hsplitter->sizes().first()); @@ -436,25 +432,6 @@ void OptionsDialog::saveWindowState() const pref->setPrefHSplitterSizes(sizes_str); } -QSize OptionsDialog::sizeFittingScreen() const -{ - int scrn = 0; - QWidget *w = this->topLevelWidget(); - - if (w) - scrn = QApplication::desktop()->screenNumber(w); - else if (QApplication::desktop()->isVirtualDesktop()) - scrn = QApplication::desktop()->screenNumber(QCursor::pos()); - else - scrn = QApplication::desktop()->screenNumber(this); - - QRect desk(QApplication::desktop()->availableGeometry(scrn)); - if (width() > desk.width() || height() > desk.height()) - if (desk.width() > 0 && desk.height() > 0) - return QSize(desk.width(), desk.height()); - return size(); -} - void OptionsDialog::saveOptions() { applyButton->setEnabled(false); diff --git a/src/gui/optionsdlg.h b/src/gui/optionsdlg.h index 7cf995496..ee874ba20 100644 --- a/src/gui/optionsdlg.h +++ b/src/gui/optionsdlg.h @@ -170,7 +170,6 @@ private: quint16 webUiPort() const; QString webUiUsername() const; QString webUiPassword() const; - QSize sizeFittingScreen() const; private: bool setSslKey(const QByteArray &key); diff --git a/src/gui/preview.ui b/src/gui/preview.ui index 66a2e0a72..7405b3e0f 100644 --- a/src/gui/preview.ui +++ b/src/gui/preview.ui @@ -16,18 +16,9 @@ - - - 16777215 - 42 - - The following files support previewing, please select one of them: - - Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft - true diff --git a/src/gui/previewselect.cpp b/src/gui/previewselect.cpp index b880550b7..f1bcbb81e 100644 --- a/src/gui/previewselect.cpp +++ b/src/gui/previewselect.cpp @@ -83,7 +83,7 @@ PreviewSelect::PreviewSelect(QWidget* parent, BitTorrent::TorrentHandle *const t } if (!previewListModel->rowCount()) { - QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file")); + QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file")); close(); } connect(this, SIGNAL(readyToPreviewFile(QString)), parent, SLOT(previewFile(QString))); @@ -120,7 +120,7 @@ void PreviewSelect::on_previewButton_clicked() { if (QFile::exists(path)) emit readyToPreviewFile(path); else - QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file")); + QMessageBox::critical(this->parentWidget(), tr("Preview impossible"), tr("Sorry, we can't preview this file")); close(); } diff --git a/src/gui/properties/peerlistwidget.cpp b/src/gui/properties/peerlistwidget.cpp index ade3b2d82..1a3ad29a0 100644 --- a/src/gui/properties/peerlistwidget.cpp +++ b/src/gui/properties/peerlistwidget.cpp @@ -245,7 +245,7 @@ void PeerListWidget::showPeerListMenu(const QPoint &) QAction *act = menu.exec(QCursor::pos()); if (act == 0) return; if (act == addPeerAct) { - QList peersList = PeersAdditionDlg::askForPeers(); + QList peersList = PeersAdditionDlg::askForPeers(this); int peerCount = 0; foreach (const BitTorrent::PeerAddress &addr, peersList) { if (torrent->connectPeer(addr)) { @@ -258,9 +258,9 @@ void PeerListWidget::showPeerListMenu(const QPoint &) } } if (peerCount < peersList.length()) - QMessageBox::information(0, tr("Peer addition"), tr("Some peers could not be added. Check the Log for details.")); + QMessageBox::information(this, tr("Peer addition"), tr("Some peers could not be added. Check the Log for details.")); else if (peerCount > 0) - QMessageBox::information(0, tr("Peer addition"), tr("The peers were added to this torrent.")); + QMessageBox::information(this, tr("Peer addition"), tr("The peers were added to this torrent.")); return; } if (act == banAct) { diff --git a/src/gui/properties/peersadditiondlg.cpp b/src/gui/properties/peersadditiondlg.cpp index a831b44be..ab20674aa 100644 --- a/src/gui/properties/peersadditiondlg.cpp +++ b/src/gui/properties/peersadditiondlg.cpp @@ -51,9 +51,9 @@ PeersAdditionDlg::~PeersAdditionDlg() delete m_ui; } -QList PeersAdditionDlg::askForPeers() +QList PeersAdditionDlg::askForPeers(QWidget *parent) { - PeersAdditionDlg dlg; + PeersAdditionDlg dlg(parent); dlg.exec(); return dlg.m_peersList; } diff --git a/src/gui/properties/peersadditiondlg.h b/src/gui/properties/peersadditiondlg.h index e754a0c30..8f09c907c 100644 --- a/src/gui/properties/peersadditiondlg.h +++ b/src/gui/properties/peersadditiondlg.h @@ -47,10 +47,10 @@ class PeersAdditionDlg: public QDialog Q_OBJECT public: - PeersAdditionDlg(QWidget *parent = 0); + PeersAdditionDlg(QWidget *parent); ~PeersAdditionDlg(); - static QList askForPeers(); + static QList askForPeers(QWidget *parent); protected slots: void validateInput(); diff --git a/src/gui/properties/peersadditiondlg.ui b/src/gui/properties/peersadditiondlg.ui index 2b24bdf25..b2c056513 100644 --- a/src/gui/properties/peersadditiondlg.ui +++ b/src/gui/properties/peersadditiondlg.ui @@ -17,7 +17,7 @@ - List of peers to add (one per line): + List of peers to add (one IP per line): @@ -40,9 +40,6 @@ - - true - Qt::Horizontal diff --git a/src/gui/properties/trackerlist.cpp b/src/gui/properties/trackerlist.cpp index f1c6f1905..716be9c52 100644 --- a/src/gui/properties/trackerlist.cpp +++ b/src/gui/properties/trackerlist.cpp @@ -347,7 +347,7 @@ void TrackerList::askForTrackers() { if (!torrent) return; QList trackers; - foreach (const QString &tracker, TrackersAdditionDlg::askForTrackers(torrent)) + foreach (const QString &tracker, TrackersAdditionDlg::askForTrackers(this, torrent)) trackers << tracker; torrent->addTrackers(trackers); } diff --git a/src/gui/properties/trackersadditiondlg.cpp b/src/gui/properties/trackersadditiondlg.cpp index a36c4b23c..cf98eea63 100644 --- a/src/gui/properties/trackersadditiondlg.cpp +++ b/src/gui/properties/trackersadditiondlg.cpp @@ -43,7 +43,7 @@ #include "guiiconprovider.h" #include "ui_trackersadditiondlg.h" -TrackersAdditionDlg::TrackersAdditionDlg(BitTorrent::TorrentHandle *const torrent, QWidget *parent) +TrackersAdditionDlg::TrackersAdditionDlg(QWidget *parent, BitTorrent::TorrentHandle *const torrent) : QDialog(parent) , m_ui(new Ui::TrackersAdditionDlg()) , m_torrent(torrent) @@ -132,10 +132,10 @@ void TrackersAdditionDlg::getTrackerError(const QString &, const QString &error) QMessageBox::warning(this, tr("Download error"), tr("The trackers list could not be downloaded, reason: %1").arg(error), QMessageBox::Ok); } -QStringList TrackersAdditionDlg::askForTrackers(BitTorrent::TorrentHandle *const torrent) +QStringList TrackersAdditionDlg::askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent) { QStringList trackers; - TrackersAdditionDlg dlg(torrent); + TrackersAdditionDlg dlg(parent, torrent); if (dlg.exec() == QDialog::Accepted) return dlg.newTrackers(); diff --git a/src/gui/properties/trackersadditiondlg.h b/src/gui/properties/trackersadditiondlg.h index b04a6f391..fc355acea 100644 --- a/src/gui/properties/trackersadditiondlg.h +++ b/src/gui/properties/trackersadditiondlg.h @@ -51,11 +51,11 @@ class TrackersAdditionDlg : public QDialog Q_OBJECT public: - TrackersAdditionDlg(BitTorrent::TorrentHandle *const torrent, QWidget *parent = 0); + TrackersAdditionDlg(QWidget *parent, BitTorrent::TorrentHandle *const torrent); ~TrackersAdditionDlg(); QStringList newTrackers() const; - static QStringList askForTrackers(BitTorrent::TorrentHandle *const torrent); + static QStringList askForTrackers(QWidget *parent, BitTorrent::TorrentHandle *const torrent); public slots: void on_uTorrentListButton_clicked(); diff --git a/src/gui/properties/trackersadditiondlg.ui b/src/gui/properties/trackersadditiondlg.ui index c4c3c0a73..bee0e607a 100644 --- a/src/gui/properties/trackersadditiondlg.ui +++ b/src/gui/properties/trackersadditiondlg.ui @@ -26,13 +26,6 @@ QTextEdit::NoWrap - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans'; font-size:10pt;"></p></body></html> - false @@ -51,23 +44,7 @@ p, li { white-space: pre-wrap; } - - - - 31 - 31 - - - - - 31 - 31 - - - - - - + diff --git a/src/gui/rss/automatedrssdownloader.cpp b/src/gui/rss/automatedrssdownloader.cpp index 31db14a84..4b54cb96d 100644 --- a/src/gui/rss/automatedrssdownloader.cpp +++ b/src/gui/rss/automatedrssdownloader.cpp @@ -149,17 +149,15 @@ AutomatedRssDownloader::~AutomatedRssDownloader() void AutomatedRssDownloader::loadSettings() { - // load dialog geometry const Preferences *const pref = Preferences::instance(); - restoreGeometry(pref->getRssGeometry()); + resize(pref->getRssGeometrySize(this->size())); m_ui->hsplitter->restoreState(pref->getRssHSplitterSizes()); } void AutomatedRssDownloader::saveSettings() { - // Save dialog geometry Preferences *const pref = Preferences::instance(); - pref->setRssGeometry(saveGeometry()); + pref->setRssGeometrySize(this->size()); pref->setRssHSplitterSizes(m_ui->hsplitter->saveState()); } diff --git a/src/gui/search/pluginselectdlg.cpp b/src/gui/search/pluginselectdlg.cpp index d99697741..df4ee6316 100644 --- a/src/gui/search/pluginselectdlg.cpp +++ b/src/gui/search/pluginselectdlg.cpp @@ -207,9 +207,9 @@ void PluginSelectDlg::on_actionUninstall_triggered() } if (error) - QMessageBox::warning(0, tr("Uninstall warning"), tr("Some plugins could not be uninstalled because they are included in qBittorrent. Only the ones you added yourself can be uninstalled.\nThose plugins were disabled.")); + QMessageBox::warning(this, tr("Uninstall warning"), tr("Some plugins could not be uninstalled because they are included in qBittorrent. Only the ones you added yourself can be uninstalled.\nThose plugins were disabled.")); else - QMessageBox::information(0, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully")); + QMessageBox::information(this, tr("Uninstall success"), tr("All selected plugins were uninstalled successfully")); } void PluginSelectDlg::enableSelection(bool enable) diff --git a/src/gui/search/searchwidget.cpp b/src/gui/search/searchwidget.cpp index 9852a74ae..23dc59b84 100644 --- a/src/gui/search/searchwidget.cpp +++ b/src/gui/search/searchwidget.cpp @@ -265,7 +265,7 @@ void SearchWidget::on_searchButton_clicked() const QString pattern = m_ui->m_searchPattern->text().trimmed(); // No search pattern entered if (pattern.isEmpty()) { - QMessageBox::critical(0, tr("Empty search pattern"), tr("Please type a search pattern first")); + QMessageBox::critical(this, tr("Empty search pattern"), tr("Please type a search pattern first")); return; } diff --git a/src/gui/shutdownconfirmdlg.cpp b/src/gui/shutdownconfirmdlg.cpp index 3fbbe0c97..116c64776 100644 --- a/src/gui/shutdownconfirmdlg.cpp +++ b/src/gui/shutdownconfirmdlg.cpp @@ -42,8 +42,9 @@ #include "base/utils/misc.h" -ShutdownConfirmDlg::ShutdownConfirmDlg(const ShutdownDialogAction &action) - : ui(new Ui::confirmShutdownDlg) +ShutdownConfirmDlg::ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action) + : QDialog(parent) + , ui(new Ui::confirmShutdownDlg) , m_timeout(15) , m_action(action) { @@ -82,9 +83,9 @@ void ShutdownConfirmDlg::showEvent(QShowEvent *event) m_timer.start(); } -bool ShutdownConfirmDlg::askForConfirmation(const ShutdownDialogAction &action) +bool ShutdownConfirmDlg::askForConfirmation(QWidget *parent, const ShutdownDialogAction &action) { - ShutdownConfirmDlg dlg(action); + ShutdownConfirmDlg dlg(parent, action); return (dlg.exec() == QDialog::Accepted); } diff --git a/src/gui/shutdownconfirmdlg.h b/src/gui/shutdownconfirmdlg.h index 88b7c48de..dafa1da86 100644 --- a/src/gui/shutdownconfirmdlg.h +++ b/src/gui/shutdownconfirmdlg.h @@ -45,10 +45,10 @@ class ShutdownConfirmDlg: public QDialog Q_OBJECT public: - ShutdownConfirmDlg(const ShutdownDialogAction &action); + ShutdownConfirmDlg(QWidget *parent, const ShutdownDialogAction &action); ~ShutdownConfirmDlg(); - static bool askForConfirmation(const ShutdownDialogAction &action); + static bool askForConfirmation(QWidget *parent, const ShutdownDialogAction &action); protected: void showEvent(QShowEvent *event) override; diff --git a/src/gui/speedlimitdlg.cpp b/src/gui/speedlimitdlg.cpp index 1f2cd8271..ef14b152c 100644 --- a/src/gui/speedlimitdlg.cpp +++ b/src/gui/speedlimitdlg.cpp @@ -39,10 +39,10 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) { m_ui->setupUi(this); qDebug("Bandwidth allocation dialog creation"); + // Connect to slots connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int))); connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int))); - move(Utils::Misc::screenCenter(this)); } SpeedLimitDialog::~SpeedLimitDialog() @@ -52,9 +52,9 @@ SpeedLimitDialog::~SpeedLimitDialog() } // -2: if cancel -long SpeedLimitDialog::askSpeedLimit(bool *ok, QString title, long default_value, long max_value) +long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value) { - SpeedLimitDialog dlg; + SpeedLimitDialog dlg(parent); dlg.setWindowTitle(title); dlg.setupDialog(max_value / 1024., default_value / 1024.); if (dlg.exec() == QDialog::Accepted) { diff --git a/src/gui/speedlimitdlg.h b/src/gui/speedlimitdlg.h index 3283febb4..45f62b144 100644 --- a/src/gui/speedlimitdlg.h +++ b/src/gui/speedlimitdlg.h @@ -44,9 +44,9 @@ namespace Ui class SpeedLimitDialog : public QDialog { Q_OBJECT public: - explicit SpeedLimitDialog(QWidget *parent=0); + explicit SpeedLimitDialog(QWidget *parent); ~SpeedLimitDialog(); - static long askSpeedLimit(bool *ok, QString title, long default_value, long max_value=10240000); + static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value=10240000); protected slots: void updateSpinValue(int val) const; diff --git a/src/gui/statsdialog.cpp b/src/gui/statsdialog.cpp index a42d44945..7a5dcb531 100644 --- a/src/gui/statsdialog.cpp +++ b/src/gui/statsdialog.cpp @@ -44,12 +44,13 @@ StatsDialog::StatsDialog(QWidget *parent) { ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose); - connect(ui->buttonOK, SIGNAL(clicked()), SLOT(close())); + connect(ui->buttonBox, SIGNAL(accepted()), SLOT(close())); updateUI(); t = new QTimer(this); t->setInterval(1500); connect(t, SIGNAL(timeout()), SLOT(updateUI())); t->start(); + show(); } diff --git a/src/gui/statsdialog.h b/src/gui/statsdialog.h index af41a5999..46c41d8a8 100644 --- a/src/gui/statsdialog.h +++ b/src/gui/statsdialog.h @@ -42,7 +42,7 @@ class StatsDialog : public QDialog { Q_OBJECT public: - explicit StatsDialog(QWidget *parent = 0); + explicit StatsDialog(QWidget *parent); ~StatsDialog(); private slots: diff --git a/src/gui/statsdialog.ui b/src/gui/statsdialog.ui index fa0d90d82..ef2ebbf08 100644 --- a/src/gui/statsdialog.ui +++ b/src/gui/statsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 273 - 395 + 286 + 401 @@ -223,28 +223,11 @@ - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - + + + QDialogButtonBox::Ok + + diff --git a/src/gui/statusbar.cpp b/src/gui/statusbar.cpp index b92af9a39..6f5144c7d 100644 --- a/src/gui/statusbar.cpp +++ b/src/gui/statusbar.cpp @@ -252,9 +252,10 @@ void StatusBar::toggleAlternativeSpeeds() void StatusBar::capDownloadSpeed() { BitTorrent::Session *const session = BitTorrent::Session::instance(); + bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); + m_bar->parentWidget(), &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit()); if (ok) { qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.); session->setDownloadSpeedLimit(newLimit); @@ -265,9 +266,10 @@ void StatusBar::capDownloadSpeed() void StatusBar::capUploadSpeed() { BitTorrent::Session *const session = BitTorrent::Session::instance(); + bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); + m_bar->parentWidget(), &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit()); if (ok) { qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.); session->setUploadSpeedLimit(newLimit); diff --git a/src/gui/transferlistwidget.cpp b/src/gui/transferlistwidget.cpp index 5efb3d51a..584e52fdf 100644 --- a/src/gui/transferlistwidget.cpp +++ b/src/gui/transferlistwidget.cpp @@ -328,7 +328,7 @@ void TransferListWidget::deleteSelectedTorrents(bool deleteLocalFiles) if (torrents.empty()) return; if (Preferences::instance()->confirmTorrentDeletion() - && !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name())) + && !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name())) return; foreach (BitTorrent::TorrentHandle *const torrent, torrents) BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles); @@ -344,8 +344,9 @@ void TransferListWidget::deleteVisibleTorrents() bool deleteLocalFiles = false; if (Preferences::instance()->confirmTorrentDeletion() - && !DeletionConfirmationDlg::askForDeletionConfirmation(deleteLocalFiles, torrents.size(), torrents[0]->name())) + && !DeletionConfirmationDlg::askForDeletionConfirmation(this, deleteLocalFiles, torrents.size(), torrents[0]->name())) return; + foreach (BitTorrent::TorrentHandle *const torrent, torrents) BitTorrent::Session::instance()->deleteTorrent(torrent->hash(), deleteLocalFiles); } @@ -445,7 +446,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Torrent Download Speed Limiting"), oldLimit + this, &ok, tr("Torrent Download Speed Limiting"), oldLimit , BitTorrent::Session::instance()->globalDownloadSpeedLimit()); if (!ok) return; @@ -470,7 +471,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() bool ok = false; const long newLimit = SpeedLimitDialog::askSpeedLimit( - &ok, tr("Torrent Upload Speed Limiting"), oldLimit + this, &ok, tr("Torrent Upload Speed Limiting"), oldLimit , BitTorrent::Session::instance()->globalUploadSpeedLimit()); if (!ok) return;