-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmainwindow.cpp
More file actions
70 lines (59 loc) · 1.79 KB
/
Copy pathmainwindow.cpp
File metadata and controls
70 lines (59 loc) · 1.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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QMenu>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog);
setWindowTitle(tr("SaveIt!"));
setWindowIcon(QIcon(":/application-icon"));
//setAttribute(Qt::WA_DeleteOnClose);
m_sysTrayIcon = new QSystemTrayIcon(QIcon(":/application-icon"), this);
m_sysTrayContextMenu = new QMenu(this);
m_sysTrayContextMenu->addAction(tr("Exit"), this, SLOT(OnExitClicked()));
m_sysTrayIcon->setContextMenu(m_sysTrayContextMenu);
m_sysTrayIcon->show();
connect(m_sysTrayIcon,
SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this,
SLOT(OnSysTrayClicked(QSystemTrayIcon::ActivationReason)));
m_backupPlanListWidget = new BackupPlanListWidget(this, m_backupPlanList);
//ui->centralWidget->setLayout(new QHBoxLayout);
ui->centralWidget->layout()->addWidget(m_backupPlanListWidget);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
MainWindow::~MainWindow()
{
delete ui;
m_sysTrayIcon->disconnect();
m_sysTrayIcon->blockSignals(true);
delete m_sysTrayIcon;
}
void MainWindow::OnExitClicked()
{
//qDebug() << "MainWindow::OnExitClicked()";
//this->close();
exit(0);
}
void MainWindow::closeEvent(QCloseEvent *e)
{
//m_sysTrayIcon->hide();
hide();
e->ignore();
//QMainWindow::closeEvent(e);
}
void MainWindow::OnSysTrayClicked(QSystemTrayIcon::ActivationReason reason)
{
if ((reason == QSystemTrayIcon::DoubleClick)
|| (reason == QSystemTrayIcon::Trigger)
|| (reason == QSystemTrayIcon::Unknown))
{
if (isVisible())
hide();
else
show();
}
}