-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_groupbox.cpp
More file actions
executable file
·127 lines (110 loc) · 4.34 KB
/
run_groupbox.cpp
File metadata and controls
executable file
·127 lines (110 loc) · 4.34 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "run_groupbox.hpp"
RunGroupBox::RunGroupBox(QString app, UserData *data, LogView *l): srcPath("N/A"), appPath("N/A"), resPath("N/A"){
log = l;
setTitle("Run");
finder = (app == "matlab")? new FileFinder("C#") : new FileFinder("Script");
QObject::connect(finder, &FileFinder::contentChanged, this, &RunGroupBox::loadCsharp);
if (app == "python")
finder->setText(data->userPreference().Pyprogram);
analyzeButton = new QPushButton("Start Analysis");
QObject::connect(analyzeButton, &QPushButton::clicked, this, &RunGroupBox::analyzeButtonClicked);
QIcon icon = style()->standardIcon(QStyle::SP_DialogApplyButton);
QIcon icon1 = style()->standardIcon(QStyle::SP_DialogCancelButton);
applyPixmap = icon.pixmap(QSize(16, 16));
cancelPixmap = icon1.pixmap(QSize(16, 16));
sourceApply = new QLabel();
appApply = new QLabel();
sourceApply->setPixmap(cancelPixmap);
appApply->setPixmap(cancelPixmap);
QLabel *videoLabel = new QLabel("Source File:");
QLabel *cSharpLabel;
if (app == "matlab")
cSharpLabel = new QLabel("C# Application:");
else
cSharpLabel = new QLabel("Python Script:");
QLabel *resultLabel = new QLabel("Result:");
sourceName = new QLabel(srcPath);
appName = new QLabel(appPath);
resultName = new QLabel(resPath);
revealOrgButton = new QToolButton();
revealOrgButton->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
revealOrgButton->setDisabled(true);
QObject::connect(revealOrgButton, &QToolButton::clicked, this, &RunGroupBox::revealOrgClicked);
revealResButton = new QToolButton();
revealResButton->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
revealResButton->setDisabled(true);
QObject::connect(revealResButton, &QToolButton::clicked, this, &RunGroupBox::revealResClicked);
QGridLayout *layout = new QGridLayout();
layout->addWidget(finder, 0, 0, 1, 4);
layout->addWidget(sourceApply, 1, 0, Qt::AlignRight);
layout->addWidget(appApply, 2, 0, Qt::AlignRight);
layout->addWidget(videoLabel, 1, 1);
layout->addWidget(cSharpLabel, 2, 1);
layout->addWidget(resultLabel, 3, 1);
layout->addWidget(sourceName, 1, 2, 1, 2, Qt::AlignLeft);
layout->addWidget(appName, 2, 2, 1, 2, Qt::AlignLeft);
layout->addWidget(resultName, 3, 2, 1, 2, Qt::AlignLeft);
layout->addWidget(revealOrgButton, 1, 3, Qt::AlignRight);
layout->addWidget(revealResButton, 3, 3, Qt::AlignRight);
layout->addWidget(analyzeButton, 4, 3, Qt::AlignLeft);
setLayout(layout);
loadCsharp();
}
void RunGroupBox::loadCsharp() {
if (finder->currentText() == appPath || finder->currentText().isEmpty())
return;
updateRes("N/A");
QFileInfo file(finder->currentText());
if (!file.exists()) {
appPath = QString::fromStdString("N/A");
appName->setText(appPath);
appApply->setPixmap(cancelPixmap);
return log->write("Error: Cannot load C# application, since it not exist.");
}
appPath = finder->currentText();
appName->setText(file.fileName());
appApply->setPixmap(applyPixmap);
}
void RunGroupBox::analyzeButtonClicked() {
emit run();
}
void RunGroupBox::revealOrgClicked() {
if(sourceName->text() != QString::fromStdString("N/A"))
showFileInFolder(srcPath);
}
void RunGroupBox::revealResClicked() {
if(resultName->text() != QString::fromStdString("N/A"))
showFileInFolder(resPath);
}
void RunGroupBox::updateSrc(QString fp) {
if (fp == srcPath)
return;
updateRes("N/A");
QFileInfo file(fp);
if (!file.exists()) {
srcPath = QString::fromStdString("N/A");
sourceName->setText(srcPath);
sourceApply->setPixmap(cancelPixmap);
revealOrgButton->setDisabled(true);
return;
}
srcPath = fp;
sourceName->setText(file.fileName());
sourceApply->setPixmap(applyPixmap);
revealOrgButton->setDisabled(false);
}
void RunGroupBox::updateRes(QString fp) {
QFileInfo file(fp);
if (!file.exists()) {
resPath = QString::fromStdString("N/A");
resultName->setText(resPath);
revealResButton->setDisabled(true);
return;
}
resPath = fp;
resultName->setText(file.fileName());
revealResButton->setDisabled(false);
}
QString RunGroupBox::getAppPath() {
return finder->currentText();
}