Visual fixes, refactoring.

This commit is contained in:
Martin Rotter 2014-08-20 09:05:19 +02:00
parent 10387c65a3
commit 6ef2a8dcbb
14 changed files with 72 additions and 63 deletions

8
src/application.cpp Normal file → Executable file
View File

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

2
src/gui/formabout.cpp Normal file → Executable file
View File

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

2
src/gui/formcategorydetails.cpp Normal file → Executable file
View File

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

2
src/gui/formfeeddetails.cpp Normal file → Executable file
View File

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

View File

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

View File

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

24
src/network-web/basenetworkaccessmanager.cpp Normal file → Executable file
View File

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

7
src/network-web/basenetworkaccessmanager.h Normal file → Executable file
View File

@ -36,14 +36,11 @@ class BaseNetworkAccessManager : public QNetworkAccessManager {
virtual void loadSettings();
protected slots:
void onSslErrors(QNetworkReply *reply,
const QList<QSslError> &error);
void onSslErrors(QNetworkReply *reply, const QList<QSslError> &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

33
src/network-web/downloader.cpp Normal file → Executable file
View File

@ -1,3 +1,20 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#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);

33
src/network-web/downloader.h Normal file → Executable file
View File

@ -1,13 +1,30 @@
// This file is part of RSS Guard.
//
// Copyright (C) 2011-2014 by Martin Rotter <rotter.martinos@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
#ifndef DOWNLOADER_H
#define DOWNLOADER_H
#include <QObject>
#include "definitions/definitions.h"
#include <QNetworkReply>
#include <QSslError>
#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;
};

5
src/network-web/networkfactory.cpp Normal file → Executable file
View File

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

3
src/network-web/webbrowser.h Normal file → Executable file
View File

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

9
src/updater/formupdater.cpp Normal file → Executable file
View File

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

1
src/updater/main.cpp Normal file → Executable file
View File

@ -53,4 +53,3 @@ int main(int argc, char *argv[]) {
return application.exec();
}