add action to hide/show menu bar

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1093874
This commit is contained in:
Volker Lanz 2010-02-21 16:58:27 +00:00
parent baa03c4d78
commit 241ae7105e
3 changed files with 24 additions and 0 deletions

View File

@ -51,5 +51,8 @@
<entry key="UsedSpaceColorCode" type="Color">
<default>255,255,200</default>
</entry>
<entry key="showMenuBar" type="Bool">
<default>true</default>
</entry>
</group>
</kcfg>

View File

@ -28,6 +28,7 @@
#include <kactioncollection.h>
#include <ktoolbar.h>
#include <kstatusbar.h>
#include <kmenubar.h>
#include <kmessagebox.h>
#include <kaboutdata.h>
#include <kcomponentdata.h>
@ -138,6 +139,9 @@ void MainWindow::setupActions()
actionCollection()->addAction("toggleDockOperations", dockOperations().toggleViewAction());
actionCollection()->addAction("toggleDockInformation", dockInformation().toggleViewAction());
actionCollection()->addAction("toggleDockLog", dockLog().toggleViewAction());
// Settings Actions
KStandardAction::showMenubar(this, SLOT(onShowMenuBar()), actionCollection());
}
void MainWindow::setupConnections()
@ -222,3 +226,19 @@ bool MainWindow::isKPart() const
// If we were instantiated with an action collection we're supposed to be a KPart
return m_ActionCollection != NULL;
}
void MainWindow::onShowMenuBar()
{
QAction* menuBarAction = actionCollection()->action(KStandardAction::name(KStandardAction::ShowMenubar));
if (menuBarAction->isChecked())
menuBar()->show();
else
{
const QString accel = menuBarAction->shortcut().toString();
KMessageBox::information(this, i18nc("@info", "This will hide the menu bar completely. You can show it again by typing %1.", accel), i18nc("@window:title", "Hide Menu Bar"), "hideMenuBarWarning");
menuBar()->hide();
}
Config::self()->setShowMenuBar(menuBarAction->isChecked());
}

View File

@ -98,6 +98,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
void on_m_PartitionManagerWidget_devicesChanged();
void on_m_PartitionManagerWidget_operationsChanged();
void on_m_PartitionManagerWidget_selectedPartitionChanged(const Partition* p);
void onShowMenuBar();
private:
QLabel* m_StatusText;