-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwindowrun.cpp
More file actions
68 lines (59 loc) · 2.32 KB
/
windowrun.cpp
File metadata and controls
68 lines (59 loc) · 2.32 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
#include "windowrun.h"
#include <QApplication>
#include <QWidget>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QProcessEnvironment>
#include <QString>
#include <filesystem>
windowRun::windowRun(QWidget* window ) {
setWindowTitle(tr("Run Utopia"));
setGeometry(300, 300, 320, 240);
testFile = new QLabel(tr("сhoose test file (*.ril) format"),this);
testFile-> move(50, 15);
option = new QLabel(tr("app options to launch utopia if needed"),this);
option-> move(50, 75);
buttonf = new QPushButton("test",this);
buttonf-> setGeometry(QRect(QPoint(50, 35), QSize(50, 30)));
connect(buttonf, SIGNAL (released()), this, SLOT(handleButton()));
applyTestFile = new QPushButton("Apply",this);
applyTestFile->setGeometry(QRect(QPoint(110, 35), QSize(50, 30)));
connect(applyTestFile, SIGNAL (released()), this, SLOT(handleApplyTestButton()));
QLineEdit *lineEdit = new QLineEdit(this);
lineEdit-> setGeometry(50, 100, 200, 30);
QPushButton *btnRunUtopia = new QPushButton("Run Utopia", this);
btnRunUtopia-> setGeometry(210, 210, 100, 30);
QPushButton *applyButton = new QPushButton("Apply", this);
applyButton-> setGeometry(220, 100, 80, 30);
connect(btnRunUtopia, &QPushButton::clicked, this, &windowRun::onBtnRunUtopiaClicked);
QObject::connect(applyButton, &QPushButton::clicked, [=]() {
text = lineEdit-> text();
});
}
void windowRun::handleButton(const QString &path) {
QString filename = path;
a = filename;
if (filename.isNull()) {
std::filesystem::path filePath(shellVariable.toStdString());
std::filesystem::path fullPath = filePath / "test/data/ril/test.ril";
filename = QFileDialog::getOpenFileName(this, tr("Open File"),QString::fromStdString(fullPath.string()), tr("RIL Files (*.ril)"));
emit fileSelected(filename);
a = filename;
}
else{
qDebug() << "No file selected: ";
}
}
void windowRun::handleApplyTestButton(){
b = a;
}
void windowRun::onBtnRunUtopiaClicked() {
std::filesystem::path filePath(shellVariable.toStdString());
std::filesystem::path fullPath = filePath / "build/src/umain";
QString program = QString::fromStdString(fullPath.string());
QStringList arguments;
arguments << text << b;
QProcess::startDetached(program, arguments);
qDebug() << QString("Starting process: %1 %2").arg(program).arg(arguments.join(" "));
}