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

List:       kde-core-devel
Subject:    [PATCH] KLanguageCombo
From:       Martijn Klingens <mklingens () yahoo ! com>
Date:       2001-07-16 22:33:04
[Download RAW message or body]

Maybe I'm the only person, but I found the KLanguageCombo as used by 
KPersonalizer, the country/language control module and the KDM control module 
extremely ugly. As long as you don't use it the fake combobox looks ok, but 
the way it is drawn and behaves when you actually use it is IMO a bit hackish.

Now that I fixed the KDE styles a few weeks ago that QPushButton::setPopup is 
properly rendered I decided to create a new language selector based on 
QPushButton. The ugly paintEvent and keyPressEvent stuff is completely gone 
and some other parts of the code look a bit cleaner as well. Especially the 
fact that you don't have to clear and reset the list after a change.

One could argue that a language selector is essentially more a ComboBox than 
a PushButton, because you select something, but I think one look at the 
result should convince everyone that this is still very intuitive and 
actually looks much nicer ;-).

If someone really insists on using a ComboBox then I challenge him/her to 
come up with a solution that draws the drop-down part in such a way that it 
1. is placed where it should be and doesn't overlap the button and 2. Looks 
like one whole, that is, the combobutton is drawn depressed or any other 
measure is taken to make sure that it is immediately clear that the popup 
menu belongs to the combo...

Attached is a tar.gz with the .cpp and .h file for KLanguageButton and a diff 
against KPersonalizer. The diff is almost nothing more than 
s/KLanguageCombo/KLanguageButton, though Qt designer decided to change quite 
some lines in the .ui file, which makes the diff rather large.

Question is: can I commit this stuff? If so, I'll manually edit the .ui file 
instead of using designer so the .ui file remains as much as possible the way 
it is now and I'll change the same stuff in the KControl modules that use 
this widget. The widget is not in kdelibs, it is duplicated around the KDE 
code wherever it is used. Might be a candidate for kdeui, but I personally 
don't want to write the docs ;-) Also, the original code from Hans Petter 
Bieker was GPL licensed, this must be changed into LGPL to get it in kdelibs. 
(CC:ed Hans Petter so he is hopefully reading this as well :-)

Martijn

PS: I assume the language selector combo works as well as the country 
selector, but I don't have _any_ i18n installed here, so I only have the 
Default (C) language here. I could only really test with the country selector 
which looks great now. Might be a that I missed something because of this, 
though it's not likely.

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

? kpersonalizer.diff
? klanguagebutton.h
? klanguagebutton.cpp
Index: Makefile.am
===================================================================
RCS file: /home/kde/kdebase/kpersonalizer/Makefile.am,v
retrieving revision 1.8
diff -b -u -p -r1.8 Makefile.am
--- Makefile.am	2001/06/15 18:07:28	1.8
+++ Makefile.am	2001/07/16 22:01:37
@@ -1,13 +1,13 @@
 ####### kdevelop will overwrite this part!!! (begin)##########
 bin_PROGRAMS = kpersonalizer
-kpersonalizer_SOURCES = klocaleadv.cpp ktagcombobox.cpp klangcombo.cpp \
krefinepage.cpp \ +kpersonalizer_SOURCES = klocaleadv.cpp ktagcombobox.cpp \
                klangcombo.cpp klanguagebutton.cpp krefinepage.cpp \
                                           kstylepage.cpp keyecandypage.cpp \
kospage.cpp kcountrypage.cpp kpersonalizer.cpp \  main.cpp \
                                           kcountrypagedlg.ui kospagedlg.ui \
keyecandypagedlg.ui kstylepagedlg.ui krefinepagedlg.ui  
 kpersonalizer_LDADD   = $(LIB_KFILE) 
 
-EXTRA_DIST = main.cpp kpersonalizer.cpp kpersonalizer.h kpersonalizer.desktop \
kcountrypage.cpp kcountrypage.h kospage.cpp kospage.h keyecandypage.cpp \
keyecandypage.h kstylepage.cpp kstylepage.h krefinepage.cpp krefinepage.h \
klangcombo.cpp klangcombo.h ktagcombobox.cpp ktagcombobox.h klocaleadv.cpp \
klocaleadv.h hi16-app-kpersonalizer.png hi32-app-kpersonalizer.png README \
kcountrypagedlg.ui kospage.ui keyecandypagedlg.ui kstylepagedlg.ui krefinepagedlg.ui \
+EXTRA_DIST = main.cpp kpersonalizer.cpp kpersonalizer.h kpersonalizer.desktop \
kcountrypage.cpp kcountrypage.h kospage.cpp kospage.h keyecandypage.cpp \
keyecandypage.h kstylepage.cpp kstylepage.h krefinepage.cpp krefinepage.h \
klangcombo.cpp klangcombo.h klanguagecombo.cpp klanguagecombo.h ktagcombobox.cpp \
ktagcombobox.h klocaleadv.cpp klocaleadv.h hi16-app-kpersonalizer.png \
hi32-app-kpersonalizer.png README kcountrypagedlg.ui kospage.ui keyecandypagedlg.ui \
kstylepagedlg.ui krefinepagedlg.ui  
 desktop_DATA = kpersonalizer.desktop
 desktopdir = $(kde_appsdir)/System
Index: kcountrypage.cpp
===================================================================
RCS file: /home/kde/kdebase/kpersonalizer/kcountrypage.cpp,v
retrieving revision 1.14
diff -b -u -p -r1.14 kcountrypage.cpp
--- kcountrypage.cpp	2001/07/14 14:16:59	1.14
+++ kcountrypage.cpp	2001/07/16 22:01:40
@@ -29,7 +29,7 @@
 #include <kconfig.h>
 #include <dcopclient.h>
 
-#include "klangcombo.h"
+#include "klanguagebutton.h"
 #include "klocaleadv.h"
 
 #include "kcountrypage.h"
@@ -112,7 +112,7 @@ KCountryPage::~KCountryPage(){
 }
 
 
-void KCountryPage::loadCountryList(KLanguageCombo *combo)
+void KCountryPage::loadCountryList(KLanguageButton *combo)
 {
 
   // temperary use of our locale as the global locale
@@ -173,7 +173,7 @@ void KCountryPage::loadCountryList(KLang
   KGlobal::_locale = lsave;
 }
 
-void KCountryPage::loadLanguageList(KLanguageCombo *combo, const QStringList &first)
+void KCountryPage::loadLanguageList(KLanguageButton *combo, const QStringList \
&first)  {
   // temperary use of our locale as the global locale
   KLocale *lsave = KGlobal::_locale;
@@ -230,7 +230,7 @@ void KCountryPage::loadLanguageList(KLan
 }
 
 /** No descriptions */
-void KCountryPage::save(KLanguageCombo *comboCountry, KLanguageCombo *comboLang){
+void KCountryPage::save(KLanguageButton *comboCountry, KLanguageButton *comboLang){
   kdDebug() << "KCountryPage::save()" << endl;
   KConfigBase *config = KGlobal::config();
 
@@ -278,8 +278,8 @@ void KCountryPage::setLangForCountry(int
   locale->setLanguage(lang);
   locale->setCountry(country);
 
-  loadLanguageList(cb_language, langs);
-  loadCountryList(cb_country);
+/*  loadLanguageList(cb_language, langs);
+  loadCountryList(cb_country);*/
 
   cb_language->setCurrentItem(lang);
 }
Index: kcountrypage.h
===================================================================
RCS file: /home/kde/kdebase/kpersonalizer/kcountrypage.h,v
retrieving revision 1.6
diff -b -u -p -r1.6 kcountrypage.h
--- kcountrypage.h	2001/06/09 23:12:41	1.6
+++ kcountrypage.h	2001/07/16 22:01:40
@@ -20,7 +20,7 @@
 
 #include "kcountrypagedlg.h"
 
-class KLanguageCombo;
+class KLanguageButton;
 class KLocaleAdvanced;
 class QStringList;
 
@@ -34,10 +34,10 @@ public:
     KCountryPage(QWidget *parent=0, const char *name=0);
     ~KCountryPage();
 
-    void loadCountryList(KLanguageCombo *combo);
-    void loadLanguageList(KLanguageCombo *combo, const QStringList &first);
+    void loadCountryList(KLanguageButton *combo);
+    void loadLanguageList(KLanguageButton *combo, const QStringList &first);
     /** No descriptions */
-    void save(KLanguageCombo *comboCountry, KLanguageCombo *comboLang);
+    void save(KLanguageButton *comboCountry, KLanguageButton *comboLang);
 
     KLocaleAdvanced *locale;
 
Index: kcountrypagedlg.ui
===================================================================
RCS file: /home/kde/kdebase/kpersonalizer/kcountrypagedlg.ui,v
retrieving revision 1.5
diff -b -u -p -r1.5 kcountrypagedlg.ui
--- kcountrypagedlg.ui	2001/06/11 07:09:03	1.5
+++ kcountrypagedlg.ui	2001/07/16 22:01:42
@@ -11,7 +11,7 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>583</width>
+            <width>575</width>
             <height>452</height>
         </rect>
     </property>
@@ -28,65 +28,6 @@
             <name>spacing</name>
             <number>6</number>
         </property>
-        <widget row="6"  column="1" >
-            <class>QLayoutWidget</class>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>Layout6</cstring>
-            </property>
-            <hbox>
-                <property stdset="1">
-                    <name>margin</name>
-                    <number>0</number>
-                </property>
-                <property stdset="1">
-                    <name>spacing</name>
-                    <number>6</number>
-                </property>
-                <widget>
-                    <class>KLanguageCombo</class>
-                    <property stdset="1">
-                        <name>name</name>
-                        <cstring>cb_language</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>sizePolicy</name>
-                        <sizepolicy>
-                            <hsizetype>1</hsizetype>
-                            <vsizetype>0</vsizetype>
-                        </sizepolicy>
-                    </property>
-                    <property stdset="1">
-                        <name>minimumSize</name>
-                        <size>
-                            <width>150</width>
-                            <height>0</height>
-                        </size>
-                    </property>
-                </widget>
-                <spacer>
-                    <property>
-                        <name>name</name>
-                        <cstring>Spacer6_2_2</cstring>
-                    </property>
-                    <property stdset="1">
-                        <name>orientation</name>
-                        <enum>Horizontal</enum>
-                    </property>
-                    <property stdset="1">
-                        <name>sizeType</name>
-                        <enum>Preferred</enum>
-                    </property>
-                    <property>
-                        <name>sizeHint</name>
-                        <size>
-                            <width>20</width>
-                            <height>20</height>
-                        </size>
-                    </property>
-                </spacer>
-            </hbox>
-        </widget>
         <widget row="5"  column="1" >
             <class>QLabel</class>
             <property stdset="1">
@@ -151,7 +92,7 @@
                     <number>6</number>
                 </property>
                 <widget>
-                    <class>KLanguageCombo</class>
+                    <class>KLanguageButton</class>
                     <property stdset="1">
                         <name>name</name>
                         <cstring>cb_country</cstring>
@@ -205,7 +146,7 @@
                 <string>Please choose your country:</string>
             </property>
         </widget>
-        <widget row="0"  column="0"  rowspan="9"  colspan="1" >
+        <widget row="0"  column="0"  rowspan="10"  colspan="1" >
             <class>QLabel</class>
             <property stdset="1">
                 <name>name</name>
@@ -263,7 +204,7 @@
                 </size>
             </property>
         </spacer>
-        <widget row="8"  column="1" >
+        <widget row="9"  column="1" >
             <class>QCheckBox</class>
             <property stdset="1">
                 <name>name</name>
@@ -285,7 +226,7 @@
                 <string>This allowes visually impaired people to use the \
personalizer</string>  </property>
         </widget>
-        <spacer row="7"  column="1" >
+        <spacer row="8"  column="1" >
             <property>
                 <name>name</name>
                 <cstring>Spacer5</cstring>
@@ -306,12 +247,71 @@
                 </size>
             </property>
         </spacer>
+        <widget row="6"  column="1" >
+            <class>QLayoutWidget</class>
+            <property stdset="1">
+                <name>name</name>
+                <cstring>Layout6</cstring>
+            </property>
+            <hbox>
+                <property stdset="1">
+                    <name>margin</name>
+                    <number>0</number>
+                </property>
+                <property stdset="1">
+                    <name>spacing</name>
+                    <number>6</number>
+                </property>
+                <widget>
+                    <class>KLanguageButton</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>cb_language</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>sizePolicy</name>
+                        <sizepolicy>
+                            <hsizetype>1</hsizetype>
+                            <vsizetype>0</vsizetype>
+                        </sizepolicy>
+                    </property>
+                    <property stdset="1">
+                        <name>minimumSize</name>
+                        <size>
+                            <width>150</width>
+                            <height>0</height>
+                        </size>
+                    </property>
+                </widget>
+                <spacer>
+                    <property>
+                        <name>name</name>
+                        <cstring>Spacer6_2_2</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>orientation</name>
+                        <enum>Horizontal</enum>
+                    </property>
+                    <property stdset="1">
+                        <name>sizeType</name>
+                        <enum>Preferred</enum>
+                    </property>
+                    <property>
+                        <name>sizeHint</name>
+                        <size>
+                            <width>20</width>
+                            <height>20</height>
+                        </size>
+                    </property>
+                </spacer>
+            </hbox>
+        </widget>
     </grid>
 </widget>
 <customwidgets>
     <customwidget>
-        <class>KLanguageCombo</class>
-        <header location="local">klangcombo.h</header>
+        <class>KLanguageButton</class>
+        <header location="local">klanguagebutton.h</header>
         <sizehint>
             <width>-1</width>
             <height>-1</height>


["kpersonalizer.tar.gz" (application/x-gzip)]

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

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