Mercurial > hg > dmlib
annotate edgui.cpp @ 398:8660c6005032
More work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 19 Oct 2012 09:46:05 +0300 |
parents | 9993873ff655 |
children | 2fdf440ea66a |
rev | line source |
---|---|
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
2 // Demo Editor -- Qt GUI setup parts and callbacks |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
3 // (C) Copyright 2012 Matti 'ccr' Hämäläinen <ccr@tnsp.org> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
4 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
5 #include "edmain.h" |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
6 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
7 #include <QCloseEvent> |
381 | 8 #include <QToolBar> |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
9 #include <QMenuBar> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 #include <QStatusBar> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
11 #include <QMenu> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #include <QProgressBar> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #include <QFileDialog> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #include <QHBoxLayout> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #include <QVBoxLayout> |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 void DemoEditor::updateMenuStates() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
21 // Set window title based on document filename and changed status |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
22 QString name; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
397 | 24 if (!currTimeline || currTimeline->filename.isEmpty()) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
25 name = DOC_DEF_FILENAME; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
26 else |
397 | 27 name = currTimeline->filename; |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
28 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
29 if (changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 name = "*" + name; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 setWindowTitle(name + " - " + QCoreApplication::applicationName()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
33 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 // Enable menu items based on states |
397 | 35 menuActSave->setEnabled(currTimeline->changed || changed); |
36 menuActSaveAs->setEnabled(currTimeline->changed || changed); | |
37 | |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
38 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 // Enable undo/redo items and set their texts based on history status |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 int historyLevels = undoHistory.size(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
41 QString itemText; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
42 bool itemEnabled; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
43 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 if (undoHistoryPos >= 0 && undoHistoryPos < historyLevels) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 itemText = " " + undoHistory.at(undoHistoryPos)->state; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 itemEnabled = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
48 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
49 else |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
51 itemText = ""; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
52 itemEnabled = false; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 menuActRedo->setEnabled(itemEnabled); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 menuActRedo->setText("&Redo" + itemText); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
58 if (undoHistoryPos > 0 && historyLevels > 0) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
60 itemText = " " + undoHistory.at(undoHistoryPos - 1)->state; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 itemEnabled = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 else |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
64 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 itemText = ""; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 itemEnabled = false; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
67 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
69 menuActUndo->setEnabled(itemEnabled); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 menuActUndo->setText("&Undo" + itemText); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
72 update(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
74 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
76 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 // Show about dialog |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
78 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 void DemoEditor::actionAboutBox() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
80 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 QMessageBox::about(this, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
82 "About "+ QCoreApplication::applicationName(), |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 "<h1>" + QCoreApplication::applicationName() + |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
84 " v"+ QCoreApplication::applicationVersion() +"</h1><br>\n" |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 "(C) Copyright 2012 Matti 'ccr' Hämäläinen<br>\n" |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
86 "<br>\n" |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 "<b>A demo editor TNSP dmlib engine.</b><br>\n"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 // Show a dialog inquiring the user whether to save the current |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 // document if it has been modified since last save/load. |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 QMessageBox::StandardButton DemoEditor::showDocumentModifiedDialog() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
97 return QMessageBox::question(this, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
98 "The document has been modified.", |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
99 "Do you want to save your changes?", |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
100 QMessageBox::Discard | QMessageBox::Cancel | QMessageBox::Save, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 QMessageBox::Save); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
102 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 // Generic error/warning dialog |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 // |
378 | 108 void DemoEditor::showFileErrorDialog(QString operation, int code) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 /* |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
111 QString msg; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
112 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
113 QMessageBox::error(this, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 "A non-critical error occured", |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 operation |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 */ |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
118 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
119 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
120 void DemoEditor::actionFileNew() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 bool okToCreate = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
124 if (changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
126 okToCreate = false; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 switch (showDocumentModifiedDialog()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 case QMessageBox::Discard: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 okToCreate = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
133 case QMessageBox::Save: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 actionFileSave(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 if (!changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
137 QMessageBox::information(this, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 "Document saved", |
397 | 139 "The document was saved as " + currTimeline->filename); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
141 okToCreate = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 default: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
147 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
149 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 if (okToCreate) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
151 createNewFile(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
153 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
155 void DemoEditor::actionFileOpen() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
157 bool okToOpen = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 if (changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 okToOpen = false; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 switch (showDocumentModifiedDialog()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 case QMessageBox::Discard: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 okToOpen = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 case QMessageBox::Save: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 actionFileSave(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 if (!changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 QMessageBox::information(this, |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 "Document saved", |
397 | 175 "The document was saved as " + currTimeline->filename); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 okToOpen = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 default: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 if (okToOpen) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 QFileDialog fdialog(this); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 fdialog.setAcceptMode(QFileDialog::AcceptOpen); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 fdialog.setFileMode(QFileDialog::ExistingFile); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 fdialog.setNameFilter("Demo timeline files (*.demo)"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 fdialog.setDefaultSuffix("demo"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 if (fdialog.exec()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 readFromFile(fdialog.selectedFiles()[0]); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
198 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
200 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
201 void DemoEditor::actionFileSaveAs() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 { |
397 | 203 if (!currTimeline) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 { |
397 | 205 qDebug() << "DemoEditor::actionFileSaveAs(): currTimeline == null"; |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 return; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 QFileDialog fdialog(this); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
210 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
211 fdialog.setAcceptMode(QFileDialog::AcceptSave); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
212 fdialog.setFileMode(QFileDialog::AnyFile); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
213 fdialog.setNameFilter("Demo files (*.demo)"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
214 fdialog.setDefaultSuffix("demo"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 fdialog.setConfirmOverwrite(true); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 |
397 | 217 fdialog.selectFile(currTimeline->filename.isEmpty() ? currTimeline->filename : DOC_DEF_FILENAME); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 if (fdialog.exec()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
220 saveToFile(fdialog.selectedFiles()[0]); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
221 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
222 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
223 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 void DemoEditor::actionFileSave() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 { |
397 | 226 if (!currTimeline) |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 { |
397 | 228 qDebug() << "DemoEditor::actionFileSave(): currTimeline == null"; |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 return; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
231 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 // If filename has been set, save .. otherwise go to save as |
397 | 233 if (!currTimeline->filename.isEmpty()) |
234 saveToFile(currTimeline->filename); | |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 else |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 actionFileSaveAs(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
238 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
239 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
240 void DemoEditor::closeEvent(QCloseEvent *event) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
241 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
242 bool okToClose = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 if (changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 okToClose = false; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
247 switch (showDocumentModifiedDialog()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 case QMessageBox::Discard: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
250 okToClose = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 case QMessageBox::Save: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
254 actionFileSave(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 if (!changed) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
256 okToClose = true; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 default: |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
260 break; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
261 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
263 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
264 if (okToClose) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 event->accept(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
266 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
267 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 // Various menu actions |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
271 // |
381 | 272 void DemoEditor::actionControlChanged(QAction *act) |
273 { | |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
274 // demoView->setToolMode(act->data().toInt()); |
381 | 275 } |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
276 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
277 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
279 // Update statusbar message text |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
280 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
281 void DemoEditor::statusMsg(QString message) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
282 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 statusBar()->showMessage(message, 0); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
285 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
286 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
287 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
288 // Set active element of an action group based on matching the data |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
289 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
290 void DemoEditor::setActionGroupChecked(QActionGroup *group, QVariant data) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
292 QList<QAction *> items = group->actions(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
293 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
294 for (int i = 0; i < items.size(); i++) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
295 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 QAction *act = items.at(i); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
297 if (act->data() == data) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
299 act->setChecked(true); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
300 return; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
301 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
302 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
303 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
304 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
305 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
306 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
307 // Helper functions for creating GUI elements |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
308 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
309 QAction * DemoEditor::createToolButton(QActionGroup *group, QString name, QIcon icon, QString statustip, QVariant data) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
310 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 QAction *action = new QAction(icon, name, group); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
313 action->setStatusTip(statustip + "."); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 action->setCheckable(true); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
315 action->setData(data); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
317 return action; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
320 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
321 QAction * DemoEditor::createMenuAction(QString name, const QKeySequence &shortcut, QString tooltip) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
322 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
323 QAction *action = new QAction(name, this); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
324 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 if (shortcut != QKeySequence(QKeySequence::UnknownKey)) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 action->setShortcut(shortcut); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
327 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 if (!tooltip.isNull()) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 action->setStatusTip(tooltip + "."); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
330 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
331 return action; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
332 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
333 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
334 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
335 QAction * DemoEditor::createMenuGroupAction(QMenu *menu, QActionGroup *group, QString name, const QKeySequence &shortcut, QString tooltip, QVariant data) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
337 QAction *action = createMenuAction(name, shortcut, tooltip); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 action->setCheckable(true); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
340 action->setData(data); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 menu->addAction(action); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
343 group->addAction(action); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
344 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 return action; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
346 } |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 #define MCONNECT(menu, act, slot) do { connect(act, SIGNAL(triggered()), this, SLOT(slot)); menu->addAction(act); } while(0) |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
351 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
353 // Create GUI elements |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 void DemoEditor::createMainGUI() |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 { |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
357 QAction *act; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
358 QMenu *fileMenu, *editMenu, *viewMenu, *helpMenu; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 qDebug() << "- Constructing menus"; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 // File menu |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 fileMenu = menuBar()->addMenu("&File"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 act = createMenuAction("&New", QKeySequence::New, "Create a new demo timeline"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 MCONNECT(fileMenu, act, actionFileNew()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
370 menuActOpen = createMenuAction("&Open", QKeySequence::Open, "Open a demo timeline file"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
371 MCONNECT(fileMenu, menuActOpen, actionFileOpen()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
373 menuActSave = createMenuAction("&Save", QKeySequence::Save, "Save demo timeline"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 MCONNECT(fileMenu, menuActSave, actionFileSave()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
376 menuActSaveAs = createMenuAction("Save &as", QKeySequence::SaveAs, "Save demo timeline as a new file"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
377 MCONNECT(fileMenu, menuActSaveAs, actionFileSaveAs()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
378 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 fileMenu->addSeparator(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
381 QKeySequence qseq(Qt::CTRL + Qt::Key_Q); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
382 act = createMenuAction("&Quit", qseq, "Exit application"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
383 MCONNECT(fileMenu, act, close()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
384 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
385 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
386 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
387 // Edit menu |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
388 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 editMenu = menuBar()->addMenu("&Edit"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
390 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
391 menuActUndo = createMenuAction("&Undo", QKeySequence::Undo, "Undo last change"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
392 MCONNECT(editMenu, menuActUndo, performUndo()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
393 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 menuActRedo = createMenuAction("&Redo", QKeySequence::Redo, "Redo last change"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
395 MCONNECT(editMenu, menuActRedo, performRedo()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
396 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
397 #if 0 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
398 editMenu->addSeparator(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
399 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
400 menuActCut = createMenuAction("Cu&t", QKeySequence::Cut, "Cut object"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
401 MCONNECT(editMenu, menuActCut, actionCut()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
402 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
403 menuActCopy = createMenuAction("&Copy", QKeySequence::Copy, "Copy object"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
404 MCONNECT(editMenu, menuActCopy, actionCopy()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 menuActPaste = createMenuAction("&Paste", QKeySequence::Paste, "Paste object"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 MCONNECT(editMenu, menuActPaste, actionPaste()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
409 menuActDelete = createMenuAction("&Delete", QKeySequence::Delete, "Delete object"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 MCONNECT(editMenu, menuActDelete, actionDelete()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
411 #endif |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
412 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
414 // Help menu |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
415 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 helpMenu = menuBar()->addMenu("&Help"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
417 act = createMenuAction("About", 0, "Show information about application"); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
418 MCONNECT(helpMenu, act, actionAboutBox()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
419 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
420 |
381 | 421 |
422 // | |
423 // Controls toolbar | |
424 // | |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
425 qDebug() << "- Constructing toolbars"; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
426 |
381 | 427 actGroupControls = new QActionGroup(this); |
428 actGroupControls->setExclusive(true); | |
429 connect(actGroupControls, SIGNAL(triggered(QAction*)), this, SLOT(actionControlChanged(QAction *))); | |
430 | |
431 createToolButton(actGroupControls, "Rewind", QIcon("rewind.png"), | |
432 "Rewind to start of the timeline", CTRL_REWIND); | |
433 | |
434 createToolButton(actGroupControls, "Play start", QIcon("play1.png"), | |
435 "Play from start", CTRL_PLAY_START); | |
436 | |
437 createToolButton(actGroupControls, "Play current", QIcon("play2.png"), | |
438 "Play from current position", CTRL_PLAY_CURRENT); | |
439 | |
440 createToolButton(actGroupControls, "Pause", QIcon("pause.png"), | |
441 "Pause", CTRL_PAUSE); | |
442 | |
443 | |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
444 QToolBar *controlButtons = new QToolBar("Player controls", this); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
445 controlButtons->setMovable(false); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
446 controlButtons->setFloatable(false); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
447 controlButtons->setIconSize(QSize(CTRL_ICON_SIZE, CTRL_ICON_SIZE)); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
448 controlButtons->setToolButtonStyle(Qt::ToolButtonIconOnly); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
449 controlButtons->addActions(actGroupControls->actions()); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
450 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
451 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
452 // |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
453 // Effects list table |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
454 // |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
455 qDebug() << "- Constructing effects list"; |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
456 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
457 effectTable = new QTableView(this); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
458 effectTable->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
459 effectTable->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); |
381 | 460 |
461 | |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
463 // Construct the main screen |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
464 // |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
465 qDebug() << "- Constructing main screen layout"; |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
466 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
467 QWidget *sideVBoxContainer = new QWidget(); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 QSizePolicy sideVBoxPolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
469 sideVBoxPolicy.setHeightForWidth(sideVBoxContainer->sizePolicy().hasHeightForWidth()); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
470 sideVBoxContainer->setSizePolicy(sideVBoxPolicy); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
471 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
472 QVBoxLayout *sideVBox = new QVBoxLayout(sideVBoxContainer); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 sideVBox->setSpacing(0); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
474 sideVBox->setContentsMargins(0, 0, 0, 0); |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
475 sideVBox->addWidget(effectTable); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
476 sideVBox->addWidget(controlButtons); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
477 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
478 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
479 QWidget *holder = new QWidget(); |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
480 QVBoxLayout *verticalSplitter = new QVBoxLayout(holder); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
481 QHBoxLayout *horizSplitter = new QHBoxLayout(); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
482 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
483 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
484 timelineScrollBar = new QScrollBar(Qt::Horizontal); |
391 | 485 connect(timelineScrollBar, SIGNAL(valueChanged(int)), this, SLOT(actionTimelineScrollChanged(int))); |
486 | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
487 timelineAudioTrack = new QWaveTrackView(); |
391 | 488 connect(timelineAudioTrack, SIGNAL(offsetChanged(float)), this, SLOT(actionOffsetChanged(float))); |
489 connect(timelineAudioTrack, SIGNAL(timeChanged(float)), this, SLOT(actionTimeChanged(float))); | |
490 | |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
491 timelineView = new QTimelineView(); |
397 | 492 connect(timelineView, SIGNAL(timelineChanged()), this, SLOT(actionTimelineChanged())); |
393
5137db55f00b
More work towards the editor ..
Matti Hamalainen <ccr@tnsp.org>
parents:
391
diff
changeset
|
493 |
398 | 494 QScrollArea *scrollArea = new QScrollArea(); |
495 scrollArea->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum); | |
496 scrollArea->setWidget(timelineView); | |
497 scrollArea->setWidgetResizable(true); | |
498 | |
499 | |
391 | 500 demoView = new SWDemoView(this); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
502 verticalSplitter->addLayout(horizSplitter); |
398 | 503 verticalSplitter->addWidget(scrollArea); |
391 | 504 verticalSplitter->addWidget(timelineAudioTrack); |
387
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
505 verticalSplitter->addWidget(timelineScrollBar); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
506 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
507 horizSplitter->addWidget(sideVBoxContainer); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
508 horizSplitter->addWidget(demoView); |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
509 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
510 |
e4aad59fb407
Twiddling on the GUI elements.
Matti Hamalainen <ccr@tnsp.org>
parents:
381
diff
changeset
|
511 updateTimelineView(); |
376
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
512 |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
513 setCentralWidget(holder); |
40e33ad0d153
Work towards a working editor .. some day.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
514 } |