From b1db565beefdd03f428b5932077b4dd4075b4552 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Fri, 20 Apr 2012 11:29:31 +0200 Subject: [PATCH] Hide the tar bar when only one database is opened. Closes #10 --- src/gui/DatabaseTabWidget.cpp | 15 +++++++++++++++ src/gui/DatabaseTabWidget.h | 1 + 2 files changed, 16 insertions(+) diff --git a/src/gui/DatabaseTabWidget.cpp b/src/gui/DatabaseTabWidget.cpp index eecdd2651..e8422ad43 100644 --- a/src/gui/DatabaseTabWidget.cpp +++ b/src/gui/DatabaseTabWidget.cpp @@ -45,6 +45,19 @@ DatabaseTabWidget::DatabaseTabWidget(QWidget* parent) connect(this, SIGNAL(currentChanged(int)), SLOT(emitEntrySelectionChanged())); } +void DatabaseTabWidget::toggleTabbar() { + if (count() > 1) { + if (!tabBar()->isVisible()) { + tabBar()->show(); + } + } + else { + if (tabBar()->isVisible()) { + tabBar()->hide(); + } + } +} + void DatabaseTabWidget::newDatabase() { DatabaseManagerStruct dbStruct; @@ -156,6 +169,7 @@ bool DatabaseTabWidget::closeDatabase(Database* db) } removeTab(index); + toggleTabbar(); m_dbList.remove(db); delete dbStruct.file; delete dbStruct.dbWidget; @@ -362,6 +376,7 @@ void DatabaseTabWidget::insertDatabase(Database* db, const DatabaseManagerStruct m_dbList.insert(db, dbStruct); addTab(dbStruct.dbWidget, ""); + toggleTabbar(); updateTabName(db); int index = databaseIndex(db); setCurrentIndex(index); diff --git a/src/gui/DatabaseTabWidget.h b/src/gui/DatabaseTabWidget.h index 161ad890c..a0bbbbf41 100644 --- a/src/gui/DatabaseTabWidget.h +++ b/src/gui/DatabaseTabWidget.h @@ -76,6 +76,7 @@ private Q_SLOTS: void openDatabaseCleanup(); void emitEntrySelectionChanged(); void modified(); + void toggleTabbar(); private: void saveDatabase(Database* db);