Removed some unused includes, and variables in mainWindow. Fixed settings not being changed back on cancel, and hotkey.

This commit is contained in:
MichaelBeeu 2013-11-25 00:28:20 -06:00
parent 72e0ed38b3
commit 06a56d8a2b
4 changed files with 22 additions and 29 deletions

View File

@ -11,29 +11,16 @@
#include <QCoreApplication> #include <QCoreApplication>
#include <QKeyEvent> #include <QKeyEvent>
#include <QAbstractEventDispatcher> #include <QAbstractEventDispatcher>
#include <QStandardPaths>
#include <QMessageBox> #include <QMessageBox>
#include <QStyleFactory> #include <QStyleFactory>
#include <QLocalSocket> #include <QLocalSocket>
#include <QDir>
#include <QSettings> #include <QSettings>
#include <QTimer> #include <QTimer>
#include <QWebSettings> #include <QWebSettings>
#include <QNetworkProxyFactory> #include <QNetworkProxyFactory>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QAbstractNetworkCache> #include <QAbstractNetworkCache>
#include <QUrl>
#include <QTemporaryFile>
#include <QtConcurrent/QtConcurrent>
#include <QFutureWatcher>
#include <QProcess>
#include <QWebFrame> #include <QWebFrame>
#include <QWebElement>
#include <QShortcut> #include <QShortcut>
#include <QFileDialog>
#include "quazip/quazip.h"
#include "JlCompress.h"
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <windows.h>
@ -57,7 +44,6 @@ MainWindow::MainWindow(QWidget *parent) :
{ {
trayIcon = nullptr; trayIcon = nullptr;
trayIconMenu = nullptr; trayIconMenu = nullptr;
naCount = 0;
// Use the platform-specific proxy settings // Use the platform-specific proxy settings
QNetworkProxyFactory::setUseSystemConfiguration(true); QNetworkProxyFactory::setUseSystemConfiguration(true);
@ -149,6 +135,7 @@ MainWindow::MainWindow(QWidget *parent) :
settingsDialog.setHotKey(hotKey); settingsDialog.setHotKey(hotKey);
nativeFilter.setEnabled(false); nativeFilter.setEnabled(false);
if(settingsDialog.exec()) { if(settingsDialog.exec()) {
setHotKey(settingsDialog.hotKey());
if(settings.value("hidingBehavior").toString() == "systray") { if(settings.value("hidingBehavior").toString() == "systray") {
createTrayIcon(); createTrayIcon();
} else if(trayIcon) { } else if(trayIcon) {

View File

@ -2,9 +2,7 @@
#define MAINWINDOW_H #define MAINWINDOW_H
#include <QMainWindow> #include <QMainWindow>
#include <QProcess>
#include <QLocalServer> #include <QLocalServer>
#include <QNetworkAccessManager>
#include <QDialog> #include <QDialog>
#include <QSettings> #include <QSettings>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
@ -43,10 +41,8 @@ private:
QSettings settings; QSettings settings;
ZealNativeEventFilter nativeFilter; ZealNativeEventFilter nativeFilter;
ZealSettingsDialog settingsDialog; ZealSettingsDialog settingsDialog;
QNetworkAccessManager naManager;
QSystemTrayIcon *trayIcon; QSystemTrayIcon *trayIcon;
QMenu *trayIconMenu; QMenu *trayIconMenu;
int naCount;
QMap<QString, QString> urls; QMap<QString, QString> urls;
private slots: private slots:
void refreshRequest(); void refreshRequest();

View File

@ -29,15 +29,7 @@ ZealSettingsDialog::ZealSettingsDialog(ZealListModel &zList, QWidget *parent) :
ui->listView->setModel( &zealList ); ui->listView->setModel( &zealList );
ui->minFontSize->setValue(settings.value("minFontSize").toInt()); loadSettings();
QString hiding = settings.value("hidingBehavior", "systray").toString();
if(hiding == "systray") {
ui->radioSysTray->setChecked(true);
} else {
ui->radioMinimize->setChecked(true);
}
ui->storageEdit->setText(docsets->docsetsDir());
connect(&naManager, &QNetworkAccessManager::finished, [this](QNetworkReply *reply){DownloadCompleteCb(reply);}); connect(&naManager, &QNetworkAccessManager::finished, [this](QNetworkReply *reply){DownloadCompleteCb(reply);});
} }
@ -57,6 +49,17 @@ QKeySequence ZealSettingsDialog::hotKey()
return ui->toolButton->keySequence(); 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){ void ZealSettingsDialog::progressCb(quint64 recv, quint64 total){
if(recv > 10240) { // don't show progress for non-docset pages (like Google Drive first request) if(recv > 10240) { // don't show progress for non-docset pages (like Google Drive first request)
ui->docsetsProgress->setMaximum(total); ui->docsetsProgress->setMaximum(total);
@ -369,7 +372,6 @@ void ZealSettingsDialog::on_buttonBox_accepted()
// reload docsets: // reload docsets:
docsets->initialiseDocsets(); docsets->initialiseDocsets();
} }
setHotKey(hotKey());
settings.setValue("minFontSize", ui->minFontSize->text()); settings.setValue("minFontSize", ui->minFontSize->text());
settings.setValue("hidingBehavior", settings.setValue("hidingBehavior",
ui->radioSysTray->isChecked() ? ui->radioSysTray->isChecked() ?
@ -380,3 +382,8 @@ void ZealSettingsDialog::on_minFontSize_valueChanged(int arg1)
{ {
minFontSizeChanged(arg1); minFontSizeChanged(arg1);
} }
void ZealSettingsDialog::on_buttonBox_rejected()
{
loadSettings();
}

View File

@ -21,7 +21,8 @@ public:
Ui::ZealSettingsDialog *ui; Ui::ZealSettingsDialog *ui;
public: private:
void loadSettings();
void progressCb(quint64 recv, quint64 total); void progressCb(quint64 recv, quint64 total);
void DownloadCompleteCb(QNetworkReply *reply); void DownloadCompleteCb(QNetworkReply *reply);
signals: signals:
@ -46,6 +47,8 @@ private slots:
void on_minFontSize_valueChanged(int arg1); void on_minFontSize_valueChanged(int arg1);
void on_buttonBox_rejected();
private: private:
ZealListModel &zealList; ZealListModel &zealList;
QNetworkAccessManager naManager; QNetworkAccessManager naManager;