[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: Re: createStandardKWindow()
From: Benjamin Meyer <ben () meyerhome ! net>
Date: 2004-06-08 0:07:18
Message-ID: 200406072007.19786.ben () meyerhome ! net
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 07 June 2004 5:18 pm, David Faure wrote:
> On Monday 07 June 2004 23:07, Benjamin Meyer wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On Monday 07 June 2004 2:48 pm, David Faure wrote:
> > > On Monday 07 June 2004 20:38, Benjamin Meyer wrote:
> > > > Much better and smaller name :) Those changes and I moved the new
> > > > functions into KMainWindow in this new patch.
> > >
> > > You can remove the "TODO modal" ... KEditToolbar _is_ modal (default
> > > value true for modal argument to KDialogBase constructor).
> > > Ah. But you should use exec() instead of show().
> >
> > yes it is modal, but it shouldn't be. Why should it block the
> > application?
>
> Because otherwise you need to take care that it won't pop up twice, so you
> need a pointer somewhere and "bring to front" code in case the action
> is activated twice. And worse problem: what if the guiFactory is updated
> meanwhile, due to plugging/unplugging kparts? Then the open kedittoolbar
> will have pointers to deleted actions... This is really a huge nest of
> worms, for very little gain (why would you want to keep the dialog open
> while using the app? it's not like configuring toolbars is something you do
> every 5 minutes). Even "being able to see the changes in the app" is
> possible with the Apply button, so there's really no reason why this dialog
> should not be modal.
Ah, didn't realize there was other ties. Changed to exec()
Also Added All to the enum. Other then KNotify (which will be a separate
patch) I think this is all done, missing anything?
- -Benjamin Meyer
- --
Public Key: http://www.csh.rit.edu/~benjamin/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFAxQM21rZ3LTw38vIRAiwvAJ9ppt09C3wzwS/9HHzjtT6Z6htdMgCbB3/m
G+7HCGH0NIaGAP7wjru9lUA=
=IVJ7
-----END PGP SIGNATURE-----
["diff" (text/x-diff)]
? .keditlistbox.h.swp
? .kmainwindow.cpp.swp
? .kmainwindow.h.swp
? diff
Index: kmainwindow.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.cpp,v
retrieving revision 1.128
diff -u -3 -p -r1.128 kmainwindow.cpp
--- kmainwindow.cpp 2 Jun 2004 23:30:56 -0000 1.128
+++ kmainwindow.cpp 8 Jun 2004 00:01:49 -0000
@@ -42,6 +42,8 @@
#include <kmenubar.h>
#include <kstatusbar.h>
#include <kwin.h>
+#include <kedittoolbar.h>
+#include <kmainwindow.h>
#include <klocale.h>
#include <kstandarddirs.h>
@@ -421,6 +423,45 @@ KXMLGUIFactory *KMainWindow::guiFactory(
return factory_;
}
+int KMainWindow::configureToolbars()
+{
+ saveMainWindowSettings(KGlobal::config());
+ KEditToolbar dlg(guiFactory(), this, "KEditToolbar");
+ connect(&dlg, SIGNAL(newToolbarConfig()), SLOT(saveNewToolbarConfig()));
+ dlg.exec();
+}
+
+void KMainWindow::saveNewToolbarConfig()
+{
+ createGUI();
+ applyMainWindowSettings( KGlobal::config() );
+}
+
+void KMainWindow::setupGUI( int options ) {
+ if( options & Keys ){
+ KStdAction::keyBindings(guiFactory(),
+ SLOT(configureShortcuts()), actionCollection());
+ }
+
+ if( (options & StatusBar) && internalStatusBar() ){
+ createStandardStatusBarAction();
+ }
+
+ if( options & ToolBar ){
+ setStandardToolBarMenuEnabled( true );
+ KStdAction::configureToolbars(this,
+ SLOT(configureToolbars() ), actionCollection());
+ }
+
+ if( options & Save ){
+ setAutoSaveSettings();
+ }
+
+ if( options & Create ){
+ createGUI();
+ }
+}
+
void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
{
// disabling the updates prevents unnecessary redraws
Index: kmainwindow.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.h,v
retrieving revision 1.101
diff -u -3 -p -r1.101 kmainwindow.h
--- kmainwindow.h 1 Jun 2004 16:44:57 -0000 1.101
+++ kmainwindow.h 8 Jun 2004 00:01:50 -0000
@@ -514,6 +514,60 @@ public:
*/
void createStandardStatusBarAction();
+ /**
+ * @see createStandardWindow()
+ */
+ enum StandardWindowOptions
+ {
+ /**
+ * adds action to show/hide the toolbar(s) and adds
+ * action to configure the toolbar(s).
+ * @see setStandardToolBarMenuEnabled
+ */
+ ToolBar = 1,
+
+ /**
+ * adds action to show the key configure action.
+ */
+ Keys = 2,
+
+ /**
+ * adds action to show/hide the statusbar if the
+ * statusbar exists. @see createStandardStatusBarAction
+ */
+ StatusBar = 4,
+
+ /**
+ * auto-saves the toolbar/menubar/statusbar settings and
+ * window size using the default name. @see setAutoSaveSettings
+ */
+ Save = 8,
+
+ /**
+ * calls createGUI() once all of the other options have been
+ * taken care of. @see createGUI
+ */
+ Create = 16,
+
+ /**
+ * All of the options, usefull for disabling one item
+ * KMainWindow::All ^ KMainWindow::ToolBar
+ */
+ All = ToolBar | Keys | StatusBar | Save | Create
+ };
+
+ /**
+ * Configures the current windows and its actions in the typical KDE
+ * fashion. The options are all enabled by default but can be turned
+ * off if desired through the params or if the prereqs don't exists.
+ *
+ * Typically this function replaces createGUI().
+ *
+ * @see StandardWindowOptions
+ *
+ * @since 3.3
+ */
+ void setupGUI( int options = All );
/**
* Returns a pointer to the mainwindows action responsible for the toolbars menu
@@ -562,6 +616,20 @@ public:
public slots:
/**
+ * Show a standard configure toolbar dialog.
+ *
+ * This slot can be connected dirrectly to the action to configure shortcuts.
+ * This is very simple to do that by adding a single line
+ * \code
+ * KStdAction::configureToolbars( guiFactory(), SLOT( configureToolbars() ),
+ * actionCollection() );
+ * \endcode
+ *
+ * @since 3.3
+ */
+ int configureToolbars();
+
+ /**
* Makes a KDE compliant caption.
*
* @param caption Your caption. @em Do @em not include the application name
@@ -810,8 +878,13 @@ protected:
void parseGeometry(bool parsewidth);
protected slots:
-
/**
+ * Stores the new toolbar
+ * @see configureToolbars()
+ */
+ void saveNewToolbarConfig();
+
+ /**
* This slot does nothing.
*
* It must be reimplemented if you want
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic