Adjust title when settings widget is active.

This commit is contained in:
Florian Geyer 2012-11-02 00:41:34 +01:00
parent b0280e9d93
commit a77c426b2d

View File

@ -131,6 +131,7 @@ MainWindow::MainWindow()
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
SLOT(setMenuActionState())); SLOT(setMenuActionState()));
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState())); connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState()));
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(updateWindowTitle()));
connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases())); connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget,
@ -334,17 +335,26 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
void MainWindow::updateWindowTitle() void MainWindow::updateWindowTitle()
{ {
int index = m_ui->tabWidget->currentIndex(); QString windowTitle;
if (index == -1) { int stackedWidgetIndex = m_ui->stackedWidget->currentIndex();
setWindowTitle(BaseWindowTitle); if (stackedWidgetIndex == 0) {
} int tabWidgetIndex = m_ui->tabWidget->currentIndex();
else { if (tabWidgetIndex == -1) {
QString windowTitle = m_ui->tabWidget->tabText(index); windowTitle = BaseWindowTitle;
if (m_ui->tabWidget->readOnly(index)) { } else {
windowTitle.append(" [").append(tr("read-only")).append("]"); windowTitle = m_ui->tabWidget->tabText(tabWidgetIndex);
if (m_ui->tabWidget->readOnly(tabWidgetIndex)) {
windowTitle.append(" [").append(tr("read-only")).append("]");
}
windowTitle.append(" - ").append(BaseWindowTitle);
} }
setWindowTitle(windowTitle.append(" - ").append(BaseWindowTitle)); } else if (stackedWidgetIndex == 1) {
windowTitle = QString("%1 - %2").arg(tr("Settings")).arg(BaseWindowTitle);
} else {
windowTitle = BaseWindowTitle;
} }
setWindowTitle(windowTitle);
} }
void MainWindow::showAboutDialog() void MainWindow::showAboutDialog()