branches/KDE/3.5/kdebase/kate/app
Dominik Haumann
dhdev at gmx.de
Tue Aug 23 16:17:36 CEST 2005
SVN commit 452489 by dhaumann:
* make it possible to hide the sidebars. If the users hides the sidebars
a message box informs him how to get them back (don't ask again included).
!!! Someone please prove-read the message box text.
If the sidebars are hidden the user cannot access the tool views with the
mouse anymore (only via the menu) - this is also the reason for the
message box. The shortcuts still work (which is pretty cool imho:
if you set shortcuts, just hide the sidebars and save space).
* load/save supported (ie session restore)
* shortcut CTRL+ALT+SHIFT+Key_F assigned (is there a better one?)
* related bug #75431. This does not fix the problem in KMDI though -
only KateMDI.
CCMAIL: kmdi-devel at kde.org
CCMAIL: kwrite-devel at kde.org
M +59 -0 katemdi.cpp
M +27 -1 katemdi.h
--- branches/KDE/3.5/kdebase/kate/app/katemdi.cpp #452488:452489
@@ -32,6 +32,7 @@
#include <kconfig.h>
#include <kiconloader.h>
#include <kpopupmenu.h>
+#include <kmessagebox.h>
#include <qvbox.h>
#include <qhbox.h>
@@ -137,7 +138,16 @@
actionCollection()->setWidget(m_mw);
m_toolMenu = new KActionMenu(i18n("Tool &Views"),actionCollection(),"kate_mdi_toolview_menu");
+ m_showSidebarsAction = new KToggleAction( i18n("Show Side&bars"),
+ CTRL|ALT|SHIFT|Key_F, actionCollection() );
+ m_showSidebarsAction->setCheckedState(i18n("Hide Side&bars"));
+ m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
+ connect( m_showSidebarsAction, SIGNAL( toggled( bool ) ),
+ m_mw, SLOT( setSidebarsVisible( bool ) ) );
+ m_toolMenu->insert( m_showSidebarsAction );
+ m_toolMenu->insert( new KActionSeparator( m_toolMenu ) );
+
// read shortcuts
actionCollection()->readShortcutSettings( "Shortcuts", kapp->config() );
}
@@ -146,6 +156,11 @@
{
}
+void GUIClient::updateSidebarsVisibleAction()
+{
+ m_showSidebarsAction->setChecked( m_mw->sidebarsVisible() );
+}
+
void GUIClient::registerToolView (ToolView *tv)
{
QString aname = QString("kate_mdi_toolview_") + tv->id;
@@ -478,6 +493,14 @@
return false;
}
+void Sidebar::showEvent( QShowEvent* ev )
+{
+ if (m_idToWidget.isEmpty() || !m_mainWin->sidebarsVisible() )
+ hide();
+ else
+ KMultiTabBar::showEvent( ev );
+}
+
void Sidebar::buttonPopupActivate (int id)
{
ToolView *w = m_idToWidget[m_popupButton];
@@ -638,6 +661,7 @@
MainWindow::MainWindow (QWidget* parentWidget, const char* name)
: KParts::MainWindow( parentWidget, name)
+ , m_sidebarsVisible(true)
, m_restoreConfig (0)
, m_guiClient (new GUIClient (this))
{
@@ -736,6 +760,37 @@
m_toolviews.remove (widget);
}
+void MainWindow::setSidebarsVisible( bool visible )
+{
+ m_sidebarsVisible = visible;
+
+ m_sidebars[0]->setShown(visible);
+ m_sidebars[1]->setShown(visible);
+ m_sidebars[2]->setShown(visible);
+ m_sidebars[3]->setShown(visible);
+
+ m_guiClient->updateSidebarsVisibleAction();
+
+ // only show the message box, if called from the GUI action.
+ if( !m_sidebarsVisible && sender() )
+ {
+ KMessageBox::information( this,
+ i18n("<qt>You are about to hide the sidebars. With "
+ "hidden sidebars it is not possible to directly "
+ "access the tool views with the mouse anymore, "
+ "so if you need to access the sidebars again "
+ "invoke <b>Window > Tool Views > Show Sidebars</b> "
+ "in the menu. It is still possible to show/hide "
+ "the tool views with the assigned shortcuts.</qt>"),
+ QString::null, i18n("Don't ask again.") );
+ }
+}
+
+bool MainWindow::sidebarsVisible() const
+{
+ return m_sidebarsVisible;
+}
+
void MainWindow::setToolViewStyle (KMultiTabBar::KMultiTabBarStyle style)
{
m_sidebars[0]->setStyle(style);
@@ -819,6 +874,7 @@
m_vSplitter->setSizes(vs);
setToolViewStyle( (KMultiTabBar::KMultiTabBarStyle)m_restoreConfig->readNumEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle()) );
+ setSidebarsVisible ( config->readBoolEntry ("Kate-MDI-Sidebar-Visible", true ) );
}
void MainWindow::finishRestore ()
@@ -881,6 +937,7 @@
// save sidebar style
config->writeEntry ("Kate-MDI-Sidebar-Style", (int)toolViewStyle());
+ config->writeEntry ("Kate-MDI-Sidebar-Visible", m_sidebarsVisible );
// save the sidebars
for (unsigned int i=0; i < 4; ++i)
@@ -890,3 +947,5 @@
//END MAIN WINDOW
} // namespace KateMDI
+
+// kate: space-indent on; indent-width 2;
--- branches/KDE/3.5/kdebase/kate/app/katemdi.h #452488:452489
@@ -85,6 +85,7 @@
void registerToolView (ToolView *tv);
void unregisterToolView (ToolView *tv);
+ void updateSidebarsVisibleAction();
private slots:
void clientAdded( KXMLGUIClient *client );
@@ -92,6 +93,7 @@
private:
MainWindow *m_mw;
+ KToggleAction *m_showSidebarsAction;
QPtrList<KAction> m_toolViewActions;
QMap<ToolView*, KAction*> m_toolToAction;
KActionMenu *m_toolMenu;
@@ -213,6 +215,8 @@
protected:
bool eventFilter(QObject *obj, QEvent *ev);
+ // only show, if we have children
+ virtual void showEvent( QShowEvent* ev );
private slots:
void buttonPopupActivate (int id);
@@ -299,7 +303,22 @@
* @return toolview's tabbar style
*/
KMultiTabBar::KMultiTabBarStyle toolViewStyle () const;
-
+
+ /**
+ * get the sidebars' visibility.
+ * @return false, if the sidebars' visibility is forced hidden, otherwise true
+ */
+ bool sidebarsVisible() const;
+
+ public slots:
+ /**
+ * set the sidebars' visibility to @p visible. If false, the sidebars
+ * are @e always hidden. Usually you do not have to call this because
+ * the user can set this in the menu.
+ * @param visible sidebars visibility
+ */
+ void setSidebarsVisible( bool visible );
+
protected:
/**
* called by toolview destructor
@@ -392,6 +411,11 @@
Sidebar *m_sidebars[4];
/**
+ * sidebars state.
+ */
+ bool m_sidebarsVisible;
+
+ /**
* config object for session restore, only valid between
* start and finish restore calls
*/
@@ -411,3 +435,5 @@
}
#endif
+
+// kate: space-indent on; indent-width 2;
More information about the Kmdi-devel
mailing list