From 82e02f71189a195afdd5a88d739a39969566ae12 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Sun, 13 Dec 2015 16:41:58 +0200 Subject: [PATCH] Don't apply some settings again if they weren't changed. Closes #4278. --- src/gui/mainwindow.cpp | 21 ++++++++++++--------- src/gui/mainwindow.h | 1 + src/gui/options_imp.cpp | 4 +--- src/gui/options_imp.h | 4 ---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/gui/mainwindow.cpp b/src/gui/mainwindow.cpp index ac9bbd729..84d6ab074 100644 --- a/src/gui/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -104,6 +104,7 @@ MainWindow::MainWindow(QWidget *parent) , m_posInitialized(false) , force_exit(false) , unlockDlgShowing(false) + , m_wasUpdateCheckEnabled(false) , has_python(false) { setupUi(this); @@ -337,6 +338,8 @@ MainWindow::MainWindow(QWidget *parent) connect(transferList->getSourceModel(), SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(updateNbTorrents())); connect(transferList->getSourceModel(), SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(updateNbTorrents())); + connect(pref, SIGNAL(changed()), this, SLOT(optionsSaved())); + qDebug("GUI Built"); #ifdef Q_OS_WIN if (!pref->neverCheckFileAssoc() && (!Preferences::isTorrentFileAssocSet() || !Preferences::isMagnetLinkAssocSet())) { @@ -1108,7 +1111,7 @@ void MainWindow::loadPreferences(bool configure_session) toolBar->setVisible(false); } - if (pref->preventFromSuspend()) { + if (pref->preventFromSuspend() && !preventTimer->isActive()) { preventTimer->start(PREVENT_SUSPEND_INTERVAL); } else { @@ -1149,10 +1152,14 @@ void MainWindow::loadPreferences(bool configure_session) properties->reloadPreferences(); #if defined(Q_OS_WIN) || defined(Q_OS_MAC) - if (pref->isUpdateCheckEnabled()) + if (pref->isUpdateCheckEnabled() && !m_wasUpdateCheckEnabled) { + m_wasUpdateCheckEnabled = true; checkProgramUpdate(); - else + } + else if (!pref->isUpdateCheckEnabled() && m_wasUpdateCheckEnabled) { + m_wasUpdateCheckEnabled = false; programUpdateTimer.stop(); + } #endif qDebug("GUI settings loaded"); @@ -1336,14 +1343,10 @@ void MainWindow::createTrayIcon() // Display Program Options void MainWindow::on_actionOptions_triggered() { - if (options) { - // Get focus + if (options) options->setFocus(); - } - else { + else options = new options_imp(this); - connect(options, SIGNAL(status_changed()), this, SLOT(optionsSaved())); - } } void MainWindow::on_actionTop_tool_bar_triggered() diff --git a/src/gui/mainwindow.h b/src/gui/mainwindow.h index a8cd49944..3fc5bdf81 100644 --- a/src/gui/mainwindow.h +++ b/src/gui/mainwindow.h @@ -202,6 +202,7 @@ private: QTimer *preventTimer; #if defined(Q_OS_WIN) || defined(Q_OS_MAC) QTimer programUpdateTimer; + bool m_wasUpdateCheckEnabled; #endif bool has_python; QMenu* toolbarMenu; diff --git a/src/gui/options_imp.cpp b/src/gui/options_imp.cpp index 64b0a6cfa..6ef0283a3 100644 --- a/src/gui/options_imp.cpp +++ b/src/gui/options_imp.cpp @@ -1000,10 +1000,9 @@ void options_imp::on_buttonBox_accepted() tabSelection->setCurrentRow(TAB_SPEED); return; } - saveOptions(); applyButton->setEnabled(false); this->hide(); - emit status_changed(); + saveOptions(); } saveWindowState(); accept(); @@ -1017,7 +1016,6 @@ void options_imp::applySettings(QAbstractButton* button) return; } saveOptions(); - emit status_changed(); } } diff --git a/src/gui/options_imp.h b/src/gui/options_imp.h index 1b8884c1f..4b7d7ffea 100644 --- a/src/gui/options_imp.h +++ b/src/gui/options_imp.h @@ -70,10 +70,6 @@ public: public slots: void showConnectionTab(); -signals: - void status_changed() const; - void exitWithCancel(); - private slots: void enableProxy(int comboIndex); void on_buttonBox_accepted();