From 6c695e3fd0d73a0433d71589c6ba803b98b89573 Mon Sep 17 00:00:00 2001 From: Florian Geyer Date: Wed, 15 Aug 2012 19:50:31 +0200 Subject: [PATCH] Remember show toolbar option. Closes #43 --- src/core/Config.cpp | 1 + src/gui/MainWindow.cpp | 8 ++++++++ src/gui/MainWindow.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 94fd14903..ac5752de5 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -91,6 +91,7 @@ void Config::init(const QString& fileName) m_defaults.insert("ModifiedOnExpandedStateChanges", true); m_defaults.insert("AutoSaveAfterEveryChange", false); m_defaults.insert("AutoSaveOnExit", false); + m_defaults.insert("ShowToolbar", true); m_defaults.insert("security/clearclipboard", true); m_defaults.insert("security/clearclipboardtimeout", 10); } diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index e1760cad5..f500baeb5 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -41,6 +41,9 @@ MainWindow::MainWindow() QAction* toggleViewAction = m_ui->toolBar->toggleViewAction(); toggleViewAction->setText(tr("Show toolbar")); m_ui->menuView->addAction(toggleViewAction); + bool showToolbar = config()->get("ShowToolbar").toBool(); + m_ui->toolBar->setVisible(showToolbar); + connect(m_ui->toolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(saveToolbarState(bool))); m_clearHistoryAction = new QAction("Clear history", m_ui->menuFile); m_lastDatabasesActions = new QActionGroup(m_ui->menuRecentDatabases); @@ -353,6 +356,11 @@ void MainWindow::showGroupContextMenu(const QPoint& globalPos) m_ui->menuGroups->popup(globalPos); } +void MainWindow::saveToolbarState(bool value) +{ + config()->set("ShowToolbar", value); +} + void MainWindow::setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback) { if (!QKeySequence::keyBindings(standard).isEmpty()) { diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 5cd656613..958a56023 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -55,6 +55,7 @@ private Q_SLOTS: void updateLastDatabasesMenu(); void showEntryContextMenu(const QPoint& globalPos); void showGroupContextMenu(const QPoint& globalPos); + void saveToolbarState(bool value); private: static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);