diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mainwindow.cpp | 16 | ||||
| -rw-r--r-- | src/mainwindow.h | 1 | ||||
| -rw-r--r-- | src/organizercore.cpp | 36 | ||||
| -rw-r--r-- | src/organizercore.h | 1 | ||||
| -rw-r--r-- | src/selfupdater.cpp | 12 | ||||
| -rw-r--r-- | src/selfupdater.h | 14 | ||||
| -rw-r--r-- | src/settings.cpp | 10 | ||||
| -rw-r--r-- | src/settings.h | 5 | ||||
| -rw-r--r-- | src/settingsdialog.ui | 203 | ||||
| -rw-r--r-- | src/settingsdialoggeneral.cpp | 2 |
10 files changed, 187 insertions, 113 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 42cbe919..cd650d2f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -263,6 +263,7 @@ MainWindow::MainWindow(Settings &settings setupToolbar(); toggleMO2EndorseState(); + toggleUpdateAction(); TaskProgressManager::instance().tryCreateTaskbar(); @@ -5007,6 +5008,7 @@ void MainWindow::on_actionSettings_triggered() bool oldDisplayForeign(settings.interface().displayForeign()); bool proxy = settings.network().useProxy(); DownloadManager *dlManager = m_OrganizerCore.downloadManager(); + const bool oldCheckForUpdates = settings.checkForUpdates(); SettingsDialog dialog(&m_PluginContainer, settings, this); @@ -5084,6 +5086,14 @@ void MainWindow::on_actionSettings_triggered() m_OrganizerCore.cycleDiagnostics(); toggleMO2EndorseState(); + + if (oldCheckForUpdates != settings.checkForUpdates()) { + toggleUpdateAction(); + + if (settings.checkForUpdates()) { + m_OrganizerCore.checkForUpdates(); + } + } } void MainWindow::on_actionNexus_triggered() @@ -5596,6 +5606,12 @@ void MainWindow::toggleMO2EndorseState() ui->actionEndorseMO->setStatusTip(text); } +void MainWindow::toggleUpdateAction() +{ + const auto& s = m_OrganizerCore.settings(); + ui->actionUpdate->setVisible(s.checkForUpdates()); +} + void MainWindow::nxmEndorsementsAvailable(QVariant userData, QVariant resultData, int) { QVariantList data = resultData.toList(); diff --git a/src/mainwindow.h b/src/mainwindow.h index 1f997ab1..524e2b6e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -313,6 +313,7 @@ private: void sendSelectedPluginsToPriority(int newPriority); void toggleMO2EndorseState(); + void toggleUpdateAction(); private: diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 0da5b604..a4a89c99 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -74,25 +74,6 @@ using namespace MOBase; //static CrashDumpsType OrganizerCore::m_globalCrashDumpsType = CrashDumpsType::None; -static bool isOnline() -{ - const auto runningFlags = - QNetworkInterface::IsUp | QNetworkInterface::IsRunning; - - for (auto&& i : QNetworkInterface::allInterfaces()) { - if (!(i.flags() & QNetworkInterface::IsLoopBack)) { - if (i.flags() & runningFlags) { - auto addresses = i.addressEntries(); - if (!addresses.empty()) { - return true; - } - } - } - } - - return false; -} - static std::wstring getProcessName(HANDLE process) { wchar_t buffer[MAX_PATH]; @@ -307,14 +288,15 @@ void OrganizerCore::setUserInterface(IUserInterface *userInterface, m_InstallationManager.setParentWidget(widget); m_Updater.setUserInterface(widget); - if (userInterface != nullptr) { - // this currently wouldn't work reliably if the ui isn't initialized yet to - // display the result - if (isOnline() && !m_Settings.network().offlineMode()) { - m_Updater.testForUpdate(); - } else { - log::debug("user doesn't seem to be connected to the internet"); - } + checkForUpdates(); +} + +void OrganizerCore::checkForUpdates() +{ + // this currently wouldn't work reliably if the ui isn't initialized yet to + // display the result + if (m_UserInterface != nullptr) { + m_Updater.testForUpdate(m_Settings); } } diff --git a/src/organizercore.h b/src/organizercore.h index a14d79a9..5de550df 100644 --- a/src/organizercore.h +++ b/src/organizercore.h @@ -109,6 +109,7 @@ public: void updateExecutablesList();
+ void checkForUpdates();
void startMOUpdate();
Settings &settings();
diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index 0ca39b19..8887927a 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -122,8 +122,18 @@ void SelfUpdater::setPluginContainer(PluginContainer *pluginContainer) m_Interface->setPluginContainer(pluginContainer);
}
-void SelfUpdater::testForUpdate()
+void SelfUpdater::testForUpdate(const Settings& settings)
{
+ if (settings.network().offlineMode()) {
+ log::debug("not checking for updates, in offline mode");
+ return;
+ }
+
+ if (!settings.checkForUpdates()) {
+ log::debug("not checking for updates, disabled");
+ return;
+ }
+
// TODO: if prereleases are disabled we could just request the latest release
// directly
try {
diff --git a/src/selfupdater.h b/src/selfupdater.h index bce49495..0c81efc5 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -37,7 +37,7 @@ namespace MOBase { class IPluginGame; } class QNetworkReply;
class QProgressDialog;
-
+class Settings;
/**
* @brief manages updates for Mod Organizer itself
@@ -81,6 +81,11 @@ public: void setPluginContainer(PluginContainer *pluginContainer);
/**
+ * @brief request information about the current version
+ **/
+ void testForUpdate(const Settings& settings);
+
+ /**
* @brief start the update process
* @note this should not be called if there is no update available
**/
@@ -91,13 +96,6 @@ public: **/
MOBase::VersionInfo getVersion() const { return m_MOVersion; }
-public slots:
-
- /**
- * @brief request information about the current version
- **/
- void testForUpdate();
-
signals:
/**
diff --git a/src/settings.cpp b/src/settings.cpp index c3e8781e..462cd92a 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -178,6 +178,16 @@ QString Settings::filename() const return m_Settings.fileName(); } +bool Settings::checkForUpdates() const +{ + return get<bool>(m_Settings, "Settings", "check_for_updates", true); +} + +void Settings::setCheckForUpdates(bool b) +{ + set(m_Settings, "Settings", "check_for_updates", b); +} + bool Settings::usePrereleases() const { return get<bool>(m_Settings, "Settings", "use_prereleases", false); diff --git a/src/settings.h b/src/settings.h index ee6ff3fe..1556ba1e 100644 --- a/src/settings.h +++ b/src/settings.h @@ -692,6 +692,11 @@ public: bool archiveParsing() const; void setArchiveParsing(bool b); + // whether the user wants to check for updates + // + bool checkForUpdates() const; + void setCheckForUpdates(bool b); + // whether the user wants to upgrade to pre-releases // bool usePrereleases() const; diff --git a/src/settingsdialog.ui b/src/settingsdialog.ui index 9d1e4da1..78bae6d7 100644 --- a/src/settingsdialog.ui +++ b/src/settingsdialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>586</width> - <height>486</height> + <height>491</height> </rect> </property> <property name="windowTitle"> @@ -23,75 +23,67 @@ <attribute name="title"> <string>General</string> </attribute> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <item> - <widget class="QLabel" name="label_5"> - <property name="text"> - <string>Language</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="languageBox"> - <property name="toolTip"> - <string>The display language</string> - </property> - <property name="whatsThis"> - <string><!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The display language. This will only displaye languages for which you have a translation installed.</span></p></body></html></string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_10"> - <property name="text"> - <string>Style</string> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="styleBox"> - <property name="toolTip"> - <string>graphical style</string> - </property> - <property name="whatsThis"> - <string>graphical style of the MO user interface</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QCheckBox" name="usePrereleaseBox"> - <property name="toolTip"> - <string>Update to non-stable releases.</string> - </property> - <property name="whatsThis"> - <string>If this is enabled, the integrated update mechanism will notify of all releases, including pre-releases (alphas, betas). Please use this only if you're sufficiently tech-savvy to investigate issues, look for known problems in the issue tracker and create meaningful reports.</string> + <layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,1"> + <item row="5" column="0" colspan="2"> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - <property name="text"> - <string>Install Pre-releases (Betas)</string> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> </property> - </widget> + </spacer> </item> - <item> + <item row="0" column="0" rowspan="2"> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>User Interface</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="2" column="0"> + <widget class="QLabel" name="label_10"> + <property name="text"> + <string>Style</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_5"> + <property name="text"> + <string>Language</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="languageBox"> + <property name="toolTip"> + <string>The display language</string> + </property> + <property name="whatsThis"> + <string><!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:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">The display language. This will only displaye languages for which you have a translation installed.</span></p></body></html></string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="styleBox"> + <property name="toolTip"> + <string>graphical style</string> + </property> + <property name="whatsThis"> + <string>graphical style of the MO user interface</string> + </property> + </widget> + </item> + <item row="4" column="0" colspan="2"> <widget class="QCheckBox" name="centerDialogs"> - <property name="statusTip"> + <property name="toolTip"> <string>Dialogs will always be centered on the main window, but will remember their size.</string> </property> <property name="whatsThis"> @@ -102,7 +94,7 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item> + <item row="5" column="0" colspan="2"> <widget class="QPushButton" name="resetDialogsButton"> <property name="maximumSize"> <size> @@ -121,7 +113,7 @@ p, li { white-space: pre-wrap; } </property> </widget> </item> - <item> + <item row="6" column="0" colspan="2"> <widget class="QPushButton" name="categoriesBtn"> <property name="toolTip"> <string>Modify the categories available to arrange your mods.</string> @@ -137,36 +129,49 @@ p, li { white-space: pre-wrap; } </layout> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QGroupBox" name="groupBox_5"> <property name="title"> <string>Download List</string> </property> - <layout class="QHBoxLayout" name="horizontalLayout_11"> + <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <widget class="QCheckBox" name="compactBox"> + <widget class="QCheckBox" name="showMetaBox"> <property name="toolTip"> - <string>If checked, the download interface will be more compact.</string> + <string>If checked, the download list will display meta information instead of file names.</string> </property> <property name="text"> - <string>Compact List</string> + <string>Show Meta Information</string> </property> </widget> </item> <item> - <widget class="QCheckBox" name="showMetaBox"> + <widget class="QCheckBox" name="compactBox"> <property name="toolTip"> - <string>If checked, the download list will display meta information instead of file names.</string> + <string>If checked, the download interface will be more compact.</string> </property> <property name="text"> - <string>Show Meta Information</string> + <string>Compact List</string> </property> </widget> </item> + <item> + <spacer name="verticalSpacer_5"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> </layout> </widget> </item> - <item> + <item row="3" column="0" colspan="2"> <widget class="QGroupBox" name="ModlistGroupBox"> <property name="title"> <string>Colors</string> @@ -240,6 +245,54 @@ p, li { white-space: pre-wrap; } </layout> </widget> </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="groupBox_6"> + <property name="title"> + <string>Updates</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QCheckBox" name="checkForUpdates"> + <property name="toolTip"> + <string>Mod Organizer checks for updates on Github on startup.</string> + </property> + <property name="whatsThis"> + <string>Mod Organizer checks for updates on Github on startup.</string> + </property> + <property name="text"> + <string>Check for updates</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="usePrereleaseBox"> + <property name="toolTip"> + <string>Update to non-stable releases.</string> + </property> + <property name="whatsThis"> + <string>If this is enabled, the integrated update mechanism will notify of all releases, including pre-releases (alphas, betas). Please use this only if you're sufficiently tech-savvy to investigate issues, look for known problems in the issue tracker and create meaningful reports.</string> + </property> + <property name="text"> + <string>Install Pre-releases (Betas)</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_9"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + </item> </layout> </widget> <widget class="QWidget" name="pathsTab"> @@ -1416,11 +1469,7 @@ programs you are intentionally running.</string> </layout> </widget> <tabstops> - <tabstop>languageBox</tabstop> - <tabstop>styleBox</tabstop> <tabstop>logLevelBox</tabstop> - <tabstop>usePrereleaseBox</tabstop> - <tabstop>categoriesBtn</tabstop> <tabstop>baseDirEdit</tabstop> <tabstop>browseBaseDirBtn</tabstop> <tabstop>downloadDirEdit</tabstop> diff --git a/src/settingsdialoggeneral.cpp b/src/settingsdialoggeneral.cpp index ae924393..07aff4a1 100644 --- a/src/settingsdialoggeneral.cpp +++ b/src/settingsdialoggeneral.cpp @@ -54,6 +54,7 @@ GeneralSettingsTab::GeneralSettingsTab(Settings& s, SettingsDialog& d) ui->centerDialogs->setChecked(settings().geometry().centerDialogs()); ui->compactBox->setChecked(settings().interface().compactDownloads()); ui->showMetaBox->setChecked(settings().interface().metaDownloads()); + ui->checkForUpdates->setChecked(settings().checkForUpdates()); ui->usePrereleaseBox->setChecked(settings().usePrereleases()); ui->colorSeparatorsBox->setChecked(settings().colors().colorSeparatorScrollbar()); @@ -95,6 +96,7 @@ void GeneralSettingsTab::update() settings().geometry().setCenterDialogs(ui->centerDialogs->isChecked()); settings().interface().setCompactDownloads(ui->compactBox->isChecked()); settings().interface().setMetaDownloads(ui->showMetaBox->isChecked()); + settings().setCheckForUpdates(ui->checkForUpdates->isChecked()); settings().setUsePrereleases(ui->usePrereleaseBox->isChecked()); settings().colors().setColorSeparatorScrollbar(ui->colorSeparatorsBox->isChecked()); } |
