Theme Editor: Enabled tag closing

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26566 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-05 07:38:29 +00:00
parent 0af8860775
commit d41a681053
4 changed files with 35 additions and 0 deletions

View file

@ -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<SkinDocument*>
(ui->editorTabs->currentWidget())->getModel());
}
void EditorWindow::closeTab(int index)
{
SkinDocument* widget = dynamic_cast<SkinDocument*>
(ui->editorTabs->widget(index));
if(widget->requestClose())
{
ui->editorTabs->removeTab(index);
widget->deleteLater();
}
}
void EditorWindow::showPanel()
{
if(sender() == ui->actionFile_Panel)

View file

@ -44,6 +44,8 @@ protected:
private slots:
void showPanel();
void newTab();
void shiftTab(int index);
void closeTab(int index);
private:
/* Setup functions */

View file

@ -35,6 +35,11 @@ SkinDocument::~SkinDocument()
delete model;
}
bool SkinDocument::requestClose()
{
return true;
}
void SkinDocument::setupUI()
{
/* Setting up the text edit */

View file

@ -39,6 +39,8 @@ public:
ParseTreeModel* getModel(){ return model; }
QString getTitle(){ return title; }
bool requestClose();
signals:
private slots: