-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
82 lines (67 loc) · 2.79 KB
/
main.cpp
File metadata and controls
82 lines (67 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "src/mainwindow.h"
#include "src/thememanager.h"
#include "src/globals.h"
#include <QApplication>
#include <QMessageBox>
#include <QSystemTrayIcon>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
/** autorun pu Task Scheduler */
const auto args = QCoreApplication::arguments();
const bool autoRun = args.contains("--autorun");
if (autoRun) {
globals::isAutorun = true;
MainWindow *w = new MainWindow;
w->setAttribute(Qt::WA_DontShowOnScreen, true);
auto *tray = new QSystemTrayIcon(&a);
tray->setIcon(QIcon(":/icons/icons/backup.png"));
tray->show();
/** mesaj pu finalizarea arhivarii */
QObject::connect(w, &MainWindow::allJobsFinished,
tray,
[tray, &a]() {
/** prezentam msg de finalizarea arhivarii - 15 secunde */
tray->showMessage(
QObject::tr("Arhivare finalizată"),
QObject::tr("Arhivarea bazelor de date 1C a fost finalizată cu succes."),
QSystemTrayIcon::Information,
15000
);
/** inchidem aplicaia peste 5 secunde */
QTimer::singleShot(5000, &a, &QCoreApplication::quit);
});
/** Mesaj inițial in tray */
tray->showMessage(
QObject::tr("Atenție"),
QObject::tr("Peste 1 minut va fi inițiată arhivarea bazelor de date 1C."),
QSystemTrayIcon::Information,
10000
);
/** Mesaj pu atentie */
QMessageBox msg;
msg.setIcon(QMessageBox::Warning);
msg.setWindowTitle(QObject::tr("Atenție"));
msg.setText(QObject::tr(
"Peste 1 minut va fi inițiată arhivarea bazelor de date 1C:Enterprise.\n"
"Pentru o arhivare corectă este necesar să închideți toate bazele de date 1C."
));
msg.setStandardButtons(QMessageBox::Ok);
msg.setWindowModality(Qt::ApplicationModal);
QTimer::singleShot(15000, &msg, &QMessageBox::accept); /** auto-close peste 15 secunde */
msg.exec();
/** lansam startBackup() dupa ce utilizatorul a vizualizat mesaje */
QTimer::singleShot(60000, w, &MainWindow::startBackup);
return a.exec();
}
/** determinam stilul */
QFile f(ThemeManager::isDark()
? ":/styles/dark_style.qss"
: ":/styles/main_style.qss");
/** incarcam stilul aplicatiei */
if (f.open(QFile::ReadOnly))
qApp->setStyleSheet(QString::fromUtf8(f.readAll()));
MainWindow w;
w.show();
return a.exec();
}