diff --git a/resources/text/CHANGELOG b/resources/text/CHANGELOG
index b6d20fb7b..ef3d128b9 100644
--- a/resources/text/CHANGELOG
+++ b/resources/text/CHANGELOG
@@ -13,6 +13,7 @@ Fixed:
Added:
+- Application can now be safely restarted from within main menu.
- HTTP request for feed files now contains special "Accept" header.
- Recycle bin with ability to trash or restore the whole bin or individual messages.
- MySQL backend now allows to defragment/optimize RSS Guard database.
diff --git a/src/gui/formmain.cpp b/src/gui/formmain.cpp
index f2f5be2b2..375fc904e 100755
--- a/src/gui/formmain.cpp
+++ b/src/gui/formmain.cpp
@@ -87,6 +87,7 @@ QList FormMain::allActions() {
actions << m_ui->m_actionSettings;
actions << m_ui->m_actionImportFeeds;
actions << m_ui->m_actionExportFeeds;
+ actions << m_ui->m_actionRestart;
actions << m_ui->m_actionQuit;
actions << m_ui->m_actionFullscreen;
actions << m_ui->m_actionAboutGuard;
@@ -202,6 +203,7 @@ void FormMain::setupIcons() {
// Setup icons of this main window.
m_ui->m_actionSettings->setIcon(icon_theme_factory->fromTheme("application-settings"));
m_ui->m_actionQuit->setIcon(icon_theme_factory->fromTheme("application-exit"));
+ m_ui->m_actionRestart->setIcon(icon_theme_factory->fromTheme("go-refresh"));
m_ui->m_actionAboutGuard->setIcon(icon_theme_factory->fromTheme("application-about"));
m_ui->m_actionCheckForUpdates->setIcon(icon_theme_factory->fromTheme("check-for-updates"));
m_ui->m_actionDefragmentDatabase->setIcon(icon_theme_factory->fromTheme("defragment-database"));
@@ -328,6 +330,7 @@ void FormMain::createConnections() {
// Menu "File" connections.
connect(m_ui->m_actionExportFeeds, SIGNAL(triggered()), this, SLOT(exportFeeds()));
connect(m_ui->m_actionImportFeeds, SIGNAL(triggered()), this, SLOT(importFeeds()));
+ connect(m_ui->m_actionRestart, SIGNAL(triggered()), qApp, SLOT(restart()));
connect(m_ui->m_actionQuit, SIGNAL(triggered()), qApp, SLOT(quit()));
// Menu "View" connections.
diff --git a/src/gui/formmain.ui b/src/gui/formmain.ui
index 1b8398171..f087e70fa 100755
--- a/src/gui/formmain.ui
+++ b/src/gui/formmain.ui
@@ -58,6 +58,7 @@
+
diff --git a/src/miscellaneous/application.cpp b/src/miscellaneous/application.cpp
index d9d284ac9..a82038383 100755
--- a/src/miscellaneous/application.cpp
+++ b/src/miscellaneous/application.cpp
@@ -32,7 +32,7 @@ Application::Application(const QString &id, int &argc, char **argv)
: QtSingleApplication(id, argc, argv),
m_closeLock(NULL), m_userActions(QList()), m_mainForm(NULL),
m_trayIcon(NULL), m_settings(NULL), m_system(NULL), m_skins(NULL),
- m_localization(NULL), m_icons(NULL), m_database(NULL) {
+ m_localization(NULL), m_icons(NULL), m_database(NULL), m_shouldRestart(false) {
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&)));
@@ -159,4 +159,28 @@ void Application::onAboutToQuit() {
// that some critical action can be processed right now.
qDebug("Close lock timed-out.");
}
+
+ // Now, we can check if application should just quit or restart itself.
+ if (m_shouldRestart) {
+ // TODO: Disable qtsinglepplication.
+ // TODO: Start new instance.
+ if (QProcess::startDetached(applicationFilePath())) {
+ finish();
+ qWarning("New application instance was not started successfully.");
+ }
+ }
}
+
+bool Application::shouldRestart() const {
+ return m_shouldRestart;
+}
+
+void Application::setShouldRestart(bool shouldRestart) {
+ m_shouldRestart = shouldRestart;
+}
+
+void Application::restart() {
+ m_shouldRestart = true;
+ quit();
+}
+
diff --git a/src/miscellaneous/application.h b/src/miscellaneous/application.h
index 472ccd67d..6776ba7d3 100755
--- a/src/miscellaneous/application.h
+++ b/src/miscellaneous/application.h
@@ -1,4 +1,4 @@
-// This file is part of RSS Guard.
+// This file is part of RSS Guard.
//
// Copyright (C) 2011-2014 by Martin Rotter
//
@@ -144,7 +144,12 @@ class Application : public QtSingleApplication {
return static_cast(QCoreApplication::instance());
}
+ bool shouldRestart() const;
+ void setShouldRestart(bool shouldRestart);
+
public slots:
+ void restart();
+
// Processes incoming message from another RSS Guard instance.
void processExecutionMessage(const QString &message);
@@ -177,6 +182,7 @@ class Application : public QtSingleApplication {
Localization *m_localization;
IconFactory *m_icons;
DatabaseFactory *m_database;
+ bool m_shouldRestart;
};
#endif // APPLICATION_H
diff --git a/src/qtsingleapplication/qtsingleapplication.cpp b/src/qtsingleapplication/qtsingleapplication.cpp
index d0fb15d76..66c70d1d8 100644
--- a/src/qtsingleapplication/qtsingleapplication.cpp
+++ b/src/qtsingleapplication/qtsingleapplication.cpp
@@ -329,6 +329,10 @@ void QtSingleApplication::activateWindow()
}
}
+void QtSingleApplication::finish()
+{
+ delete peer; peer = 0;
+}
/*!
\fn void QtSingleApplication::messageReceived(const QString& message)
diff --git a/src/qtsingleapplication/qtsingleapplication.h b/src/qtsingleapplication/qtsingleapplication.h
index 049406f72..80181740b 100644
--- a/src/qtsingleapplication/qtsingleapplication.h
+++ b/src/qtsingleapplication/qtsingleapplication.h
@@ -90,6 +90,7 @@ public:
public Q_SLOTS:
bool sendMessage(const QString &message, int timeout = 5000);
void activateWindow();
+ void finish();
Q_SIGNALS: