[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-07 21:07:57
Message-ID: 200406071708.00489.ben () meyerhome ! net
[Download RAW message or body]

-----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?  
Currently it doesn't even let you if you wanted to.  Every app in kdeui 
should let you if you want to (i.e. the dev forgot to put it in the 
constructor)

> KNotifyDialog is a problem. You can't use it from kdeui, it's in libkio.
> I think you have to drop the Notifications item completely, unfortunately.

:(  True, where could we put the function in kio to make life easier?

> > if( actionCollection()->count() > 0 ){
>
> should be !actionCollection()->isEmpty(). But in fact KEditToolBar will
> find all actions from the guiFactory, not only from KMainWindow, so I
> think the test is incorrect, I suggest removing it.

Yah, ok, updated (and smaller) diff attached.

- -Benjamin Meyer

- -- 
Public Key: http://www.csh.rit.edu/~benjamin/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFAxNkw1rZ3LTw38vIRAupSAJ9+Om6ojpaFohqiCqV0TZIqBndfxgCdH/9s
qg4Lx6PSeeJb7kiBCN6BT4w=
=9k/Z
-----END PGP SIGNATURE-----

["diff" (text/x-diff)]

? .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	7 Jun 2004 21:04:55 -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_;
 }
 
+void KMainWindow::configureToolbars()
+{
+    saveMainWindowSettings(KGlobal::config());
+    KEditToolbar *dlg = new KEditToolbar(guiFactory(), this, "KEditToolbar");
+    connect(dlg, SIGNAL(newToolbarConfig()), SLOT(saveNewToolbarConfig()));
+    dlg->show();
+}
+
+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	7 Jun 2004 21:04:55 -0000
@@ -514,6 +514,55 @@ 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
+    };
+    
+    /**
+     * 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 =
+		    ToolBar | Keys | StatusBar | Save | Create );
 
     /**
      * Returns a pointer to the mainwindows action responsible for the toolbars menu
@@ -562,6 +611,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
+     */
+   void configureToolbars();
+
+    /**
      * Makes a KDE compliant caption.
      *
      * @param caption Your caption. @em Do @em not include the application name
@@ -810,8 +873,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