-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQSummaryShow.cpp
102 lines (81 loc) · 2.92 KB
/
QSummaryShow.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
#include "QSummaryShow.h"
QSummaryShow::QSummaryShow(QWidget *parent) : QSummary(parent)
{
createWidget(createLayoutShow());
}
QSummaryShow::QSummaryShow(string pname,QWidget *parent) : QSummary(parent)
{
createWidget(createLayoutShow());
lshow->setText(Easylast::stoqs(pname));
}
QSummaryShow::QSummaryShow(string pname,int pseason,int pepisode,QWidget *parent) : QSummary(parent)
{
createWidget(createLayoutShow());
lshow->setText(Easylast::stoqs(pname));
lseason->setText(Easylast::stoqs(Easylast::itos(pseason)));
lepisode->setText(Easylast::stoqs(Easylast::itos(pepisode)));
}
QVBoxLayout* QSummaryShow::createLayoutShow()
{
QHBoxLayout *layout_name = new QHBoxLayout;
QHBoxLayout *layout_season = new QHBoxLayout;
QHBoxLayout *layout_episode = new QHBoxLayout;
QVBoxLayout *layout_main = new QVBoxLayout;
QLabel * label_show = new QLabel("Show :");
QLabel * label_season = new QLabel("Season :");
QLabel * label_episode = new QLabel("Episode :");
QSizePolicy policy_edit(QSizePolicy::Maximum,QSizePolicy::Maximum);
lshow = new QLineEdit;
lseason = new QLineEdit;
lepisode = new QLineEdit;
label_season->setFixedWidth(60);
label_episode->setFixedWidth(60);
label_show->setFixedWidth(60);
label_show->setMargin(0);
label_season->setMargin(0);
label_episode->setMargin(0);
lshow->setSizePolicy(policy_edit);
lshow->setMaximumWidth(200);
lseason->setSizePolicy(policy_edit);
lseason->setMaxLength(3);
lseason->setMaximumWidth(40);
lepisode->setSizePolicy(policy_edit);
lepisode->setMaxLength(3);
lepisode->setMaximumWidth(40);
layout_name->addWidget(label_show,Qt::AlignLeft);
layout_name->addWidget(lshow,Qt::AlignLeft);
layout_name->addStretch();
layout_season->addWidget(label_season,Qt::AlignLeft);
layout_season->addWidget(lseason,Qt::AlignLeft);
layout_season->addStretch();
layout_episode->addWidget(label_episode,Qt::AlignLeft);
layout_episode->addWidget(lepisode,Qt::AlignLeft);
layout_episode->addStretch();
layout_main->addLayout(layout_name);
layout_main->addLayout(layout_season);
layout_main->addLayout(layout_episode);
return layout_main;
}
void QSummaryShow::add_summary()
{
string textShow = lshow->text().toStdString();
string textSea = lseason->text().toStdString();
string textEp = lepisode->text().toStdString();
string textSumm = lsummary->toPlainText().toStdString();
if( textSea != "" && textEp !="" && textSumm != "" && textShow != "")
{
if( isNumber(textEp) && isNumber(textSea))
{
string cmd = "client_last --as -t \""+textShow+"\" -n "+textSea+"x"+textEp+" -s \""+textSumm+"\"";
if(system(cmd.c_str()) == 0)
{
displayBox("Summary added");
lsummary->setText("");
}
}
else
displayBox("Season or Episode is not a number");
}
else
displayBox("A text is empty");
}