Refactor updateWindowTitle function.

This commit is contained in:
Florian Geyer 2012-11-02 01:00:50 +01:00
parent a77c426b2d
commit 8748c76de2

View File

@ -335,23 +335,23 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
void MainWindow::updateWindowTitle() void MainWindow::updateWindowTitle()
{ {
QString windowTitle; QString customWindowTitlePart;
int stackedWidgetIndex = m_ui->stackedWidget->currentIndex(); int stackedWidgetIndex = m_ui->stackedWidget->currentIndex();
if (stackedWidgetIndex == 0) {
int tabWidgetIndex = m_ui->tabWidget->currentIndex(); int tabWidgetIndex = m_ui->tabWidget->currentIndex();
if (tabWidgetIndex == -1) { if (stackedWidgetIndex == 0 && tabWidgetIndex != -1) {
windowTitle = BaseWindowTitle; customWindowTitlePart = m_ui->tabWidget->tabText(tabWidgetIndex);
} else {
windowTitle = m_ui->tabWidget->tabText(tabWidgetIndex);
if (m_ui->tabWidget->readOnly(tabWidgetIndex)) { if (m_ui->tabWidget->readOnly(tabWidgetIndex)) {
windowTitle.append(" [").append(tr("read-only")).append("]"); customWindowTitlePart.append(" [%1]").arg(tr("read-only"));
}
windowTitle.append(" - ").append(BaseWindowTitle);
} }
} else if (stackedWidgetIndex == 1) { } else if (stackedWidgetIndex == 1) {
windowTitle = QString("%1 - %2").arg(tr("Settings")).arg(BaseWindowTitle); customWindowTitlePart = tr("Settings");
} else { }
QString windowTitle;
if (customWindowTitlePart.isEmpty()) {
windowTitle = BaseWindowTitle; windowTitle = BaseWindowTitle;
} else {
windowTitle = QString("%1 - %2").arg(customWindowTitlePart).arg(BaseWindowTitle);
} }
setWindowTitle(windowTitle); setWindowTitle(windowTitle);