Added blau skin, some refactoring.

This commit is contained in:
Martin Rotter 2014-09-12 07:12:33 +02:00
parent 36ed580f4d
commit b1258d48fe
8 changed files with 75 additions and 68 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 343 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

View File

@ -13,6 +13,7 @@ Fixed:
Added:
<ul>
<li>Re-introduced "blau" (dark) skin.</li>
<li>Import/export dialog now offers "Check/uncheck all items" button.</li>
</ul>

View File

@ -215,52 +215,6 @@ void FormMain::display() {
Application::alert(this);
}
void FormMain::onCommitData(QSessionManager &manager) {
qDebug("OS asked application to commit its data.");
manager.setRestartHint(QSessionManager::RestartNever);
manager.release();
}
void FormMain::onSaveState(QSessionManager &manager) {
qDebug("OS asked application to save its state.");
manager.setRestartHint(QSessionManager::RestartNever);
manager.release();
}
void FormMain::onAboutToQuit() {
// Make sure that we obtain close lock
// BEFORE even trying to quit the application.
bool locked_safely = qApp->closeLock()->tryLock(CLOSE_LOCK_TIMEOUT);
qApp->processEvents();
qDebug("Cleaning up resources and saving application state.");
m_ui->m_tabWidget->feedMessageViewer()->quit();
if (qApp->settings()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool()) {
m_ui->m_tabWidget->feedMessageViewer()->feedsView()->clearAllReadMessages();
}
qApp->database()->saveDatabase();
saveSize();
if (locked_safely) {
// Application obtained permission to close
// in a safety way.
qDebug("Close lock was obtained safely.");
// We locked the lock to exit peacefully, unlock it to avoid warnings.
qApp->closeLock()->unlock();
}
else {
// Request for write lock timed-out. This means
// that some critical action can be processed right now.
qDebug("Close lock timed-out.");
}
}
void FormMain::setupIcons() {
IconFactory *icon_theme_factory = qApp->icons();
@ -375,10 +329,6 @@ void FormMain::createConnections() {
connect(m_statusBar->fullscreenSwitcher(), SIGNAL(toggled(bool)), m_ui->m_actionFullscreen, SLOT(setChecked(bool)));
connect(m_ui->m_actionFullscreen, SIGNAL(toggled(bool)), m_statusBar->fullscreenSwitcher(), SLOT(setChecked(bool)));
// Core connections.
connect(qApp, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(onCommitData(QSessionManager&)));
connect(qApp, SIGNAL(saveStateRequest(QSessionManager&)), this, SLOT(onSaveState(QSessionManager&)));
// Menu "File" connections.
connect(m_ui->m_actionExportFeeds, SIGNAL(triggered()), this, SLOT(exportFeeds()));
connect(m_ui->m_actionImportFeeds, SIGNAL(triggered()), this, SLOT(importFeeds()));
@ -398,9 +348,6 @@ void FormMain::createConnections() {
connect(m_ui->m_actionReportBugGitHub, SIGNAL(triggered()), this, SLOT(reportABugOnGitHub()));
connect(m_ui->m_actionReportBugBitBucket, SIGNAL(triggered()), this, SLOT(reportABugOnBitBucket()));
// General connections.
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
// Menu "Web browser" connections.
connect(m_ui->m_tabWidget, SIGNAL(currentChanged(int)),
this, SLOT(loadWebBrowserMenu(int)));

View File

@ -60,6 +60,10 @@ class FormMain : public QMainWindow {
// for given actions.
QList<QAction*> allActions();
// Loads/saves visual state of the application.
void loadSize();
void saveSize();
protected:
// Creates all needed menus and sets them up.
void prepareMenus();
@ -73,10 +77,6 @@ class FormMain : public QMainWindow {
// Sets up proper icons for this widget.
void setupIcons();
// Loads/saves visual state of the application.
void loadSize();
void saveSize();
public slots:
// Processes incoming message from another RSS Guard instance.
void processExecutionMessage(const QString &message);
@ -97,13 +97,6 @@ class FormMain : public QMainWindow {
void switchMainMenu();
protected slots:
// Last-minute reactors.
void onCommitData(QSessionManager &manager);
void onSaveState(QSessionManager &manager);
// Used for last-minute actions.
void onAboutToQuit();
// Loads web browser menu if user selects to change tabs.
void loadWebBrowserMenu(int index);

View File

@ -23,6 +23,7 @@
#include "gui/messagebox.h"
#include "gui/formmain.h"
#include <QSessionManager>
#include <QThread>
@ -31,6 +32,9 @@ Application::Application(const QString &id, int &argc, char **argv)
m_closeLock(NULL), m_userActions(QList<QAction*>()), m_mainForm(NULL),
m_trayIcon(NULL), m_settings(NULL), m_system(NULL), m_skins(NULL),
m_localization(NULL), m_icons(NULL), m_database(NULL) {
connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
connect(this, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(onCommitData(QSessionManager&)));
connect(this, SIGNAL(saveStateRequest(QSessionManager&)), this, SLOT(onSaveState(QSessionManager&)));
}
Application::~Application() {
@ -87,8 +91,7 @@ void Application::showGuiMessage(const QString& title, const QString& message,
QSystemTrayIcon::MessageIcon message_type,
QWidget *parent, int duration) {
if (SystemTrayIcon::isSystemTrayActivated()) {
// TODO: Maybe show OSD instead if tray icon bubble,
// depending on settings.
// TODO: Maybe show OSD instead if tray icon bubble, depending on settings.
trayIcon()->showMessage(title, message, message_type, duration);
}
else {
@ -96,3 +99,49 @@ void Application::showGuiMessage(const QString& title, const QString& message,
MessageBox::show(parent, (QMessageBox::Icon) message_type, title, message);
}
}
void Application::onCommitData(QSessionManager &manager) {
qDebug("OS asked application to commit its data.");
manager.setRestartHint(QSessionManager::RestartNever);
manager.release();
}
void Application::onSaveState(QSessionManager &manager) {
qDebug("OS asked application to save its state.");
manager.setRestartHint(QSessionManager::RestartNever);
manager.release();
}
void Application::onAboutToQuit() {
// Make sure that we obtain close lock
// BEFORE even trying to quit the application.
bool locked_safely = closeLock()->tryLock(CLOSE_LOCK_TIMEOUT);
processEvents();
qDebug("Cleaning up resources and saving application state.");
mainForm()->tabWidget()->feedMessageViewer()->quit();
if (settings()->value(APP_CFG_MESSAGES, "clear_read_on_exit", false).toBool()) {
mainForm()->tabWidget()->feedMessageViewer()->feedsView()->clearAllReadMessages();
}
database()->saveDatabase();
mainForm()->saveSize();
if (locked_safely) {
// Application obtained permission to close
// in a safety way.
qDebug("Close lock was obtained safely.");
// We locked the lock to exit peacefully, unlock it to avoid warnings.
closeLock()->unlock();
}
else {
// Request for write lock timed-out. This means
// that some critical action can be processed right now.
qDebug("Close lock timed-out.");
}
}

View File

@ -125,8 +125,7 @@ class Application : public QtSingleApplication {
#else
QString temp_directory = QDesktopServices::storageLocation(QDesktopServices::TempLocation);
#endif
return temp_directory;
return temp_directory;
}
// Access to application tray icon. Always use this in cooperation with
@ -146,6 +145,12 @@ class Application : public QtSingleApplication {
return static_cast<Application*>(QCoreApplication::instance());
}
private slots:
// Last-minute reactors.
void onCommitData(QSessionManager &manager);
void onSaveState(QSessionManager &manager);
void onAboutToQuit();
private:
// This read-write lock is used by application on its close.
// Application locks this lock for WRITING.