-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmainview.cpp
More file actions
697 lines (599 loc) · 21.2 KB
/
mainview.cpp
File metadata and controls
697 lines (599 loc) · 21.2 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
#include <functional>
#include "PythonAccess/emb.h"
#include "PythonAccess/pythonworker.h"
#include "UI/mainview.h"
#include "ui_mainview.h"
#include <QSettings>
#include <QShortcut>
#include <QStringListModel>
#include "CodeEditor/antlrsyntaxhighlighter.h"
MainView::MainView(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainView) {
ui->setupUi(this);
LoadSettings(); // 1) Setup UI first, so things look nice
LoadResources(); // 2) Load the required files
SetupHighlighter(); // 3) No (2) is required for this step
SetupTerminal();
SetupPython();
SetupShortuctKeys();
m_tute = new XTute(this);
}
/**
* @brief Setup python embedding
*/
void MainView::SetupPython() {
emb::setMainView(this);
m_worker = new PythonWorker();
emb::setWorker(m_worker);
m_workerThread = new QThread();
m_worker->moveToThread(m_workerThread);
connect(m_workerThread, &QThread::finished, m_worker, &QObject::deleteLater);
connect(this, &MainView::operate, m_worker, &PythonWorker::RunPython);
connect(this, &MainView::terminate, m_worker, &PythonWorker::StopPython);
connect(m_worker, &PythonWorker::WriteOutput, this, &MainView::WriteOutput);
connect(m_worker, &PythonWorker::SetCode, this, &MainView::SetCode);
connect(m_worker, &PythonWorker::SetInput, this, &MainView::SetInput);
connect(m_worker, &PythonWorker::SetOutput, this, &MainView::SetOutput);
connect(m_worker, &PythonWorker::StartPythonRun, this,
&MainView::StartPythonRun);
connect(m_worker, &PythonWorker::EndPythonRun, this, &MainView::EndPythonRun);
connect(m_worker, &PythonWorker::SetSearchRegex, this,
&MainView::SetSearchRegex);
m_workerThread->start();
}
// Buttons to enable when you execute a python script
void MainView::StartPythonRun() {
this->SaveContent(); // Backup the typed content and window positions
ui->btnRun->setEnabled(false);
ui->btnRunSnippet->setEnabled(false);
ui->btnRunSnippetFromCombo->setEnabled(false);
ui->dwTutorial->setEnabled(false);
ui->btnStopPython->setEnabled(true);
}
// End python script
void MainView::EndPythonRun() {
if (m_markTute) {
m_tute->Mark(m_markIndex, ui->txtOutput->toPlainText(), ui->lwTute, ui->pbTute);
m_markTute = false;
m_markIndex = -1;
}
ui->btnRun->setEnabled(true);
ui->btnRunSnippet->setEnabled(true);
ui->btnRunSnippetFromCombo->setEnabled(true);
ui->dwTutorial->setEnabled(true);
ui->btnStopPython->setEnabled(false);
}
// Util function: Confirm message box
bool MainView::Confirm(const QString &what) {
QMessageBox msgBox(this);
msgBox.setWindowTitle(tr(APP_NAME));
msgBox.setText(what);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
if (msgBox.exec() == QMessageBox::Yes) {
return true;
}
return false;
}
/**
* @brief Load text box content and docking locations
*/
void MainView::LoadSettings() {
QSettings settings;
ui->dwNote->setVisible(settings.value(KEY_SHOW_NOTE, 0).toInt() == 1);
ui->dwSnippet->setVisible(settings.value(KEY_SHOW_SNIPPETS, 0).toInt() == 1);
ui->dwTutorial->setVisible(settings.value(KEY_SHOW_TUTE, 0).toInt() == 1);
ui->dwTerminal->setContentsMargins(10,30,10,10);
this->restoreState(settings.value(KEY_DOCK_LOCATIONS).toByteArray(),
SAVE_STATE_VERSION);
this->restoreGeometry(settings.value(KEY_GEOMETRY).toByteArray());
this->SetCode(settings.value(KEY_CODEBOX, QString()).toString());
this->SetInput(settings.value(KEY_INPUTBOX, QString()).toString());
this->SetOutput(settings.value(KEY_OUTPUTBOX, QString()).toString());
ui->txtSnippet->setPlainText(
settings.value(KEY_SNIPPETBOX, QString()).toString());
ui->txtNotes->setPlainText(
settings.value(KEY_NOTESBOX, QString()).toString());
ui->dwTerminal->hide(); // hide the terminal on start
QString font = settings.value(KEY_FONT, tr("Courier New")).toString();
int sizeIndex = settings.value(KEY_FONTSIZE, 6).toInt(); // select 12pt
int pos = ui->fntCombo->findText(font);
if (pos != -1) {
ui->fntCombo->setCurrentIndex(pos);
} else {
ui->fntCombo->setCurrentIndex(0);
}
if (sizeIndex >= 0) {
ui->cmbFontSize->setCurrentIndex(sizeIndex);
} else {
ui->cmbFontSize->setCurrentIndex(4);
}
ChangeFontSize(ui->fntCombo->currentFont(),
ui->cmbFontSize->currentText().toInt());
}
void MainView::SetupShortuctKeys() {
// Save file
QShortcut *save = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_S), this);
QObject::connect(save, &QShortcut::activated, this, &MainView::on_btnCodeSave_clicked);
// Load file
QShortcut *open = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_O), this);
QObject::connect(open, &QShortcut::activated, this, &MainView::on_btnCodeOpen_clicked);
// Load terminal
QShortcut *terminal = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_T), this);
QObject::connect(terminal, &QShortcut::activated, this, &MainView::on_btnTerminal_clicked);
// Run code
QShortcut *run = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_R), this);
QObject::connect(run, &QShortcut::activated, this, &MainView::on_btnRun_clicked);
}
void MainView::SetSnippets(Snippets *snip) {
m_snippets = snip;
LoadSnippetsToCombo();
}
void MainView::SetupHighlighter() {
m_highlighterCodeArea = new ANTLRSyntaxHighlighter(ui->txtCode->document());
ui->txtCode->setFocus();
m_highlighterSnippetArea =
new ANTLRSyntaxHighlighter(ui->txtSnippet->document());
SetCompleter(ui->txtCode);
}
void MainView::SetupTerminal() {
#ifndef Q_OS_WIN
setenv("TERM", "xterm-256color", 1);
SetTerminal();
#endif
}
void MainView::SetTerminal() {
#ifndef Q_OS_WIN
terminal = new QTermWidget();
#endif
#ifdef Q_OS_MACX
terminal->setKeyBindings("macbook");
#endif
#ifdef Q_OS_LINUX
terminal->setKeyBindings("linux");
#endif
#ifndef Q_OS_WIN
terminal->setColorScheme("Tango");
ui->dwTerminal->setWidget(terminal);
terminal->setAutoClose(false);
#endif
}
void MainView::SetCompleter(CodeEditor *editor) {
completer = new QCompleter(this);
QFile file(":/data/Features/autocomplete.txt");
if (!file.open(QFile::ReadOnly))
return;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
QStringList words;
while (!file.atEnd()) {
QByteArray line = file.readLine();
if (!line.isEmpty())
words << line.trimmed();
}
QApplication::restoreOverrideCursor();
QStringListModel *model = new QStringListModel(words, completer);
completer->setModel(model);
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setWrapAround(false);
completer->popup()->setStyleSheet("background-color: black; color: white");
editor->setCompleter(completer);
// Jedi Completer
QCompleter* jediCompleter = new QCompleter();
QStringListModel *initialJedi = new QStringListModel(words, jediCompleter);
jediCompleter->setModel(initialJedi);
jediCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
jediCompleter->setCaseSensitivity(Qt::CaseInsensitive);
jediCompleter->setCompletionMode(QCompleter::PopupCompletion);
jediCompleter->setWrapAround(false);
jediCompleter->popup()->setStyleSheet("background-color: #9090FF; color: black");
editor->setJediCompleter(jediCompleter, this->m_getJedi);
}
void MainView::LoadResources() {
bool success = false;
m_startMe = LoadFile(STARTUP_SCRIPT_FILE, success, false);
if (!success) {
m_startMe = LoadFile(":/data/ep_runner.py", success);
}
if (!success) {
QMessageBox::critical(this, tr(APP_NAME), tr("Loading startup script failed"));
qApp->quit();
}
m_getJedi = LoadFile(":/data/ep_jedi.py", success);
if (!success) {
QMessageBox::critical(this, tr(APP_NAME), tr("Loading startup script failed"));
qApp->quit();
}
m_about = LoadFile(":/data/About.htm", success);
if (!success) {
m_about = tr(APP_NAME " Written by Bhathiya Perera");
}
}
MainView::~MainView() {
this->SaveContent();
m_workerThread->quit();
m_workerThread->wait();
#ifndef Q_OS_WIN
delete terminal;
#endif
delete m_workerThread;
delete ui;
delete m_tute;
}
void MainView::SaveContent() {
// Save all the details of windows to QSettings
// This is called on exit and command execution
QSettings settings;
settings.setValue(KEY_DOCK_LOCATIONS, this->saveState(SAVE_STATE_VERSION));
settings.setValue(KEY_GEOMETRY, this->saveGeometry());
settings.setValue(KEY_CODEBOX, this->GetCode());
settings.setValue(KEY_INPUTBOX, this->GetInput());
settings.setValue(KEY_OUTPUTBOX, this->GetOutput());
settings.setValue(KEY_SNIPPETBOX, ui->txtSnippet->toPlainText());
settings.setValue(KEY_NOTESBOX, ui->txtNotes->toPlainText());
settings.setValue(KEY_FONT, ui->fntCombo->currentText());
settings.setValue(KEY_FONTSIZE, ui->cmbFontSize->currentIndex());
}
QString MainView::LoadFile(const QString &fileName, bool &success,
const bool showMessage) {
success = false;
QFile file(fileName);
if (!file.open(QFile::ReadOnly | QFile::Text)) {
if (showMessage) {
QMessageBox::warning(this, tr(APP_NAME), tr("Cannot read file %1:\n%2.")
.arg(fileName)
.arg(file.errorString()));
}
return QString();
}
QTextStream in(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
QString text = in.readAll();
QApplication::restoreOverrideCursor();
in.flush();
file.close();
success = true;
return text;
}
void MainView::BrowseAndLoadFile(CodeEditor *codeEditor, const bool isPython) {
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open"), QApplication::applicationDirPath(),
((isPython) ? FILETYPES_PYTHON : FILETYPES_OTHER));
if (fileName.isEmpty()) {
return;
}
bool success;
QString text = LoadFile(fileName, success);
if (success) {
codeEditor->setPlainText(text);
}
}
void MainView::SaveFile(CodeEditor *codeEditor, const bool isPython) {
QString fileName = QFileDialog::getSaveFileName(
this, tr("Save"), QApplication::applicationDirPath(),
((isPython) ? FILETYPES_PYTHON : FILETYPES_OTHER));
if (fileName.isEmpty()) {
return;
}
QFile file(fileName);
if (!file.open(QFile::WriteOnly | QFile::Text)) {
QMessageBox::warning(
this, tr(APP_NAME),
tr("Cannot write file %1:\n%2.").arg(fileName).arg(file.errorString()));
return;
}
QTextStream out(&file);
QApplication::setOverrideCursor(Qt::WaitCursor);
out << codeEditor->toPlainText();
QApplication::restoreOverrideCursor();
}
QString MainView::GetInput() {
return ui->txtInput->toPlainText();
}
void MainView::SetInput(QString txt) {
ui->txtInput->setPlainText(txt);
}
QString MainView::GetOutput() {
return ui->txtOutput->toPlainText();
}
void MainView::SetOutput(QString txt) {
ui->txtOutput->setPlainText(txt);
}
QString MainView::GetCode() {
return ui->txtCode->toPlainText();
}
void MainView::SetCode(QString txt) {
ui->txtCode->setPlainText(txt);
}
void MainView::SetSearchRegex(QString txt) {
m_highlighterCodeArea->SetSearchRegEx(txt);
m_highlighterCodeArea->rehighlight();
}
void MainView::WriteOutput(QString output) {
QString txt = ui->txtOutput->toPlainText();
txt.append(output);
ui->txtOutput->setPlainText(txt);
}
void MainView::RunPythonCode(const QString &code) {
m_markTute = false;
m_markIndex = -1;
emit operate(m_startMe, code);
}
void MainView::on_btnRun_clicked() {
if (ui->chkClearOut->isChecked()) {
ui->txtOutput->clear();
}
RunPythonCode(ui->txtCode->toPlainText());
}
void MainView::ChangeFontSize(QFont font, int fontSize) {
QFont sized(font);
sized.setPointSize(fontSize);
sized.setFixedPitch(true);
ui->txtCode->setFont(sized);
ui->txtInput->setFont(sized);
ui->txtOutput->setFont(sized);
ui->txtSnippet->setFont(sized);
ui->txtNotes->setFont(sized);
}
void MainView::on_fntCombo_currentFontChanged(const QFont &font) {
ChangeFontSize(font, ui->cmbFontSize->currentText().toInt());
}
void MainView::on_cmbFontSize_currentIndexChanged(const QString &fontSize) {
ChangeFontSize(ui->fntCombo->currentFont(), fontSize.toInt());
}
void MainView::on_btnCodeClear_clicked() {
if (Confirm(tr("Are you sure you want to clear code ?"))) {
ui->txtCode->clear();
}
}
void MainView::on_btnInputClear_clicked() {
if (Confirm(tr("Are you sure you want to clear input ?"))) {
ui->txtInput->clear();
}
}
void MainView::on_btnOutputClear_clicked() {
if (Confirm(tr("Are you sure you want to clear output ?"))) {
ui->txtOutput->clear();
}
}
void MainView::on_btnOutputOpen_clicked() {
BrowseAndLoadFile(ui->txtOutput);
}
void MainView::on_btnInputOpen_clicked() {
BrowseAndLoadFile(ui->txtInput);
}
void MainView::on_btnCodeOpen_clicked() {
if (!ui->txtCode->toPlainText().isEmpty() &&
Confirm(tr("Would you like to save code ?"))) {
on_btnCodeSave_clicked();
}
BrowseAndLoadFile(ui->txtCode, true);
}
void MainView::on_btnOutputSave_clicked() {
SaveFile(ui->txtOutput);
}
void MainView::on_btnInputSave_clicked() {
SaveFile(ui->txtInput);
}
void MainView::on_btnCodeSave_clicked() {
SaveFile(ui->txtCode, true);
}
void MainView::on_btnCodeDatabase_clicked() {
bool success;
m_snippets->SaveSnippets(success);
if (success) {
QMessageBox::information(this, tr(APP_NAME),
tr("Snippets database saved."));
} else {
QMessageBox::critical(this, tr(APP_NAME),
tr("Snippets database saving failed."));
}
}
void MainView::on_btnRunSnippet_clicked() {
if (!Confirm(
"Are you sure you want to run this snippet (from snippet area) ?")) {
return;
}
if (ui->chkClearOut->isChecked()) {
ui->txtOutput->clear();
}
RunPythonCode(ui->txtSnippet->toPlainText());
}
void MainView::on_btnLoadSnippet_clicked() {
if (!Confirm("Are you sure you want to load snippet to snippet area ?")) {
return;
}
bool success;
QString code =
m_snippets->GetSnippet(ui->cmbSnippets->currentText(), success);
if (success) {
ui->txtSnippet->setPlainText(code);
}
}
void MainView::on_btnRemoveSnippet_clicked() {
if (!Confirm("Are you sure you want to delete the selected snippet ?")) {
return;
}
bool success;
m_snippets->RemoveSnippet(ui->cmbSnippets->currentText(), success);
if (success) {
QMessageBox::information(this, tr(APP_NAME), tr("Snippet removed."));
} else {
QMessageBox::critical(this, tr(APP_NAME), tr("Snippet removal failed."));
}
LoadSnippetsToCombo();
}
void MainView::on_btnAddSnippet_clicked() {
if (ui->txtSnippet->toPlainText().isEmpty()) {
return;
}
bool ok = false;
QString text = QInputDialog::getText(this, tr(APP_NAME), tr("Snippet name:"),
QLineEdit::Normal, tr(""), &ok);
if (!ok || text.isEmpty()) {
return;
}
if (!m_snippets->OkToInsert(text)) {
ok = Confirm(tr("This snippet already exists, do you want to overwrite ?"));
}
if (!ok) {
return;
}
m_snippets->AddSnippet(text, ui->txtSnippet->toPlainText(), ok);
if (ok) {
QMessageBox::information(this, tr(APP_NAME), tr("Snippet added."));
} else {
QMessageBox::critical(this, tr(APP_NAME), tr("Snippet adding failed."));
}
LoadSnippetsToCombo();
}
void MainView::on_btnAbout_clicked() {
QMessageBox::about(this, tr(APP_NAME), m_about);
}
void MainView::LoadSnippetsToCombo() {
ui->cmbSnippets->clear();
bool success;
QList<QString> keys = m_snippets->GetKeys(success);
if (success) {
ui->cmbSnippets->addItems(QStringList(keys));
}
}
void MainView::on_btnUpdateSnippet_clicked() {
if (ui->txtSnippet->toPlainText().isEmpty()) {
return;
}
if (!Confirm("Are you sure you want to overwrite selected snippet ?")) {
return;
}
bool ok;
m_snippets->AddSnippet(ui->cmbSnippets->currentText(),
ui->txtSnippet->toPlainText(), ok);
if (ok) {
QMessageBox::information(this, tr(APP_NAME), tr("Snippet updated."));
} else {
QMessageBox::critical(this, tr(APP_NAME), tr("Snippet updating failed."));
}
LoadSnippetsToCombo();
}
void MainView::on_btnSnippetClear_clicked() {
if (Confirm(tr("Are you sure you want to clear snippet area ?"))) {
ui->txtSnippet->clear();
}
}
void MainView::on_btnSnippetSave_clicked() {
SaveFile(ui->txtSnippet, true);
}
void MainView::on_btnSnippetOpen_clicked() {
if (!ui->txtSnippet->toPlainText().isEmpty() &&
Confirm(tr("Would you like to save current snippet ?"))) {
on_btnSnippetSave_clicked();
}
BrowseAndLoadFile(ui->txtSnippet, true);
}
void MainView::on_btnRunSnippetFromCombo_clicked() {
if (!Confirm(
"Are you sure you want to run this snippet (from combo-box) ?")) {
return;
}
bool success;
QString code =
m_snippets->GetSnippet(ui->cmbSnippets->currentText(), success);
if (success) {
RunPythonCode(code);
}
}
// =========================================================================
// NOTES
// =========================================================================
void MainView::on_btnNotesOpen_clicked() {
if (!ui->txtNotes->toPlainText().isEmpty() &&
Confirm(tr("Would you like to save notes ?"))) {
on_btnNotesSave_clicked();
}
BrowseAndLoadFile(ui->txtNotes, true);
}
void MainView::on_btnNotesSave_clicked() {
SaveFile(ui->txtNotes);
}
void MainView::on_btnNotesClear_clicked() {
if (Confirm(tr("Are you sure you want to clear notes ?"))) {
ui->txtNotes->clear();
}
}
void MainView::on_btnTuteOpen_clicked() {
if (!Confirm(tr("Are you sure you want to load a tute, this will reset current progress (if any) ?"))) {
return;
}
QString fileName = QFileDialog::getOpenFileName(
this, tr("Open"), QApplication::applicationDirPath(), FILETYPES_TUTE);
if (fileName.isEmpty()) {
return;
}
m_tute->Load(fileName);
if (!m_tute->IsLoaded()) {
QMessageBox::warning(this, tr(APP_NAME), tr("Cannot read file %1").arg(fileName));
return;
}
m_tute->InitList(ui->lwTute, ui->pbTute);
}
void MainView::on_btnTuteLoad_clicked() {
if (!Confirm(tr("Are you sure you want to load a question, this will reset current progress (if any) ?"))) {
return;
}
int index = ui->lwTute->currentRow();
if (index < 0 || index >= ui->lwTute->count()) {
return;
}
m_tute->LoadQuestion(index, ui->txtInput, ui->txtNotes, ui->txtCode);
}
void MainView::on_btnTuteMark_clicked() {
int index = ui->lwTute->currentRow();
if (index < 0 || index >= ui->lwTute->count()) {
return;
}
// Reset input before marking
m_tute->SetInput(index, ui->txtInput);
ui->txtOutput->clear();
m_markTute = true;
m_markIndex = index;
emit operate(m_startMe, ui->txtCode->toPlainText());
}
void MainView::on_btnStopPython_clicked() {
m_worker->killed.store(1);
//emit this->terminate();
}
void MainView::on_btnTerminal_clicked() {
#ifndef Q_OS_WIN
if(ui->dwTerminal->isHidden()) {
delete terminal;
SetTerminal();
ui->dwTerminal->show();
} else {
ui->dwTerminal->hide();
}
#else
QMessageBox::information(this, tr(APP_NAME), tr("Currently, terminal is not available for Windows"));
#endif
}
void MainView::on_btnSnippet_clicked() {
if(ui->dwSnippet->isHidden()) {
ui->dwSnippet->show();
} else {
ui->dwSnippet->hide();
}
}
void MainView::on_btnTutorial_clicked() {
if(ui->dwTutorial->isHidden()) {
ui->dwTutorial->show();
} else {
ui->dwTutorial->hide();
}
}
void MainView::on_btnNotes_clicked() {
if(ui->dwNote->isHidden()) {
ui->dwNote->show();
} else {
ui->dwNote->hide();
}
}