summaryrefslogtreecommitdiff
path: root/utils/themeeditor/editorwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/editorwindow.cpp')
-rw-r--r--utils/themeeditor/editorwindow.cpp61
1 files changed, 59 insertions, 2 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index cadc6313a9..4d2ed87169 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -96,9 +96,22 @@ void EditorWindow::setupMenus()
96 QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()), 96 QObject::connect(ui->actionPreview_Panel, SIGNAL(triggered()),
97 this, SLOT(showPanel())); 97 this, SLOT(showPanel()));
98 98
99 /* Connecting the document opening/closing actions */ 99 /* Connecting the document management actions */
100 QObject::connect(ui->actionNew_Document, SIGNAL(triggered()), 100 QObject::connect(ui->actionNew_Document, SIGNAL(triggered()),
101 this, SLOT(newTab())); 101 this, SLOT(newTab()));
102 QObject::connect(ui->actionToolbarNew, SIGNAL(triggered()),
103 this, SLOT(newTab()));
104
105 QObject::connect(ui->actionClose_Document, SIGNAL(triggered()),
106 this, SLOT(closeCurrent()));
107
108 QObject::connect(ui->actionSave_Document, SIGNAL(triggered()),
109 this, SLOT(saveCurrent()));
110 QObject::connect(ui->actionSave_Document_As, SIGNAL(triggered()),
111 this, SLOT(saveCurrentAs()));
112 QObject::connect(ui->actionToolbarSave, SIGNAL(triggered()),
113 this, SLOT(saveCurrent()));
114
102} 115}
103 116
104 117
@@ -115,13 +128,23 @@ void EditorWindow::newTab()
115void EditorWindow::shiftTab(int index) 128void EditorWindow::shiftTab(int index)
116{ 129{
117 if(index < 0) 130 if(index < 0)
131 {
118 ui->parseTree->setModel(0); 132 ui->parseTree->setModel(0);
133 ui->actionSave_Document->setEnabled(false);
134 ui->actionSave_Document_As->setEnabled(false);
135 ui->actionClose_Document->setEnabled(false);
136 }
119 else 137 else
138 {
120 ui->parseTree->setModel(dynamic_cast<SkinDocument*> 139 ui->parseTree->setModel(dynamic_cast<SkinDocument*>
121 (ui->editorTabs->currentWidget())->getModel()); 140 (ui->editorTabs->currentWidget())->getModel());
141 ui->actionSave_Document->setEnabled(true);
142 ui->actionSave_Document_As->setEnabled(true);
143 ui->actionClose_Document->setEnabled(true);
144 }
122} 145}
123 146
124void EditorWindow::closeTab(int index) 147bool EditorWindow::closeTab(int index)
125{ 148{
126 SkinDocument* widget = dynamic_cast<SkinDocument*> 149 SkinDocument* widget = dynamic_cast<SkinDocument*>
127 (ui->editorTabs->widget(index)); 150 (ui->editorTabs->widget(index));
@@ -129,9 +152,30 @@ void EditorWindow::closeTab(int index)
129 { 152 {
130 ui->editorTabs->removeTab(index); 153 ui->editorTabs->removeTab(index);
131 widget->deleteLater(); 154 widget->deleteLater();
155 return true;
132 } 156 }
157
158 return false;
159}
160
161void EditorWindow::closeCurrent()
162{
163 closeTab(ui->editorTabs->currentIndex());
133} 164}
134 165
166void EditorWindow::saveCurrent()
167{
168 if(ui->editorTabs->currentIndex() >= 0)
169 dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->save();
170}
171
172void EditorWindow::saveCurrentAs()
173{
174 if(ui->editorTabs->currentIndex() >= 0)
175 dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->saveAs();
176}
177
178
135void EditorWindow::tabTitleChanged(QString title) 179void EditorWindow::tabTitleChanged(QString title)
136{ 180{
137 SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender()); 181 SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender());
@@ -150,7 +194,20 @@ void EditorWindow::showPanel()
150 194
151void EditorWindow::closeEvent(QCloseEvent* event) 195void EditorWindow::closeEvent(QCloseEvent* event)
152{ 196{
197
153 saveSettings(); 198 saveSettings();
199
200 /* Closing all the tabs */
201 for(int i = 0; i < ui->editorTabs->count(); i++)
202 {
203 if(!dynamic_cast<SkinDocument*>
204 (ui->editorTabs->widget(i))->requestClose())
205 {
206 event->ignore();
207 return;
208 }
209 }
210
154 event->accept(); 211 event->accept();
155} 212}
156 213