[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Compatibility fix for my automatically created toolbar action
From: Joseph Wenninger <jowenn () kde ! org>
Date: 2002-06-30 16:19:55
[Download RAW message or body]
Hi
Bernd pointed me to a compatibility issue with my new auto updating "Show
Toolbar" menu.
I'm attaching a small compatibility patch, which removes my action
automatically, if an application uses the KStdAction::showToolbar(.....)
functions with the mainwindows actioncollection.
Does someone see a problem with that patch ? It should be binary and source
compatible and solve problems with old applications using eg:
KStdAction::configureToolbars(parent, SLOT(mySlot()), actionCollection)
->setToolTip("mytooltip")
I'll adapt kdelibs/kdebase/.. than not to use the KStdAction::ShowToolbar
functions. At the moment they use them, although they are just ignored.
(without the patch)
Kind regards
Joseph Wenninger
["jw_patch2.diff" (text/x-diff)]
? jw_patch2.diff
Index: kaction.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kaction.cpp,v
retrieving revision 1.275
diff -u -3 -p -r1.275 kaction.cpp
--- kaction.cpp 2002/06/17 10:10:35 1.275
+++ kaction.cpp 2002/06/30 14:00:38
@@ -3189,6 +3189,7 @@ public:
m_highlight = false;
m_currentHighlightAction = 0;
m_statusCleared = true;
+ m_mw=0;
}
KInstance *m_instance;
@@ -3203,12 +3204,13 @@ public:
KAccel *m_kaccel;
QWidget *m_builderWidget;
KAccel *m_builderKAccel;
-
+
QAsciiDict<KAction> m_actionDict;
QPtrDict< QPtrList<KAction> > m_dctHighlightContainers;
bool m_highlight;
KAction *m_currentHighlightAction;
bool m_statusCleared;
+ KMainWindow *m_mw;
};
KActionCollection::KActionCollection( QWidget *parent, const char *name,
@@ -3223,6 +3225,7 @@ KActionCollection::KActionCollection( QW
setInstance( instance );
}
+
KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char \
*name, KInstance *instance )
: QObject( parent, name )
@@ -3272,6 +3275,10 @@ KActionCollection::~KActionCollection()
delete d->m_builderKAccel;
delete d; d = 0;
}
+
+void KActionCollection::setMainActionCollectionFor(KMainWindow *w){d->m_mw=w;}
+KMainWindow *KActionCollection::mainActionCollectionFor(){return d->m_mw;}
+
void KActionCollection::setWidget( QWidget* w )
{
Index: kaction.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kaction.h,v
retrieving revision 1.154
diff -u -3 -p -r1.154 kaction.h
--- kaction.h 2002/06/09 20:22:06 1.154
+++ kaction.h 2002/06/30 14:00:41
@@ -1905,6 +1905,12 @@ protected:
private:
class KActionCollectionPrivate;
KActionCollectionPrivate *d;
+
+protected:
+ friend class KMainWindow;
+ void setMainActionCollectionFor(KMainWindow *);
+public:
+ KMainWindow *mainActionCollectionFor();
};
#endif
Index: kmainwindow.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.cpp,v
retrieving revision 1.77
diff -u -3 -p -r1.77 kmainwindow.cpp
--- kmainwindow.cpp 2002/06/29 05:45:15 1.77
+++ kmainwindow.cpp 2002/06/30 14:00:43
@@ -163,6 +163,11 @@ KMainWindow::KMainWindow( QWidget* paren
initKMainWindow(createToolbarAction,name);
}
+void KMainWindow::removeToolBarMenuAction()
+{
+ delete d->toolbarMenu;
+ d->toolbarMenu=0;
+}
void KMainWindow::initKMainWindow(bool createToolbarAction,const char *name)
{
@@ -173,6 +178,7 @@ void KMainWindow::initKMainWindow(bool c
mHelpMenu = 0;
kapp->setTopWidget( this );
actionCollection()->setWidget( this );
+ actionCollection()->setMainActionCollectionFor(this);
connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
if( !memberList )
memberList = new QPtrList<KMainWindow>;
Index: kmainwindow.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmainwindow.h,v
retrieving revision 1.50
diff -u -3 -p -r1.50 kmainwindow.h
--- kmainwindow.h 2002/06/24 23:01:58 1.50
+++ kmainwindow.h 2002/06/30 14:00:43
@@ -502,7 +502,7 @@ public slots:
* Returns a pointer to the mainwindows action responsible for the toolbars menu
*/
KToolBarMenuAction *toolBarMenuAction();
-
+ void removeToolBarMenuAction();
protected:
void paintEvent( QPaintEvent* e );
void childEvent( QChildEvent* e);
Index: kstdaction.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kstdaction.cpp,v
retrieving revision 1.72
diff -u -3 -p -r1.72 kstdaction.cpp
--- kstdaction.cpp 2002/06/27 19:53:05 1.72
+++ kstdaction.cpp 2002/06/30 14:00:43
@@ -29,6 +29,7 @@
#include <kiconloader.h>
#include <klocale.h>
#include <kstdaccel.h>
+#include <kmainwindow.h>
namespace KStdAction
{
@@ -97,7 +98,7 @@ const KStdActionInfo g_rgActionInfo[] =
{ Spelling, KStdAccel::AccelNone, "tools_spelling", I18N_NOOP("&Spelling..."), \
0, "spellcheck" },
{ ShowMenubar, KStdAccel::ShowMenubar, "options_show_menubar", I18N_NOOP("Show \
&Menubar"), 0, "showmenu" },
- { ShowToolbar, KStdAccel::AccelNone, "options_show_toolbar_old", I18N_NOOP("Show \
&Toolbar"), 0, 0 }, + { ShowToolbar, KStdAccel::AccelNone, "options_show_toolbar", \
I18N_NOOP("Show &Toolbar"), 0, 0 }, { ShowStatusbar, KStdAccel::AccelNone, \
"options_show_statusbar", I18N_NOOP("Show St&atusbar"), 0, 0 }, { SaveOptions, \
KStdAccel::AccelNone, "options_save_options", I18N_NOOP("&Save Settings"), 0, 0 }, { \
KeyBindings, KStdAccel::AccelNone, "options_configure_keybinding", \
I18N_NOOP("Configure S&hortcuts..."), 0,"configure_shortcuts" }, @@ -281,6 +282,11 @@ \
KToggleAction *showMenubar( const QObjec KToggleAction *showToolbar( const QObject \
*recvr, const char *slot, KActionCollection* parent, const char *name ) {
KToggleAction *ret;
+ if ((!name) && (parent->mainActionCollectionFor()))
+ {
+ parent->mainActionCollectionFor()->removeToolBarMenuAction();
+ }
+
ret = new KToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent,
name ? name : stdName(ShowToolbar));
ret->setChecked(true);
@@ -290,6 +296,10 @@ KToggleAction *showToolbar( const QObjec
KToggleToolBarAction *showToolbar( const char* toolBarName, KActionCollection* \
parent, const char *name ) {
+ if ((!name) && (parent->mainActionCollectionFor()))
+ {
+ parent->mainActionCollectionFor()->removeToolBarMenuAction();
+ }
KToggleToolBarAction *ret;
ret = new KToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent,
name ? name : stdName(ShowToolbar));
Index: kstdaction.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kstdaction.h,v
retrieving revision 1.25
diff -u -3 -p -r1.25 kstdaction.h
--- kstdaction.h 2002/05/29 20:48:46 1.25
+++ kstdaction.h 2002/06/30 14:00:43
@@ -448,11 +448,13 @@ namespace KStdAction
KActionCollection* parent, const char *name = 0 );
/**
+ * @obsolete. toolbar actions are created automatically now in the Settings menu. \
Don't use this anymore
* Show/Hide the primary toolbar.
*/
KToggleAction *showToolbar(const QObject *recvr, const char *slot,
KActionCollection* parent, const char *name = 0 );
/**
+ * @obsolete. toolbar actions are created automatically now in the Settings menu. \
Don't use this anymore
* Show/Hide the primary toolbar.
*/
KToggleToolBarAction *showToolbar(const char* toolBarName,
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic