qeditor: rework mainwindow tab names handling
With the previous code, tab names would be ignored if tab is detached which can happen early on. Change-Id: I9eac4202850f3e79a04590a4ba1444850ec6a583 Reviewed-on: http://gerrit.rockbox.org/986 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
parent
fe1fed8873
commit
3b4e63173d
4 changed files with 20 additions and 7 deletions
|
@ -43,8 +43,15 @@ void DocumentTab::OnModified(bool modified)
|
|||
m_tab->SetTabModified(this, modified);
|
||||
}
|
||||
|
||||
void DocumentTab::SetTabWidget(MyTabWidget *tab)
|
||||
{
|
||||
m_tab = tab;
|
||||
SetTabName(m_tabname);
|
||||
}
|
||||
|
||||
void DocumentTab::SetTabName(const QString& name)
|
||||
{
|
||||
m_tabname = name;
|
||||
if(m_tab)
|
||||
m_tab->SetTabName(this, name);
|
||||
}
|
||||
|
@ -201,20 +208,20 @@ void MainWindow::OnLoadDesc()
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::AddTab(DocumentTab *doc, const QString& title)
|
||||
void MainWindow::AddTab(DocumentTab *doc)
|
||||
{
|
||||
m_tab->setCurrentIndex(m_tab->addTab(doc->GetWidget(), title));
|
||||
m_tab->setCurrentIndex(m_tab->addTab(doc->GetWidget(), ""));
|
||||
doc->SetTabWidget(m_tab);
|
||||
}
|
||||
|
||||
void MainWindow::OnNewRegTab()
|
||||
{
|
||||
AddTab(new RegTab(m_backend, this), "Register Tab");
|
||||
AddTab(new RegTab(m_backend, this));
|
||||
}
|
||||
|
||||
void MainWindow::OnNewRegEdit()
|
||||
{
|
||||
AddTab(new RegEdit(m_backend, this), "Register Editor");
|
||||
AddTab(new RegEdit(m_backend, this));
|
||||
}
|
||||
|
||||
bool MainWindow::Quit()
|
||||
|
|
|
@ -35,12 +35,13 @@ public:
|
|||
DocumentTab() { m_tab = 0; }
|
||||
virtual bool Quit() = 0;
|
||||
virtual QWidget *GetWidget() = 0;
|
||||
void SetTabWidget(MyTabWidget *tab) { m_tab = tab; }
|
||||
void SetTabWidget(MyTabWidget *tab);
|
||||
|
||||
protected:
|
||||
void OnModified(bool modified);
|
||||
void SetTabName(const QString& name);
|
||||
MyTabWidget *m_tab;
|
||||
QString m_tabname;
|
||||
};
|
||||
|
||||
class MyTabWidget : public QTabWidget
|
||||
|
@ -70,7 +71,7 @@ private:
|
|||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
protected:
|
||||
void AddTab(DocumentTab *tab, const QString& title);
|
||||
void AddTab(DocumentTab *tab);
|
||||
bool Quit();
|
||||
|
||||
private slots:
|
||||
|
|
|
@ -961,6 +961,7 @@ RegEdit::RegEdit(Backend *backend, QWidget *parent)
|
|||
SetModified(false, false);
|
||||
m_right_panel = 0;
|
||||
SetPanel(new EmptyEditPanel(this));
|
||||
UpdateTabName();
|
||||
|
||||
connect(m_file_open, SIGNAL(clicked()), this, SLOT(OnOpen()));
|
||||
connect(m_file_save, SIGNAL(clicked()), this, SLOT(OnSave()));
|
||||
|
@ -1080,7 +1081,10 @@ bool RegEdit::SaveSocFile(const QString& filename)
|
|||
void RegEdit::UpdateTabName()
|
||||
{
|
||||
QFileInfo info(m_cur_socfile.GetFilename());
|
||||
SetTabName(info.fileName());
|
||||
if(info.exists())
|
||||
SetTabName(info.fileName());
|
||||
else
|
||||
SetTabName("Register Editor");
|
||||
}
|
||||
|
||||
void RegEdit::LoadSocFile(const QString& filename)
|
||||
|
|
|
@ -178,6 +178,7 @@ RegTab::RegTab(Backend *backend, QWidget *parent)
|
|||
|
||||
OnSocListChanged();
|
||||
SetDataSocName("");
|
||||
UpdateTabName();
|
||||
}
|
||||
|
||||
QWidget *RegTab::GetWidget()
|
||||
|
|
Loading…
Reference in a new issue