9f17d59e
陈明泉
no message
|
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
|
#include "mainapp.h"
#include "mainwindow.h"
#include <QSystemTrayIcon>
#include "ishowview.h"
#include "ishowframe.h"
#include <QSettings>
#include <QDesktopWidget>
#include "login/widgetLogon.h"
#include "dragproxy.h"
#include <QDir>
#include <QDebug>
#include <QMenu>
#include <QPainter>
#include <qmath.h>
#include "ui_main.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
#ifndef Q_OS_MAC
QApplication::setWindowIcon(QIcon(":icons/ishow"));
setWindowIcon(QIcon(":icons/ishow"));
#else
setUnifiedTitleAndToolBarOnMac(true);
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
//this->installEventFilter(this);
this->resize(1002, 702);
this->setMinimumSize(1002, 702);
//setWindowFlags( Qt::FramelessWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint|Qt::WindowSystemMenuHint);
this->setMouseTracking(true);
|
6e10e93e
陈明泉
no message
|
37
38
|
this->setWindowTitle("viptalk");
|
9f17d59e
陈明泉
no message
|
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
|
iShowFrame = new IShowFrame(this);
setCentralWidget(iShowFrame);
DragProxy *dragproxy = new DragProxy(this);
dragproxy->SetBorderWidth(4, 4, 4, 4);
createActions();
createTrayIcon();
createTrayIconMenu();
}
MainWindow::~MainWindow()
{
}
bool MainWindow::addIShow(const QString& name)
{
return iShowFrame->addIShow(name);
return false;
}
bool MainWindow::setCurrentIShow(const QString& name)
{
return iShowFrame->setCurrentIShow(name);
}
void MainWindow::removeAllIShows()
{
iShowFrame->removeAllIShows();
}
void MainWindow::createActions()
{
QActionGroup *tabGroup = new QActionGroup(this);
overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
overviewAction->setStatusTip(tr("Show general overview of wallet"));
overviewAction->setToolTip(overviewAction->statusTip());
overviewAction->setCheckable(true);
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
tabGroup->addAction(overviewAction);
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
|
6e10e93e
陈明泉
no message
|
86
|
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit "), this);
|
9f17d59e
陈明泉
no message
|
87
|
quitAction->setStatusTip(tr("Quit application"));
|
6e10e93e
陈明泉
no message
|
88
89
|
// quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
// quitAction->setMenuRole(QAction::QuitRole);
|
9f17d59e
陈明泉
no message
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet"));
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
}
void MainWindow::createTrayIcon()
{
#ifndef Q_OS_MAC
trayIcon = new QSystemTrayIcon(this);
|
6e10e93e
陈明泉
no message
|
107
|
trayIcon->setToolTip(tr("viptalk"));
|
9f17d59e
陈明泉
no message
|
108
109
110
111
|
trayIcon->setIcon(QIcon(":Images/logo/feitalk.ico"));
trayIcon->show();
#endif
|
9f17d59e
陈明泉
no message
|
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
}
void MainWindow::createTrayIconMenu()
{
QMenu *trayIconMenu;
// return if trayIcon is unset (only on non-Mac OSes)
if (!trayIcon)
return;
trayIconMenu = new QMenu(this);
trayIcon->setContextMenu(trayIconMenu);
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
trayIconMenu->addAction(quitAction);
}
void MainWindow::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
{
if(reason == QSystemTrayIcon::Trigger && isLoginSuccess)
{
// Click on system tray icon triggers show/hide of the main window
toggleHideAction->trigger();
this->show();
}
}
void MainWindow::saveWindowGeometry()
{
QSettings settings;
settings.setValue("nWindowPos", pos());
settings.setValue("nWindowSize", size());
}
void MainWindow::restoreWindowGeometry()
{
QSettings settings;
QPoint pos = settings.value("nWindowPos").toPoint();
QSize size = settings.value("nWindowSize", QSize(850, 550)).toSize();
if (!pos.x() && !pos.y())
{
QRect screen = QApplication::desktop()->screenGeometry();
pos.setX((screen.width()-size.width())/2);
pos.setY((screen.height()-size.height())/2);
}
resize(size);
move(pos);
}
void MainWindow::resizeEvent(QResizeEvent *size)
{
iShowFrame->setGeometry(1, 1, this->width()-2,this->height()-2);
size->accept();
QMainWindow::resizeEvent(size);
}
void MainWindow::paintEvent(QPaintEvent *)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
int cut = 1;
path.addRect(cut, cut, this->width()-cut*2, this->height()-cut*2);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing, true);
painter.fillPath(path, QBrush(Qt::white));
QColor color("#d9d9d9");
for(int i=0; i<cut; i++)
{
QPainterPath path;
path.setFillRule(Qt::WindingFill);
path.addRect(cut-i, cut-i, this->width()-(cut-i)*2, this->height()-(cut-i)*2);
color.setAlpha(150 - qSqrt(i)*50);
painter.setPen(color);
painter.drawPath(path);
}
}
|