From 6bcbfa2e05338b998db89dc452afc65bc739b14c Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Tue, 21 Dec 2010 17:41:11 +0000 Subject: [PATCH] FEATURE: Software update check can now be disabled (Mac OS X / Windows) --- Changelog | 1 + src/mainwindow.cpp | 28 +++++++++++++++------------- src/preferences/advancedsettings.h | 22 +++++++++++++++++++++- src/preferences/preferences.h | 9 +++++++++ 4 files changed, 46 insertions(+), 14 deletions(-) diff --git a/Changelog b/Changelog index dd094cc99..be2e89642 100644 --- a/Changelog +++ b/Changelog @@ -2,6 +2,7 @@ - FEATURE: Use system icons (Linux, Qt >= 4.6) - FEATURE: Improved ETA calculation - FEATURE: Simplify program preferences + - FEATURE: Software update check can now be disabled (Mac OS X / Windows) - COSMETIC: Same deletion confirmation dialog in the GUI and Web UI - COSMETIC: Simplified the top toolbar - COSMETIC: Display execution log as a tab instead of a modal window diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d9282ea7f..590426911 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -271,9 +271,11 @@ MainWindow::MainWindow(QWidget *parent, QStringList torrentCmdLine) : QMainWindo #endif #if defined(Q_WS_WIN) || defined(Q_WS_MAC) // Check for update - ProgramUpdater *updater = new ProgramUpdater(this); - connect(updater, SIGNAL(updateCheckFinished(bool, QString)), SLOT(handleUpdateCheckFinished(bool, QString))); - updater->checkForUpdates(); + if(pref.isUpdateCheckEnabled()) { + ProgramUpdater *updater = new ProgramUpdater(this); + connect(updater, SIGNAL(updateCheckFinished(bool, QString)), SLOT(handleUpdateCheckFinished(bool, QString))); + updater->checkForUpdates(); + } #endif } @@ -1260,14 +1262,14 @@ void MainWindow::showConnectionSettings() void MainWindow::on_actionExecution_Logs_triggered(bool checked) { - if(checked) { - Q_ASSERT(!m_executionLog); - m_executionLog = new ExecutionLog(tabs); - int index_tab = tabs->addTab(m_executionLog, tr("Execution Log")); - tabs->setTabIcon(index_tab, misc::getIcon("view-calendar-journal")); - } else { - Q_ASSERT(m_executionLog); - delete m_executionLog; - } - Preferences().setExecutionLogEnabled(checked); + if(checked) { + Q_ASSERT(!m_executionLog); + m_executionLog = new ExecutionLog(tabs); + int index_tab = tabs->addTab(m_executionLog, tr("Execution Log")); + tabs->setTabIcon(index_tab, misc::getIcon("view-calendar-journal")); + } else { + Q_ASSERT(m_executionLog); + delete m_executionLog; + } + Preferences().setExecutionLogEnabled(checked); } diff --git a/src/preferences/advancedsettings.h b/src/preferences/advancedsettings.h index 6a203359e..606912f6b 100644 --- a/src/preferences/advancedsettings.h +++ b/src/preferences/advancedsettings.h @@ -11,7 +11,11 @@ #include "preferences.h" enum AdvSettingsCols {PROPERTY, VALUE}; -enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, ROW_COUNT }; +enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT, + #if defined(Q_WS_WIN) || define(Q_WS_MAC) + UPDATE_CHECK, + #endif + ROW_COUNT }; class AdvancedSettings: public QTableWidget { Q_OBJECT @@ -20,6 +24,9 @@ private: QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen, *spin_tracker_port; QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding, *cb_program_notifications, *cb_tracker_status; QComboBox *combo_iface; +#if defined(Q_WS_WIN) || define(Q_WS_MAC) + QCheckBox *cb_update_check; +#endif public: AdvancedSettings(QWidget *parent=0): QTableWidget(parent) { @@ -54,6 +61,9 @@ public: delete cb_program_notifications; delete spin_tracker_port; delete cb_tracker_status; +#if defined(Q_WS_WIN) || define(Q_WS_MAC) + delete cb_update_check; +#endif } public slots: @@ -93,6 +103,9 @@ public slots: // Tracker pref.setTrackerEnabled(cb_tracker_status->isChecked()); pref.setTrackerPort(spin_tracker_port->value()); +#if defined(Q_WS_WIN) || define(Q_WS_MAC) + pref.setUpdateCheckEnabled(cb_update_check->isChecked()); +#endif } protected slots: @@ -215,6 +228,13 @@ protected slots: spin_tracker_port->setMaximum(65535); spin_tracker_port->setValue(pref.getTrackerPort()); setCellWidget(TRACKER_PORT, VALUE, spin_tracker_port); +#if defined(Q_WS_WIN) || define(Q_WS_MAC) + setItem(UPDATE_CHECK, PROPERTY, new QTableWidgetItem(tr("Check for software updates"))); + cb_update_check = new QCheckBox(); + connect(cb_update_check, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged())); + cb_update_check->setChecked(pref.isUpdateCheckEnabled()); + setCellWidget(UPDATE_CHECK, VALUE, cb_update_check); +#endif } void emitSettingsChanged() { diff --git a/src/preferences/preferences.h b/src/preferences/preferences.h index fa277de9f..72e3ea0bb 100644 --- a/src/preferences/preferences.h +++ b/src/preferences/preferences.h @@ -978,6 +978,15 @@ public: setValue(QString::fromUtf8("Preferences/Advanced/trackerPort"), port); } +#if defined(Q_WS_WIN) || define(Q_WS_MAC) + bool isUpdateCheckEnabled() const { + return value(QString::fromUtf8("Preferences/Advanced/updateCheck"), true).toBool(); + } + + void setUpdateCheckEnabled(bool enabled) { + setValue(QString::fromUtf8("Preferences/Advanced/updateCheck"), enabled); + } +#endif }; #endif // PREFERENCES_H