Skip to content

Commit ac9f6fc

Browse files
committed
fixup samples structure, adjust both to match
1 parent e548d55 commit ac9f6fc

File tree

12 files changed

+123
-140
lines changed

12 files changed

+123
-140
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
TEMPLATE = app
2+
3+
QT += core gui widgets autoupdatergui
4+
CONFIG += C++11
5+
6+
TARGET = SimpleUpdaterGui
7+
8+
SOURCES += \
9+
main.cpp \
10+
mainwindow.cpp
11+
12+
HEADERS += \
13+
mainwindow.h
14+
15+
FORMS += \
16+
mainwindow.ui
17+
18+
target.path = $$[QT_INSTALL_EXAMPLES]/autoupdatergui/$$TARGET
19+
INSTALLS += target
20+
21+
#not found by linker?
22+
unix:!mac {
23+
LIBS += -L$$OUT_PWD/../../../lib #required to make this the first place to search
24+
LIBS += -L$$[QT_INSTALL_LIBS] -licudata
25+
LIBS += -L$$[QT_INSTALL_LIBS] -licui18n
26+
LIBS += -L$$[QT_INSTALL_LIBS] -licuuc
27+
}
28+
29+
#add lib dir to rpath
30+
mac: QMAKE_LFLAGS += '-Wl,-rpath,\'$$OUT_PWD/../../../lib\''
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include "mainwindow.h"
2+
#include <QApplication>
3+
#include <QTranslator>
4+
#include <QLocale>
5+
#include <QLibraryInfo>
6+
7+
int main(int argc, char *argv[])
8+
{
9+
QApplication a(argc, argv);
10+
11+
//Translate app
12+
QTranslator translator;
13+
translator.load(QLocale(),
14+
QStringLiteral("qt"),
15+
QStringLiteral("_"),
16+
QLibraryInfo::location(QLibraryInfo::TranslationsPath));
17+
a.installTranslator(&translator);
18+
19+
//Translate updater
20+
QTranslator translatorUpdater;
21+
translatorUpdater.load(QLocale(),
22+
QStringLiteral("qtautoupdatergui"),
23+
QStringLiteral("_"),
24+
QStringLiteral("translations"));
25+
a.installTranslator(&translatorUpdater);
26+
27+
//Launch GUI
28+
MainWindow w;
29+
w.show();
30+
31+
return a.exec();
32+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "mainwindow.h"
2+
#include "ui_mainwindow.h"
3+
4+
MainWindow::MainWindow(QWidget *parent) :
5+
QMainWindow(parent),
6+
ui(new Ui::MainWindow),
7+
controller(nullptr), //add this
8+
updateButton(new QtAutoUpdater::UpdateButton(this)) //and this for the updater
9+
{
10+
ui->setupUi(this);
11+
12+
updateButton->setVisible(false); //The updateButton is not visible
13+
initializeUpdater(); //Initialize the updater
14+
15+
controller->start(QtAutoUpdater::UpdateController::InfoLevel); //Search for updates. Display a message if updates found, otherwise do nothing
16+
17+
//Connect the checkUpdateButton button to the checkUpdate method (starts the update check process)
18+
connect(ui->checkUpdateButton, &QAbstractButton::clicked,
19+
this, &MainWindow::checkUpdate);
20+
21+
//Connect the actionCheck_for_updates_2 to the method (starts the update check process)
22+
connect(ui->actionCheck_for_updates_2, &QAction::triggered,
23+
this, &MainWindow::checkUpdate);
24+
}
25+
26+
MainWindow::~MainWindow()
27+
{
28+
delete ui;
29+
}
30+
31+
//Initialize the updater
32+
void MainWindow::initializeUpdater()
33+
{
34+
controller = new QtAutoUpdater::UpdateController(QStringLiteral("maintenancetool.exe"), qApp); //Updater app name
35+
controller->setDetailedUpdateInfo(true);
36+
updateButton->setController(controller);
37+
}
38+
39+
//Starts update check process
40+
void MainWindow::checkUpdate()
41+
{
42+
controller->start(QtAutoUpdater::UpdateController::ProgressLevel); //Check for updates. Displays a progress bar when searching
43+
}

examples/autoupdatergui/simpleUpdaterGui/mainwindow.h renamed to examples/autoupdatergui/SimpleUpdaterGui/mainwindow.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include <QMainWindow>
55
#include <QDebug>
6-
#include <QtAutoUpdaterGui>
76
#include <QtAutoUpdaterGui/UpdateController>
87
#include <QtAutoUpdaterGui/UpdateButton>
98

@@ -13,20 +12,20 @@ class MainWindow;
1312

1413
class MainWindow : public QMainWindow
1514
{
16-
Q_OBJECT
15+
Q_OBJECT
1716

1817
public:
19-
explicit MainWindow(QWidget *parent = 0);
20-
~MainWindow();
18+
explicit MainWindow(QWidget *parent = nullptr);
19+
~MainWindow();
2120

2221
private:
23-
Ui::MainWindow *ui;
24-
QtAutoUpdater::UpdateController *controller;
25-
QtAutoUpdater::UpdateButton *updateButton;
22+
Ui::MainWindow *ui;
23+
QtAutoUpdater::UpdateController *controller;
24+
QtAutoUpdater::UpdateButton *updateButton;
2625

2726
private slots:
28-
void initializeUpdater();
29-
void checkUpdate();
27+
void initializeUpdater();
28+
void checkUpdate();
3029
};
3130

3231
#endif // MAINWINDOW_H

examples/autoupdatergui/simpleUpdaterGui/mainwindow.ui renamed to examples/autoupdatergui/SimpleUpdaterGui/mainwindow.ui

File renamed without changes.

examples/autoupdatergui/WidgetsUpdater/WidgetsUpdater.pro

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
#-------------------------------------------------
2-
#
3-
# Project created by QtCreator 2015-12-23T13:59:22
4-
#
5-
#-------------------------------------------------
61
TEMPLATE = app
72

8-
QT += core gui widgets autoupdatergui
3+
QT += core gui widgets autoupdatergui
94
CONFIG += C++11
105

116
TARGET = WidgetsUpdater
127

13-
SOURCES += main.cpp\
14-
mainwindow.cpp
8+
SOURCES += main.cpp \
9+
mainwindow.cpp
1510

16-
HEADERS += mainwindow.h
11+
HEADERS += mainwindow.h
1712

18-
FORMS += mainwindow.ui
13+
FORMS += mainwindow.ui
1914

2015
RESOURCES += \
2116
main_res.qrc
2217

23-
target.path = $$[QT_INSTALL_EXAMPLES]/autoupdatergui/WidgetsUpdater
18+
target.path = $$[QT_INSTALL_EXAMPLES]/autoupdatergui/$$TARGET
2419
INSTALLS += target
2520

2621
#not found by linker?

examples/autoupdatergui/WidgetsUpdater/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ int main(int argc, char *argv[])
1313

1414
QTranslator tr;
1515
tr.load(QLocale(),
16-
QStringLiteral("QtAutoUpdaterController"),
16+
QStringLiteral("qtautoupdatergui"),
1717
QStringLiteral("_"),
1818
QApplication::applicationDirPath());
1919
QApplication::installTranslator(&tr);
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
TEMPLATE = subdirs
22

3-
SUBDIRS += WidgetsUpdater simpleUpdaterGui
3+
SUBDIRS += \
4+
WidgetsUpdater \
5+
SimpleUpdaterGui

examples/autoupdatergui/simpleUpdaterGui/main.cpp

Lines changed: 0 additions & 31 deletions
This file was deleted.

examples/autoupdatergui/simpleUpdaterGui/mainwindow.cpp

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)