-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup.cpp
More file actions
77 lines (69 loc) · 2.98 KB
/
setup.cpp
File metadata and controls
77 lines (69 loc) · 2.98 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
#include "setup.h"
#include <QColorDialog>
#include <QIntValidator>
Setup::Setup(QWidget *tab, QObject *parent) : QObject(parent),
m_pTab(tab)
{
initUI();
connect(m_pbtnSendClr, SIGNAL(clicked(bool)), this, SLOT(onSendClr()));
connect(m_pbtnRecvClr, SIGNAL(clicked(bool)), this, SLOT(onRecvClr()));
connect(m_pedtSize, &QLineEdit::editingFinished, [&](){
this->m_fontSize = m_pedtSize->text();
});
connect(m_pedtHistory, &QLineEdit::editingFinished, [&](){
this->m_iHistory = m_pedtHistory->text().toInt();
});
connect(m_pedtRecvDelay, &QLineEdit::editingFinished, [&](){
this->m_iRecvDelay = m_pedtRecvDelay->text().toInt();
});
connect(m_pedtFileDelay, &QLineEdit::editingFinished, [&](){
this->m_iFileDelay = m_pedtFileDelay->text().toInt();
});
}
void Setup::initUI() {
this->m_plabSend = m_pTab->findChild<QLabel*>(QStringLiteral("labSend"));
this->m_plabRecv = m_pTab->findChild<QLabel*>(QStringLiteral("labRecv"));
this->m_pbtnSendClr = m_pTab->findChild<QPushButton*>(QStringLiteral("btnSendColor"));
this->m_pbtnRecvClr = m_pTab->findChild<QPushButton*>(QStringLiteral("btnRecvColor"));
this->m_pedtSize = m_pTab->findChild<QLineEdit*>(QStringLiteral("edtFontSize"));
this->m_pedtHistory = m_pTab->findChild<QLineEdit*>(QStringLiteral("edtHistory"));
this->m_pcbxTextCode = m_pTab->findChild<QComboBox*>(QStringLiteral("cbxTextCode"));
this->m_pedtRecvDelay = m_pTab->findChild<QLineEdit*>(QStringLiteral("edtRecvDelay"));
this->m_pedtFileDelay = m_pTab->findChild<QLineEdit*>(QStringLiteral("edtFileDelay"));
this->m_pedtSize->setValidator(new QIntValidator(0, 20, this));
this->m_pedtHistory->setValidator(new QIntValidator(0, 100, this));
this->m_pcbxTextCode->addItem(QStringLiteral("ANSI"));
this->m_pcbxTextCode->addItem(QStringLiteral("UTF-8"));
this->m_pedtRecvDelay->setValidator(new QIntValidator(0, 1000, this));
this->m_pedtFileDelay->setValidator(new QIntValidator(0, 86400000, this));
}
void Setup::updateUI() {
m_plabSend->setStyleSheet(QString("color:%1").arg(m_qclrSend.name()));
m_plabRecv->setStyleSheet(QString("color:%1").arg(m_qclrRecv.name()));
m_pedtSize->setText(m_fontSize);
m_pedtHistory->setText(QString("%1").arg(m_iHistory));
m_pedtRecvDelay->setText(QString("%1").arg(m_iRecvDelay));
m_pedtFileDelay->setText(QString("%1").arg(m_iFileDelay));
}
void Setup::showColor(bool bSend) {
QColor *pclrSet;
QLabel *plab;
if (bSend) {
pclrSet = &m_qclrSend;
plab = m_plabSend;
} else {
pclrSet = &m_qclrRecv;
plab = m_plabRecv;
}
QColor clrRet = QColorDialog::getColor(*pclrSet, m_pTab);
if (clrRet.isValid()) {
*pclrSet = clrRet;
plab->setStyleSheet(QString("color:%1").arg(pclrSet->name()));
}
}
void Setup::onSendClr() {
showColor(true);
}
void Setup::onRecvClr() {
showColor(false);
}