-
Notifications
You must be signed in to change notification settings - Fork 0
/
functionbar.cpp
131 lines (113 loc) · 3.84 KB
/
functionbar.cpp
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
123
124
125
126
127
128
129
130
131
#include "functionbar.h"
#include "ui_functionbar.h"
#include "blockchain.h"
#include "commondialog.h"
#include "debug_log.h"
#include <QPainter>
#include <QDebug>
#define FUNCTIONPAGE_BTN_SELECTED "background-color: rgb(62,43,90);color: rgb(255,255,255);border:none;"
#define FUNCTIONPAGE_BTN_UNSELECTED "background-color: rgb(109,91,255);color: rgb(255,255,255);border:none;"
FunctionBar::FunctionBar(QWidget *parent) :
QWidget(parent),
ui(new Ui::FunctionBar)
{
DLOG_QT_WALLET_FUNCTION_BEGIN;
ui->setupUi(this);
setAutoFillBackground(true);
QPalette palette;
palette.setColor(QPalette::Background, QColor(FUNCTION_BAR_COLOR));
setPalette(palette);
ui->marketBtn->hide();
ui->contactBtn->move(0, 173);
choosePage(1);
DLOG_QT_WALLET_FUNCTION_END;
}
FunctionBar::~FunctionBar()
{
delete ui;
}
void FunctionBar::on_accountBtn_clicked()
{
choosePage(1);
emit showMainPage();
}
void FunctionBar::on_assetBtn_clicked()
{
choosePage(2);
emit showAssetPage();
}
void FunctionBar::on_transferBtn_clicked()
{
mutexForAddressMap.lock();
int size = Blockchain::getInstance()->addressMap.size();
mutexForAddressMap.unlock();
if( size > 0) // 有至少一个账户
{
choosePage(3);
emit showTransferPage();
}
else
{
CommonDialog commonDialog(CommonDialog::OkOnly);
commonDialog.setText(tr("No account for transfering,\nadd an account first"));
// commonDialog.move( this->mapToGlobal(QPoint(318,150)));
commonDialog.pop();
on_accountBtn_clicked();
}
}
void FunctionBar::on_marketBtn_clicked()
{
choosePage(4);
emit showMarketPage();
}
void FunctionBar::on_contactBtn_clicked()
{
choosePage(5);
emit showContactPage();
}
void FunctionBar::choosePage(int pageIndex)
{
switch (pageIndex) {
case 1:
ui->accountBtn->setStyleSheet(FUNCTIONPAGE_BTN_SELECTED);
ui->assetBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->transferBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->marketBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->contactBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
break;
case 2:
ui->accountBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->assetBtn->setStyleSheet(FUNCTIONPAGE_BTN_SELECTED);
ui->transferBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->marketBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->contactBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
break;
case 3:
ui->accountBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->assetBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->transferBtn->setStyleSheet(FUNCTIONPAGE_BTN_SELECTED);
ui->marketBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->contactBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
break;
case 4:
ui->accountBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->assetBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->transferBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->marketBtn->setStyleSheet(FUNCTIONPAGE_BTN_SELECTED);
ui->contactBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
break;
case 5:
ui->accountBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->assetBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->transferBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->marketBtn->setStyleSheet(FUNCTIONPAGE_BTN_UNSELECTED);
ui->contactBtn->setStyleSheet(FUNCTIONPAGE_BTN_SELECTED);
break;
default:
break;
}
}
void FunctionBar::retranslator()
{
ui->retranslateUi(this);
}