From 6ef2a8dcbba5eb8ed9683bbb4a14194de258e9da Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Wed, 20 Aug 2014 09:05:19 +0200 Subject: [PATCH] Visual fixes, refactoring. --- src/application.cpp | 8 ++--- src/gui/formabout.cpp | 2 +- src/gui/formcategorydetails.cpp | 2 +- src/gui/formfeeddetails.cpp | 2 +- src/gui/formsettings.cpp | 4 +-- src/gui/formupdate.cpp | 2 +- src/network-web/basenetworkaccessmanager.cpp | 24 +++++--------- src/network-web/basenetworkaccessmanager.h | 7 ++--- src/network-web/downloader.cpp | 33 ++++++++++++++------ src/network-web/downloader.h | 33 ++++++++++++++------ src/network-web/networkfactory.cpp | 5 +-- src/network-web/webbrowser.h | 3 +- src/updater/formupdater.cpp | 9 +++--- src/updater/main.cpp | 1 - 14 files changed, 72 insertions(+), 63 deletions(-) mode change 100644 => 100755 src/application.cpp mode change 100644 => 100755 src/gui/formabout.cpp mode change 100644 => 100755 src/gui/formcategorydetails.cpp mode change 100644 => 100755 src/gui/formfeeddetails.cpp mode change 100644 => 100755 src/network-web/basenetworkaccessmanager.cpp mode change 100644 => 100755 src/network-web/basenetworkaccessmanager.h mode change 100644 => 100755 src/network-web/downloader.cpp mode change 100644 => 100755 src/network-web/downloader.h mode change 100644 => 100755 src/network-web/networkfactory.cpp mode change 100644 => 100755 src/network-web/webbrowser.h mode change 100644 => 100755 src/updater/formupdater.cpp mode change 100644 => 100755 src/updater/main.cpp diff --git a/src/application.cpp b/src/application.cpp old mode 100644 new mode 100755 index 16d8f843a..ae8e1c67e --- a/src/application.cpp +++ b/src/application.cpp @@ -34,9 +34,7 @@ Application::~Application() { SystemTrayIcon *Application::trayIcon() { if (m_trayIcon == NULL) { - m_trayIcon = new SystemTrayIcon(APP_ICON_PATH, - APP_ICON_PLAIN_PATH, - m_mainForm); + m_trayIcon = new SystemTrayIcon(APP_ICON_PATH, APP_ICON_PLAIN_PATH, m_mainForm); m_trayIcon->setToolTip(APP_LONG_NAME); } @@ -44,19 +42,17 @@ SystemTrayIcon *Application::trayIcon() { } void Application::showTrayIcon() { + qDebug("Showing tray icon."); trayIcon()->show(); if (m_mainForm != NULL) { m_mainForm->tabWidget()->feedMessageViewer()->feedsView()->notifyWithCounts(); } - - qDebug("Showing tray icon."); } void Application::deleteTrayIcon() { if (m_trayIcon != NULL) { qDebug("Disabling tray icon, deleting it and raising main application window."); - m_mainForm->display(); delete m_trayIcon; m_trayIcon = NULL; diff --git a/src/gui/formabout.cpp b/src/gui/formabout.cpp old mode 100644 new mode 100755 index e266f9a53..7cf848834 --- a/src/gui/formabout.cpp +++ b/src/gui/formabout.cpp @@ -32,7 +32,7 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout) m_ui->setupUi(this); // Set flags and attributes. - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint); setWindowIcon(IconFactory::instance()->fromTheme("application-about")); //: About RSS Guard dialog title. diff --git a/src/gui/formcategorydetails.cpp b/src/gui/formcategorydetails.cpp old mode 100644 new mode 100755 index f62e425aa..9607b7327 --- a/src/gui/formcategorydetails.cpp +++ b/src/gui/formcategorydetails.cpp @@ -197,7 +197,7 @@ void FormCategoryDetails::initialize() { m_ui->m_txtDescription->lineEdit()->setToolTip(tr("Set description for your category.")); // Set flags and attributes. - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(IconFactory::instance()->fromTheme("folder-category")); // Setup button box. diff --git a/src/gui/formfeeddetails.cpp b/src/gui/formfeeddetails.cpp old mode 100644 new mode 100755 index 0b064d55a..df5124322 --- a/src/gui/formfeeddetails.cpp +++ b/src/gui/formfeeddetails.cpp @@ -353,7 +353,7 @@ void FormFeedDetails::initialize() { m_ui->setupUi(this); // Set flags and attributes. - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(IconFactory::instance()->fromTheme("folder-feed")); // Setup button box. diff --git a/src/gui/formsettings.cpp b/src/gui/formsettings.cpp index d1349a1a0..7b44e6d9e 100755 --- a/src/gui/formsettings.cpp +++ b/src/gui/formsettings.cpp @@ -51,7 +51,7 @@ FormSettings::FormSettings(QWidget *parent) : QDialog(parent), m_ui(new Ui::Form m_ui->setupUi(this); // Set flags and attributes. - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(IconFactory::instance()->fromTheme("application-settings")); #if !defined(Q_OS_WIN) @@ -442,7 +442,7 @@ void FormSettings::loadLanguage() { item->setText(2, language.m_version); item->setText(3, language.m_author); item->setText(4, language.m_email); - item->setIcon(0, IconFactory::instance()->fromTheme("flags" + QDir::separator() + + item->setIcon(0, IconFactory::instance()->fromTheme(FLAG_ICON_SUBFOLDER + QDir::separator() + language.m_code)); } diff --git a/src/gui/formupdate.cpp b/src/gui/formupdate.cpp index 1eb32cd60..11a030e61 100755 --- a/src/gui/formupdate.cpp +++ b/src/gui/formupdate.cpp @@ -36,7 +36,7 @@ FormUpdate::FormUpdate(QWidget *parent) m_ui->setupUi(this); // Set flags and attributes. - setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog); + setWindowFlags(Qt::MSWindowsFixedSizeDialogHint | Qt::Dialog | Qt::WindowSystemMenuHint | Qt::WindowTitleHint); setWindowIcon(IconFactory::instance()->fromTheme("application-about")); m_btnUpdate = m_ui->m_buttonBox->addButton(tr("Update"), QDialogButtonBox::ActionRole); diff --git a/src/network-web/basenetworkaccessmanager.cpp b/src/network-web/basenetworkaccessmanager.cpp old mode 100644 new mode 100755 index a3cec19cc..2d6cf1172 --- a/src/network-web/basenetworkaccessmanager.cpp +++ b/src/network-web/basenetworkaccessmanager.cpp @@ -57,14 +57,10 @@ void BaseNetworkAccessManager::loadSettings() { // Custom proxy is selected, set it up. new_proxy.setType(selected_proxy_type); - new_proxy.setHostName(settings->value(APP_CFG_PROXY, - "host").toString()); - new_proxy.setPort(settings->value(APP_CFG_PROXY, - "port", 80).toInt()); - new_proxy.setUser(settings->value(APP_CFG_PROXY, - "username").toString()); - new_proxy.setPassword(settings->value(APP_CFG_PROXY, - "password").toString()); + new_proxy.setHostName(settings->value(APP_CFG_PROXY, "host").toString()); + new_proxy.setPort(settings->value(APP_CFG_PROXY, "port", 80).toInt()); + new_proxy.setUser(settings->value(APP_CFG_PROXY, "username").toString()); + new_proxy.setPassword(settings->value(APP_CFG_PROXY, "password").toString()); setProxy(new_proxy); qDebug("Settings of BaseNetworkAccessManager loaded."); @@ -72,10 +68,8 @@ void BaseNetworkAccessManager::loadSettings() { void BaseNetworkAccessManager::onSslErrors(QNetworkReply *reply, const QList &error) { - qDebug("SSL errors for '%s': '%s' (code %d).", - qPrintable(reply->url().toString()), - qPrintable(reply->errorString()), - (int) reply->error()); + qDebug("SSL errors for '%s': '%s' (code %d).", qPrintable(reply->url().toString()), + qPrintable(reply->errorString()), (int) reply->error()); reply->ignoreSslErrors(error); } @@ -87,12 +81,10 @@ QNetworkReply *BaseNetworkAccessManager::createRequest(QNetworkAccessManager::Op // This rapidly speeds up loading of web sites. // NOTE: https://en.wikipedia.org/wiki/HTTP_pipelining - new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, - true); + new_request.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); // Setup custom user-agent. - new_request.setRawHeader(USER_AGENT_HTTP_HEADER, - QString(APP_USERAGENT).toLocal8Bit()); + new_request.setRawHeader(USER_AGENT_HTTP_HEADER, QString(APP_USERAGENT).toLocal8Bit()); return QNetworkAccessManager::createRequest(op, new_request, outgoingData); } diff --git a/src/network-web/basenetworkaccessmanager.h b/src/network-web/basenetworkaccessmanager.h old mode 100644 new mode 100755 index 7341db003..3c39678b0 --- a/src/network-web/basenetworkaccessmanager.h +++ b/src/network-web/basenetworkaccessmanager.h @@ -36,14 +36,11 @@ class BaseNetworkAccessManager : public QNetworkAccessManager { virtual void loadSettings(); protected slots: - void onSslErrors(QNetworkReply *reply, - const QList &error); + void onSslErrors(QNetworkReply *reply, const QList &error); protected: // Creates custom request. - QNetworkReply *createRequest(Operation op, - const QNetworkRequest &request, - QIODevice *outgoingData); + QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData); }; #endif // BASENETWORKACCESSMANAGER_H diff --git a/src/network-web/downloader.cpp b/src/network-web/downloader.cpp old mode 100644 new mode 100755 index ad749b952..0ba87b4bd --- a/src/network-web/downloader.cpp +++ b/src/network-web/downloader.cpp @@ -1,3 +1,20 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2014 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + #include "network-web/downloader.h" #include "network-web/silentnetworkaccessmanager.h" @@ -11,7 +28,7 @@ Downloader::Downloader(QObject *parent) m_downloadManager(new SilentNetworkAccessManager(this)), m_timer(new QTimer(this)) { - m_timer->setInterval(2000); + m_timer->setInterval(DOWNLOAD_TIMEOUT); m_timer->setSingleShot(true); connect(m_timer, SIGNAL(timeout()), this, SLOT(timeout())); @@ -33,10 +50,9 @@ void Downloader::downloadFile(const QString &url, bool protected_contents, originatingObject.setProperty("password", password); request.setOriginatingObject(&originatingObject); - // Set url for this reques. + // Set url for this request and fire it up. request.setUrl(url); - - runRequest(request); + runGetRequest(request); } void Downloader::finished(QNetworkReply *reply) { @@ -54,12 +70,10 @@ void Downloader::finished(QNetworkReply *reply) { m_activeReply->deleteLater(); m_activeReply = NULL; - runRequest(request); + runGetRequest(request); } else { - // No redirection is indicated. Final file is obtained - // in our "reply" object. - + // No redirection is indicated. Final file is obtained in our "reply" object. // Read the data into output buffer. QByteArray output = reply->readAll(); QNetworkReply::NetworkError reply_error = reply->error(); @@ -81,11 +95,12 @@ void Downloader::progressInternal(qint64 bytes_received, qint64 bytes_total) { void Downloader::timeout() { if (m_activeReply != NULL) { + // Download action timed-out, too slow connection or target is no reachable. m_activeReply->abort(); } } -void Downloader::runRequest(const QNetworkRequest &request) { +void Downloader::runGetRequest(const QNetworkRequest &request) { m_timer->start(); m_activeReply = m_downloadManager->get(request); diff --git a/src/network-web/downloader.h b/src/network-web/downloader.h old mode 100644 new mode 100755 index 0768a5666..d347baa9e --- a/src/network-web/downloader.h +++ b/src/network-web/downloader.h @@ -1,13 +1,30 @@ +// This file is part of RSS Guard. +// +// Copyright (C) 2011-2014 by Martin Rotter +// +// RSS Guard is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// RSS Guard is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with RSS Guard. If not, see . + #ifndef DOWNLOADER_H #define DOWNLOADER_H #include +#include "definitions/definitions.h" + #include #include -#include "definitions/definitions.h" - class SilentNetworkAccessManager; class QTimer; @@ -21,12 +38,9 @@ class Downloader : public QObject { virtual ~Downloader(); public slots: - // Performs asynchronous download of given file. - // Redirections are handled. - void downloadFile(const QString &url, - bool protected_contents = false, - const QString &username = QString(), - const QString &password = QString()); + // Performs asynchronous download of given file. Redirections are handled. + void downloadFile(const QString &url, bool protected_contents = false, + const QString &username = QString(), const QString &password = QString()); signals: // Emitted when new progress is known. @@ -44,11 +58,10 @@ class Downloader : public QObject { void timeout(); private: - void runRequest(const QNetworkRequest &request); + void runGetRequest(const QNetworkRequest &request); private: QNetworkReply *m_activeReply; - SilentNetworkAccessManager *m_downloadManager; QTimer *m_timer; }; diff --git a/src/network-web/networkfactory.cpp b/src/network-web/networkfactory.cpp old mode 100644 new mode 100755 index 589cc5b1c..794a1a77f --- a/src/network-web/networkfactory.cpp +++ b/src/network-web/networkfactory.cpp @@ -104,10 +104,7 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QString &url, QString google_s2_with_url = QString("http://www.google.com/s2/favicons?domain=%1").arg(Qt::escape(url)); #endif QByteArray icon_data; - - QNetworkReply::NetworkError network_result = downloadFeedFile(google_s2_with_url, - timeout, - icon_data); + QNetworkReply::NetworkError network_result = downloadFeedFile(google_s2_with_url, timeout, icon_data); if (network_result == QNetworkReply::NoError) { QPixmap icon_pixmap; diff --git a/src/network-web/webbrowser.h b/src/network-web/webbrowser.h old mode 100644 new mode 100755 index 759c39930..e048b2ce8 --- a/src/network-web/webbrowser.h +++ b/src/network-web/webbrowser.h @@ -18,9 +18,10 @@ #ifndef WEBBROWSER_H #define WEBBROWSER_H +#include "gui/tabcontent.h" + #include "core/messagesmodel.h" #include "network-web/webview.h" -#include "gui/tabcontent.h" #include "gui/locationlineedit.h" #include diff --git a/src/updater/formupdater.cpp b/src/updater/formupdater.cpp old mode 100644 new mode 100755 index f96c1ce2b..a6c087d1b --- a/src/updater/formupdater.cpp +++ b/src/updater/formupdater.cpp @@ -60,7 +60,6 @@ FormUpdater::FormUpdater(QWidget *parent) setCentralWidget(m_txtOutput); setWindowTitle("RSS Guard updater"); setWindowIcon(QIcon(APP_ICON_PATH)); - moveToCenterAndResize(); connect(this, SIGNAL(debugMessageProduced(QtMsgType,QString)), @@ -134,19 +133,19 @@ void FormUpdater::triggerDebugMessageConsumption(QtMsgType type, const QString & void FormUpdater::consumeDebugMessage(QtMsgType type, const QString &message) { switch (type) { case QtDebugMsg: - s_instance->printText(QString("DEBUG: %1").arg(message)); + printText(QString("DEBUG: %1").arg(message)); break; case QtWarningMsg: - s_instance->printText(QString("WARNING: %1").arg(message)); + printText(QString("WARNING: %1").arg(message)); break; case QtCriticalMsg: - s_instance->printText(QString("CRITICAL: %1").arg(message)); + printText(QString("CRITICAL: %1").arg(message)); break; case QtFatalMsg: - s_instance->printText(QString("FATAL: %1").arg(message)); + printText(QString("FATAL: %1").arg(message)); qApp->exit(EXIT_FAILURE); default: diff --git a/src/updater/main.cpp b/src/updater/main.cpp old mode 100644 new mode 100755 index 9a638a8c1..e4fb0101d --- a/src/updater/main.cpp +++ b/src/updater/main.cpp @@ -53,4 +53,3 @@ int main(int argc, char *argv[]) { return application.exec(); } -