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

List:       kde-commits
Subject:    [kde-workspace/previewsoc13] kcontrol/keyboard: Cleanup and improvements for keyboard layout preview
From:       Andriy Rysin <arysin () gmail ! com>
Date:       2013-09-05 3:28:45
Message-ID: E1VHQFR-000460-DJ () scm ! kde ! org
[Download RAW message or body]

Git commit 9785ad6cc08a305f3f0adb5e7cd91bc0e9d2c9ab by Andriy Rysin.
Committed on 05/09/2013 at 03:28.
Pushed by rysin into branch 'previewsoc13'.

Cleanup and improvements for keyboard layout preview code

M  +2    -2    kcontrol/keyboard/CMakeLists.txt
M  +5    -3    kcontrol/keyboard/kcm_add_layout_dialog.cpp
M  +2    -2    kcontrol/keyboard/kcm_keyboard.ui
M  +21   -23   kcontrol/keyboard/kcm_keyboard_widget.cpp
M  +0    -3    kcontrol/keyboard/preview/TODO
M  +21   -25   kcontrol/keyboard/preview/geometry_parser.cpp
M  +6    -3    kcontrol/keyboard/preview/kbpreviewframe.cpp
M  +9    -27   kcontrol/keyboard/preview/keyaliases.cpp
M  +5    -0    kcontrol/keyboard/preview/keysymhelper.cpp
M  +3    -27   kcontrol/keyboard/preview/symbol_parser.cpp
M  +3    -2    kcontrol/keyboard/tests/CMakeLists.txt
M  +31   -0    kcontrol/keyboard/x11_helper.cpp
M  +1    -0    kcontrol/keyboard/x11_helper.h
M  +3    -0    kcontrol/keyboard/xkb_helper.cpp
M  +14   -32   kcontrol/keyboard/xkb_rules.cpp
M  +2    -2    kcontrol/keyboard/xkb_rules.h

http://commits.kde.org/kde-workspace/9785ad6cc08a305f3f0adb5e7cd91bc0e9d2c9ab

diff --git a/kcontrol/keyboard/CMakeLists.txt b/kcontrol/keyboard/CMakeLists.txt
index c9a0ae3..3a2e729 100644
--- a/kcontrol/keyboard/CMakeLists.txt
+++ b/kcontrol/keyboard/CMakeLists.txt
@@ -121,8 +121,8 @@ if(Boost_FOUND)
     preview/keysym2ucs.cpp)
   
 else(Boost_FOUND)
-  message("Boost not found, Install Boost Libraries to enable keyboard geometry preview.")
-  
+
+  message("Boost not found, install Boost libraries to enable keyboard geometry preview")
 
 endif(Boost_FOUND)
 
diff --git a/kcontrol/keyboard/kcm_add_layout_dialog.cpp b/kcontrol/keyboard/kcm_add_layout_dialog.cpp
index d893308..84bac6e 100644
--- a/kcontrol/keyboard/kcm_add_layout_dialog.cpp
+++ b/kcontrol/keyboard/kcm_add_layout_dialog.cpp
@@ -68,9 +68,10 @@ AddLayoutDialog::AddLayoutDialog(const Rules* rules_, Flags* flags_, bool showLa
     connect(layoutDialogUi->layoutComboBox, SIGNAL(activated(int)), this, SLOT(layoutChanged(int)));
 
 #ifdef NEW_GEOMETRY
-    connect(layoutDialogUi->prevbutton,SIGNAL(clicked()),this,SLOT(preview()));
+    connect(layoutDialogUi->prevbutton, SIGNAL(clicked()), this, SLOT(preview()));
+#else
+    layoutDialogUi->prevbutton->setVisible(false);
 #endif
-    layoutDialogUi->prevbutton->setEnabled(false);
 
 }
 
@@ -159,7 +160,8 @@ void AddLayoutDialog::accept()
 }
 
 #ifdef NEW_GEOMETRY
-void AddLayoutDialog::preview(){
+void AddLayoutDialog::preview()
+{
     int index = layoutDialogUi->variantComboBox->currentIndex();
     QString variant = layoutDialogUi->variantComboBox->itemData(index).toString();
     KeyboardPainter* layoutPreview = new KeyboardPainter();
diff --git a/kcontrol/keyboard/kcm_keyboard.ui b/kcontrol/keyboard/kcm_keyboard.ui
index f64eeea..892bf26 100644
--- a/kcontrol/keyboard/kcm_keyboard.ui
+++ b/kcontrol/keyboard/kcm_keyboard.ui
@@ -329,7 +329,7 @@
           </widget>
          </item>
          <item>
-          <widget class="QPushButton" name="previewbutton">
+          <widget class="QPushButton" name="previewButton">
            <property name="enabled">
             <bool>false</bool>
            </property>
@@ -433,7 +433,7 @@
    <attribute name="title">
     <string>Advanced</string>
    </attribute>
-   <layout class="QGridLayout" name="gridLayout">
+   <layout class="QGridLayout" name="gridLayout_7">
     <item row="0" column="0" colspan="2">
      <widget class="QCheckBox" name="configureKeyboardOptionsChk">
       <property name="text">
diff --git a/kcontrol/keyboard/kcm_keyboard_widget.cpp b/kcontrol/keyboard/kcm_keyboard_widget.cpp
index ede5ce6..72f4b4b 100644
--- a/kcontrol/keyboard/kcm_keyboard_widget.cpp
+++ b/kcontrol/keyboard/kcm_keyboard_widget.cpp
@@ -339,7 +339,7 @@ void KCMKeyboardWidget::initializeLayoutsUI()
 	connect(uiWidget->moveDownBtn, SIGNAL(clicked(bool)), this, SLOT(moveDown()));
 
 #ifdef NEW_GEOMETRY
-    connect(uiWidget->previewbutton,SIGNAL(clicked(bool)),this,SLOT(previewLayout()));
+    connect(uiWidget->previewButton, SIGNAL(clicked(bool)), this, SLOT(previewLayout()));
 #endif
 
 	connect(uiWidget->xkbGrpClearBtn, SIGNAL(clicked(bool)), this, SLOT(clearGroupShortcuts()));
@@ -366,37 +366,33 @@ void KCMKeyboardWidget::initializeLayoutsUI()
 	connect(uiWidget->layoutLoopingCheckBox, SIGNAL(clicked(bool)), this, SLOT(uiChanged()));
 	connect(uiWidget->layoutLoopCountSpinBox, SIGNAL(valueChanged(int)), this, SLOT(uiChanged()));
 }
+
 #ifdef NEW_GEOMETRY
 void KCMKeyboardWidget::previewLayout(){
-    QMessageBox q;
-    QModelIndex index = uiWidget->layoutsTableView->currentIndex() ;
+    QModelIndex index = uiWidget->layoutsTableView->currentIndex();
+    
     QModelIndex idcountry = index.sibling(index.row(),0) ;
     QString country=uiWidget->layoutsTableView->model()->data(idcountry).toString();
     QModelIndex idvariant = index.sibling(index.row(),2) ;
     QString variant=uiWidget->layoutsTableView->model()->data(idvariant).toString();
     QString model = keyboardConfig->keyboardModel;
-    q.setText(model);
-    q.exec();
-    if(index.row()==-1 || index.column()==-1){
-        q.setText(i18n("No layout selected "));
-        q.exec();
-    }
-    else{
-        KeyboardPainter* layoutPreview = new KeyboardPainter();
-        const LayoutInfo* layoutInfo = rules->getLayoutInfo(country);
-        foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) {
-            if(variant==variantInfo->description){
-                variant=variantInfo->name;
-                break;
-            }
-        }
 
-        layoutPreview->generateKeyboardLayout(country,variant,model);
-        layoutPreview->exec();
-        layoutPreview->setModal(true);
+    KeyboardPainter* layoutPreview = new KeyboardPainter();
+    const LayoutInfo* layoutInfo = rules->getLayoutInfo(country);
+    foreach(const VariantInfo* variantInfo, layoutInfo->variantInfos) {
+        if(variant==variantInfo->description){
+            variant=variantInfo->name;
+            break;
+        }
     }
+
+    layoutPreview->generateKeyboardLayout(country,variant,model);
+    layoutPreview->exec();
+    layoutPreview->setModal(true);
+    delete layoutPreview;
 }
 #endif
+
 void KCMKeyboardWidget::configureLayoutsChanged()
 {
 	if( uiWidget->layoutsGroupBox->isChecked()	&& keyboardConfig->layouts.isEmpty() ) {
@@ -425,11 +421,13 @@ void KCMKeyboardWidget::layoutSelectionChanged()
 	uiWidget->removeLayoutBtn->setEnabled( ! selected.isEmpty() );
 	QPair<int, int> rowsRange( getSelectedRowRange(selected) );
 	uiWidget->moveUpBtn->setEnabled( ! selected.isEmpty() && rowsRange.first > 0);
+
 #ifdef NEW_GEOMETRY
-    uiWidget->previewbutton->setEnabled(! selected.isEmpty());
+    uiWidget->previewButton->setEnabled( \
uiWidget->layoutsTableView->selectionModel()->selectedRows().size() == 1 );  #else
-    uiWidget->previewbutton->setEnabled(false);
+    uiWidget->previewButton->setVisible(false);
 #endif
+
     uiWidget->moveDownBtn->setEnabled( ! selected.isEmpty() && rowsRange.second < \
keyboardConfig->layouts.size()-1 );  }
 
diff --git a/kcontrol/keyboard/preview/TODO b/kcontrol/keyboard/preview/TODO
index 784924f..6920404 100644
--- a/kcontrol/keyboard/preview/TODO
+++ b/kcontrol/keyboard/preview/TODO
@@ -1,9 +1,6 @@
 Important:
-* display tooltip for each key with key description from symbol file
 
 Good to have:
-* read keyboard geometry and show it properly instead of default keyboard
-* use some common parser to parse symbol and geometry descriptions
 * replace symkey2ucs with something more reliable (e.g. XLookupString?)
 
 Cleanup:
diff --git a/kcontrol/keyboard/preview/geometry_parser.cpp \
b/kcontrol/keyboard/preview/geometry_parser.cpp index 6882e7d..954aafb 100644
--- a/kcontrol/keyboard/preview/geometry_parser.cpp
+++ b/kcontrol/keyboard/preview/geometry_parser.cpp
@@ -1,5 +1,24 @@
+/*
+ *  Copyright (C) 2013 Shivam Makkar (amourphious1992@gmail.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
 #include "geometry_parser.h"
 #include "geometry_components.h"
+#include "x11_helper.h"
 
 #include <QtCore/QString>
 #include <QtCore/QStringList>
@@ -530,33 +549,10 @@ template<typename Iterator>
 
     }
 
-
-
     QString findGeometryBaseDir()
     {
-        QString xkbParentDir;
-
-        QString base(XLIBDIR);
-        if( base.count('/') >= 3 ) {
-            // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
-            QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
-            QDir baseDir(base + delta);
-            if( baseDir.exists() ) {
-                xkbParentDir = baseDir.absolutePath();
-            }
-            else {
-                QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
-                if( baseDir.exists() ) {
-                    xkbParentDir = baseDir.absolutePath();
-                }
-            }
-        }
-
-        if( xkbParentDir.isEmpty() ) {
-            xkbParentDir = "/usr/share/X11";
-        }
-
-        return QString("%1/xkb/geometry/").arg(xkbParentDir);
+        QString xkbDir = X11Helper::findXkbDir();
+        return QString("%1/geometry/").arg(xkbDir);
     }
 
 }
diff --git a/kcontrol/keyboard/preview/kbpreviewframe.cpp b/kcontrol/keyboard/preview/kbpreviewframe.cpp
index 91a6a46..f6af4b6 100644
--- a/kcontrol/keyboard/preview/kbpreviewframe.cpp
+++ b/kcontrol/keyboard/preview/kbpreviewframe.cpp
@@ -37,7 +37,8 @@
 
 static const QColor keyBorderColor("#d4d4d4");
 static const QColor lev12color(Qt::black);
-static const QColor lev34color("#FF3300");
+static const QColor lev34color("#0033FF");
+static const QColor unknownSymbolColor("#FF3300");
 static const int xOffset[] = {10, 10, -15, -15 };
 static const int yOffset[] = {5, -20, 5, -20 };
 static const QColor color[] = { lev12color, lev12color, lev34color, lev34color };
@@ -72,8 +73,10 @@ void KbPreviewFrame::drawKeySymbols(QPainter &painter,QPoint temp[], const GShap
         float tooltipX = 0, toolTipY = 0;
         QString tip;
         for(int level=0; level< (key.getSymbolCount() < 4 ? key.getSymbolCount() : 4); level++) {
-            painter.setPen(color[level]);
-            painter.drawText(temp[cordinate[level]].x()+xOffset[level], \
temp[cordinate[level]].y()+yOffset[level], sz, sz, Qt::AlignTop, \
symbol.getKeySymbol(key.getSymbol(level))); +            QString txt = \
symbol.getKeySymbol(key.getSymbol(level)); +            QColor txtColor = txt[0] == -1 ? \
unknownSymbolColor : color[level]; +            painter.setPen(txtColor);
+            painter.drawText(temp[cordinate[level]].x()+xOffset[level], \
temp[cordinate[level]].y()+yOffset[level], sz, sz, Qt::AlignTop, txt);  \
tip.append(key.getSymbol(level)+"\n");  }
         for(int i = 0 ; i < 4; i++){
diff --git a/kcontrol/keyboard/preview/keyaliases.cpp b/kcontrol/keyboard/preview/keyaliases.cpp
index b564595..f040136 100644
--- a/kcontrol/keyboard/preview/keyaliases.cpp
+++ b/kcontrol/keyboard/preview/keyaliases.cpp
@@ -17,6 +17,8 @@
  */
 
 #include "keyaliases.h"
+#include "x11_helper.h"
+
 #include <QtCore/QString>
 #include <QtCore/QMap>
 #include <QtGui/QMessageBox>
@@ -88,40 +90,20 @@ Aliases::Aliases()
 QString Aliases::getAlias(const QString& cname, const QString& name)
 {
     QMessageBox q;
-    QString a=name;
+    QString a = name;
+
     if(cname=="ma" || cname == "be" || cname == "fr"){
         a=azerty.value(name);
     }
     else{
         a=qwerty.value(name);
     }
+
     return a;
 }
 
-QString Aliases::findaliasdir(){
-
-    QString aliasdir;
-    QString xkbParentDir;
-
-    QString base(XLIBDIR);
-    if( base.count('/') >= 3 ) {
-        // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
-        QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
-        QDir baseDir(base + delta);
-        if( baseDir.exists() ) {
-            xkbParentDir = baseDir.absolutePath();
-        }
-        else {
-            QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
-            if( baseDir.exists() ) {
-                xkbParentDir = baseDir.absolutePath();
-            }
-        }
-    }
-
-    if( xkbParentDir.isEmpty() ) {
-        xkbParentDir = "/usr/share/X11";
-    }
-    aliasdir=QString("%1/xkb/keycodes/aliases").arg(xkbParentDir);
-    return(aliasdir);
+QString Aliases::findaliasdir()
+{
+    QString xkbDir = X11Helper::findXkbDir();
+    return QString("%1/keycodes/aliases").arg(xkbDir);
 }
diff --git a/kcontrol/keyboard/preview/keysymhelper.cpp b/kcontrol/keyboard/preview/keysymhelper.cpp
index 67beb80..b84b9d1 100644
--- a/kcontrol/keyboard/preview/keysymhelper.cpp
+++ b/kcontrol/keyboard/preview/keysymhelper.cpp
@@ -46,6 +46,11 @@ QString KeySymHelper::getKeySymbol(const QString& opton)
 #else
 
     KeySym keysym = XStringToKeysym(str);
+
+    //TODO: make it more generic
+//    if( keysym == 0xfe03 )
+//	return "L3";
+    
     long ucs = keysym2ucs(keysym);
 
 //    if( ucs == -1 && (keysym >= 0xFE50 && keysym <= 0xFE5F) ) {
diff --git a/kcontrol/keyboard/preview/symbol_parser.cpp b/kcontrol/keyboard/preview/symbol_parser.cpp
index dac8fe6..ea58219 100644
--- a/kcontrol/keyboard/preview/symbol_parser.cpp
+++ b/kcontrol/keyboard/preview/symbol_parser.cpp
@@ -1,6 +1,7 @@
 #include "symbol_parser.h"
 #include "keyboardlayout.h"
 #include "keyaliases.h"
+#include "x11_helper.h"
 
 #include <QtCore/QString>
 #include <QtCore/QStringList>
@@ -9,10 +10,6 @@
 #include <QFile>
 
 
-#include <fixx11h.h>
-#include <config-workspace.h>
-
-
 
 namespace grammar{
 
@@ -127,29 +124,8 @@ void Symbol_parser<Iterator>::setName(std::string n){
 
 QString findSymbolBaseDir()
 {
-    QString xkbParentDir;
-
-    QString base(XLIBDIR);
-    if( base.count('/') >= 3 ) {
-        // .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
-        QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
-        QDir baseDir(base + delta);
-        if( baseDir.exists() ) {
-            xkbParentDir = baseDir.absolutePath();
-        }
-        else {
-            QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
-            if( baseDir.exists() ) {
-                xkbParentDir = baseDir.absolutePath();
-            }
-        }
-    }
-
-    if( xkbParentDir.isEmpty() ) {
-        xkbParentDir = "/usr/share/X11";
-    }
-
-    return QString("%1/xkb/symbols/").arg(xkbParentDir);
+    QString xkbDir = X11Helper::findXkbDir();
+    return QString("%1/symbols/").arg(xkbDir);
 }
 
 
diff --git a/kcontrol/keyboard/tests/CMakeLists.txt b/kcontrol/keyboard/tests/CMakeLists.txt
index d06b1b4..eb0dd1e 100644
--- a/kcontrol/keyboard/tests/CMakeLists.txt
+++ b/kcontrol/keyboard/tests/CMakeLists.txt
@@ -1,7 +1,7 @@
 set ( text_paint_LIB ${KDE4_PLASMA_LIBS} )
 
 MACRO(KEYBOARD_DAEMON_UNIT_TESTS _testname)
-               kde4_add_unit_test(${_testname}_test TESTNAME kcm-keyboard-${_testname} NOGUI \
${_testname}_test.cpp ../${_testname}.cpp) +               kde4_add_unit_test(${_testname}_test TESTNAME \
                kcm-keyboard-${_testname} NOGUI ${_testname}_test.cpp ../${_testname}.cpp \
                ../x11_helper.cpp)
                target_link_libraries(${_testname}_test ${KDE4_KDEUI_LIBS} ${QT_QTXML_LIBRARY} \
${QT_QTTEST_LIBRARY} ${X11_Xkbfile_LIB} ${X11_LIBRARIES})  ENDMACRO(KEYBOARD_DAEMON_UNIT_TESTS)
 
@@ -21,8 +21,9 @@ if(Boost_FOUND)
     set (CMAKE_CXX_FLAGS "-fpermissive")
 
     ADD_DEFINITIONS(-DNEW_GEOMETRY=1)
+    include_directories(..)
 
-    kde4_add_unit_test(geometry_parser_test TESTNAME geometry_parser NOGUI \
../preview/geometry_parser.cpp ../preview/geometry_components.cpp geometry_parser_test.cpp) +    \
kde4_add_unit_test(geometry_parser_test TESTNAME geometry_parser NOGUI ../preview/geometry_parser.cpp \
                ../preview/geometry_components.cpp geometry_parser_test.cpp ../x11_helper.cpp)
     target_link_libraries(geometry_parser_test ${KDE4_KDEUI_LIBS} ${QT_QTTEST_LIBRARY} ${X11_LIBRARIES})
 endif(Boost_FOUND)
 
diff --git a/kcontrol/keyboard/x11_helper.cpp b/kcontrol/keyboard/x11_helper.cpp
index ebd09f3..dc82d0f 100644
--- a/kcontrol/keyboard/x11_helper.cpp
+++ b/kcontrol/keyboard/x11_helper.cpp
@@ -21,6 +21,7 @@
 #include <kapplication.h>
 #include <kdebug.h>
 
+#include <QtCore/QDir>
 #include <QtGui/QX11Info>
 
 #include <X11/X.h>
@@ -29,6 +30,7 @@
 #include <X11/XKBlib.h>
 #include <X11/extensions/XKBrules.h>
 #include <fixx11h.h>
+#include <config-workspace.h>
 
 
 // more information about the limit https://bugs.freedesktop.org/show_bug.cgi?id=19501
@@ -397,4 +399,33 @@ QString LayoutUnit::toString() const
 	return layout + LAYOUT_VARIANT_SEPARATOR_PREFIX+variant+LAYOUT_VARIANT_SEPARATOR_SUFFIX;
 }
 
+QString X11Helper::findXkbDir()
+{
+	QString rulesDir;
+
+	QString xkbParentDir;
+
+	QString base(XLIBDIR);
+	if( base.count('/') >= 3 ) {
+		// .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
+		QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
+		QDir baseDir(base + delta);
+		if( baseDir.exists() ) {
+			xkbParentDir = baseDir.absolutePath();
+		}
+		else {
+			QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
+			if( baseDir.exists() ) {
+				xkbParentDir = baseDir.absolutePath();
+			}
+		}
+	}
+
+	if( xkbParentDir.isEmpty() ) {
+		xkbParentDir = "/usr/share/X11";
+	}
+
+	return xkbParentDir + "/xkb";
+}
+
 const int LayoutUnit::MAX_LABEL_LENGTH = 3;
diff --git a/kcontrol/keyboard/x11_helper.h b/kcontrol/keyboard/x11_helper.h
index 31f76f9..dea1c03 100644
--- a/kcontrol/keyboard/x11_helper.h
+++ b/kcontrol/keyboard/x11_helper.h
@@ -171,6 +171,7 @@ public:
 
 	enum FetchType { ALL, LAYOUTS_ONLY, MODEL_ONLY };
 	static bool getGroupNames(Display* dpy, XkbConfig* xkbConfig, FetchType fetchType);
+        static QString findXkbDir();
 
 private:
 	static unsigned int getGroup();
diff --git a/kcontrol/keyboard/xkb_helper.cpp b/kcontrol/keyboard/xkb_helper.cpp
index 60bf5a8..21cd6bf 100644
--- a/kcontrol/keyboard/xkb_helper.cpp
+++ b/kcontrol/keyboard/xkb_helper.cpp
@@ -30,6 +30,9 @@
 #include <kprocess.h>
 #include <kdebug.h>
 
+//#include <fixx11h.h>
+//#include <config-workspace.h>
+
 #include "keyboard_config.h"
 
 
diff --git a/kcontrol/keyboard/xkb_rules.cpp b/kcontrol/keyboard/xkb_rules.cpp
index 616e7b8..f09d436 100644
--- a/kcontrol/keyboard/xkb_rules.cpp
+++ b/kcontrol/keyboard/xkb_rules.cpp
@@ -39,8 +39,8 @@
 #include <X11/Xatom.h>
 #include <X11/XKBlib.h>
 #include <X11/extensions/XKBrules.h>
-#include <fixx11h.h>
-#include <config-workspace.h>
+//#include <fixx11h.h>
+//#include <config-workspace.h>
 
 
 class RulesHandler : public QXmlDefaultHandler
@@ -147,36 +147,18 @@ QString Rules::getRulesName()
 
 static QString findXkbRulesFile()
 {
-	QString rulesFile;
-	QString rulesName = Rules::getRulesName();
-
-	if ( ! rulesName.isNull() ) {
-		QString xkbParentDir;
-
-		QString base(XLIBDIR);
-		if( base.count('/') >= 3 ) {
-			// .../usr/lib/X11 -> /usr/share/X11/xkb vs .../usr/X11/lib -> /usr/X11/share/X11/xkb
-			QString delta = base.endsWith("X11") ? "/../../share/X11" : "/../share/X11";
-			QDir baseDir(base + delta);
-			if( baseDir.exists() ) {
-				xkbParentDir = baseDir.absolutePath();
-			}
-			else {
-				QDir baseDir(base + "/X11");	// .../usr/X11/lib/X11/xkb (old XFree)
-				if( baseDir.exists() ) {
-					xkbParentDir = baseDir.absolutePath();
-				}
-			}
-		}
-
-		if( xkbParentDir.isEmpty() ) {
-			xkbParentDir = "/usr/share/X11";
-		}
-
-		rulesFile = QString("%1/xkb/rules/%2.xml").arg(xkbParentDir, rulesName);
-	}
-
-	return rulesFile;
+    QString xkbDir;
+    
+    QString rulesName = Rules::getRulesName();
+    if ( ! rulesName.isNull() ) {
+	xkbDir = X11Helper::findXkbDir();
+    }
+    
+    if( xkbDir.isEmpty() )
+	return xkbDir;
+	
+    return QString("%1/rules/%2.xml").arg(xkbDir, rulesName);
+ 
 }
 
 static
diff --git a/kcontrol/keyboard/xkb_rules.h b/kcontrol/keyboard/xkb_rules.h
index 2be8562..b54ce9a 100644
--- a/kcontrol/keyboard/xkb_rules.h
+++ b/kcontrol/keyboard/xkb_rules.h
@@ -44,7 +44,7 @@ struct VariantInfo: public ConfigItem {
 	const bool fromExtras;
 
 	VariantInfo(bool fromExtras_):
-		fromExtras(fromExtras_) {}
+	fromExtras(fromExtras_) {}
 };
 
 struct LayoutInfo: public ConfigItem {
@@ -54,7 +54,7 @@ struct LayoutInfo: public ConfigItem {
 
 //	LayoutInfo() {}
 	LayoutInfo(bool fromExtras_):
-		fromExtras(fromExtras_) {}
+	fromExtras(fromExtras_) {}
 	~LayoutInfo() { foreach(VariantInfo* variantInfo, variantInfos) delete variantInfo; }
 
 	VariantInfo* getVariantInfo(const QString& variantName) const {


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

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