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

List:       kde-core-devel
Subject:    [PATCH] new method kstdguiitem::preferences?
From:       Martijn Klingens <klingens () kde ! org>
Date:       2003-09-21 13:03:57
[Download RAW message or body]

See patch. I could use it in Kopete because there's no way you can subclass 
KStdAction::preferences(), and duplicating strings and icons inside Kopete 
won't make translators happy, nor would it adapt to changes in kdelibs (other 
string, other icon) if these ever happen.

The code is basically taken from KStdAction::preferences, but I'm not reusing 
it there because the current KStdAction API doesn't easily allow reusing 
KStdGuiItems. Simon said he once had a patch tackling the issue, but he 
forgot what happened with it. It's for sure not in KDE CVS HEAD ;)

And yes, I know we're in a freeze, that's why I'm posting here. Ok to apply?

-- 
Martijn

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

Index: kstdguiitem.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kstdguiitem.cpp,v
retrieving revision 1.27
diff -u -p -r1.27 kstdguiitem.cpp
--- kstdguiitem.cpp	24 Jul 2003 02:38:16 -0000	1.27
+++ kstdguiitem.cpp	21 Sep 2003 12:56:19 -0000
@@ -18,9 +18,10 @@
 
 #include "kstdguiitem.h"
 
+#include <kaboutdata.h>
+#include <kapplication.h>
 #include <kguiitem.h>
 #include <klocale.h>
-#include <kapplication.h>
 
 KGuiItem KStdGuiItem::guiItem ( StdItem ui_enum )
 {
@@ -112,6 +113,14 @@ KGuiItem KStdGuiItem::dontSave()
 {
   return KGuiItem( i18n( "&Don't Save" ), "filedontsave",
                    i18n( "Don't save data" ) );
+}
+
+KGuiItem KStdGuiItem::preferences()
+{
+  const KAboutData *aboutData = KGlobal::instance()->aboutData();
+  QString appName = aboutData ? aboutData->programName() : QString::fromLatin1( qApp->name() );
+
+  return KGuiItem( i18n( "&Configure %1..." ).arg( appName ), "configure" );
 }
 
 KGuiItem KStdGuiItem::saveAs()
Index: kstdguiitem.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kstdguiitem.h,v
retrieving revision 1.14
diff -u -p -r1.14 kstdguiitem.h
--- kstdguiitem.h	6 Sep 2003 19:06:32 -0000	1.14
+++ kstdguiitem.h	21 Sep 2003 12:56:19 -0000
@@ -34,7 +34,7 @@ public:
      * and force 'Western' behavior instead, use the IgnoreRTL value instead.
      */
     enum BidiMode { UseRTL = 0, IgnoreRTL };
-    
+
     enum StdItem
     {
         Ok=1, Cancel, Yes, No, Discard, Save, DontSave, SaveAs,
@@ -64,6 +64,11 @@ public:
     static KGuiItem open();
 
     /**
+     * The standard GUI item for the preferences/options dialog.
+     */
+    static KGuiItem preferences();
+
+    /**
      * Return a GUI item for a 'back' action, like Konqueror's back button.
      * This GUI item can optionally honor the user's setting for BiDi, so the
      * icon for right-to-left languages (Hebrew and Arab) has the arrow
@@ -74,7 +79,7 @@ public:
      * in the separate backAndForward() method.
      */
     static KGuiItem back( BidiMode useBidi = IgnoreRTL );
-    
+
     /**
      * Return a GUI item for a 'forward' action, like Konqueror's forward
      * button. This GUI item can optionally honor the user's setting for BiDi,


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

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