-
Notifications
You must be signed in to change notification settings - Fork 0
/
scripteditdialog.cpp
56 lines (55 loc) · 1.61 KB
/
scripteditdialog.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
#include "scripteditdialog.h"
#include "ui_scripteditdialog.h"
#include "QComboBox"
ScriptEditDialog::ScriptEditDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ScriptEditDialog)
{
ui->setupUi(this);
QFont f("unexistent");
f.setStyleHint(QFont::Monospace);
ui->txtScriptEdit->setFont(f);
}
ScriptEditDialog::ScriptEditDialog(QWidget *parent, ScriptScoreChecker * scorechecker) :
QDialog(parent),
ui(new Ui::ScriptEditDialog)
{
ui->setupUi(this);
this->scorechecker=scorechecker;
QFont f("unexistent");
f.setStyleHint(QFont::Monospace);
ui->txtScriptEdit->setFont(f);
this->oldScript=scorechecker->getScript();
ui->txtScriptEdit->setPlainText(QString(this->oldScript.c_str()));
if (this->scorechecker->getScriptExtension()==".sh")ui->extCombo->setCurrentIndex(0);
else if (this->scorechecker->getScriptExtension()==".bat")ui->extCombo->setCurrentIndex(1);
else if (this->scorechecker->getScriptExtension()==".ps1")ui->extCombo->setCurrentIndex(2);
}
ScriptEditDialog::~ScriptEditDialog()
{
delete ui;
}
void ScriptEditDialog::on_buttonBox_accepted()
{
this->newScript=ui->txtScriptEdit->toPlainText().toStdString();
this->scorechecker->setScript(this->newScript);
this->scorechecker->setScriptExtension(this->getExtension());
}
std::string ScriptEditDialog::getScript()
{
return this->newScript;
}
std::string ScriptEditDialog::getExtension()
{
int index=ui->extCombo->currentIndex();
switch (index) {
case 0:
return ".sh";
case 1:
return ".bat";
case 2:
return ".ps1";
default:
break;
}
}