diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 4268788772..a2fc11afdf 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp @@ -78,6 +78,12 @@ void EditorWindow::setupUI() model->setRootPath(QDir::currentPath()); ui->fileTree->setModel(model); + /* Connecting the tab bar signals */ + QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)), + this, SLOT(shiftTab(int))); + QObject::connect(ui->editorTabs, SIGNAL(tabCloseRequested(int)), + this, SLOT(closeTab(int))); + } void EditorWindow::setupMenus() @@ -102,6 +108,26 @@ void EditorWindow::newTab() ui->editorTabs->addTab(doc, doc->getTitle()); } +void EditorWindow::shiftTab(int index) +{ + if(index < 0) + ui->parseTree->setModel(0); + else + ui->parseTree->setModel(dynamic_cast + (ui->editorTabs->currentWidget())->getModel()); +} + +void EditorWindow::closeTab(int index) +{ + SkinDocument* widget = dynamic_cast + (ui->editorTabs->widget(index)); + if(widget->requestClose()) + { + ui->editorTabs->removeTab(index); + widget->deleteLater(); + } +} + void EditorWindow::showPanel() { if(sender() == ui->actionFile_Panel) diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index 157ee6a30b..1c02bb378d 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h @@ -44,6 +44,8 @@ protected: private slots: void showPanel(); void newTab(); + void shiftTab(int index); + void closeTab(int index); private: /* Setup functions */ diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index 380f16fa7d..5391f9155d 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp @@ -35,6 +35,11 @@ SkinDocument::~SkinDocument() delete model; } +bool SkinDocument::requestClose() +{ + return true; +} + void SkinDocument::setupUI() { /* Setting up the text edit */ diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index 5f25d8e292..e15dd613fd 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h @@ -39,6 +39,8 @@ public: ParseTreeModel* getModel(){ return model; } QString getTitle(){ return title; } + bool requestClose(); + signals: private slots: