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 <QKeyEvent>
#include <QAbstractEventDispatcher>
#include <QStandardPaths>
#include <QMessageBox>
#include <QStyleFactory>
#include <QLocalSocket>
#include <QDir>
#include <QSettings>
#include <QTimer>
#include <QWebSettings>
#include <QNetworkProxyFactory>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QAbstractNetworkCache>
#include <QUrl>
#include <QTemporaryFile>
#include <QtConcurrent/QtConcurrent>
#include <QFutureWatcher>
#include <QProcess>
#include <QWebFrame>
#include <QWebElement>
#include <QShortcut>
#include <QFileDialog>
#include "quazip/quazip.h"
#include "JlCompress.h"
#ifdef WIN32
#include <windows.h>
@ -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) {

View File

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

View File

@ -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();
}

View File

@ -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;