forked from leuat/TRSE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
522 lines (362 loc) · 14.5 KB
/
mainwindow.h
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
/*
* Turbo Rascal Syntax error, “;” expected but “BEGIN” (TRSE, Turbo Rascal SE)
* 8 bit software development IDE for the Commodore 64
* Copyright (C) 2018 Nicolaas Ervik Groeneboom ([email protected])
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program (LICENSE.txt).
* If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "imageworker.h"
#include <QString>
#include <QPixmap>
#include <QFontDatabase>
#include <QMovie>
#include <QFileDialog>
#include "source/LeLib/data.h"
#include <QThread>
#include <thread>
#include <QFileSystemModel>
#include <QLayout>
#include <QPointF>
#include <QTimer>
#include <QStandardPaths>
#include <source/toolbox.h>
#include "source/workerthread.h"
#include "imageeditor.h"
#include "dialogimport.h"
#include "source/PmmEdit/highlighter.h"
#include "source/PmmEdit/codeeditor.h"
#include "source/LeLib/util/cinifile.h"
#include "source/trsedocuments/formraseditor.h"
#include "source/trsedocuments/formimageeditor.h"
#include "source/trsedocuments/formfjong.h"
#include "source/trsedocuments/formrtf.h"
#include "source/trsedocuments/formpaw.h"
#include "source/trsedocuments/formhexedit.h"
#include "source/trsedocuments/formttredit.h"
#include "source/dialogtrsesettings.h"
#include "source/messages.h"
#include "source/LeLib/limage/movieconverter.h"
#include "ui_mainwindow.h"
#include "source/dialogprojectsettings.h"
#include "source/dialogdonate.h"
#include "source/dialogfindfile.h"
#include "source/dialogexport3d.h"
#include "source/dialogprojectbuilder.h"
#include "source/tutorials.h"
#include <QDesktopServices>
#include "source/dialognewproject.h"
#include <QStandardItemModel>
#include <QFileSystemWatcher>
#include <source/LeLib/lglslideshow.h>
#include "source/dialogsplash.h"
#include "source/dialognewtrt.h"
#include "source/LeLib/util/util.h"
#include "source/dialogsizeanalyser.h"
namespace Ui {
class MainWindow;
}
class TRSEProject {
public:
QSharedPointer<CIniFile> m_ini;
QString m_filename="";
QString m_projectName = "";
// QStringList m_acceptedFileTypes = {"asm", "flf", "ras", "prg", "paw", "inc", "fjo"};
void Load(QString projectfile) {
m_ini = QSharedPointer<CIniFile>(new CIniFile());
m_ini->Load(projectfile);
m_filename = projectfile;
m_projectName = QDir::toNativeSeparators(projectfile).split(QDir::separator()).last().split(".").first();
QStringList l = m_filename.split("/");
l.removeLast();
QString path = "";
for (QString s: l) path+=s+"/";
m_ini->setString("project_path", path);
}
void VerifyDefaults();
void ConvertFromOldDiskSystem()
{
// cc1541_disk_type
// d64name
// dirart_flf_file
// d64_paw_file
if (m_ini->contains("d64_paw_file") && m_ini->getString("d64_paw_file")!="none") {
// Convert!
m_ini->setString("disk1_paw",m_ini->getString("d64_paw_file"));
m_ini->setString("disk1_name",m_ini->getString("d64name"));
m_ini->setString("disk1_type",m_ini->getString("cc1541_disk_type"));
m_ini->setString("disk1_flf",m_ini->getString("dirart_flf_file"));
m_ini->remove("d64_paw_file_disk2");
m_ini->remove("d64name");
m_ini->remove("dirart_flf_file");
m_ini->remove("d64_paw_file");
}
}
void Close() {
m_filename = "";
}
void Save() {
m_ini->Save(m_filename);
}
};
class CustomFileSystemModel : public QFileSystemModel {
Q_OBJECT
public:
CustomFileSystemModel(QWidget* parent) : QFileSystemModel(parent) {
}
QVariant data ( const QModelIndex & index, int role ) const override
{
if( index.column() == 0 && role == Qt::DecorationRole ) {
//you may want to check "index.data().toString()" for the file-name/-extension
QImage img;
QString f = index.data().toString();
if (f.contains(".ras"))
// img.load(":resources/images/trselogo.png");
img.load(":resources/images/ras.png");
if (f.contains(".asm"))
img.load(":resources/images/asm_icon.png");
if (f.contains(".ll"))
img.load(":resources/images/asm_icon.png");
if (f.contains(".prg"))
img.load(":resources/images/cmb_icon.png");
if (f.contains(".flf"))
img.load(":resources/images/image_icon.png");
if (f.contains(".paw"))
img.load(":resources/images/paw_icon.png");
if (f.contains(".fjo"))
img.load(":resources/images/torus.jpg");
if (f.contains(".tru"))
img.load(":resources/images/tru.png");
QIcon ic(QPixmap::fromImage(img));
return QVariant(ic);
}
else
return QFileSystemModel::data(index, role);
}
};
class MainWindow : public QMainWindow
{
Q_OBJECT
private:
QString m_autoLoadProject = "";
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
QMap<QString, QSharedPointer<SymbolPointer>> m_symPointers, m_orgSymPointers;
QMap<QString, QTreeWidgetItem*> m_treeItems;
bool m_isClosingWindows = false;
QSharedPointer<CIniFile> m_iniFile;
QMap<QString, QTreeWidgetItem*> m_symbolItems;
// CodeEditor m_codeEditor;
CustomFileSystemModel *fileSystemModel = nullptr;
QStringList m_commandParams;
QString m_iniFileNameOld = "fluff64.ini";
QString m_iniFileName = "trse.ini";
QString m_iniFileHomeDir = ".TRSE";
QString m_keepFile = "";
QPalette m_defaultPalette;
QString m_currentPath;
QString m_restrictRecentProjectsSystem = "";
QStringList m_expandedList;
QStringList m_truFilesInProject;
QSharedPointer<DialogSplash> m_splash;
void findExpanded(QAbstractItemModel* model, QStringList& lst, QModelIndex parent = QModelIndex());
void setExpanded(QAbstractItemModel* model, QStringList& lst, QModelIndex parent = QModelIndex());
QSharedPointer<QStandardItemModel> m_im = nullptr;
QVector<TRSEDocument*> m_documents;
Tutorials m_tutorials;
QSharedPointer<QFileSystemWatcher> m_watcher;
QMap<QString, QIcon> m_icons;
QMap<QString, QColor> m_fileColors;
TRSEProject m_currentProject;
QStringList exts_all = QStringList() << "*.ras" << "*.tru" <<"*.asm" << "*.txt"/* << "*.prg" */<< "*.inc" << "*.flf" <<"*.paw" << "*.fjo" <<"*.bin"<<"*.bin_c" <<"*.prg" << "*.sid" <<"*.trt"<<"*.rtf" << "*.pal" <<"*.ll";
QStringList exts_few = QStringList() << "*.ras" << "*.tru" <<"*.inc" << "*.flf" <<"*.paw" << "*.fjo" <<"*.trt"<<"*.rtf" <<"*.pal";
QStringList allowedOpenExtensions = QStringList() <<".tru"<<".ras"<<".asm"<<".inc"<<".flf"<<".paw"<<".fjo"<<".bin"<<".bin_c"<<".sid"<<".trt"<<".rtf" <<".pal" << ".ll";
TRSEDocument* m_currentDoc = nullptr;
void LoadIniFile();
void InitOpenGLBanners();
void AfterStart(QString oldCurDir);
void SearchInSource();
void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void wheelEvent(QWheelEvent *event) override;
void keyPressEvent(QKeyEvent* e) override;
void keyReleaseEvent(QKeyEvent *e) override;
void RestoreSettings();
void ConnectDocument();
void VerifyDefaults();
void VerifyProjectDefaults();
void SetDarkPalette();
void LoadDocument(QString fileName, bool isExternal = false);
bool m_quit = false;
bool VerifyFile(QString file, QString message);
// void setupEditor();
void SetupFileList();
public slots:
void slotLoadProject();
void HandleBuildSuccess();
void ShowSplash();
void RefreshFileList();
void AcceptUpdateSourceFiles(QSharedPointer<SourceBuilder> sourceBuilder);
void UpdateSymbolTree(QString search="");
void acceptBuildMain(bool run);
void acceptSearchSymbols();
void OpenSidfile(QString file);
void acceptRunMain();
void setupIcons();
void acceptBuild() {
//ui->lblBuild->setHidden(false);
//QTimer::singleShot(500, ui->lblBuild, &QLabel::hide);
SaveAllRas();
}
void OpenProjectSettings();
void ClearSymbols();
void OnQuit();
void ForceOpenFile(QString s, int ln);
/* void updateImage() {
FormImageEditor* imageEdit = dynamic_cast<FormImageEditor*>(ui->tabMain->currentWidget());
if (imageEdit==nullptr)
return;
// imageEdit->UpdateImage();
}*/
void closeWindowSlot();
void updatePalette() {
//setPalette(m_updateThread->m_pal);
ui->lblSave->setHidden(false);
QTimer::singleShot(500, ui->lblSave, &QLabel::hide);
}
void UpdateRecentProjects();
bool SaveAs();
void SaveAllRas();
bool RemoveTab(int, bool save=true);
void LoadProject(QString filename);
bool CloseAll();
QString getProjectPath();
QStringList getTRUPaths();
void closeEvent(QCloseEvent *event) override;
void CreateNewSourceFile(QString type);
void AddTreeFileItem(QStandardItem* parent, QString path, QStringList ext);
QStandardItem* AddTreeRoot(QString path, QString name);
void VerifyTRSEVersion();
void PopulateTutorialTable();
signals:
void ValueChanged();
private slots:
void AcceptRequestSystemChange(QString system);
void AcceptMemoryAnalyse();
void LoadTutorialProject(QString file);
void ShowContextMenu(const QPoint &pos);
void ShowFileContext(const QPoint &pos);
void UpdateOutputSystemChange();
void FindFileDialog();
void GotoSymbol(QString s);
void GotoAssemblerLine(QString s, int lineNumber);
void onImageMouseMove();
void on_treeFiles_doubleClicked(const QModelIndex &index);
void on_helpFileType();
void on_tabMain_currentChanged(int index);
void PropagateMainOutput();
void on_btnSave_3_clicked();
void UpdateFailure();
void xon_new_file(QString name);
void xon_new_flf_file();
void xon_add_existing_file();
void xon_new_ras_file();
void xon_new_tru_file();
void xon_new_rtf_file();
void xon_new_inc_file();
void xon_new_fjo_file();
void xon_duplicate_file();
void xon_new_folder();
void xon_rename_file();
void xon_actionDelete_file_triggered();
void on_actionImage_triggered();
void on_actionSave_As_triggered();
void on_actionTRSE_Settings_triggered();
void on_actionNew_project_triggered();
void on_actionClose_all_triggered();
void on_actionOpen_project_triggered();
void on_lstRecentProjects_itemDoubleClicked(QListWidgetItem *item);
void on_btnBuild_3_clicked();
void on_btnBuild_4_clicked();
void on_actionAbout_triggered();
void on_actionAuto_ident_triggered();
void on_actionClose_current_project_triggered();
void on_actionHelp_F1_triggered();
void on_btnMemoryAnalyze_clicked();
void on_actionMovie_Creator_triggered();
void on_actionCheck_for_new_version_triggered();
void on_actionPaw_packed_resource_file_triggered();
void on_actionProject_Settings_triggered();
void on_btnProjectSettings_clicked();
void on_actionDonate_triggered();
void on_actionFind_file_c_s_triggered();
void on_actionEffects_triggered();
void on_actionFjong_Raymarcher_document_triggered();
void on_actionWavefront_obj_to_amiga_converter_triggered();
void on_btnBuildAll_clicked();
/* void on_treeTutorials_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_treeTutorials_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
*/
void on_action_Project_Settings_triggered();
void on_actionBuild_C_b_triggered();
void on_actionBuild_All_triggered();
void on_action_Run_triggered();
void on_action_Memory_map_C_u_triggered();
void on_actionSave_triggered();
void on_actionOpen_project_location_triggered();
void on_btnProjectDir_clicked();
void on_btnNewProject_clicked();
void on_treeSymbols_itemDoubleClicked(QTreeWidgetItem *item, int column);
void on_leFilterSymbols_textChanged(const QString &arg1);
void on_actionLook_up_symbol_F2_triggered();
void on_treeSymbols_itemClicked(QTreeWidgetItem *item, int column);
void on_actionBuild_current_File_only_Shift_C_b_triggered();
void on_action_TRU_Unit_source_file_triggered();
void on_action_include_source_file_triggered();
void on_actionRas_source_file_triggered();
// void on_lstSystems_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
// void on_lstSampleProjects_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
// void on_lstSampleProjects_itemDoubleClicked(QListWidgetItem *item);
void removeFromRecentList();
void on_btnClearProject_clicked();
void on_actionTRSE_Showcases_triggered();
void on_btnShowcases_clicked();
void on_cmbSelectSystem_activated(int index);
// void on_btnChangelog_clicked();
void on_actionView_changelog_triggered();
void on_action_Comment_Uncomment_triggered();
void on_actionLook_up_assembly_line_under_cursor_F3_triggered();
void on_action_Rename_current_file_triggered();
void on_cmbSelectSystemRecent_currentTextChanged(const QString &arg1);
void on_actionTRSE_Tracker_File_trt_triggered();
// void on_checkBox_stateChanged(int arg1);
void on_chkShowAllFiles_clicked();
void on_actionSave_All_triggered();
void on_btnSizeAnalyser_clicked();
void on_actionChip_8_emulator_triggered();
private:
void cleanSymbol(QTreeWidgetItem* parent, QString on, QString name, int ln, QString fn,Parser* p, QColor bcol,QString search);
TRSEDocument* getMainDocument();
void saveCurrentProject();
QString FindPathInProjectFolders(const QModelIndex &index);
void BuildAll();
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H