[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 17:03:18
Message-ID: 200406071303.22327.ben () meyerhome ! net
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday 07 June 2004 8:36 am, David Faure wrote:
> On Monday 07 June 2004 02:13, Benjamin Meyer wrote:
> > 1) Rather than a number of bools for params have only two params. The
> > first being params disabled, and the second being enabled ones (or'd
> > together). This way you can turn off one or two things you don't want,
> > but in the future as new things are added they will work by default.
>
> Yes. A series of bools is difficult to read ("false, true, false, false" ==
> ??), and difficult to extend. I would have suggested a simple bitfield enum
> though. Having two bitfields is a bit strange - if something is not
> specified in the disabled list nor in the enabled list, what does it mean?
> That KMainWindow can choose what to do about it? Sounds a bit undefined.
Yah, it is simple that way. Changed with docs (it is suprising how many enums
in kdelibs don't have docs)
> > 2) Rather than looking for options_configure_keybinding if keys is true
> > and actions->count() > 0 add?
>
> i.e. not looking whether the action exists already? Since the addition of
> the action is controlled by a bool/flag already, I guess it's not needed
> indeed.
changed.
> > 3) createStandardKWindow() Name it something else? createKMainWindow()
> > createStandardKMainWindow() createStandardWindow() ?
>
> It's in the KMainWindow namespace already, so no need for KMainWindow in
> the name. But in fact this isn't "creating"... That's what the constructor
> did. This is more about activating a number of automatic features....
> setWindowFeatures? enableMainWindowFeatures?
Well if you have something that is "enable" you might think you can disable
it. I removing the K and changed it to createStandardWindow() sense it can
create actions and it could create the GUI if Create is passed.
Attached is a new patch with the above changes and adds a mission param,
notifications.
- -Benjamin Meyer
P.S. Why can't the KeyDialog and Toolbar dialog be modal?
- --
Public Key: http://www.csh.rit.edu/~benjamin/public_key.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQFAxJ/Z1rZ3LTw38vIRAiYgAJ4vKjsiiSLhV0+amGvZckxEDPzlLgCeOYNw
cTMq1gGe9FiMqPNMQUtSfJE=
=aqXH
-----END PGP SIGNATURE-----
["diff" (text/x-diff)]
? .kmainwindow.cpp.swp
? .kmainwindow.h.swp
? .kxmlguifactory.cpp.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 16:55:59 -0000
@@ -421,6 +421,38 @@ KXMLGUIFactory *KMainWindow::guiFactory(
return factory_;
}
+void KMainWindow::createStandardWindow( int options ) {
+ if( options && Keys ){
+ if( actionCollection()->count() > 0 ){
+ KStdAction::keyBindings(guiFactory(),
+ SLOT(configureShortcuts()), actionCollection());
+ }
+ }
+
+ if( (options && StatusBar) && internalStatusBar() ){
+ createStandardStatusBarAction();
+ }
+
+ if( options && ToolBar ){
+ setStandardToolBarMenuEnabled( true );
+ KStdAction::configureToolbars(guiFactory(),
+ SLOT(configureToolbars() ), actionCollection());
+ }
+
+ if( options && Notifications ){
+ KStdAction::configureNotifications(guiFactory(),
+ SLOT(configureNotifications() ), 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 16:55:59 -0000
@@ -514,6 +514,61 @@ 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 if any actions
+ * are in the actionCollection().
+ */
+ Keys = 2,
+
+ /**
+ * adds action to show/hide the statusbar if the
+ * statusbar exists. @see createStandardStatusBarAction
+ */
+ StatusBar = 3,
+
+ /**
+ * auto-saves the toolbar/menubar/statusbar settings and
+ * window size using the default name. @see setAutoSaveSettings
+ */
+ Save = 4,
+
+ /**
+ * creates the Notifications action and manages the
+ * configuring of the notifications.
+ */
+ Notifications = 5,
+
+ /**
+ * calls createGUI() once all of the other options have been
+ * taken care of. @see createGUI
+ */
+ Create = 6
+ };
+ /**
+ * 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
+ *
+ * @sinse 3.3
+ */
+ void createStandardWindow( int options =
+ ToolBar | Keys | StatusBar | Save | Notifications | Create );
/**
* Returns a pointer to the mainwindows action responsible for the toolbars menu
Index: kxmlguifactory.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kxmlguifactory.cpp,v
retrieving revision 1.147
diff -u -3 -p -r1.147 kxmlguifactory.cpp
--- kxmlguifactory.cpp 13 May 2004 16:53:28 -0000 1.147
+++ kxmlguifactory.cpp 7 Jun 2004 16:55:59 -0000
@@ -38,6 +38,9 @@
#include <kshortcut.h>
#include <kstandarddirs.h>
#include <kkeydialog.h>
+#include <kedittoolbar.h>
+#include <kmainwindow.h>
+#include <knotifydialog.h>
using namespace KXMLGUI;
@@ -541,7 +544,7 @@ void KXMLGUIFactory::configureAction( KA
int KXMLGUIFactory::configureShortcuts(bool bAllowLetterShortcuts , bool bSaveSettings )
{
- KKeyDialog dlg( bAllowLetterShortcuts, dynamic_cast<QWidget*>(parent()) );
+ KKeyDialog dlg( bAllowLetterShortcuts, dynamic_cast<QWidget*>(parent()), false );
QPtrListIterator<KXMLGUIClient> it( d->m_clients );
KXMLGUIClient *client;
while( (client=it.current()) !=0 )
@@ -553,6 +556,28 @@ int KXMLGUIFactory::configureShortcuts(b
return dlg.configure(bSaveSettings);
}
+void KXMLGUIFactory::configureToolbars()
+{
+ (dynamic_cast<KMainWindow*>(parent()))->saveMainWindowSettings(KGlobal::config());
+ KEditToolbar *dlg = new KEditToolbar(this,
+ (dynamic_cast<KMainWindow*>(parent())), false );
+ connect(dlg, SIGNAL(newToolbarConfig()), SLOT(saveNewToolbarConfig()));
+ dlg->show();
+}
+
+void KXMLGUIFactory::saveNewToolbarConfig()
+{
+ (dynamic_cast<KMainWindow*>(parent()))->createGUI();
+ (dynamic_cast<KMainWindow*>(parent()))->applyMainWindowSettings( KGlobal::config() );
+}
+
+void KXMLGUIFactory::configureNotifications() {
+ KNotifyDialog *dialog =
+ new KNotifyDialog(dynamic_cast<KMainWindow*>(parent()),
+ "KNotifyDialog", false);
+ dialog->show();
+}
+
QDomElement KXMLGUIFactory::actionPropertiesElement( QDomDocument& doc )
{
const QString tagActionProp = QString::fromLatin1("ActionProperties");
Index: kxmlguifactory.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kxmlguifactory.h,v
retrieving revision 1.79
diff -u -3 -p -r1.79 kxmlguifactory.h
--- kxmlguifactory.h 28 Apr 2004 14:12:07 -0000 1.79
+++ kxmlguifactory.h 7 Jun 2004 16:55:59 -0000
@@ -192,6 +192,34 @@ class KXMLGUIFactory : public QObject
* @since 3.3
*/
int configureShortcuts(bool bAllowLetterShortcuts = true, bool bSaveSettings = true);
+
+ /**
+ * 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();
+
+ /**
+ * Show a standard configure notifications 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::configureNotifications( guiFactory(),
+ * SLOT( configureNotifications() ), actionCollection() );
+ * \endcode
+ *
+ * @since 3.3
+ */
+ void configureNotifications();
signals:
void clientAdded( KXMLGUIClient *client );
@@ -209,6 +237,14 @@ class KXMLGUIFactory : public QObject
protected:
virtual void virtual_hook( int id, void* data );
+
+protected slots:
+ /**
+ * Stores the new toolbar
+ * @see configureToolbars()
+ */
+ void saveNewToolbarConfig();
+
private:
KXMLGUIFactoryPrivate *d;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic