-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
96 lines (84 loc) · 2.47 KB
/
mainwindow.cpp
File metadata and controls
96 lines (84 loc) · 2.47 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QTimer>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->ui->StopButton->hide();
mSystemTrayIcon = new QSystemTrayIcon(this);
mSystemTrayIcon->setIcon(QIcon(":/icons/icon.png"));
connect(mSystemTrayIcon, &QSystemTrayIcon::activated, this, &MainWindow::maximize_try_icon);
}
MainWindow::~MainWindow()
{
delete ui;
}
void MainWindow::changeEvent(QEvent* e)
{
switch (e->type())
{
case QEvent::LanguageChange:
this->ui->retranslateUi(this);
break;
case QEvent::WindowStateChange:
{
if (this->windowState() & Qt::WindowMinimized)
{
QTimer::singleShot(250, this, SLOT(hide()));
mSystemTrayIcon->show();
mSystemTrayIcon->showMessage("","AreYouOK? was minimized to the system tray.");
}
break;
}
default:
break;
}
QMainWindow::changeEvent(e);
}
void MainWindow::maximize_try_icon( QSystemTrayIcon::ActivationReason reason )
{
if( reason )
{
if( reason != QSystemTrayIcon::DoubleClick )
return;
}
if( isVisible() )
{
this->hide();
}
else
{
this->show();
this->setWindowState(Qt::WindowState::WindowActive);
this->setFocus();
}
}
void MainWindow::on_RunButton_clicked()
{
unsigned long timeRepeat=0;
unsigned long timeMessage=0;
this->ui->RunButton->hide();
this->ui->StopButton->show();
this->ui->MessageTimeH->setDisabled(true);
this->ui->MessageTimeMin->setDisabled(true);
this->ui->repeatTimeH->setDisabled(true);
this->ui->repeatTimeMin->setDisabled(true);
timeRepeat+=this->ui->repeatTimeH->value()*3600000;
timeRepeat+=this->ui->repeatTimeMin->value()*60000;
timeMessage+=this->ui->MessageTimeH->value()*3600000;
timeMessage+=this->ui->MessageTimeMin->value()*60000;
this->areYouOk=new AreYouOkDialog(nullptr, timeRepeat,timeMessage);
this->areYouOk->run();
}
void MainWindow::on_StopButton_clicked()
{
this->areYouOk->stop();
this->ui->StopButton->hide();
this->ui->MessageTimeH->setDisabled(false);
this->ui->MessageTimeMin->setDisabled(false);
this->ui->repeatTimeH->setDisabled(false);
this->ui->repeatTimeMin->setDisabled(false);
this->ui->RunButton->show();
}