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

List:       kde-devel
Subject:    commit approval request for 3.5.3 (kxkb layout labels)
From:       Andriy Rysin <arysin () myrealbox ! com>
Date:       2006-04-02 15:51:29
Message-ID: 442FF301.7020309 () myrealbox ! com
[Download RAW message or body]

Hi all,

due to more strict rules on code commits to 3.5.3 I am posting here the 
change I have to commit .

Subject: to allow users to specify layout labels themselves in 
kcm_keyboard configuration module
Changes to approve: additional feature with UI change and two i18n 
strings ("Label:" and "Label" - the strings may change a bit)
Rationale: due to increased demand for a feature which allows to switch 
variants (which is especially critical with xorg >= 6.9, where all 
layout variations went inside variants) we'd need a way to distinguish 
layout/variant pairs in system tray. Currently with only two letters 
representing layout it's impossible to distinguish between different 
variants in same layout.
Change: allow users to enter up to 3 letter label for a layout/variant 
pair (reasonable defaults will be provided)
Note: this feature was ready in 3.5.2 but UI did not get in because of 
i18n messages freeze.
Note2: the engine for a feature was committed in 3.5.2 code, i.e. the 
code which reads config file with layout display names and displays them 
in tray is there, and it worked for me so far, so only UI part has to be 
added in 3.5.3.

Again, I'd like to stress that without this feature it'll be pretty hard 
to use multiple variants with same layout so I'd consider it's critical 
update.

There's still some testing and polishing to be done but as we have to 
request new features early I am posting preliminary patch and snapshot 
for updated kcmlayout for upproval.

Please let me know if there's any objections, otherwise I'll be 
committing the code some time soon.

Andriy



["layout_labels.patch" (text/x-patch)]

Index: pixmap.h
===================================================================
--- pixmap.h	(revision 525649)
+++ pixmap.h	(working copy)
@@ -20,7 +20,6 @@
 	QPixmap* createErrorPixmap();
 	void dimPixmap(QPixmap& pixmap);
 	QString getCountryFromLayoutName(const QString& layoutName);
-	QString getDefaultDisplayName(const QString& layoutName);
 	
   public:
 	static const QString& ERROR_CODE;
Index: kcmlayoutwidget.ui
===================================================================
--- kcmlayoutwidget.ui	(revision 525649)
+++ kcmlayoutwidget.ui	(working copy)
@@ -8,8 +8,8 @@
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>733</width>
-            <height>556</height>
+            <width>709</width>
+            <height>563</height>
         </rect>
     </property>
     <property name="sizePolicy">
@@ -26,14 +26,14 @@
             <height>510</height>
         </size>
     </property>
-    <vbox>
+    <property name="caption">
+        <string>LayoutConfigWidget</string>
+    </property>
+    <grid>
         <property name="name">
             <cstring>unnamed</cstring>
         </property>
-        <property name="margin">
-            <number>0</number>
-        </property>
-        <widget class="QTabWidget">
+        <widget class="QTabWidget" row="0" column="0">
             <property name="name">
                 <cstring>tabWidget</cstring>
             </property>
@@ -79,288 +79,248 @@
                             <property name="name">
                                 <cstring>unnamed</cstring>
                             </property>
-                            <widget class="QLayoutWidget" row="0" column="0" \
rowspan="1" colspan="2"> +                            <widget class="QLabel" row="2" \
column="0" rowspan="1" colspan="2">  <property name="name">
-                                    <cstring>layout5</cstring>
+                                    <cstring>textLabel1_4</cstring>
                                 </property>
-                                <grid>
+                                <property name="text">
+                                    <string>Available layouts:</string>
+                                </property>
+                            </widget>
+                            <widget class="QLabel" row="2" column="2" rowspan="1" \
colspan="3"> +                                <property name="name">
+                                    <cstring>textLabel1_4_2</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Active layouts:</string>
+                                </property>
+                            </widget>
+                            <widget class="QLabel" row="0" column="2" rowspan="1" \
colspan="3"> +                                <property name="name">
+                                    <cstring>textLabel1_2</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Keyboard &amp;model:</string>
+                                </property>
+                                <property name="buddy" stdset="0">
+                                    <cstring>comboModel</cstring>
+                                </property>
+                            </widget>
+                            <widget class="QComboBox" row="1" column="2" rowspan="1" \
colspan="3"> +                                <property name="name">
+                                    <cstring>comboModel</cstring>
+                                </property>
+                                <property name="sizePolicy">
+                                    <sizepolicy>
+                                        <hsizetype>7</hsizetype>
+                                        <vsizetype>0</vsizetype>
+                                        <horstretch>0</horstretch>
+                                        <verstretch>0</verstretch>
+                                    </sizepolicy>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>Here you can choose a keyboard model. \
This setting is independent of your keyboard layout and refers to the "hardware" \
model, i.e. the way your keyboard is manufactured. Modern keyboards that come with \
your computer usually have two extra keys and are referred to as "104-key" models, \
which is probably what you want if you do not know what kind of keyboard you have. \
+</string> +                                </property>
+                            </widget>
+                            <widget class="QListView" row="3" column="2" rowspan="1" \
colspan="3"> +                                <column>
+                                    <property name="text">
+                                        <string>1</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>false</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Layout</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>true</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Keymap</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>true</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Variant</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>true</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>5</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>false</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Label</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>false</bool>
+                                    </property>
+                                </column>
+                                <property name="name">
+                                    <cstring>listLayoutsDst</cstring>
+                                </property>
+                                <property name="allColumnsShowFocus">
+                                    <bool>true</bool>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>If more than one layout is present in \
this list, the KDE panel will offer a docked flag. By clicking on this flag you can \
easily switch between layouts. The first layout will be default one.</string> +       \
</property> +                            </widget>
+                            <widget class="QLayoutWidget" row="4" column="2" \
rowspan="1" colspan="3"> +                                <property name="name">
+                                    <cstring>layout10</cstring>
+                                </property>
+                                <hbox>
                                     <property name="name">
                                         <cstring>unnamed</cstring>
                                     </property>
-                                    <widget class="QLabel" row="2" column="0">
+                                    <widget class="QPushButton">
                                         <property name="name">
-                                            <cstring>textLabel1_4</cstring>
+                                            <cstring>btnAdd</cstring>
                                         </property>
                                         <property name="text">
-                                            <string>Available layouts:</string>
+                                            <string>Add &gt;&gt;</string>
                                         </property>
                                     </widget>
-                                    <widget class="QLabel" row="2" column="1">
+                                    <widget class="QPushButton">
                                         <property name="name">
-                                            <cstring>textLabel1_4_2</cstring>
+                                            <cstring>btnRemove</cstring>
                                         </property>
                                         <property name="text">
-                                            <string>Active layouts:</string>
+                                            <string>&lt;&lt; Remove</string>
                                         </property>
                                     </widget>
-                                    <widget class="QLabel" row="0" column="1">
+                                    <widget class="QPushButton">
                                         <property name="name">
-                                            <cstring>textLabel1_2</cstring>
+                                            <cstring>btnUp</cstring>
                                         </property>
+                                        <property name="sizePolicy">
+                                            <sizepolicy>
+                                                <hsizetype>0</hsizetype>
+                                                <vsizetype>0</vsizetype>
+                                                <horstretch>0</horstretch>
+                                                <verstretch>0</verstretch>
+                                            </sizepolicy>
+                                        </property>
                                         <property name="text">
-                                            <string>Keyboard &amp;model:</string>
+                                            <string></string>
                                         </property>
-                                        <property name="buddy" stdset="0">
-                                            <cstring>comboModel</cstring>
-                                        </property>
                                     </widget>
-                                    <widget class="QComboBox" row="1" column="1">
+                                    <widget class="QPushButton">
                                         <property name="name">
-                                            <cstring>comboModel</cstring>
+                                            <cstring>btnDown</cstring>
                                         </property>
                                         <property name="sizePolicy">
                                             <sizepolicy>
-                                                <hsizetype>7</hsizetype>
+                                                <hsizetype>0</hsizetype>
                                                 <vsizetype>0</vsizetype>
                                                 <horstretch>0</horstretch>
                                                 <verstretch>0</verstretch>
                                             </sizepolicy>
                                         </property>
-                                        <property name="whatsThis" stdset="0">
-                                            <string>Here you can choose a keyboard \
model. This setting is independent of your keyboard layout and refers to the \
"hardware" model, i.e. the way your keyboard is manufactured. Modern keyboards that \
come with your computer usually have two extra keys and are referred to as "104-key" \
models, which is probably what you want if you do not know what kind of keyboard you \
                have.
-</string>
-                                        </property>
-                                    </widget>
-                                    <widget class="QCheckBox" row="6" column="1">
-                                        <property name="name">
-                                            <cstring>chkLatin</cstring>
-                                        </property>
-                                        <property name="enabled">
-                                            <bool>false</bool>
-                                        </property>
                                         <property name="text">
-                                            <string>Include latin layout</string>
+                                            <string></string>
                                         </property>
-                                        <property name="whatsThis" stdset="0">
-                                            <string>If after you switch to this \
layout some keyboard shortcuts based on latin keys do not work try to enable this \
                option.</string>
-                                        </property>
                                     </widget>
-                                    <widget class="QListView" row="3" column="1">
-                                        <column>
-                                            <property name="text">
-                                                <string></string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>false</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string>Layout</string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>true</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string>Keymap</string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>true</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string>Variant</string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>true</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string></string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>false</bool>
-                                            </property>
-                                        </column>
-                                        <property name="name">
-                                            <cstring>listLayoutsDst</cstring>
-                                        </property>
-                                        <property name="allColumnsShowFocus">
-                                            <bool>true</bool>
-                                        </property>
-                                        <property name="whatsThis" stdset="0">
-                                            <string>If more than one layout is \
present in this list, the KDE panel will offer a docked flag. By clicking on this \
flag you can easily switch between layouts. The first layout will be default \
                one.</string>
-                                        </property>
-                                    </widget>
-                                    <widget class="QLayoutWidget" row="5" \
                column="1">
-                                        <property name="name">
-                                            <cstring>layout11</cstring>
-                                        </property>
-                                        <hbox>
-                                            <property name="name">
-                                                <cstring>unnamed</cstring>
-                                            </property>
-                                            <widget class="QLabel">
-                                                <property name="name">
-                                                    <cstring>textLabel1</cstring>
-                                                </property>
-                                                <property name="text">
-                                                    <string>Layout variant:</string>
-                                                </property>
-                                                <property name="buddy" stdset="0">
-                                                    <cstring>comboVariant</cstring>
-                                                </property>
-                                            </widget>
-                                            <widget class="QComboBox">
-                                                <property name="name">
-                                                    <cstring>comboVariant</cstring>
-                                                </property>
-                                                <property name="whatsThis" \
                stdset="0">
-                                                    <string>Here you can choose a \
variant of selected keyboard layout. Layout variants usually represent different key \
maps for the same language. For example, Ukrainian layout might have four variants: \
basic, winkeys (as in Windows), typewriter (as in typewriters) and phonetic (each \
                Ukrainian letter is placed on a transliterated latin one).
-</string>
-                                                </property>
-                                            </widget>
-                                        </hbox>
-                                    </widget>
-                                    <widget class="QLayoutWidget" row="4" \
                column="1">
-                                        <property name="name">
-                                            <cstring>layout10</cstring>
-                                        </property>
-                                        <hbox>
-                                            <property name="name">
-                                                <cstring>unnamed</cstring>
-                                            </property>
-                                            <widget class="QPushButton">
-                                                <property name="name">
-                                                    <cstring>btnAdd</cstring>
-                                                </property>
-                                                <property name="text">
-                                                    <string>Add &gt;&gt;</string>
-                                                </property>
-                                            </widget>
-                                            <widget class="QPushButton">
-                                                <property name="name">
-                                                    <cstring>btnRemove</cstring>
-                                                </property>
-                                                <property name="text">
-                                                    <string>&lt;&lt; Remove</string>
-                                                </property>
-                                            </widget>
-                                            <widget class="QPushButton">
-                                                <property name="name">
-                                                    <cstring>btnUp</cstring>
-                                                </property>
-                                                <property name="sizePolicy">
-                                                    <sizepolicy>
-                                                        <hsizetype>0</hsizetype>
-                                                        <vsizetype>0</vsizetype>
-                                                        <horstretch>0</horstretch>
-                                                        <verstretch>0</verstretch>
-                                                    </sizepolicy>
-                                                </property>
-                                                <property name="text">
-                                                    <string></string>
-                                                </property>
-                                            </widget>
-                                            <widget class="QPushButton">
-                                                <property name="name">
-                                                    <cstring>btnDown</cstring>
-                                                </property>
-                                                <property name="sizePolicy">
-                                                    <sizepolicy>
-                                                        <hsizetype>0</hsizetype>
-                                                        <vsizetype>0</vsizetype>
-                                                        <horstretch>0</horstretch>
-                                                        <verstretch>0</verstretch>
-                                                    </sizepolicy>
-                                                </property>
-                                                <property name="text">
-                                                    <string></string>
-                                                </property>
-                                            </widget>
-                                        </hbox>
-                                    </widget>
-                                    <widget class="QListView" row="3" column="0" \
                rowspan="4" colspan="1">
-                                        <column>
-                                            <property name="text">
-                                                <string></string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>false</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string>Layout</string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>true</bool>
-                                            </property>
-                                        </column>
-                                        <column>
-                                            <property name="text">
-                                                <string>Keymap</string>
-                                            </property>
-                                            <property name="clickable">
-                                                <bool>false</bool>
-                                            </property>
-                                            <property name="resizable">
-                                                <bool>true</bool>
-                                            </property>
-                                        </column>
-                                        <property name="name">
-                                            <cstring>listLayoutsSrc</cstring>
-                                        </property>
-                                        <property name="minimumSize">
-                                            <size>
-                                                <width>260</width>
-                                                <height>0</height>
-                                            </size>
-                                        </property>
-                                        <property name="allColumnsShowFocus">
-                                            <bool>true</bool>
-                                        </property>
-                                        <property name="whatsThis" stdset="0">
-                                            <string>This is the list of available \
keyboard layouts in your system. You can add layout to the active list by selecting \
                it and pressing "Add" button.</string>
-                                        </property>
-                                    </widget>
-                                </grid>
+                                </hbox>
                             </widget>
-                            <widget class="QLabel" row="1" column="0">
+                            <widget class="QLabel" row="8" column="0">
                                 <property name="name">
                                     <cstring>textLabel1_3</cstring>
                                 </property>
                                 <property name="text">
                                     <string>Command:</string>
                                 </property>
+                                <property name="buddy" stdset="0">
+                                    <cstring>editCmdLine</cstring>
+                                </property>
                             </widget>
-                            <widget class="QLineEdit" row="1" column="1">
+                            <widget class="QListView" row="3" column="0" rowspan="5" \
colspan="2"> +                                <column>
+                                    <property name="text">
+                                        <string></string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>false</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Layout</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>true</bool>
+                                    </property>
+                                </column>
+                                <column>
+                                    <property name="text">
+                                        <string>Keymap</string>
+                                    </property>
+                                    <property name="clickable">
+                                        <bool>false</bool>
+                                    </property>
+                                    <property name="resizable">
+                                        <bool>true</bool>
+                                    </property>
+                                </column>
                                 <property name="name">
+                                    <cstring>listLayoutsSrc</cstring>
+                                </property>
+                                <property name="minimumSize">
+                                    <size>
+                                        <width>260</width>
+                                        <height>0</height>
+                                    </size>
+                                </property>
+                                <property name="allColumnsShowFocus">
+                                    <bool>true</bool>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>This is the list of available keyboard \
layouts in your system. You can add layout to the active list by selecting it and \
pressing "Add" button.</string> +                                </property>
+                            </widget>
+                            <widget class="QLineEdit" row="8" column="1" rowspan="1" \
colspan="4"> +                                <property name="name">
                                     <cstring>editCmdLine</cstring>
                                 </property>
                                 <property name="readOnly">
@@ -370,6 +330,96 @@
                                     <string>This is the command which is executed \
when switching to the selected layout. It may help you if you want to debug layout \
switching, or if you want to switch layouts without the help of KDE.</string>  \
</property>  </widget>
+                            <widget class="QCheckBox" row="7" column="2" rowspan="1" \
colspan="3"> +                                <property name="name">
+                                    <cstring>chkLatin</cstring>
+                                </property>
+                                <property name="enabled">
+                                    <bool>false</bool>
+                                </property>
+                                <property name="text">
+                                    <string>Include latin layout</string>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>If after you switch to this layout some \
keyboard shortcuts based on latin keys do not work try to enable this \
option.</string> +                                </property>
+                            </widget>
+                            <widget class="QLabel" row="6" column="2">
+                                <property name="name">
+                                    <cstring>textLabel1_6</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Label:</string>
+                                </property>
+                                <property name="buddy" stdset="0">
+                                    <cstring>editDisplayName</cstring>
+                                </property>
+                            </widget>
+                            <widget class="QLineEdit" row="6" column="3">
+                                <property name="name">
+                                    <cstring>editDisplayName</cstring>
+                                </property>
+                                <property name="enabled">
+                                    <bool>false</bool>
+                                </property>
+                                <property name="maxLength">
+                                    <number>3</number>
+                                </property>
+                            </widget>
+                            <widget class="QLabel" row="5" column="2">
+                                <property name="name">
+                                    <cstring>textLabel1</cstring>
+                                </property>
+                                <property name="text">
+                                    <string>Layout variant:</string>
+                                </property>
+                                <property name="buddy" stdset="0">
+                                    <cstring>comboVariant</cstring>
+                                </property>
+                            </widget>
+                            <widget class="QComboBox" row="5" column="3">
+                                <property name="name">
+                                    <cstring>comboVariant</cstring>
+                                </property>
+                                <property name="whatsThis" stdset="0">
+                                    <string>Here you can choose a variant of \
selected keyboard layout. Layout variants usually represent different key maps for \
the same language. For example, Ukrainian layout might have four variants: basic, \
winkeys (as in Windows), typewriter (as in typewriters) and phonetic (each Ukrainian \
letter is placed on a transliterated latin one). +</string>
+                                </property>
+                            </widget>
+                            <spacer row="5" column="4">
+                                <property name="name">
+                                    <cstring>spacer3</cstring>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Horizontal</enum>
+                                </property>
+                                <property name="sizeType">
+                                    <enum>Expanding</enum>
+                                </property>
+                                <property name="sizeHint">
+                                    <size>
+                                        <width>210</width>
+                                        <height>20</height>
+                                    </size>
+                                </property>
+                            </spacer>
+                            <spacer row="6" column="4">
+                                <property name="name">
+                                    <cstring>spacer2</cstring>
+                                </property>
+                                <property name="orientation">
+                                    <enum>Horizontal</enum>
+                                </property>
+                                <property name="sizeType">
+                                    <enum>Expanding</enum>
+                                </property>
+                                <property name="sizeHint">
+                                    <size>
+                                        <width>210</width>
+                                        <height>20</height>
+                                    </size>
+                                </property>
+                            </spacer>
                         </grid>
                     </widget>
                 </grid>
@@ -624,7 +674,7 @@
                 </vbox>
             </widget>
         </widget>
-    </vbox>
+    </grid>
 </widget>
 <connections>
     <connection>
Index: kcmlayout.h
===================================================================
--- kcmlayout.h	(revision 525649)
+++ kcmlayout.h	(working copy)
@@ -29,11 +29,13 @@
 
 protected:
   QString createOptionString();
+  void updateIndicator(QListViewItem* selLayout);
 
 protected slots:
   void moveUp();
   void moveDown();
   void variantChanged();
+  void displayNameChanged(const QString& name);
   void latinChanged();
   void layoutSelChanged(QListViewItem *);
   void loadRules();
@@ -53,6 +55,7 @@
 
   QWidget* makeOptionsTab();
   void updateStickyLimit();
+  static LayoutUnit getLayoutUnitKey(QListViewItem *sel);
 };
 
 
Index: kxkbconfig.cpp
===================================================================
--- kxkbconfig.cpp	(revision 525649)
+++ kxkbconfig.cpp	(working copy)
@@ -181,25 +181,38 @@
 	config->writeEntry("Options", m_options );
 
 	QStringList layoutList;
+	QStringList includeList;
+	QStringList displayNamesList;
+	
 	QValueList<LayoutUnit>::ConstIterator it;
 	for(it = m_layouts.begin(); it != m_layouts.end(); ++it) {
-		layoutList.append( (*it).toPair() );
-	}
-	
-	config->writeEntry("LayoutList", layoutList);
-	kdDebug() << "Saving Layouts: " << layoutList << endl;
-
-
- 	QStringList includeList;
-	for(QValueList<LayoutUnit>::ConstIterator it = m_layouts.begin(); it != \
m_layouts.end(); ++it) {  const LayoutUnit& layoutUnit = *it;
+		
+		layoutList.append( layoutUnit.toPair() );
+		
 		if( layoutUnit.includeGroup.isEmpty() == false ) {
 			QString incGroupUnit = QString("%1:%2").arg(layoutUnit.toPair(), \
layoutUnit.includeGroup);  includeList.append( incGroupUnit );
 		}
- 	}
- 	config->writeEntry("IncludeGroups", includeList);
+	
+		QString displayName( layoutUnit.displayName );
+		kdDebug() << " displayName " << layoutUnit.toPair() << " : " << displayName << \
endl; +		if( displayName.isEmpty() == false && displayName != layoutUnit.layout ) {
+			displayName = QString("%1:%2").arg(layoutUnit.toPair(), displayName);
+			displayNamesList.append( displayName );
+		}
+	}
+	
+	config->writeEntry("LayoutList", layoutList);
+	kdDebug() << "Saving Layouts: " << layoutList << endl;
+ 	
+	config->writeEntry("IncludeGroups", includeList);
  	kdDebug() << "Saving includeGroups: " << includeList << endl;
+	
+//	if( displayNamesList.empty() == false )
+		config->writeEntry("DisplayNames", displayNamesList);
+// 	else
+// 		config->deleteEntry("DisplayNames");
 
 	config->writeEntry("Use", m_useKxkb);
 	config->writeEntry("ShowSingle", m_showSingle);
@@ -255,6 +268,40 @@
 }
 
 
+QString KxkbConfig::getDefaultDisplayName(const QString& code_)
+{
+	QString displayName;
+	
+	if( code_.length() <= 2 ) {
+		displayName = code_;
+	}
+	else {
+		int sepPos = code_.find(QRegExp("[-_]"));
+		QString leftCode = code_.mid(0, sepPos);
+		QString rightCode;
+		if( sepPos != -1 )
+			rightCode = code_.mid(sepPos+1);
+		
+		if( rightCode.length() > 0 )
+			displayName = leftCode.left(2) + rightCode.left(1).lower();
+		else
+			displayName = leftCode.left(3);
+	}
+	
+	return displayName;
+}
+
+QString KxkbConfig::getDefaultDisplayName(const LayoutUnit& layoutUnit, bool single)
+{
+	if( layoutUnit.variant == "" )
+		return getDefaultDisplayName( layoutUnit.layout );
+	
+	QString displayName = layoutUnit.layout.left(2);
+	if( single == false )
+		displayName += layoutUnit.variant.left(1);
+	return displayName;
+}
+
 /**
  * @brief Gets the single layout part of a layout(variant) string
  * @param[in] layvar String in form layout(variant) to parse
Index: pixmap.cpp
===================================================================
--- pixmap.cpp	(revision 525649)
+++ pixmap.cpp	(working copy)
@@ -11,6 +11,7 @@
 
 #include "pixmap.h"
 #include "x11helper.h"
+#include "kxkbconfig.h"
 
 
 static const int FLAG_MAX_WIDTH = 21;
@@ -53,7 +54,7 @@
 	QString displayName(displayName_);
 	
 	if( displayName.isEmpty() ) {
-		displayName = getDefaultDisplayName(code_);
+		displayName = KxkbConfig::getDefaultDisplayName(code_);
 	}
 	if( displayName.length() > 3 )
 		displayName = displayName.left(3);
@@ -110,29 +111,6 @@
 	return *pm;
 }
 
-QString LayoutIcon::getDefaultDisplayName(const QString& code_)
-{
-	QString displayName;
-	
-	if( code_.length() <= 2 ) {
-		displayName = code_;
-	}
-	else {
-		int sepPos = code_.find(QRegExp("[-_]"));
-		QString leftCode = code_.mid(0, sepPos);
-		QString rightCode;
-		if( sepPos != -1 )
-			rightCode = code_.mid(sepPos+1);
-		
-		if( rightCode.length() > 0 )
-			displayName = leftCode.left(2) + rightCode.left(1).lower();
-		else
-			displayName = leftCode.left(3);
-	}
-	
-	return displayName;
-}
-
 /**
 @brief Try to get country code from layout name in xkb before xorg 6.9.0
 */
Index: kcmlayout.cpp
===================================================================
--- kcmlayout.cpp	(revision 525649)
+++ kcmlayout.cpp	(working copy)
@@ -40,8 +40,9 @@
  LAYOUT_COLUMN_MAP = 2,
  LAYOUT_COLUMN_VARIANT = 3,
  LAYOUT_COLUMN_INCLUDE = 4,
+ LAYOUT_COLUMN_DISPLAY_NAME = 5,
  SRC_LAYOUT_COLUMN_COUNT = 3,
- DST_LAYOUT_COLUMN_COUNT = 5
+ DST_LAYOUT_COLUMN_COUNT = 6
 };
 
 static const QString DEFAULT_VARIANT_NAME("<default>");
@@ -117,6 +118,8 @@
   connect( widget->listLayoutsDst, SIGNAL(selectionChanged(QListViewItem *)),
 		this, SLOT(layoutSelChanged(QListViewItem *)));
 
+  connect( widget->editDisplayName, SIGNAL(textChanged(const QString&)), this, \
SLOT(displayNameChanged(const QString&))); +
   connect( widget->chkLatin, SIGNAL(clicked()), this, SLOT(changed()));
   connect( widget->chkLatin, SIGNAL(clicked()), this, SLOT(latinChanged()));
 
@@ -135,13 +138,16 @@
   widget->listLayoutsSrc->setColumnText(LAYOUT_COLUMN_FLAG, "");
   widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_FLAG, "");
   widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_INCLUDE, "");
+//  widget->listLayoutsDst->setColumnText(LAYOUT_COLUMN_DISPLAY_NAME, "");
 
   widget->listLayoutsSrc->setColumnWidth(LAYOUT_COLUMN_FLAG, 28);
   widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_FLAG, 28);
 
   widget->listLayoutsDst->header()->setResizeEnabled(FALSE, LAYOUT_COLUMN_INCLUDE);
+  widget->listLayoutsDst->header()->setResizeEnabled(FALSE, \
LAYOUT_COLUMN_DISPLAY_NAME);  \
widget->listLayoutsDst->setColumnWidthMode(LAYOUT_COLUMN_INCLUDE, QListView::Manual); \
widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_INCLUDE, 0); +  \
widget->listLayoutsDst->setColumnWidth(LAYOUT_COLUMN_DISPLAY_NAME, 0);  
   widget->listLayoutsDst->setSorting(-1);
 #if 0
@@ -193,10 +199,10 @@
 				
 				newItem->setText(LAYOUT_COLUMN_VARIANT, layoutUnit.variant);
 				newItem->setText(LAYOUT_COLUMN_INCLUDE, layoutUnit.includeGroup);
+				newItem->setText(LAYOUT_COLUMN_DISPLAY_NAME, layoutUnit.displayName);
 				widget->listLayoutsDst->insertItem(newItem);
 				newItem->moveItem(widget->listLayoutsDst->lastItem());
 
-// 				m_includes[ layoutUnit ] = layoutUnit.includeGroup;
 				break;
 			}
 		}
@@ -274,13 +280,17 @@
 		QString layout = item->text(LAYOUT_COLUMN_MAP);
 		QString variant = item->text(LAYOUT_COLUMN_VARIANT);
 		QString includes = item->text(LAYOUT_COLUMN_INCLUDE);
+		QString displayName = item->text(LAYOUT_COLUMN_DISPLAY_NAME);
 		
 		LayoutUnit layoutUnit(layout, variant);
 		layoutUnit.includeGroup = includes;
+		layoutUnit.displayName = displayName;
 		layouts.append( layoutUnit );
 		
 		item = item->nextSibling();
-		kdDebug() << "Tosave: layout " << layoutUnit.toPair() << ", inc: " << \
layoutUnit.includeGroup << endl; +		kdDebug() << "To save: layout " << \
layoutUnit.toPair()  +				<< ", inc: " << layoutUnit.includeGroup 
+				<< ", disp: " << layoutUnit.displayName << endl;
 	}
 	m_kxkbConfig.m_layouts = layouts;
 
@@ -415,13 +425,38 @@
 }
 
 // helper
-static LayoutUnit getLayoutUnit(QListViewItem *sel)
+LayoutUnit LayoutConfig::getLayoutUnitKey(QListViewItem *sel)
 {
 	QString kbdLayout = sel->text(LAYOUT_COLUMN_MAP);
 	QString kbdVariant = sel->text(LAYOUT_COLUMN_VARIANT);
 	return LayoutUnit(kbdLayout, kbdVariant);
 }
 
+void LayoutConfig::displayNameChanged(const QString& newDisplayName)
+{
+	QListViewItem* selLayout = widget->listLayoutsDst->selectedItem();
+	
+	const LayoutUnit layoutUnitKey = getLayoutUnitKey( selLayout );
+	LayoutUnit& layoutUnit = *m_kxkbConfig.m_layouts.find(layoutUnitKey);
+	
+	QString oldName = selLayout->text(LAYOUT_COLUMN_DISPLAY_NAME);
+	 
+	if( oldName.isEmpty() )
+		oldName = KxkbConfig::getDefaultDisplayName( layoutUnit );
+	
+	if( oldName != newDisplayName ) {
+		kdDebug() << "setting " << layoutUnit.toPair() << " : " << newDisplayName << endl;
+		selLayout->setText(LAYOUT_COLUMN_DISPLAY_NAME, newDisplayName);
+		updateIndicator(selLayout);
+	//	emit changed();
+	}
+}
+
+void LayoutConfig::updateIndicator(QListViewItem* selLayout)
+{
+}
+
+
 void LayoutConfig::latinChanged()
 {
     QListViewItem* selLayout = widget->listLayoutsDst->selectedItem();
@@ -438,24 +473,24 @@
 		include = "";
 	selLayout->setText(LAYOUT_COLUMN_INCLUDE, include);
 
- 	LayoutUnit layoutUnitKey = getLayoutUnit(selLayout);
+ 	LayoutUnit layoutUnitKey = getLayoutUnitKey(selLayout);
 	kdDebug() << "layout " << layoutUnitKey.toPair() << ", inc: " << include << endl;
 }
 
 void LayoutConfig::layoutSelChanged(QListViewItem *sel)
 {
     widget->comboVariant->clear();
-    widget->comboVariant->setEnabled( sel != 0 );
+    widget->comboVariant->setEnabled( sel != NULL );
     widget->chkLatin->setChecked( false );
-    widget->chkLatin->setEnabled( sel != 0 );
+    widget->chkLatin->setEnabled( sel != NULL );
 
-    if( sel == 0 ) {
+    if( sel == NULL ) {
         updateLayoutCommand();
         return;
     }
 
 
-	LayoutUnit layoutUnitKey = getLayoutUnit(sel);
+	LayoutUnit layoutUnitKey = getLayoutUnitKey(sel);
 	QString kbdLayout = layoutUnitKey.layout;
 
 	// TODO: need better algorithm here for determining if needs us group
@@ -578,9 +613,10 @@
 void LayoutConfig::updateLayoutCommand()
 {
   QString setxkbmap;
+  QString layoutDisplayName;
   QListViewItem* sel = widget->listLayoutsDst->selectedItem();
 
-  if( sel ) {
+  if( sel != NULL ) {
     QString kbdLayout = sel->text(LAYOUT_COLUMN_MAP);
     QString variant = widget->comboVariant->currentText();
 	if( variant == DEFAULT_VARIANT_NAME )
@@ -593,6 +629,23 @@
       setxkbmap += "us,";
     setxkbmap += kbdLayout;
 
+/*	LayoutUnit layoutUnitKey = getLayoutUnitKey(sel);
+	layoutDisplayName = m_kxkbConfig.getLayoutDisplayName( \
*m_kxkbConfig.m_layouts.find(layoutUnitKey) );*/ +	layoutDisplayName = \
sel->text(LAYOUT_COLUMN_DISPLAY_NAME); +	if( layoutDisplayName.isEmpty() ) {
+		int count = 0;
+		QListViewItem *item = widget->listLayoutsDst->firstChild();
+		while (item) {
+			QString layout_ = item->text(LAYOUT_COLUMN_MAP);
+			if( layout_ == kbdLayout )
+				++count;
+			item = item->nextSibling();
+		}
+		bool single = count < 2;
+		layoutDisplayName = m_kxkbConfig.getDefaultDisplayName(LayoutUnit(kbdLayout, \
variant), single); +	}
+	kdDebug() << "disp: '" << layoutDisplayName << "'" << endl;
+	
     if( !variant.isEmpty() ) {
       setxkbmap += " -variant ";
       if( widget->chkLatin->isChecked() )
@@ -600,7 +653,11 @@
       setxkbmap += variant;
     }
   }
+  
   widget->editCmdLine->setText(setxkbmap);
+  
+  widget->editDisplayName->setEnabled( sel != NULL );
+  widget->editDisplayName->setText(layoutDisplayName);
 }
 
 void LayoutConfig::changed()
Index: kxkbconfig.h
===================================================================
--- kxkbconfig.h	(revision 525649)
+++ kxkbconfig.h	(working copy)
@@ -111,7 +111,9 @@
 	void setDefaults();
 	
 	QStringList getLayoutStringList(/*bool compact*/);
-	
+	static QString getDefaultDisplayName(const QString& code_);
+	static QString getDefaultDisplayName(const LayoutUnit& layoutUnit, bool \
single=false); +
 private:	
 	static const QMap<QString, QString> parseIncludesMap(const QStringList& pairList);
 };


["kcmlayout3.5.3.png" (image/png)]

>> 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