-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaTrayIcon.cpp
More file actions
122 lines (106 loc) · 2.76 KB
/
Copy pathmaTrayIcon.cpp
File metadata and controls
122 lines (106 loc) · 2.76 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "maTrayIcon.h"
#include <QApplication>
#include <QIcon>
#include <QDebug>
#include <QDir>
#include "maMainWindow.h"
#include "NewsList/CNewsListWidget.h"
#include "InfoEditor/CInfoEditor.h"
#include "KindomFight/KFMain.h"
CTrayIcon::CTrayIcon(CMainWindow& window, QObject *parent) :
QSystemTrayIcon(parent),
m_mainWindow(window),
m_newsListWidget(0),
m_infoEditor(0),
m_kfMain(0)
{
setIcon(QIcon(":/dragon.png"));
createContextMenu();
setToolTip("MyTrayIcon");
qDebug()<<QDir::currentPath();
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(on_tryaIcon_clicked(QSystemTrayIcon::ActivationReason)));
}
CTrayIcon::~CTrayIcon()
{
if (m_newsListWidget)
{
m_newsListWidget->deleteLater();
m_newsListWidget = 0;
}
if (m_infoEditor)
{
m_infoEditor->deleteLater();
m_infoEditor = 0;
}
if (m_kfMain)
{
m_kfMain->closeMainWindow();
m_kfMain->deleteLater();
m_kfMain = 0;
}
}
void CTrayIcon::showMainWindow()
{
m_mainWindow.show();
}
void CTrayIcon::showNewsListWidget()
{
if (!m_newsListWidget)
{
m_newsListWidget = new CNewsListWidget;
}
m_newsListWidget->show();
}
void CTrayIcon::showInfoEditor()
{
if (!m_infoEditor)
{
m_infoEditor = new CInfoEditor;
}
m_infoEditor->show();
}
void CTrayIcon::showKFMainWindow()
{
if (!m_kfMain)
{
m_kfMain = new KFMain;
connect(m_kfMain, SIGNAL(mainWindowClosed()), SLOT(on_KFMainWindowClosed()));
}
m_kfMain->showKFMainWindow();
}
void CTrayIcon::on_KFMainWindowClosed()
{
m_kfMain->deleteLater();
m_kfMain = 0;
}
void CTrayIcon::on_tryaIcon_clicked(QSystemTrayIcon::ActivationReason reasion)
{
switch (reasion) {
case QSystemTrayIcon::Trigger:
break;
case QSystemTrayIcon::DoubleClick:
m_mainWindow.show();
break;
default:
break;
}
}
void CTrayIcon::on_message_remind(QString msg)
{
showMessage(tr("Info"), msg, QSystemTrayIcon::Information, 5000);
}
void CTrayIcon::createContextMenu()
{
QAction* action = m_menu.addAction(tr("Quit"));
action->setIcon(QIcon(":/exit.png"));
connect(action, SIGNAL(triggered()), qApp, SLOT(quit()));
action = m_menu.addAction(tr("MainWindow"));
connect(action, SIGNAL(triggered()), this, SLOT(showMainWindow()));
action = m_menu.addAction(tr("NewList"));
connect(action, SIGNAL(triggered()), this, SLOT(showNewsListWidget()));
action = m_menu.addAction(tr("InfoEditor"));
connect(action, SIGNAL(triggered()), this, SLOT(showInfoEditor()));
action = m_menu.addAction(tr("KingdomFight"));
connect(action, SIGNAL(triggered()), this, SLOT(showKFMainWindow()));
setContextMenu(&m_menu);
}