[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    [PATCH] Shortcut for Show Desktop
From:       Carsten Pfeiffer <carpdjih () cetus ! zrz ! tu-berlin ! de>
Date:       2001-06-23 22:57:16
[Download RAW message or body]

Hiya,

I don't know how many requests / bugreports there have been, but this is 
something that should be fixed before 2.2.

To avoid having tons of KGlobalAccel objects all over the place in kicker, I 
moved the existing object (for the K-Button) to PGlobal. Keep in mind you can 
also have multiple K-Buttons or Show-Desktop buttons, we don't want one 
KGlobalAccel object for every button.

Besides that, the following made me a bit curious:
keys->insertItem(i18n("Panel"), "Program:kicker", 0);

I guess this is for grouping all those entries in the keybindings control 
module? Why is it misusing insertItem() for that?

Cheers,
Carsten Pfeiffer
["showdesktop.patch" (text/x-c++)]

? showdesktop.patch
Index: global.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/global.cpp,v
retrieving revision 1.6
diff -u -p -B -w -r1.6 global.cpp
--- global.cpp	2001/06/04 19:34:07	1.6
+++ global.cpp	2001/06/23 22:51:19
@@ -27,6 +27,7 @@ Panel* PGlobal::panel = 0;
 KickerPluginManager* PGlobal::pluginmgr = 0;
 KWinModule* PGlobal::kwin_module = 0;
 ExtensionManager* PGlobal::extensionManager = 0;
+KGlobalAccel* PGlobal::globalKeys = 0;
 
 int PGlobal::sizeValue(Size s)
 {
Index: global.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/global.h,v
retrieving revision 1.6
diff -u -p -B -w -r1.6 global.h
--- global.h	2001/06/04 19:34:07	1.6
+++ global.h	2001/06/23 22:51:19
@@ -32,6 +32,7 @@ enum Size {Tiny=0, Small, Normal, Large}
 
 class Panel;
 class KickerPluginManager;
+class KGlobalAccel;
 class KWinModule;
 class ExtensionManager;
 
@@ -43,6 +44,7 @@ public:
     static KWinModule *kwin_module;
     static KickerPluginManager *pluginmgr;
     static ExtensionManager *extensionManager;
+    static KGlobalAccel *globalKeys;
 };
 
 #endif // __pglobal_h__
Index: kickerbindings.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/kickerbindings.cpp,v
retrieving revision 1.3
diff -u -p -B -w -r1.3 kickerbindings.cpp
--- kickerbindings.cpp	2001/06/10 04:10:41	1.3
+++ kickerbindings.cpp	2001/06/23 22:51:19
@@ -1,5 +1,16 @@
+#ifdef KICKER_ALL_BINDINGS
+#define LAUNCH_MENU
+#define SHOW_DESKTOP
+#endif
+
+
+#ifdef LAUNCH_MENU
 #ifdef WITH_LABELS
 keys->insertItem(i18n("Panel"), "Program:kicker", 0);
 #endif
 keys->insertItem(i18n("Popup Launch Menu"),"Popup Launch Menu", KKey("ALT+F1"), \
KKey("Meta+Space")); +#endif
 
+#ifdef SHOW_DESKTOP
+keys->insertItem(i18n("Toggle showing Desktop"),"Toggle Show Desktop", \
KKey("CTRL+ALT+D"), KKey("Meta+Ctrl+D")); +#endif
Index: main.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/main.cpp,v
retrieving revision 1.21
diff -u -p -B -w -r1.21 main.cpp
--- main.cpp	2001/06/04 19:34:07	1.21
+++ main.cpp	2001/06/23 22:51:19
@@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include <kconfig.h>
 #include <dcopclient.h>
 #include <kwinmodule.h>
+#include <kglobalaccel.h>
 
 #include <X11/Xlib.h>
 
@@ -77,6 +78,7 @@ KickerApp::KickerApp() : KUniqueApplicat
     // instantiate plugin manager and kwin module
     PGlobal::pluginmgr = new KickerPluginManager();
     PGlobal::kwin_module = new KWinModule(this );
+    PGlobal::globalKeys = new KGlobalAccel();
 
     p = new Panel();
     setMainWidget(p);
Index: panelbutton.cpp
===================================================================
RCS file: /home/kde/kdebase/kicker/core/panelbutton.cpp,v
retrieving revision 1.37
diff -u -p -B -w -r1.37 panelbutton.cpp
--- panelbutton.cpp	2001/06/22 20:24:22	1.37
+++ panelbutton.cpp	2001/06/23 22:51:20
@@ -438,7 +438,7 @@ void PanelServiceMenuButton::initPopup()
 
 
 PanelKButton::PanelKButton(QWidget *parent, const char *name)
-    :PanelPopupButton(parent, name), keys(0)
+    :PanelPopupButton(parent, name)
 {
     QToolTip::add(this, i18n("Start Application"));
     setTitle(i18n("Start Application"));
@@ -451,23 +451,26 @@ PanelKButton::PanelKButton(QWidget *pare
     menuMgr = new KickerMenuManager( topMenu, this, "kickerMenuManager" );
     connect(menuMgr, SIGNAL(popupKMenu(int, int)), this,
             SLOT(slotExecMenuAt(int, int)));
-
-    keys = new KGlobalAccel();
 
+    static bool initGlobal = true;
+    if ( initGlobal ) {
+        initGlobal = false;
+        KGlobalAccel *keys = PGlobal::globalKeys;
+#define LAUNCH_MENU
 #include "kickerbindings.cpp"
-
-    keys->connectItem( "Popup Launch Menu", this, SLOT( slotAccelActivated() ) );
+#undef LAUNCH_MENU
+        keys->connectItem( "Popup Launch Menu", this,
+                           SLOT( slotAccelActivated() ) );
+    }
 }
 
 PanelKButton::~PanelKButton()
 {
-    delete keys;
 }
 
 void PanelKButton::configure()
 {
-    if ( keys )
-	keys->readSettings();
+    PGlobal::globalKeys->readSettings();
     if ( topMenu )
 	topMenu->reinitialize();
 
@@ -538,6 +541,16 @@ PanelDesktopButton::PanelDesktopButton(Q
     QToolTip::add(this, i18n("Show Desktop"));
     setTitle(i18n("Show Desktop"));
 
+    static bool initGlobal = true;
+    if ( initGlobal ) {
+        initGlobal = false;
+        KGlobalAccel *keys = PGlobal::globalKeys;
+#define SHOW_DESKTOP
+#include "kickerbindings2.cpp"
+#undef SHOW_DESKTOP
+        keys->connectItem("Toggle Show Desktop", this, SLOT(toggle()));
+    }
+
     // on desktop changes or when a window is deiconified, we abort the show desktop \
                mode
     connect(PGlobal::kwin_module, SIGNAL(currentDesktopChanged(int)), \
                SLOT(slotCurrentDesktopChanged(int)));
     connect( PGlobal::kwin_module, SIGNAL( windowChanged(WId,unsigned int) ),
@@ -621,6 +634,8 @@ void PanelDesktopButton::configure()
 {
     PanelButton::configure();
 
+    PGlobal::globalKeys->readSettings();
+
     KConfig *config = KGlobal::config();
     config->setGroup("buttons");
 
Index: panelbutton.h
===================================================================
RCS file: /home/kde/kdebase/kicker/core/panelbutton.h,v
retrieving revision 1.18
diff -u -p -B -w -r1.18 panelbutton.h
--- panelbutton.h	2001/05/23 14:37:31	1.18
+++ panelbutton.h	2001/06/23 22:51:20
@@ -28,7 +28,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE 
 #include "panelbuttonbase.h"
 #include "global.h"
 
-class KGlobalAccel;
 class KPropertiesDialog;
 class PanelBrowserMenu;
 class PanelKMenu;
@@ -195,7 +194,6 @@ protected:
 
     PanelKMenu *topMenu;
     KickerMenuManager* menuMgr;
-    KGlobalAccel *keys;
 };
 
 


["showdesktop2.patch" (text/x-c)]

? showdesktop2.patch
Index: keyconfig.cpp
===================================================================
RCS file: /home/kde/kdebase/kcontrol/keys/keyconfig.cpp,v
retrieving revision 1.55
diff -u -p -B -w -r1.55 keyconfig.cpp
--- keyconfig.cpp	2001/06/19 19:05:18	1.55
+++ keyconfig.cpp	2001/06/23 22:54:27
@@ -36,6 +36,7 @@
 #include "keyconfig.h"
 #include "keyconfig.moc"
 
+#define KICKER_ALL_BINDINGS
 
 //----------------------------------------------------------------------------
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic