Commit 9d0c6516 authored by Aurélien Gâteau's avatar Aurélien Gâteau

Use standard kdelibs method to show/hide menubar and toolbars

CCMAIL: sarang@users.sourceforge.net

svn path=/trunk/KDE/kdeaccessibility/kmag/; revision=1200382
parent 73d9b19f
......@@ -67,8 +67,6 @@
#include "kmagselrect.h"
#define havesetCheckedState
KmagApp::KmagApp(QWidget* , const char* name)
: KXmlGuiWindow(0) // Qt::WStyle_MinMax | Qt::WType_TopLevel | Qt::WDestructiveClose | Qt::WStyle_ContextHelp | Qt::WindowCloseButtonHint | Qt::WStyle_StaysOnTop
, m_defaultMouseCursorType(2)
......@@ -171,31 +169,9 @@ void KmagApp::initActions()
m_pCopy->setWhatsThis(i18n("Click on this button to copy the current zoomed view to the clipboard which you can paste in other applications."));
m_pCopy->setToolTip(i18n("Copy zoomed image to clipboard"));
m_pShowMenu = new KToggleAction(KIcon(QLatin1String( "show-menu" )), i18n("Show &Menu"), this);
actionCollection()->addAction(QLatin1String( "show_menu" ), m_pShowMenu);
connect(m_pShowMenu, SIGNAL(triggered(bool)), SLOT(slotShowMenu()));
m_pShowMenu->setShortcut(Qt::CTRL+Qt::Key_M);
#ifdef havesetCheckedState
m_pShowMenu->setCheckedState(KGuiItem(i18n("Hide &Menu")));
#endif
m_pShowMainToolBar = new KToggleAction(i18n("Show Main &Toolbar"), this);
actionCollection()->addAction(QLatin1String( "show_mainToolBar" ), m_pShowMainToolBar);
connect(m_pShowMainToolBar, SIGNAL(triggered(bool)), SLOT(slotShowMainToolBar()));
#ifdef havesetCheckedState
m_pShowMainToolBar->setCheckedState(KGuiItem(i18n("Hide Main &Toolbar")));
#endif
m_pShowViewToolBar = new KToggleAction(i18n("Show &View Toolbar"), this);
actionCollection()->addAction(QLatin1String( "show_viewToolBar" ), m_pShowViewToolBar);
connect(m_pShowViewToolBar, SIGNAL(triggered(bool)), SLOT(slotShowViewToolBar()));
#ifdef havesetCheckedState
m_pShowViewToolBar->setCheckedState(KGuiItem(i18n("Hide &View Toolbar")));
#endif
m_pShowSettingsToolBar = new KToggleAction(i18n("Show &Settings Toolbar"), this);
actionCollection()->addAction(QLatin1String( "show_settingsToolBar" ), m_pShowSettingsToolBar);
connect(m_pShowSettingsToolBar, SIGNAL(triggered(bool)), SLOT(slotShowSettingsToolBar()));
#ifdef havesetCheckedState
m_pShowSettingsToolBar->setCheckedState(KGuiItem(i18n("Hide &Settings Toolbar")));
#endif
m_pShowMenu = KStandardAction::showMenubar(this, SLOT(slotShowMenu()), actionCollection());
setStandardToolBarMenuEnabled(true);
m_modeFollowMouse = new KToggleAction(KIcon(QLatin1String( "followmouse" )), i18n("&Follow Mouse Mode"), this);
actionCollection()->addAction(QLatin1String( "mode_followmouse" ), m_modeFollowMouse);
......@@ -279,7 +255,7 @@ void KmagApp::initActions()
m_pColorBox->setWhatsThis(i18n("Select a mode to simulate various types of color-blindness."));
m_pColorBox->setToolTip(i18n("Color-blindness Simulation Mode"));
createGUI();
setupGUI();
}
void KmagApp::initView()
......@@ -359,18 +335,6 @@ void KmagApp::saveOptions()
cg.writeEntry("Mode", "wholescreen");
else if (m_modeSelWin->isChecked())
cg.writeEntry("Mode", "selectionwindow");
cg.writeEntry("ShowMenu", m_pShowMenu->isChecked());
cg.writeEntry("ShowMainToolBar", m_pShowMainToolBar->isChecked());
cg.writeEntry("ShowViewToolBar", m_pShowViewToolBar->isChecked());
cg.writeEntry("ShowSettingsToolBar", m_pShowSettingsToolBar->isChecked());
KConfigGroup mainToolBarGroup(config,"Main ToolBar");
toolBar(QLatin1String( "mainToolBar" ))->saveSettings( mainToolBarGroup );
KConfigGroup viewToolBarGroup(config,"View ToolBar" );
toolBar(QLatin1String( "viewToolBar" ))->saveSettings( viewToolBarGroup );
KConfigGroup settingsToolbarGroup(config,"Settings ToolBar" );
toolBar(QLatin1String( "settingsToolBar" ))->saveSettings( settingsToolbarGroup );
}
......@@ -435,30 +399,8 @@ void KmagApp::readOptions()
m_staysOnTop->setChecked(cg.readEntry("StaysOnTop", true));
slotStaysOnTop();
KConfigGroup settingsToolbarGroup(config,"Settings ToolBar");
if( settingsToolbarGroup.exists() )
toolBar(QLatin1String( "settingsToolBar" ))->applySettings(settingsToolbarGroup );
KConfigGroup mainToolbarGroup(config,"Main ToolBar");
if( mainToolbarGroup.exists() )
toolBar(QLatin1String( "mainToolBar" ))->applySettings( mainToolbarGroup );
KConfigGroup viewToolbarGroup(config,"View ToolBar" );
if( viewToolbarGroup.exists() )
toolBar(QLatin1String( "viewToolBar" ))->applySettings( viewToolbarGroup );
KConfigGroup generalOptionGroup(config,"General Options");
m_pShowMenu->setChecked( generalOptionGroup.readEntry("ShowMenu", true));
slotShowMenu();
m_pShowMainToolBar->setChecked(generalOptionGroup.readEntry("ShowMainToolBar", false));
slotShowMainToolBar();
m_pShowViewToolBar->setChecked(generalOptionGroup.readEntry("ShowViewToolBar", true));
slotShowViewToolBar();
m_pShowSettingsToolBar->setChecked(generalOptionGroup.readEntry("ShowSettingsToolBar", true));
slotShowSettingsToolBar();
// XMLGui has already read and set up the menuBar for us
m_pShowMenu->setChecked(menuBar()->isVisible());
}
bool KmagApp::queryClose()
......@@ -859,50 +801,6 @@ void KmagApp::slotShowMenu()
{
menuBar()->show();
}
}
void KmagApp::slotShowMainToolBar()
{
///////////////////////////////////////////////////////////////////
// turn mainToolbar on or off
if(!m_pShowMainToolBar->isChecked())
{
toolBar(QLatin1String( "mainToolBar" ))->hide();
}
else
{
toolBar(QLatin1String( "mainToolBar" ))->show();
}
}
void KmagApp::slotShowViewToolBar()
{
///////////////////////////////////////////////////////////////////
// turn viewToolbar on or off
if(!m_pShowViewToolBar->isChecked())
{
toolBar(QLatin1String( "viewToolBar" ))->hide();
}
else
{
toolBar(QLatin1String( "viewToolBar" ))->show();
}
}
void KmagApp::slotShowSettingsToolBar()
{
///////////////////////////////////////////////////////////////////
// turn viewToolbar on or off
if(!m_pShowSettingsToolBar->isChecked())
{
toolBar(QLatin1String( "settingsToolBar" ))->hide();
}
else
{
toolBar(QLatin1String( "settingsToolBar" ))->show();
}
}
void KmagApp::slotConfKeys()
......
......@@ -142,9 +142,6 @@ class KmagApp : public KXmlGuiWindow
void showMouseCursor(bool show);
void slotShowMenu();
void slotShowMainToolBar();
void slotShowViewToolBar();
void slotShowSettingsToolBar();
void slotToggleHideCursor();
void slotStaysOnTop();
......@@ -200,7 +197,7 @@ class KmagApp : public KXmlGuiWindow
QAction *m_pZoomOut;
QAction *m_pQuit;
KAction *refreshSwitch;
KToggleAction *m_pShowMenu, *m_pShowMainToolBar, *m_pShowViewToolBar, *m_pShowSettingsToolBar;
KToggleAction *m_pShowMenu;
KSelectAction *m_pZoomBox, *m_pRotationBox, *m_pFPSBox, *m_pColorBox;
/// zoom slider
......
<!DOCTYPE kpartgui>
<kpartgui name="kmag" version="14">
<ToolBar noMerge="1" name="mainToolBar">
<kpartgui name="kmag" version="15">
<ToolBar noMerge="1" name="mainToolBar"><text>Main Toolbar</text>
<Action name="new_window"/>
<Separator />
<Action name="snapshot"/>
......@@ -8,7 +8,7 @@
<Action name="edit_copy"/>
</ToolBar>
<ToolBar noMerge="1" name="viewToolBar">
<ToolBar noMerge="1" name="viewToolBar"><text>View Toolbar</text>
<Action name="start_stop_refresh"/>
<Separator />
<Action name="view_zoom_in"/>
......@@ -18,7 +18,7 @@
<Action name="fps_selector"/>
</ToolBar>
<ToolBar noMerge="1" name="settingsToolBar">
<ToolBar noMerge="1" name="settingsToolBar"><text>Settings Toolbar</text>
<Action name="mode_followmouse"/>
<Action name="mode_followfocus"/>
<Action name="mode_selectionwindow"/>
......@@ -50,11 +50,12 @@
<Separator />
<Action name="color_mode"/>
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
<Action name="show_menu"/>
<Action name="show_mainToolBar"/>
<Menu name="settings" noMerge="1"><text>&amp;Settings</text>
<Action name="options_show_menubar"/>
<Merge name="StandardToolBarMenuHandler"/>
<!--Action name="show_mainToolBar"/>
<Action name="show_viewToolBar"/>
<Action name="show_settingsToolBar"/>
<Action name="show_settingsToolBar"/-->
<Separator />
<Action name="mode_followmouse"/>
<Action name="mode_followfocus"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment