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

List:       kde-commits
Subject:    [plasma-desktop] kcms/keyboard: porting to Qt5/KDE5
From:       Andriy Rysin <arysin () gmail ! com>
Date:       2014-04-22 1:37:03
Message-ID: E1WcPdv-00032m-Rd () scm ! kde ! org
[Download RAW message or body]

Git commit 7f31fd5fb1b29feb9c8e97fea0d95f46c6dac4db by Andriy Rysin.
Committed on 22/04/2014 at 01:36.
Pushed by rysin into branch 'master'.

porting to Qt5/KDE5

M  +2    -15   kcms/keyboard/kcm_keyboard.ui
M  +3    -2    kcms/keyboard/layout_tray_icon.cpp
M  +0    -1    kcms/keyboard/preview/kbpreviewframe.cpp
M  +16   -16   kcms/keyboard/x11_helper.cpp
M  +8    -11   kcms/keyboard/xinput_helper.cpp
M  +11   -12   kcms/keyboard/xkb_helper.cpp
M  +6    -6    kcms/keyboard/xkb_rules.cpp

http://commits.kde.org/plasma-desktop/7f31fd5fb1b29feb9c8e97fea0d95f46c6dac4db

diff --git a/kcms/keyboard/kcm_keyboard.ui b/kcms/keyboard/kcm_keyboard.ui
index 57bb251..0062d1c 100644
--- a/kcms/keyboard/kcm_keyboard.ui
+++ b/kcms/keyboard/kcm_keyboard.ui
@@ -97,7 +97,7 @@
     <item row="0" column="0">
      <layout class="QHBoxLayout" name="horizontalLayout_3">
       <item>
-       <widget class="KButtonGroup" name="kbuttongroup">
+       <widget class="QGroupBox" name="kbuttongroup">
         <property name="title">
          <string>Layout Indicator</string>
         </property>
@@ -141,7 +141,7 @@
        </widget>
       </item>
       <item>
-       <widget class="KButtonGroup" name="switchingPolicyButtonGroup">
+       <widget class="QGroupBox" name="switchingPolicyButtonGroup">
         <property name="whatsThis">
          <string>If you select &quot;Application&quot; or &quot;Window&quot; \
switching policy, changing the keyboard layout will only affect the current \
application or window.</string>  </property>
@@ -460,19 +460,6 @@
    </layout>
   </widget>
  </widget>
- <customwidgets>
-  <customwidget>
-   <class>KButtonGroup</class>
-   <extends>QGroupBox</extends>
-   <header>kbuttongroup.h</header>
-   <container>1</container>
-  </customwidget>
-  <customwidget>
-   <class>KKeySequenceWidget</class>
-   <extends>QWidget</extends>
-   <header>kkeysequencewidget.h</header>
-  </customwidget>
- </customwidgets>
  <resources/>
  <connections/>
  <slots>
diff --git a/kcms/keyboard/layout_tray_icon.cpp b/kcms/keyboard/layout_tray_icon.cpp
index 814c560..5f5bf2a 100644
--- a/kcms/keyboard/layout_tray_icon.cpp
+++ b/kcms/keyboard/layout_tray_icon.cpp
@@ -21,7 +21,8 @@
 //#include <kdebug.h>
 #include <kstatusnotifieritem.h>
 #include <klocalizedstring.h>
-#include <kmenu.h>
+
+#include <qmenu.h>
 
 #include "xkb_rules.h"
 #include "x11_helper.h"
@@ -46,7 +47,7 @@ LayoutTrayIcon::LayoutTrayIcon(const Rules* rules_, const \
                KeyboardConfig& keyboa
     m_notifierItem->setToolTipTitle(i18nc("tooltip title", "Keyboard Layout"));
     m_notifierItem->setTitle(i18nc("tooltip title", "Keyboard Layout"));
 
-	KMenu* menu = new KMenu("");
+	QMenu* menu = new QMenu("");
     m_notifierItem->setContextMenu(menu);
 	m_notifierItem->setStandardActionsEnabled(false);
 
diff --git a/kcms/keyboard/preview/kbpreviewframe.cpp \
b/kcms/keyboard/preview/kbpreviewframe.cpp index f9cc5a3..3368355 100644
--- a/kcms/keyboard/preview/kbpreviewframe.cpp
+++ b/kcms/keyboard/preview/kbpreviewframe.cpp
@@ -22,7 +22,6 @@
 #include <QFile>
 #include <QFont>
 
-#include <KApplication>
 #include <KLocalizedString>
 
 
diff --git a/kcms/keyboard/x11_helper.cpp b/kcms/keyboard/x11_helper.cpp
index 7790902..0e2806e 100644
--- a/kcms/keyboard/x11_helper.cpp
+++ b/kcms/keyboard/x11_helper.cpp
@@ -22,10 +22,10 @@
 #include <xcb/xkb.h>
 #undef explicit
 
-#include <kdebug.h>
 
 #include <QX11Info>
 #include <QCoreApplication>
+#include <QDebug>
 
 #include <X11/X.h>
 #include <X11/Xlib.h>
@@ -52,7 +52,7 @@ bool X11Helper::xkbSupported(int* xkbOpcode)
 
     if (!XkbLibraryVersion(&major, &minor))
     {
-        kWarning() << "Xlib XKB extension " << major << '.' << minor <<
+        qWarning() << "Xlib XKB extension " << major << '.' << minor <<
             " != " << XkbMajorVersion << '.' << XkbMinorVersion;
         return false;
     }
@@ -63,7 +63,7 @@ bool X11Helper::xkbSupported(int* xkbOpcode)
     int error_rtrn;
     int xkb_opcode;
     if( ! XkbQueryExtension(QX11Info::display(), &opcode_rtrn, &xkb_opcode, \
                &error_rtrn, &major, &minor)) {
-        kWarning() << "X server XKB extension " << major << '.' << minor <<
+        qWarning() << "X server XKB extension " << major << '.' << minor <<
             " != " << XkbMajorVersion << '.' << XkbMinorVersion;
         return false;
     }
@@ -105,7 +105,7 @@ bool X11Helper::setLayout(const LayoutUnit& layout)
 	QList<LayoutUnit> currentLayouts = getLayoutsList();
 	int idx = currentLayouts.indexOf(layout);
 	if( idx == -1 || idx >= X11Helper::MAX_GROUP_COUNT ) {
-		kWarning() << "Layout" << layout.toString() << "is not found in current layout \
list" +		qWarning() << "Layout" << layout.toString() << "is not found in current \
layout list"  << getLayoutsListAsString(currentLayouts);
 		return false;
 	}
@@ -128,7 +128,7 @@ LayoutUnit X11Helper::getCurrentLayout()
 	if( group < (unsigned int)currentLayouts.size() )
 		return currentLayouts[group];
 
-	kWarning() << "Current group number" << group << "is outside of current layout \
list" << +	qWarning() << "Current group number" << group << "is outside of current \
layout list" <<  getLayoutsListAsString(currentLayouts);
 	return LayoutUnit();
 }
@@ -145,7 +145,7 @@ LayoutSet X11Helper::getCurrentLayouts()
 		layoutSet.currentLayout = currentLayouts[group];
 	}
 	else {
-		kWarning() << "Current group number" << group << "is outside of current layout \
list" << getLayoutsListAsString(currentLayouts); +		qWarning() << "Current group \
number" << group << "is outside of current layout list" << \
getLayoutsListAsString(currentLayouts);  layoutSet.currentLayout = LayoutUnit();
 	}
 
@@ -187,7 +187,7 @@ QList<LayoutUnit> X11Helper::getLayoutsList()
 //		}
 	}
 	else {
-		kWarning() << "Failed to get layout groups from X server";
+		qWarning() << "Failed to get layout groups from X server";
 	}
 	return layouts;
 }
@@ -234,7 +234,7 @@ bool X11Helper::getGroupNames(Display* display, XkbConfig* \
xkbConfig, FetchType  
 	/* no such atom! */
 	if (rules_atom == None) {       /* property cannot exist */
-		kWarning() << "Failed to fetch layouts from server:" << "could not find the atom" \
<< _XKB_RF_NAMES_PROP_ATOM; +		qWarning() << "Failed to fetch layouts from server:" \
<< "could not find the atom" << _XKB_RF_NAMES_PROP_ATOM;  return false;
 	}
 
@@ -247,7 +247,7 @@ bool X11Helper::getGroupNames(Display* display, XkbConfig* \
xkbConfig, FetchType  
 	/* property not found! */
 	if (ret != Success) {
-		kWarning() << "Failed to fetch layouts from server:" << "Could not get the \
property"; +		qWarning() << "Failed to fetch layouts from server:" << "Could not get \
the property";  return false;
 	}
 
@@ -255,7 +255,7 @@ bool X11Helper::getGroupNames(Display* display, XkbConfig* \
xkbConfig, FetchType  if ((extra_bytes > 0) || (real_prop_type != XA_STRING) || (fmt \
!= 8)) {  if (prop_data)
 			XFree(prop_data);
-		kWarning() << "Failed to fetch layouts from server:" << "Wrong property format";
+		qWarning() << "Failed to fetch layouts from server:" << "Wrong property format";
 		return false;
 	}
 
@@ -279,21 +279,21 @@ bool X11Helper::getGroupNames(Display* display, XkbConfig* \
xkbConfig, FetchType  xkbConfig->layouts << (layouts[ii] != NULL ? layouts[ii] : "");
 			xkbConfig->variants << (ii < variants.count() && variants[ii] != NULL ? \
variants[ii] : "");  }
-		kDebug() << "Fetched layout groups from X server:"
+		qDebug() << "Fetched layout groups from X server:"
 				<< "\tlayouts:" << xkbConfig->layouts
 				<< "\tvariants:" << xkbConfig->variants;
 	}
 
 	if( fetchType == ALL || fetchType == MODEL_ONLY ) {
 		xkbConfig->keyboardModel = (names[1] != NULL ? names[1] : "");
-		kDebug() << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel;
+		qDebug() << "Fetched keyboard model from X server:" << xkbConfig->keyboardModel;
 	}
 
 	if( fetchType == ALL ) {
 		if( names.count() >= 5 ) {
 			QString options = (names[4] != NULL ? names[4] : "");
 			xkbConfig->options = options.split(OPTIONS_SEPARATOR);
-			kDebug() << "Fetched xkbOptions from X server:" << options;
+			qDebug() << "Fetched xkbOptions from X server:" << options;
 		}
 	}
 
@@ -305,13 +305,13 @@ XEventNotifier::XEventNotifier():
 		xkbOpcode(-1)
 {
 	if( QCoreApplication::instance() == NULL ) {
-		kWarning() << "Layout Widget won't work properly without KApplication instance";
+		qWarning() << "Layout Widget won't work properly without QCoreApplication \
instance";  }
 }
 
 void XEventNotifier::start()
 {
-	kDebug() << "qCoreApp" << QCoreApplication::instance();
+	qDebug() << "qCoreApp" << QCoreApplication::instance();
 	if( QCoreApplication::instance() != NULL && X11Helper::xkbSupported(&xkbOpcode) ) {
 		registerForXkbEvents(QX11Info::display());
 
@@ -406,7 +406,7 @@ int XEventNotifier::registerForXkbEvents(Display* display)
 {
     int eventMask = XkbNewKeyboardNotifyMask | XkbStateNotifyMask;
     if( ! XkbSelectEvents(display, XkbUseCoreKbd, eventMask, eventMask) ) {
-    	kWarning() << "Couldn't select desired XKB events";
+    	qWarning() << "Couldn't select desired XKB events";
     	return false;
     }
     return true;
diff --git a/kcms/keyboard/xinput_helper.cpp b/kcms/keyboard/xinput_helper.cpp
index ada7d66..b311579 100644
--- a/kcms/keyboard/xinput_helper.cpp
+++ b/kcms/keyboard/xinput_helper.cpp
@@ -18,10 +18,9 @@
 
 #include "xinput_helper.h"
 
-#include <kapplication.h>
-#include <kdebug.h>
-
+#include <QCoreApplication>
 #include <QX11Info>
+#include <QDebug>
 
 #include <X11/X.h>
 #include <X11/Xlib.h>
@@ -31,8 +30,6 @@
 #include <X11/extensions/XInput.h>
 #endif
 
-#include <fixx11h.h>
-
 #include "x11_helper.h"
 
 #include <fixx11h.h>
@@ -49,7 +46,7 @@ XInputEventNotifier::XInputEventNotifier(QWidget* parent):
 
 void XInputEventNotifier::start()
 {
-	if( KApplication::kApplication() != NULL ) {
+	if( QCoreApplication::instance() != NULL ) {
 		registerForNewDeviceEvent(QX11Info::display());
 	}
 
@@ -60,7 +57,7 @@ void XInputEventNotifier::stop()
 {
 	XEventNotifier::stop();
 
-	if( KApplication::kApplication() != NULL ) {
+	if( QCoreApplication::instance() != NULL ) {
 	//    XEventNotifier::unregisterForNewDeviceEvent(QX11Info::display());
 	}
 }
@@ -113,13 +110,13 @@ int \
                XInputEventNotifier::getNewDeviceEventType(xcb_generic_event_t* \
                event)
 						if( devices[i].use == IsXKeyboard || devices[i].use == IsXExtensionKeyboard ) \
{  if( isRealKeyboard(devices[i].name) ) {
 								newDeviceType = DEVICE_KEYBOARD;
-								kDebug() << "new keyboard device, id:" << devices[i].id << "name:" << \
devices[i].name << "used as:" << devices[i].use; +								qDebug() << "new keyboard \
device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << \
devices[i].use;  break;
 							}
 						}
 						if( devices[i].use == IsXPointer || devices[i].use == IsXExtensionPointer ) {
 							newDeviceType = DEVICE_POINTER;
-							kDebug() << "new pointer device, id:" << devices[i].id << "name:" << \
devices[i].name << "used as:" << devices[i].use; +							qDebug() << "new pointer \
device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << \
devices[i].use;  break;
 						}
 					}
@@ -139,7 +136,7 @@ int XInputEventNotifier::registerForNewDeviceEvent(Display* \
display)  
 	DevicePresence(display, xitype, xiclass);
 	XSelectExtensionEvent(display, DefaultRootWindow(display), &xiclass, 1);
-	kDebug() << "Registered for new device events from XInput, class" << xitype;
+	qDebug() << "Registered for new device events from XInput, class" << xitype;
 	xinputEventType = xitype;
 	return xitype;
 }
@@ -152,7 +149,7 @@ int XInputEventNotifier::registerForNewDeviceEvent(Display* \
display)  
 int XInputEventNotifier::registerForNewDeviceEvent(Display* /*display*/)
 {
-	kWarning() << "Keyboard kded daemon is compiled without XInput, xkb configuration \
will be reset when new keyboard device is plugged in!"; +	qWarning() << "Keyboard \
kded daemon is compiled without XInput, xkb configuration will be reset when new \
keyboard device is plugged in!";  return -1;
 }
 
diff --git a/kcms/keyboard/xkb_helper.cpp b/kcms/keyboard/xkb_helper.cpp
index 1096987..967399e 100644
--- a/kcms/keyboard/xkb_helper.cpp
+++ b/kcms/keyboard/xkb_helper.cpp
@@ -24,11 +24,10 @@
 #include <QStringList>
 #include <QTime>
 #include <QX11Info>
+#include <QStandardPaths>
+#include <QDebug>
 
-#include <kglobal.h>
-#include <kstandarddirs.h>
 #include <kprocess.h>
-#include <kdebug.h>
 
 #include "keyboard_config.h"
 
@@ -51,10 +50,10 @@ QString getSetxkbmapExe()
 		return "";
 
 	if( setxkbmapExe.isEmpty() ) {
-		setxkbmapExe = KGlobal::dirs()->findExe(SETXKBMAP_EXEC);
+		setxkbmapExe = QStandardPaths::findExecutable(SETXKBMAP_EXEC);
 		if( setxkbmapExe.isEmpty() ) {
 			setxkbmapNotFound = true;
-			kError() << "Can't find" << SETXKBMAP_EXEC << "- keyboard layouts won't be \
configured"; +			qCritical() << "Can't find" << SETXKBMAP_EXEC << "- keyboard layouts \
won't be configured";  return "";
 		}
 	}
@@ -69,10 +68,10 @@ void executeXmodmap(const QString& configFileName)
 
     if( QFile(configFileName).exists() ) {
     	if( xmodmapExe.isEmpty() ) {
-    		xmodmapExe = KGlobal::dirs()->findExe(XMODMAP_EXEC);
+    		xmodmapExe = QStandardPaths::findExecutable(XMODMAP_EXEC);
         	if( xmodmapExe.isEmpty() ) {
     			xmodmapNotFound = true;
-    			kError() << "Can't find" << XMODMAP_EXEC << "- xmodmap files won't be run";
+    			qCritical() << "Can't find" << XMODMAP_EXEC << "- xmodmap files won't be \
run";  return;
         	}
     	}
@@ -80,9 +79,9 @@ void executeXmodmap(const QString& configFileName)
     	KProcess xmodmapProcess;
     	xmodmapProcess << xmodmapExe;
     	xmodmapProcess << configFileName;
-    	kDebug() << "Executing" << xmodmapProcess.program().join(" ");
+    	qDebug() << "Executing" << xmodmapProcess.program().join(" ");
     	if( xmodmapProcess.execute() != 0 ) {
-    		kError() << "Failed to execute " << xmodmapProcess.program();
+    		qCritical() << "Failed to execute " << xmodmapProcess.program();
     	}
     }
 }
@@ -108,13 +107,13 @@ bool XkbHelper::runConfigLayoutCommand(const QStringList& \
setxkbmapCommandArgume  int res = setxkbmapProcess.execute();
 
 	if( res == 0 ) {	// restore Xmodmap mapping reset by setxkbmap
-		kDebug() << "Executed successfully in " << timer.elapsed() << "ms" << \
setxkbmapProcess.program().join(" "); +		qDebug() << "Executed successfully in " << \
timer.elapsed() << "ms" << setxkbmapProcess.program().join(" ");  restoreXmodmap();
-		kDebug() << "\t and with xmodmap" << timer.elapsed() << "ms";
+		qDebug() << "\t and with xmodmap" << timer.elapsed() << "ms";
 	    return true;
 	}
 	else {
-		kError() << "Failed to run" << setxkbmapProcess.program().join(" ") << "return \
code:" << res; +		qCritical() << "Failed to run" << setxkbmapProcess.program().join(" \
") << "return code:" << res;  }
 	return false;
 }
diff --git a/kcms/keyboard/xkb_rules.cpp b/kcms/keyboard/xkb_rules.cpp
index a1840f8..f09e675 100644
--- a/kcms/keyboard/xkb_rules.cpp
+++ b/kcms/keyboard/xkb_rules.cpp
@@ -19,7 +19,6 @@
 #include "xkb_rules.h"
 #include "config-workspace.h"
 
-#include <kdebug.h>
 #include <kglobal.h>
 #include <KLocalizedString>
 
@@ -28,6 +27,7 @@
 #include <QTextDocument> // for Qt::escape
 #include <QXmlAttributes>
 #include <QtConcurrentFilter>
+#include <QtDebug>
 
 //#include <libintl.h>
 //#include <locale.h>
@@ -208,7 +208,7 @@ void mergeRules(Rules* rules, Rules* extraRules)
 		}
 	}
 	rules->layoutInfos.append(layoutsToAdd);
-	kDebug() << "Merged from extra rules:" << extraRules->layoutInfos.size() << \
"layouts," << extraRules->modelInfos.size() << "models," << \
extraRules->optionGroupInfos.size() << "option groups"; +	qDebug() << "Merged from \
extra rules:" << extraRules->layoutInfos.size() << "layouts," << \
extraRules->modelInfos.size() << "models," << extraRules->optionGroupInfos.size() << \
"option groups";  
 	// base rules now own the objects - remove them from extra rules so that it does \
not try to delete them  extraRules->layoutInfos.clear();
@@ -244,7 +244,7 @@ Rules* Rules::readRules(Rules* rules, const QString& filename, \
bool fromExtras)  {
 	QFile file(filename);
 	if( !file.open(QFile::ReadOnly | QFile::Text) ) {
-		kError() << "Cannot open the rules file" << file.fileName();
+		qCritical() << "Cannot open the rules file" << file.fileName();
 		return NULL;
 	}
 
@@ -256,10 +256,10 @@ Rules* Rules::readRules(Rules* rules, const QString& filename, \
bool fromExtras)  
 	QXmlInputSource xmlInputSource(&file);
 
-	kDebug() << "Parsing xkb rules from" << file.fileName();
+	qDebug() << "Parsing xkb rules from" << file.fileName();
 
 	if( ! reader.parse(xmlInputSource) ) {
-		kError() << "Failed to parse the rules file" << file.fileName();
+		qCritical() << "Failed to parse the rules file" << file.fileName();
 		delete rules;
 		return NULL;
 	}
@@ -293,7 +293,7 @@ bool RulesHandler::startElement(const QString &/*namespaceURI*/, \
const QString &  }
 	else if( strPath == ("xkbConfigRegistry") && ! \
attributes.value("version").isEmpty()  ) {  rules->version = \
                attributes.value("version");
-		kDebug() << "xkbConfigRegistry version" << rules->version;
+		qDebug() << "xkbConfigRegistry version" << rules->version;
 	}
 	return true;
 }


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

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