-
Notifications
You must be signed in to change notification settings - Fork 0
/
insertdialog.cpp
executable file
·79 lines (62 loc) · 2.13 KB
/
insertdialog.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
#include "insertdialog.h"
#include "ui_insertdialog.h"
InsertDialog::InsertDialog(QWidget *parent) : QDialog(parent), ui(new Ui::InsertDialog){
ui->setupUi(this);
btbButtons = findChild<QDialogButtonBox*>("btbButtons");
connect(btbButtons, SIGNAL(accepted()), this, SLOT(okPressed()));
connect(btbButtons, SIGNAL(rejected()), this, SLOT(cancelPressed()));
txtName = findChild<QLineEdit*>("txtName");
txtSeason = findChild<QLineEdit*>("txtSeason");
txtEpisode = findChild<QLineEdit*>("txtEpisode");
btbButtons->button(QDialogButtonBox::Ok)->setEnabled(false);
btbButtons->button(QDialogButtonBox::Cancel)->setText(tr("&Cancel"));
connect(txtName, SIGNAL(textChanged(QString)), this, SLOT(txtNameChanged(QString)));
connect(txtSeason, SIGNAL(textChanged(QString)), this, SLOT(txtSeasonChanged(QString)));
connect(txtEpisode, SIGNAL(textChanged(QString)), this, SLOT(txtEpisodeChanged(QString)));
name = false;
season = true;
episode = true;
QPixmap tickPNG(":/icons/imgs/tick.png");
QPixmap delPNG(":/icons/imgs/delete.png");
QIcon tickICO(tickPNG);
QIcon delICO(delPNG);
btbButtons->button(QDialogButtonBox::Ok)->setIcon(tickICO);
btbButtons->button(QDialogButtonBox::Cancel)->setIcon(delICO);
}
InsertDialog::~InsertDialog(){
delete ui;
delete btbButtons;
delete txtName;
delete txtSeason;
delete txtEpisode;
}
void InsertDialog::okPressed(){
emit newSeries(txtName->text(), txtSeason->text(), txtEpisode->text());
reset();
}
void InsertDialog::cancelPressed(){
reset();
}
void InsertDialog::reset(){
txtName->setText("");
txtSeason->setText("1");
txtEpisode->setText("0");
name = false;
season = true;
episode = true;
}
void InsertDialog::enableOk(){
btbButtons->button(QDialogButtonBox::Ok)->setEnabled(name && season && episode);
}
void InsertDialog::txtNameChanged(QString text){
name = text != "";
enableOk();
}
void InsertDialog::txtSeasonChanged(QString text){
season = text != "";
enableOk();
}
void InsertDialog::txtEpisodeChanged(QString text){
episode = text != "";
enableOk();
}