Merge branch 'master' of bitbucket.org:skunkos/rssguard
This commit is contained in:
commit
652ebb2c7b
@ -30,9 +30,7 @@ You can download source tarballs or binaries for some platforms in [Downloads](d
|
||||
|
||||
* [stable releases](http://software.opensuse.org/download.html?project=home%3Askunkos&package=rssguard),
|
||||
* [development releases](http://software.opensuse.org/download.html?project=home%3Askunkos&package=rssguard-git) (compiled from the master branch of RSS Guard Git repository),
|
||||
* [Archlinux AUR stable package (compiled with Qt 5)](https://aur.archlinux.org/packages/rssguard/),
|
||||
* [Archlinux AUR stable package (compiled with Qt 4)](https://aur.archlinux.org/packages/rssguard-qt4/),
|
||||
* [Archlinux AUR development package (compiled with Qt 5)](https://aur.archlinux.org/packages/rssguard-git/).
|
||||
* Archlinux AUR package ([stable-qt5](https://aur.archlinux.org/packages/rssguard/), [stable-qt4](https://aur.archlinux.org/packages/rssguard-qt4/), [development-qt5](https://aur.archlinux.org/packages/rssguard-git/)].
|
||||
- - -
|
||||
Features
|
||||
--------
|
||||
|
@ -8,7 +8,7 @@ Fixed:
|
||||
|
||||
Added:
|
||||
<ul>
|
||||
<li>Application is now able to self-update itself on OS/2 and Windows. Currently, this is EXPERIMENTAL support. Please, report any bugs.</li>
|
||||
<li>Application is now able to self-update itself on OS/2 and Windows. Currently, this is EXPERIMENTAL support. Please, report any bugs. Authors take no responsibility for removed files or lost application settings.</li>
|
||||
<li>Added option to adjust icons/buttons displayed in toolbars. See Settings/User interface/Toolbars dialog for more information.</li>
|
||||
<li>Added option to search messages via regular expression.</li>
|
||||
<li>Added option to highlight particular messages - unread, important, none.</li>
|
||||
|
@ -1,8 +1,25 @@
|
||||
// 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 "application.h"
|
||||
|
||||
|
||||
Application::Application(int &argc, char **argv)
|
||||
: QtSingleApplication(argc, argv) {
|
||||
Application::Application(const QString &id, int &argc, char **argv)
|
||||
: QtSingleApplication(id, argc, argv) {
|
||||
}
|
||||
|
||||
Application::~Application() {
|
||||
|
@ -1,8 +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 APPLICATION_H
|
||||
#define APPLICATION_H
|
||||
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
|
||||
#if defined(qApp)
|
||||
#undef qApp
|
||||
#endif
|
||||
#define qApp (Application::instance())
|
||||
|
||||
|
||||
// TODO: presunout nektery veci sem, settings atp
|
||||
class Application : public QtSingleApplication {
|
||||
@ -10,7 +32,7 @@ class Application : public QtSingleApplication {
|
||||
|
||||
public:
|
||||
// Constructors and destructors.
|
||||
explicit Application(int &argc, char **argv);
|
||||
explicit Application(const QString &id, int &argc, char **argv);
|
||||
virtual ~Application();
|
||||
|
||||
// Returns pointer to "GOD" application singleton.
|
||||
|
@ -21,7 +21,6 @@
|
||||
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
FeedDownloader::FeedDownloader(QObject *parent) : QObject(parent) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "core/feedsmodelrootitem.h"
|
||||
|
||||
#include <QSqlRecord>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
class FeedsModelFeed;
|
||||
|
@ -25,12 +25,11 @@
|
||||
#include <QSqlRecord>
|
||||
#include <QPair>
|
||||
#include <QNetworkReply>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
class Message;
|
||||
|
||||
|
||||
// Represents BASE class for feeds contained in FeedsModel.
|
||||
// NOTE: This class should be derived to create PARTICULAR feed types.
|
||||
class FeedsModelFeed : public FeedsModelRootItem {
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "core/feedsmodelrootitem.h"
|
||||
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QVariant>
|
||||
|
||||
@ -35,7 +35,7 @@ FeedsModelRootItem::~FeedsModelRootItem() {
|
||||
}
|
||||
|
||||
void FeedsModelRootItem::setupFonts() {
|
||||
m_normalFont = QtSingleApplication::font("FeedsView");
|
||||
m_normalFont = Application::font("FeedsView");
|
||||
m_boldFont = m_normalFont;
|
||||
m_boldFont.setBold(true);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "miscellaneous/textfactory.h"
|
||||
#include "miscellaneous/databasefactory.h"
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QSqlRecord>
|
||||
#include <QSqlError>
|
||||
@ -62,7 +62,7 @@ void MessagesModel::fetchAll() {
|
||||
}
|
||||
|
||||
void MessagesModel::setupFonts() {
|
||||
m_normalFont = QtSingleApplication::font("MessagesView");
|
||||
m_normalFont = Application::font("MessagesView");
|
||||
m_boldFont = m_normalFont;
|
||||
m_boldFont.setBold(true);
|
||||
}
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include <QSplitter>
|
||||
#include <QToolBar>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QLineEdit>
|
||||
#include <QAction>
|
||||
#include <QToolButton>
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "gui/statusbar.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/formupdate.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QSessionManager>
|
||||
@ -219,7 +219,7 @@ void FormMain::display() {
|
||||
raise();
|
||||
|
||||
// Raise alert event. Check the documentation for more info on this.
|
||||
QtSingleApplication::alert(this);
|
||||
Application::alert(this);
|
||||
}
|
||||
|
||||
void FormMain::onCommitData(QSessionManager &manager) {
|
||||
|
@ -38,8 +38,8 @@
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/basetoolbar.h"
|
||||
#include "gui/messagestoolbar.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "dynamic-shortcuts/dynamicshortcuts.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QProcess>
|
||||
#include <QNetworkProxy>
|
||||
|
@ -17,13 +17,7 @@
|
||||
|
||||
#include "gui/locationlineedit.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QStyleOptionFrameV2>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
|
||||
|
||||
LocationLineEdit::LocationLineEdit(QWidget *parent)
|
||||
|
@ -18,13 +18,14 @@
|
||||
#include "gui/messagebox.h"
|
||||
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QtGlobal>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QStyle>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
MessageBox::MessageBox(QWidget *parent) : QMessageBox(parent) {
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/formsettings.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QTimer>
|
||||
@ -36,7 +36,7 @@ TrayIconMenu::~TrayIconMenu() {
|
||||
}
|
||||
|
||||
bool TrayIconMenu::event(QEvent *event) {
|
||||
if (QtSingleApplication::activeModalWidget() != NULL &&
|
||||
if (Application::activeModalWidget() != NULL &&
|
||||
event->type() == QEvent::Show) {
|
||||
QTimer::singleShot(0, this, SLOT(hide()));
|
||||
SystemTrayIcon::instance()->showMessage(APP_LONG_NAME,
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "gui/formmain.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
|
||||
|
18
src/main.cpp
18
src/main.cpp
@ -27,7 +27,7 @@
|
||||
#include "gui/systemtrayicon.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
// Needed for setting ini file format on Mac OS.
|
||||
#ifdef Q_OS_MAC
|
||||
@ -66,8 +66,8 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// Instantiate base application object.
|
||||
QtSingleApplication application(APP_LOW_NAME, argc, argv);
|
||||
qDebug("Instantiated QtSingleApplication class.");
|
||||
Application application(APP_LOW_NAME, argc, argv);
|
||||
qDebug("Instantiated Application class.");
|
||||
|
||||
// Check if another instance is running.
|
||||
if (application.sendMessage(APP_IS_RUNNING)) {
|
||||
@ -85,11 +85,11 @@ int main(int argc, char *argv[]) {
|
||||
Localization::instance()->load();
|
||||
|
||||
// These settings needs to be set before any QSettings object.
|
||||
QtSingleApplication::setApplicationName(APP_NAME);
|
||||
QtSingleApplication::setApplicationVersion(APP_VERSION);
|
||||
QtSingleApplication::setOrganizationName(APP_AUTHOR);
|
||||
QtSingleApplication::setOrganizationDomain(APP_URL);
|
||||
QtSingleApplication::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||
Application::setApplicationName(APP_NAME);
|
||||
Application::setApplicationVersion(APP_VERSION);
|
||||
Application::setOrganizationName(APP_AUTHOR);
|
||||
Application::setOrganizationDomain(APP_URL);
|
||||
Application::setWindowIcon(QIcon(APP_ICON_PATH));
|
||||
|
||||
qDebug().nospace() << "Creating main application form in thread: \'" <<
|
||||
QThread::currentThreadId() << "\'.";
|
||||
@ -126,5 +126,5 @@ int main(int argc, char *argv[]) {
|
||||
&main_window, SLOT(processExecutionMessage(QString)));
|
||||
|
||||
// Enter global event loop.
|
||||
return QtSingleApplication::exec();
|
||||
return Application::exec();
|
||||
}
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QSqlQuery>
|
||||
#include <QSqlError>
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "miscellaneous/debugging.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include <cstdio>
|
||||
|
@ -18,15 +18,17 @@
|
||||
#ifndef ICONFACTORY_H
|
||||
#define ICONFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QPointer>
|
||||
#include <QHash>
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
|
||||
class IconFactory : public QObject {
|
||||
public:
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QApplication>
|
||||
#include <QTranslator>
|
||||
#include <QDir>
|
||||
#include <QFileInfoList>
|
||||
@ -61,7 +60,7 @@ void Localization::load() {
|
||||
if (app_translator->load(QString("rssguard-%1.qm").arg(desired_localization),
|
||||
APP_LANG_PATH,
|
||||
"-")) {
|
||||
QApplication::installTranslator(app_translator);
|
||||
Application::installTranslator(app_translator);
|
||||
qDebug("Application localization '%s' loaded successfully.",
|
||||
qPrintable(desired_localization));
|
||||
}
|
||||
@ -74,7 +73,7 @@ void Localization::load() {
|
||||
if (qt_translator->load(QString("qt-%1.qm").arg(desired_localization),
|
||||
APP_LANG_PATH,
|
||||
"-")) {
|
||||
QApplication::installTranslator(qt_translator);
|
||||
Application::installTranslator(qt_translator);
|
||||
qDebug("Qt localization '%s' loaded successfully.",
|
||||
qPrintable(desired_localization));
|
||||
}
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include "miscellaneous/settings.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QPointer>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
#include <QStyleFactory>
|
||||
#include <QDomDocument>
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define SKINFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QPointer>
|
||||
#include <QStringList>
|
||||
#include <QMetaType>
|
||||
|
@ -19,16 +19,14 @@
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
#include "application.h"
|
||||
|
||||
#if defined(Q_OS_WIN)
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
|
||||
#include <QSettings>
|
||||
#endif
|
||||
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QApplication>
|
||||
#include <QDomDocument>
|
||||
#include <QDomElement>
|
||||
#include <QDomAttr>
|
||||
@ -55,7 +53,7 @@ SystemFactory::AutoStartStatus SystemFactory::getAutoStartStatus() {
|
||||
bool autostart_enabled = registry_key.value(APP_LOW_NAME,
|
||||
"").toString().replace('\\',
|
||||
'/') ==
|
||||
QtSingleApplication::applicationFilePath();
|
||||
Application::applicationFilePath();
|
||||
|
||||
if (autostart_enabled) {
|
||||
return SystemFactory::Enabled;
|
||||
@ -138,8 +136,8 @@ bool SystemFactory::setAutoStartStatus(const AutoStartStatus &new_status) {
|
||||
switch (new_status) {
|
||||
case SystemFactory::Enabled:
|
||||
registry_key.setValue(APP_LOW_NAME,
|
||||
QtSingleApplication::applicationFilePath().replace('/',
|
||||
'\\'));
|
||||
Application::applicationFilePath().replace('/',
|
||||
'\\'));
|
||||
return true;
|
||||
case SystemFactory::Disabled:
|
||||
registry_key.remove(APP_LOW_NAME);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define SYSTEMFACTORY_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <QPointer>
|
||||
#include <QMutex>
|
||||
#include <QMetaType>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#define NETWORKFACTORY_H
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QApplication>
|
||||
#include <QCoreApplication>
|
||||
|
||||
|
||||
class NetworkFactory {
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QAuthenticator>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
SilentNetworkAccessManager::SilentNetworkAccessManager(QObject *parent)
|
||||
|
@ -17,8 +17,9 @@
|
||||
|
||||
#include "network-web/webbrowsernetworkaccessmanager.h"
|
||||
|
||||
#include "application.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
QPointer<WebBrowserNetworkAccessManager> WebBrowserNetworkAccessManager::s_instance;
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "miscellaneous/settings.h"
|
||||
#include "application.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QRegExp>
|
||||
#include <QWebSettings>
|
||||
#include <QProcess>
|
||||
|
@ -54,7 +54,7 @@ void WebView::onLoadFinished(bool ok) {
|
||||
}
|
||||
|
||||
void WebView::copySelectedText() {
|
||||
QApplication::clipboard()->setText(selectedText());
|
||||
Application::clipboard()->setText(selectedText());
|
||||
}
|
||||
|
||||
void WebView::openLinkInNewTab() {
|
||||
|
@ -1,9 +1,25 @@
|
||||
// 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 "updater/formupdater.h"
|
||||
|
||||
#include "definitions/definitions.h"
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QIcon>
|
||||
#include <QDir>
|
||||
@ -19,12 +35,17 @@
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
FormUpdater *FormUpdater::s_instance;
|
||||
|
||||
FormUpdater::FormUpdater(QWidget *parent)
|
||||
: QMainWindow(parent, Qt::Dialog | Qt::WindowStaysOnTopHint),
|
||||
m_state(NoState),
|
||||
m_txtOutput(new QTextEdit(this)),
|
||||
m_parsedArguments(QHash<QString, QString>()) {
|
||||
|
||||
// Initialize singleton.
|
||||
s_instance = this;
|
||||
|
||||
m_txtOutput->setAutoFormatting(QTextEdit::AutoNone);
|
||||
m_txtOutput->setAcceptRichText(true);
|
||||
m_txtOutput->setFontPointSize(10.0);
|
||||
@ -41,16 +62,21 @@ FormUpdater::FormUpdater(QWidget *parent)
|
||||
setWindowIcon(QIcon(APP_ICON_PATH));
|
||||
|
||||
moveToCenterAndResize();
|
||||
|
||||
connect(this, SIGNAL(debugMessageProduced(QtMsgType,QString)),
|
||||
this, SLOT(consumeDebugMessage(QtMsgType,QString)));
|
||||
}
|
||||
|
||||
FormUpdater::~FormUpdater() {
|
||||
}
|
||||
|
||||
void FormUpdater::startUpgrade() {
|
||||
qDebug("Started...");
|
||||
|
||||
printHeading("Welcome to RSS Guard updater");
|
||||
printText("Analyzing updater arguments.");
|
||||
|
||||
if (QApplication::arguments().size() != 5) {
|
||||
if (QtSingleApplication::arguments().size() != 5) {
|
||||
printText("Insufficient arguments passed. Update process cannot proceed.");
|
||||
printText("\nPress any key to exit updater...");
|
||||
|
||||
@ -70,23 +96,14 @@ void FormUpdater::startUpgrade() {
|
||||
}
|
||||
|
||||
doFinalCleanup();
|
||||
|
||||
printText("Application was upgraded without serious errors.");
|
||||
|
||||
if (!QProcess::startDetached(m_parsedArguments["rssguard_executable_path"])) {
|
||||
printText("RSS Guard was not started successfully. Start it manually.");
|
||||
m_state = ExitError;
|
||||
}
|
||||
else {
|
||||
m_state = ExitNormal;
|
||||
}
|
||||
executeMainApplication();
|
||||
|
||||
printText("\nPress any key to exit updater...");
|
||||
}
|
||||
|
||||
void FormUpdater::saveArguments() {
|
||||
// Obtain parameters.
|
||||
QStringList arguments = QApplication::arguments();
|
||||
QStringList arguments = QtSingleApplication::arguments();
|
||||
|
||||
m_parsedArguments["updater_path"] = QDir::toNativeSeparators(qApp->applicationFilePath());
|
||||
m_parsedArguments["current_version"] = arguments.at(1);
|
||||
@ -98,6 +115,70 @@ void FormUpdater::saveArguments() {
|
||||
m_parsedArguments["output_temp_path"] = m_parsedArguments["temp_path"] + QDir::separator() + APP_LOW_NAME;
|
||||
}
|
||||
|
||||
void FormUpdater::executeMainApplication() {
|
||||
printText("\nApplication was upgraded without serious errors.");
|
||||
|
||||
if (!QProcess::startDetached(m_parsedArguments["rssguard_executable_path"])) {
|
||||
printText("RSS Guard was not started successfully. Start it manually.");
|
||||
m_state = ExitError;
|
||||
}
|
||||
else {
|
||||
m_state = ExitNormal;
|
||||
}
|
||||
}
|
||||
|
||||
void FormUpdater::triggerDebugMessageConsumption(QtMsgType type, const QString &message) {
|
||||
emit debugMessageProduced(type, message);
|
||||
}
|
||||
|
||||
void FormUpdater::consumeDebugMessage(QtMsgType type, const QString &message) {
|
||||
switch (type) {
|
||||
case QtDebugMsg:
|
||||
s_instance->printText(QString("DEBUG: %1").arg(message));
|
||||
break;
|
||||
|
||||
case QtWarningMsg:
|
||||
s_instance->printText(QString("WARNING: %1").arg(message));
|
||||
break;
|
||||
|
||||
case QtCriticalMsg:
|
||||
s_instance->printText(QString("CRITICAL: %1").arg(message));
|
||||
break;
|
||||
|
||||
case QtFatalMsg:
|
||||
s_instance->printText(QString("FATAL: %1").arg(message));
|
||||
qApp->exit(EXIT_FAILURE);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
void FormUpdater::debugHandler(QtMsgType type,
|
||||
const QMessageLogContext &placement,
|
||||
const QString &message) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
Q_UNUSED(placement)
|
||||
|
||||
s_instance->triggerDebugMessageConsumption(type, message);
|
||||
#else
|
||||
Q_UNUSED(type)
|
||||
Q_UNUSED(placement)
|
||||
Q_UNUSED(message)
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
void FormUpdater::debugHandler(QtMsgType type, const char *message) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
s_instance->triggerDebugMessageConsumption(type, QString(message));
|
||||
#else
|
||||
Q_UNUSED(type)
|
||||
Q_UNUSED(message)
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void FormUpdater::printArguments() {
|
||||
printNewline();
|
||||
printHeading("Arguments");
|
||||
@ -145,7 +226,7 @@ bool FormUpdater::doPreparationCleanup() {
|
||||
|
||||
printText(QString("Check for running instances of RSS Guard, attempt %1.").arg(i));
|
||||
|
||||
if (static_cast<QtSingleApplication*>(qApp)->sendMessage(APP_QUIT_INSTANCE)) {
|
||||
if (static_cast<QtSingleApplication*>(QCoreApplication::instance())->sendMessage(APP_QUIT_INSTANCE)) {
|
||||
printText("The main application is running. Quitting it.");
|
||||
printText("Waiting for 6000 ms for main application to finish.");
|
||||
|
||||
@ -198,7 +279,7 @@ bool FormUpdater::doExtractionAndCopying() {
|
||||
|
||||
extractor_arguments << "x" << "-r" << "-y" <<
|
||||
QString("-o%1").arg(m_parsedArguments["output_temp_path"]) <<
|
||||
m_parsedArguments["update_file_path"];
|
||||
m_parsedArguments["update_file_path"];
|
||||
|
||||
printText(QString("Calling extractor %1 with these arguments:").arg(APP_7ZA_EXECUTABLE));
|
||||
|
||||
@ -209,13 +290,7 @@ bool FormUpdater::doExtractionAndCopying() {
|
||||
process_extractor.setEnvironment(QProcessEnvironment::systemEnvironment().toStringList());
|
||||
process_extractor.setWorkingDirectory(m_parsedArguments["rssguard_path"]);
|
||||
|
||||
QString prog_line = QString(APP_7ZA_EXECUTABLE) + " " +
|
||||
"x -r -y \"-o" + m_parsedArguments["output_temp_path"] +
|
||||
"\" \"" + m_parsedArguments["update_file_path"] + "\"";
|
||||
printText(prog_line);
|
||||
|
||||
process_extractor.start(prog_line);
|
||||
//process_extractor.start(APP_7ZA_EXECUTABLE, extractor_arguments);
|
||||
process_extractor.start(APP_7ZA_EXECUTABLE, extractor_arguments);
|
||||
|
||||
if (!process_extractor.waitForFinished()) {
|
||||
process_extractor.close();
|
||||
@ -252,13 +327,22 @@ bool FormUpdater::doExtractionAndCopying() {
|
||||
}
|
||||
|
||||
bool FormUpdater::doFinalCleanup() {
|
||||
bool result_file;
|
||||
bool result_path;
|
||||
|
||||
qApp->processEvents();
|
||||
|
||||
printNewline();
|
||||
printHeading("Final cleanup");
|
||||
|
||||
return removeDirectory(m_parsedArguments["output_temp_path"]) &&
|
||||
QFile::remove(m_parsedArguments["update_file_path"]);
|
||||
result_path = removeDirectory(m_parsedArguments["output_temp_path"]);
|
||||
result_file = QFile::remove(m_parsedArguments["update_file_path"]);
|
||||
|
||||
printText(QString("Removing temporary files\n -> %1 -> %2\n -> %3 -> %4").arg(
|
||||
m_parsedArguments["output_temp_path"], result_path ? "success" : "failure",
|
||||
m_parsedArguments["update_file_path"], result_file ? "success" : "failure"));
|
||||
|
||||
return result_file && result_path;
|
||||
}
|
||||
|
||||
void FormUpdater::keyPressEvent(QKeyEvent* event) {
|
||||
|
@ -1,8 +1,26 @@
|
||||
// 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 FORMUPDATER_H
|
||||
#define FORMUPDATER_H
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QHash>
|
||||
|
||||
|
||||
@ -13,6 +31,7 @@ class FormUpdater : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Describes the state of updater.
|
||||
enum UpdaterState {
|
||||
NoState,
|
||||
ExitNormal,
|
||||
@ -23,6 +42,11 @@ class FormUpdater : public QMainWindow {
|
||||
explicit FormUpdater(QWidget *parent = 0);
|
||||
virtual ~FormUpdater();
|
||||
|
||||
// Prints various texts.
|
||||
void printText(const QString &text);
|
||||
void printNewline();
|
||||
void printHeading(const QString &header);
|
||||
|
||||
// Starts the whole update process.
|
||||
void startUpgrade();
|
||||
|
||||
@ -33,17 +57,34 @@ class FormUpdater : public QMainWindow {
|
||||
bool doPreparationCleanup();
|
||||
bool doExtractionAndCopying();
|
||||
bool doFinalCleanup();
|
||||
void executeMainApplication();
|
||||
|
||||
// Used to trigger signal informaing about new debug message.
|
||||
void triggerDebugMessageConsumption(QtMsgType type, const QString &message);
|
||||
|
||||
// Debug handlers for messages.
|
||||
#if QT_VERSION >= 0x050000
|
||||
static void debugHandler(QtMsgType type,
|
||||
const QMessageLogContext &placement,
|
||||
const QString &message);
|
||||
#else
|
||||
static void debugHandler(QtMsgType type,
|
||||
const char *message);
|
||||
#endif
|
||||
|
||||
public slots:
|
||||
// Should be always called on GUI thread which is enforced
|
||||
// by signal/slot auto connection.
|
||||
void consumeDebugMessage(QtMsgType type, const QString &message);
|
||||
|
||||
signals:
|
||||
// Emitted if new debug messaages is produced and should be printed.
|
||||
void debugMessageProduced(QtMsgType type, QString message);
|
||||
|
||||
protected:
|
||||
// Catch the "press any key event" to exit the updater.
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
private:
|
||||
// Prints various texts.
|
||||
void printText(const QString &text);
|
||||
void printNewline();
|
||||
void printHeading(const QString &header);
|
||||
|
||||
// Moves the window into the center of the screen and resizes it.
|
||||
void moveToCenterAndResize();
|
||||
|
||||
@ -56,8 +97,9 @@ class FormUpdater : public QMainWindow {
|
||||
private:
|
||||
UpdaterState m_state;
|
||||
QTextEdit *m_txtOutput;
|
||||
|
||||
QHash<QString, QString> m_parsedArguments;
|
||||
|
||||
static FormUpdater *s_instance;
|
||||
};
|
||||
|
||||
#endif // FORMUPDATER_H
|
||||
|
@ -26,8 +26,6 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
// Main entry point to "rssguard_updater.exe".
|
||||
// It expects 4 ARGUMENTS:
|
||||
@ -39,11 +37,17 @@
|
||||
int main(int argc, char *argv[]) {
|
||||
// Instantiate base application object.
|
||||
QtSingleApplication application(APP_LOW_NAME, argc, argv);
|
||||
|
||||
application.setQuitOnLastWindowClosed(true);
|
||||
QtSingleApplication::setQuitOnLastWindowClosed(true);
|
||||
|
||||
FormUpdater main_form;
|
||||
|
||||
// Setup debug output system.
|
||||
#if QT_VERSION >= 0x050000
|
||||
qInstallMessageHandler(FormUpdater::debugHandler);
|
||||
#else
|
||||
qInstallMsgHandler(FormUpdater::debugHandler);
|
||||
#endif
|
||||
|
||||
main_form.show();
|
||||
main_form.startUpgrade();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user