-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettingsdialog.cpp
More file actions
85 lines (72 loc) · 1.86 KB
/
Copy pathsettingsdialog.cpp
File metadata and controls
85 lines (72 loc) · 1.86 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
#include "settingsdialog.h"
#include "canvas.h"
#include <QtGui>
SettingsDialog::SettingsDialog(Canvas *c, QWidget *parent) :
QDialog(parent)
{
setupUi(this);
canvas = c;
QSize d;
bool wA;
canvas->getParametres(d, C_Color, N_Color, wA);
updateColorLabel(label_3,C_Color);
updateColorLabel(label,N_Color);
wArc->setChecked(wA);
hCanvas->setText(QString::number(d.height()));
wCanvas->setText(QString::number(d.width()));
// Çàïðåò íà ââîä ëåâûõ çíà÷åíèé â ðàçìåð êàíâàñà
QRegExp rx("[1-9]\\d{0,3}");
hCanvas->setValidator(new QRegExpValidator(rx,0));
wCanvas->setValidator(new QRegExpValidator(rx,0));
}
SettingsDialog::~SettingsDialog()
{
this->~QDialog();
}
void SettingsDialog::Show()
{
this->show();
}
void SettingsDialog::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
retranslateUi(this);
break;
default:
break;
}
}
void SettingsDialog::updateColorLabel(QLabel *label, const QColor &color)
{
QPixmap pixmap(90, 18);
pixmap.fill(color);
label->setPixmap(pixmap);
}
void SettingsDialog::chooseColor(QLabel *label, QColor *color)
{
QColor newColor = QColorDialog::getColor(*color, this);
if (newColor.isValid()) {
*color = newColor;
updateColorLabel(label, *color);
}
}
void SettingsDialog::on_BgColor_clicked()
{
chooseColor(label_3, &C_Color);
}
void SettingsDialog::on_nodeColor_clicked()
{
chooseColor(label, &N_Color);
}
void SettingsDialog::on_buttonBox_accepted()
{
canvas->setChanges(QSize(hCanvas->text().toUInt(), wCanvas->text().toUInt()),
C_Color,N_Color,wArc);
this->accept();
}
void SettingsDialog::on_buttonBox_rejected()
{
this->reject();
}