Hmmmm.
This commit is contained in:
parent
b35d10f319
commit
3d320bbaf1
@ -19,12 +19,17 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
FormUpdater *FormUpdater::s_instance;
|
||||||
|
|
||||||
FormUpdater::FormUpdater(QWidget *parent)
|
FormUpdater::FormUpdater(QWidget *parent)
|
||||||
: QMainWindow(parent, Qt::Dialog | Qt::WindowStaysOnTopHint),
|
: QMainWindow(parent, Qt::Dialog | Qt::WindowStaysOnTopHint),
|
||||||
m_state(NoState),
|
m_state(NoState),
|
||||||
m_txtOutput(new QTextEdit(this)),
|
m_txtOutput(new QTextEdit(this)),
|
||||||
m_parsedArguments(QHash<QString, QString>()) {
|
m_parsedArguments(QHash<QString, QString>()) {
|
||||||
|
|
||||||
|
// Initialize singleton.
|
||||||
|
s_instance = this;
|
||||||
|
|
||||||
m_txtOutput->setAutoFormatting(QTextEdit::AutoNone);
|
m_txtOutput->setAutoFormatting(QTextEdit::AutoNone);
|
||||||
m_txtOutput->setAcceptRichText(true);
|
m_txtOutput->setAcceptRichText(true);
|
||||||
m_txtOutput->setFontPointSize(10.0);
|
m_txtOutput->setFontPointSize(10.0);
|
||||||
@ -47,6 +52,8 @@ FormUpdater::~FormUpdater() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FormUpdater::startUpgrade() {
|
void FormUpdater::startUpgrade() {
|
||||||
|
qDebug("Started...");
|
||||||
|
|
||||||
printHeading("Welcome to RSS Guard updater");
|
printHeading("Welcome to RSS Guard updater");
|
||||||
printText("Analyzing updater arguments.");
|
printText("Analyzing updater arguments.");
|
||||||
|
|
||||||
@ -101,6 +108,70 @@ void FormUpdater::executeMainApplication() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
void FormUpdater::debugHandler(QtMsgType type,
|
||||||
|
const QMessageLogContext &placement,
|
||||||
|
const QString &message) {
|
||||||
|
#ifndef QT_NO_DEBUG_OUTPUT
|
||||||
|
Q_UNUSED(placement)
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#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
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
Q_UNUSED(type)
|
||||||
|
Q_UNUSED(message)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void FormUpdater::printArguments() {
|
void FormUpdater::printArguments() {
|
||||||
printNewline();
|
printNewline();
|
||||||
printHeading("Arguments");
|
printHeading("Arguments");
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
|
||||||
|
|
||||||
@ -13,6 +14,7 @@ class FormUpdater : public QMainWindow {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Describes the state of updater.
|
||||||
enum UpdaterState {
|
enum UpdaterState {
|
||||||
NoState,
|
NoState,
|
||||||
ExitNormal,
|
ExitNormal,
|
||||||
@ -23,6 +25,11 @@ class FormUpdater : public QMainWindow {
|
|||||||
explicit FormUpdater(QWidget *parent = 0);
|
explicit FormUpdater(QWidget *parent = 0);
|
||||||
virtual ~FormUpdater();
|
virtual ~FormUpdater();
|
||||||
|
|
||||||
|
// Prints various texts.
|
||||||
|
void printText(const QString &text);
|
||||||
|
void printNewline();
|
||||||
|
void printHeading(const QString &header);
|
||||||
|
|
||||||
// Starts the whole update process.
|
// Starts the whole update process.
|
||||||
void startUpgrade();
|
void startUpgrade();
|
||||||
|
|
||||||
@ -35,16 +42,20 @@ class FormUpdater : public QMainWindow {
|
|||||||
bool doFinalCleanup();
|
bool doFinalCleanup();
|
||||||
void executeMainApplication();
|
void executeMainApplication();
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Catch the "press any key event" to exit the updater.
|
// Catch the "press any key event" to exit the updater.
|
||||||
void keyPressEvent(QKeyEvent *event);
|
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.
|
// Moves the window into the center of the screen and resizes it.
|
||||||
void moveToCenterAndResize();
|
void moveToCenterAndResize();
|
||||||
|
|
||||||
@ -57,8 +68,9 @@ class FormUpdater : public QMainWindow {
|
|||||||
private:
|
private:
|
||||||
UpdaterState m_state;
|
UpdaterState m_state;
|
||||||
QTextEdit *m_txtOutput;
|
QTextEdit *m_txtOutput;
|
||||||
|
|
||||||
QHash<QString, QString> m_parsedArguments;
|
QHash<QString, QString> m_parsedArguments;
|
||||||
|
|
||||||
|
static FormUpdater *s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FORMUPDATER_H
|
#endif // FORMUPDATER_H
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
// Main entry point to "rssguard_updater.exe".
|
// Main entry point to "rssguard_updater.exe".
|
||||||
// It expects 4 ARGUMENTS:
|
// It expects 4 ARGUMENTS:
|
||||||
// 0) - the actual path of this process,
|
// 0) - the actual path of this process,
|
||||||
@ -39,11 +40,13 @@
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// Instantiate base application object.
|
// Instantiate base application object.
|
||||||
QtSingleApplication application(APP_LOW_NAME, argc, argv);
|
QtSingleApplication application(APP_LOW_NAME, argc, argv);
|
||||||
|
|
||||||
application.setQuitOnLastWindowClosed(true);
|
application.setQuitOnLastWindowClosed(true);
|
||||||
|
|
||||||
FormUpdater main_form;
|
FormUpdater main_form;
|
||||||
|
|
||||||
|
// Setup message handler after main_form is created.
|
||||||
|
qInstallMessageHandler(FormUpdater::debugHandler);
|
||||||
|
|
||||||
main_form.show();
|
main_form.show();
|
||||||
main_form.startUpgrade();
|
main_form.startUpgrade();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user