Git commit 34d19b36cd06e7b286e129b9f8b1f671680c16f5 by Benjamin Kaiser. Committed on 28/11/2013 at 14:09. Pushed by jkt into branch 'master'.
GUI: Save state of menu bar between launches REVIEW: 114177 M +13 -0 src/Gui/Window.cpp http://commits.kde.org/trojita/34d19b36cd06e7b286e129b9f8b1f671680c16f5 diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp index c799f6c..d0af08f 100644 --- a/src/Gui/Window.cpp +++ b/src/Gui/Window.cpp @@ -271,6 +271,7 @@ void MainWindow::createActions() showMenuBar->setChecked(true); addAction(showMenuBar); // otherwise it won't work with hidden menu bar connect(showMenuBar, SIGNAL(triggered(bool)), menuBar(), SLOT(setVisible(bool))); + connect(showMenuBar, SIGNAL(triggered(bool)), m_delayedStateSaving, SLOT(start())); showToolBar = new QAction(tr("Show &Toolbar"), this); showToolBar->setCheckable(true); @@ -2274,6 +2275,8 @@ void MainWindow::saveSizesAndState() for (int i = 0; i < msgListWidget->tree->header()->count(); ++i) { items << QByteArray::number(msgListWidget->tree->header()->sectionSize(i)); } + // a bool cannot be pushed directly onto a QByteArray so we must convert it to a number + items << QByteArray::number(menuBar()->isVisible()); QByteArray buf; QDataStream stream(&buf, QIODevice::WriteOnly); stream << items.size(); @@ -2388,6 +2391,16 @@ void MainWindow::applySizesAndState() } } + if (size-- && !stream.atEnd()) { + stream >> item; + bool ok; + bool visibility = item.toInt(&ok); + if (ok) { + menuBar()->setVisible(visibility); + showMenuBar->setChecked(visibility); + } + } + m_skipSavingOfUI = skipSaving; }
