GUI based updater.

This commit is contained in:
Martin Rotter 2014-04-13 20:17:38 +02:00
parent 31c0d11e1c
commit 23a775d484
4 changed files with 71 additions and 9 deletions

View File

@ -466,15 +466,19 @@ if(WIN32 OR OS2)
set(UPDATER_SOURCES
# QTSINGLEAPPLICATION sources.
src/qtsingleapplication/qtlocalpeer.cpp
src/qtsingleapplication/qtsinglecoreapplication.cpp
src/qtsingleapplication/qtsingleapplication.cpp
src/updater/main.cpp
src/updater/formupdater.cpp
)
set(UPDATER_HEADERS
# QTSINGLEAPPLICATION headers.
src/qtsingleapplication/qtlocalpeer.h
src/qtsingleapplication/qtsinglecoreapplication.h
src/qtsingleapplication/qtsingleapplication.h
src/updater/formupdater.h
)
endif(WIN32 OR OS2)
@ -523,17 +527,22 @@ if(WIN32 OR OS2)
message(STATUS "[${APP_LOW_NAME}] RSS Guard updater will be compiled.")
if(${USE_QT_5})
add_executable(${UPDATER_EXE_NAME}
add_executable(${UPDATER_EXE_NAME} WIN32
${UPDATER_SOURCES}
)
if(WIN32)
target_link_libraries(${UPDATER_EXE_NAME} Qt5::WinMain)
endif(WIN32)
# Use modules from Qt.
qt5_use_modules(rssguard_updater
Core
Widgets
Network
)
else(${USE_QT_5})
add_executable(${UPDATER_EXE_NAME}
add_executable(${UPDATER_EXE_NAME} WIN32
${UPDATER_SOURCES}
${UPDATER_MOC}
)
@ -541,7 +550,9 @@ if(WIN32 OR OS2)
# Link modules from Qt.
target_link_libraries(${UPDATER_EXE_NAME}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
${QT_QTNETWORK_LIBRARY}
${QT_QTMAIN_LIBRARY}
)
endif(${USE_QT_5})
endif(WIN32 OR OS2)

View File

@ -0,0 +1,23 @@
#include "updater/formupdater.h"
#include "definitions/definitions.h"
#include <QApplication>
#include <QDesktopWidget>
#include <QIcon>
FormUpdater::FormUpdater(QWidget *parent) : QMainWindow(parent) {
setWindowTitle("RSS Guard updater");
setWindowIcon(QIcon(APP_ICON_PATH));
moveToCenterAndResize();
}
FormUpdater::~FormUpdater() {
}
void FormUpdater::moveToCenterAndResize() {
resize(500, 400);
move(qApp->desktop()->screenGeometry().center() - rect().center());
}

20
src/updater/formupdater.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef FORMUPDATER_H
#define FORMUPDATER_H
#include <QMainWindow>
class FormUpdater : public QMainWindow {
Q_OBJECT
public:
// Constructors and destructors.
explicit FormUpdater(QWidget *parent = 0);
virtual ~FormUpdater();
private:
void moveToCenterAndResize();
};
#endif // FORMUPDATER_H

View File

@ -16,7 +16,8 @@
// along with RSS Guard. If not, see <http://www.gnu.org/licenses/>.
#include "definitions/definitions.h"
#include "qtsingleapplication/qtsinglecoreapplication.h"
#include "qtsingleapplication/qtsingleapplication.h"
#include "updater/formupdater.h"
#include <QTranslator>
#include <QDebug>
@ -28,7 +29,7 @@
#include <iostream>
#include <limits>
/*
bool removeDir(const QString & dirName,
const QStringList &exception_file_list = QStringList(),
const QStringList &exception_folder_list = QStringList()) {
@ -85,7 +86,7 @@ bool copyPath(QString src, QString dst) {
}
return true;
}
}*/
// Main entry point to "rssguard_updater.exe".
// It expects 4 ARGUMENTS:
@ -96,8 +97,15 @@ bool copyPath(QString src, QString dst) {
// 4) - path to update file (stored in TEMP folder).
int main(int argc, char *argv[]) {
// Instantiate base application object.
QtSingleCoreApplication application(APP_LOW_NAME, argc, argv);
QtSingleApplication application(APP_LOW_NAME, argc, argv);
FormUpdater main_form;
main_form.show();
return application.exec();
/*
qDebug("\n===== RSS Guard updater ====\n");
if (argc != 5) {
@ -273,6 +281,6 @@ int main(int argc, char *argv[]) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
return EXIT_SUCCESS;*/
}