-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetcolorpanel.cpp
50 lines (47 loc) · 1.29 KB
/
setcolorpanel.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
#include "setcolorpanel.h"
#include "ui_setcolorpanel.h"
SetColorPanel::SetColorPanel(QWidget *parent, QStringList graphNames) :
QDialog(parent),
ui(new Ui::SetColorPanel)
{
ui->setupUi(this);
// map to ui
colorWidget = ui->colorWidget;
nameForm = ui->nameForm;
yesBtn = ui->yesBtn;
cancelBtn = ui->cancelBtn;
// connect
connect(yesBtn, SIGNAL(clicked()), this, SLOT(yesExit()));
connect(cancelBtn, SIGNAL(clicked()), this, SLOT(cancelExit()));
// init content config
colorWidget->setWindowFlags(Qt::Widget);
/* a few options that we must set for it to work nicely */
colorWidget->setOptions(
/* do not use native dialog */
QColorDialog::DontUseNativeDialog |
QColorDialog::NoButtons
);
this->graphNames = graphNames;
nameForm->addItems(graphNames);
}
void SetColorPanel::yesExit()
{
QString curName = nameForm->currentText();
QColor color = colorWidget->currentColor();
unsigned int size = graphNames.size();
for(int i=0;i<size;i++){
if(graphNames.at(i)==curName){
emit sendSetColorInfo(i,color);
break;
}
}
this->close();
}
void SetColorPanel::cancelExit()
{
this->close();
}
SetColorPanel::~SetColorPanel()
{
delete ui;
}