diff --git a/zeal/mainwindow.cpp b/zeal/mainwindow.cpp index e8f34dc..8e7e573 100644 --- a/zeal/mainwindow.cpp +++ b/zeal/mainwindow.cpp @@ -11,29 +11,16 @@ #include #include #include -#include #include #include #include -#include #include #include #include #include -#include -#include #include -#include -#include -#include -#include -#include #include -#include #include -#include -#include "quazip/quazip.h" -#include "JlCompress.h" #ifdef WIN32 #include @@ -57,7 +44,6 @@ MainWindow::MainWindow(QWidget *parent) : { trayIcon = nullptr; trayIconMenu = nullptr; - naCount = 0; // Use the platform-specific proxy settings QNetworkProxyFactory::setUseSystemConfiguration(true); @@ -149,6 +135,7 @@ MainWindow::MainWindow(QWidget *parent) : settingsDialog.setHotKey(hotKey); nativeFilter.setEnabled(false); if(settingsDialog.exec()) { + setHotKey(settingsDialog.hotKey()); if(settings.value("hidingBehavior").toString() == "systray") { createTrayIcon(); } else if(trayIcon) { diff --git a/zeal/mainwindow.h b/zeal/mainwindow.h index 4b8ca86..8dce01b 100644 --- a/zeal/mainwindow.h +++ b/zeal/mainwindow.h @@ -2,9 +2,7 @@ #define MAINWINDOW_H #include -#include #include -#include #include #include #include @@ -43,10 +41,8 @@ private: QSettings settings; ZealNativeEventFilter nativeFilter; ZealSettingsDialog settingsDialog; - QNetworkAccessManager naManager; QSystemTrayIcon *trayIcon; QMenu *trayIconMenu; - int naCount; QMap urls; private slots: void refreshRequest(); diff --git a/zeal/zealsettingsdialog.cpp b/zeal/zealsettingsdialog.cpp index 297da9a..920327c 100644 --- a/zeal/zealsettingsdialog.cpp +++ b/zeal/zealsettingsdialog.cpp @@ -29,15 +29,7 @@ ZealSettingsDialog::ZealSettingsDialog(ZealListModel &zList, QWidget *parent) : ui->listView->setModel( &zealList ); - ui->minFontSize->setValue(settings.value("minFontSize").toInt()); - QString hiding = settings.value("hidingBehavior", "systray").toString(); - if(hiding == "systray") { - ui->radioSysTray->setChecked(true); - } else { - ui->radioMinimize->setChecked(true); - } - ui->storageEdit->setText(docsets->docsetsDir()); - + loadSettings(); connect(&naManager, &QNetworkAccessManager::finished, [this](QNetworkReply *reply){DownloadCompleteCb(reply);}); } @@ -57,6 +49,17 @@ QKeySequence ZealSettingsDialog::hotKey() return ui->toolButton->keySequence(); } +void ZealSettingsDialog::loadSettings(){ + ui->minFontSize->setValue(settings.value("minFontSize").toInt()); + QString hiding = settings.value("hidingBehavior", "systray").toString(); + if(hiding == "systray") { + ui->radioSysTray->setChecked(true); + } else { + ui->radioMinimize->setChecked(true); + } + ui->storageEdit->setText(docsets->docsetsDir()); +} + void ZealSettingsDialog::progressCb(quint64 recv, quint64 total){ if(recv > 10240) { // don't show progress for non-docset pages (like Google Drive first request) ui->docsetsProgress->setMaximum(total); @@ -369,7 +372,6 @@ void ZealSettingsDialog::on_buttonBox_accepted() // reload docsets: docsets->initialiseDocsets(); } - setHotKey(hotKey()); settings.setValue("minFontSize", ui->minFontSize->text()); settings.setValue("hidingBehavior", ui->radioSysTray->isChecked() ? @@ -380,3 +382,8 @@ void ZealSettingsDialog::on_minFontSize_valueChanged(int arg1) { minFontSizeChanged(arg1); } + +void ZealSettingsDialog::on_buttonBox_rejected() +{ + loadSettings(); +} diff --git a/zeal/zealsettingsdialog.h b/zeal/zealsettingsdialog.h index f1e8b39..d4b5315 100644 --- a/zeal/zealsettingsdialog.h +++ b/zeal/zealsettingsdialog.h @@ -21,7 +21,8 @@ public: Ui::ZealSettingsDialog *ui; - public: +private: + void loadSettings(); void progressCb(quint64 recv, quint64 total); void DownloadCompleteCb(QNetworkReply *reply); signals: @@ -46,6 +47,8 @@ private slots: void on_minFontSize_valueChanged(int arg1); + void on_buttonBox_rejected(); + private: ZealListModel &zealList; QNetworkAccessManager naManager;