summaryrefslogtreecommitdiffstats
path: root/src/platformsupport
diff options
context:
space:
mode:
authorRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:18:59 +1000
committerRohan McGovern <rohan.mcgovern@nokia.com>2012-02-29 09:23:14 +1000
commit98dd1781d9256f68025d2a2db408f4f5947f3214 (patch)
treedbe1424abd90014edb5546c920ca585ed62b46e3 /src/platformsupport
parent6c1bdc1854a7700c2b3a345b95f6a2fdca84037d (diff)
parentfa1b9070af66edb81b2a3735c1951f78b22bd666 (diff)
Merge master -> api_changes
Includes fixes for tst_qfiledialog2, tst_qtextedit autotests on mac. Change-Id: I49cac26894d31291a8339ccc1eb80b6a940f0827
Diffstat (limited to 'src/platformsupport')
-rw-r--r--src/platformsupport/fontdatabases/fontconfig/fontconfig.pri4
-rw-r--r--src/platformsupport/themes/genericunix/qgenericunixthemes.cpp19
-rw-r--r--src/platformsupport/udev/qudevhelper_p.h1
-rw-r--r--src/platformsupport/udev/qudevicehelper.cpp235
-rw-r--r--src/platformsupport/udev/qudevicehelper_p.h98
-rw-r--r--src/platformsupport/udev/udev.pri4
6 files changed, 356 insertions, 5 deletions
diff --git a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
index 2c896ef2cc..af9bd0a01c 100644
--- a/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
+++ b/src/platformsupport/fontdatabases/fontconfig/fontconfig.pri
@@ -1,5 +1,5 @@
HEADERS += $$PWD/qfontconfigdatabase_p.h \
- fontdatabases/fontconfig/qfontenginemultifontconfig_p.h
+ $$PWD/qfontenginemultifontconfig_p.h
SOURCES += $$PWD/qfontconfigdatabase.cpp \
- fontdatabases/fontconfig/qfontenginemultifontconfig.cpp
+ $$PWD/qfontenginemultifontconfig.cpp
DEFINES -= QT_NO_FONTCONFIG
diff --git a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
index a9f05f6084..257fe9156f 100644
--- a/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
+++ b/src/platformsupport/themes/genericunix/qgenericunixthemes.cpp
@@ -89,12 +89,15 @@ QVariant QGenericUnixTheme::themeHint(ThemeHint hint) const
return QVariant(QString(QStringLiteral("hicolor")));
case QPlatformTheme::IconThemeSearchPaths:
return xdgIconThemePaths();
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
case QPlatformTheme::StyleNames: {
QStringList styleNames;
styleNames << QStringLiteral("Plastique") << QStringLiteral("Windows");
return QVariant(styleNames);
}
- break;
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(X11KeyboardScheme));
default:
break;
}
@@ -229,6 +232,12 @@ static QStringList kdeIconThemeSearchPaths(const QString &kdeHome)
QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::UseFullScreenForPopupMenu:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(2); // QDialogButtonBox::KdeLayout
case QPlatformTheme::ToolButtonStyle:
return QVariant(m_toolButtonStyle);
case QPlatformTheme::ToolBarIconSize:
@@ -241,6 +250,8 @@ QVariant QKdeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
return QVariant(kdeIconThemeSearchPaths(m_kdeHome));
case QPlatformTheme::StyleNames:
return QVariant(m_styleNames);
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(KdeKeyboardScheme));
default:
break;
}
@@ -282,6 +293,10 @@ QPlatformTheme *QKdeTheme::createKdeTheme()
QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
{
switch (hint) {
+ case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
+ return QVariant(true);
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(3); // QDialogButtonBox::GnomeLayout
case QPlatformTheme::SystemIconThemeName:
case QPlatformTheme::SystemIconFallbackThemeName:
return QVariant(QString(QStringLiteral("gnome")));
@@ -292,6 +307,8 @@ QVariant QGnomeTheme::themeHint(QPlatformTheme::ThemeHint hint) const
styleNames << QStringLiteral("GTK+") << QStringLiteral("cleanlooks") << QStringLiteral("windows");
return QVariant(styleNames);
}
+ case QPlatformTheme::KeyboardScheme:
+ return QVariant(int(GnomeKeyboardScheme));
default:
break;
}
diff --git a/src/platformsupport/udev/qudevhelper_p.h b/src/platformsupport/udev/qudevhelper_p.h
index e6046ca085..3895da87b6 100644
--- a/src/platformsupport/udev/qudevhelper_p.h
+++ b/src/platformsupport/udev/qudevhelper_p.h
@@ -43,6 +43,7 @@
#define QUDEVHELPER_P_H
#include <QString>
+#include <QObject>
QT_BEGIN_NAMESPACE
diff --git a/src/platformsupport/udev/qudevicehelper.cpp b/src/platformsupport/udev/qudevicehelper.cpp
new file mode 100644
index 0000000000..bf3ce67b43
--- /dev/null
+++ b/src/platformsupport/udev/qudevicehelper.cpp
@@ -0,0 +1,235 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qudevicehelper_p.h"
+
+#include <QStringList>
+#include <QCoreApplication>
+#include <QObject>
+#include <QHash>
+#include <QSocketNotifier>
+
+#include <linux/input.h>
+
+//#define QT_QPA_UDEVICE_HELPER_DEBUG
+
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+#include <QtDebug>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QUDeviceHelper *QUDeviceHelper::createUDeviceHelper(QUDeviceTypes types, QObject *parent)
+{
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "Try to create new UDeviceHelper";
+#endif
+
+ QUDeviceHelper *helper = 0;
+ struct udev *udev;
+
+ udev = udev_new();
+ if (udev) {
+ helper = new QUDeviceHelper(types, udev, parent);
+ } else {
+ qWarning("Failed to get udev library context.");
+ }
+
+ return helper;
+}
+
+QUDeviceHelper::QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent) :
+ QObject(parent),
+ m_udev(udev), m_types(types), m_udevMonitor(0), m_udevMonitorFileDescriptor(-1), m_udevSocketNotifier(0)
+{
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "New UDeviceHelper created for type" << types;
+#endif
+
+ if (!m_udev)
+ return;
+
+ m_udevMonitor = udev_monitor_new_from_netlink(m_udev, "udev");
+ if (!m_udevMonitor) {
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning("Unable to create an Udev monitor. No devices can be detected.");
+#endif
+ return;
+ }
+
+ udev_monitor_filter_add_match_subsystem_devtype(m_udevMonitor, "input", 0);
+ udev_monitor_enable_receiving(m_udevMonitor);
+ m_udevMonitorFileDescriptor = udev_monitor_get_fd(m_udevMonitor);
+
+ m_udevSocketNotifier = new QSocketNotifier(m_udevMonitorFileDescriptor, QSocketNotifier::Read, this);
+ connect(m_udevSocketNotifier, SIGNAL(activated(int)), this, SLOT(handleUDevNotification()));
+}
+
+QUDeviceHelper::~QUDeviceHelper()
+{
+ if (m_udevMonitor)
+ udev_monitor_unref(m_udevMonitor);
+
+ if (m_udev)
+ udev_unref(m_udev);
+}
+
+QStringList QUDeviceHelper::scanConnectedDevices()
+{
+ QStringList devices;
+
+ if (!m_udev)
+ return devices;
+
+ udev_enumerate *ue = udev_enumerate_new(m_udev);
+ udev_enumerate_add_match_subsystem(ue, "input");
+
+ if (m_types & UDev_Mouse)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_MOUSE", "1");
+ if (m_types & UDev_Touchpad)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHPAD", "1");
+ if (m_types & UDev_Touchscreen)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_TOUCHSCREEN", "1");
+ if (m_types & UDev_Keyboard)
+ udev_enumerate_add_match_property(ue, "ID_INPUT_KEYBOARD", "1");
+
+ if (udev_enumerate_scan_devices(ue) != 0) {
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "UDeviceHelper scan connected devices for enumeration failed";
+#endif
+ return devices;
+ }
+
+ udev_list_entry *entry;
+ udev_list_entry_foreach (entry, udev_enumerate_get_list_entry(ue)) {
+ const char *syspath = udev_list_entry_get_name(entry);
+ udev_device *udevice = udev_device_new_from_syspath(m_udev, syspath);
+ QString candidate = QString::fromUtf8(udev_device_get_devnode(udevice));
+ if (candidate.startsWith(QLatin1String("/dev/input/event")))
+ devices << candidate;
+
+ udev_device_unref(udevice);
+ }
+ udev_enumerate_unref(ue);
+
+#ifdef QT_QPA_UDEVICE_HELPER_DEBUG
+ qWarning() << "UDeviceHelper found matching devices" << devices;
+#endif
+
+ return devices;
+}
+
+void QUDeviceHelper::handleUDevNotification()
+{
+ if (!m_udevMonitor)
+ return;
+
+ struct udev_device *dev;
+ QString devNode;
+ QUDeviceTypes types = QFlag(UDev_Unknown);
+
+ dev = udev_monitor_receive_device(m_udevMonitor);
+ if (!dev)
+ goto cleanup;
+
+ const char *action;
+ action = udev_device_get_action(dev);
+ if (!action)
+ goto cleanup;
+
+ const char *str;
+ str = udev_device_get_devnode(dev);
+ if (!str)
+ goto cleanup;
+
+ devNode = QString::fromUtf8(str);
+ if (!devNode.startsWith(QLatin1String("/dev/input/event")))
+ goto cleanup;
+
+ // does not increase the refcount
+ dev = udev_device_get_parent_with_subsystem_devtype(dev, "input", 0);
+ if (!dev)
+ goto cleanup;
+
+ types = checkDeviceType(dev);
+
+ if (types && (qstrcmp(action, "add") == 0))
+ emit deviceDetected(devNode, types);
+
+ if (types && (qstrcmp(action, "remove") == 0))
+ emit deviceRemoved(devNode, types);
+
+cleanup:
+ udev_device_unref(dev);
+}
+
+QUDeviceHelper::QUDeviceTypes QUDeviceHelper::checkDeviceType(udev_device *dev)
+{
+ QUDeviceTypes types = QFlag(UDev_Unknown);
+
+ if ((m_types & UDev_Keyboard) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"), "1") == 0 )) {
+ const char *capabilities_key = udev_device_get_sysattr_value(dev, "capabilities/key");
+ QStringList val = QString::fromUtf8(capabilities_key).split(QString::fromUtf8(" "), QString::SkipEmptyParts);
+ if (!val.isEmpty()) {
+ bool ok;
+ unsigned long long keys = val.last().toULongLong(&ok, 16);
+ if (ok) {
+ // Tests if the letter Q is valid for the device. We may want to alter this test, but it seems mostly reliable.
+ bool test = (keys >> KEY_Q) & 1;
+ if (test)
+ types |= UDev_Keyboard;
+ }
+ }
+ }
+
+ if ((m_types & UDev_Mouse) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_MOUSE"), "1") == 0))
+ types |= UDev_Mouse;
+
+ if ((m_types & UDev_Touchpad) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHPAD"), "1") == 0))
+ types |= UDev_Touchpad;
+
+ if ((m_types & UDev_Touchscreen) && (qstrcmp(udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN"), "1") == 0))
+ types |= UDev_Touchscreen;
+
+ return types;
+}
+
+QT_END_NAMESPACE
diff --git a/src/platformsupport/udev/qudevicehelper_p.h b/src/platformsupport/udev/qudevicehelper_p.h
new file mode 100644
index 0000000000..b7544fa6c2
--- /dev/null
+++ b/src/platformsupport/udev/qudevicehelper_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUDEVICEHELPER_H
+#define QUDEVICEHELPER_H
+
+#include <QObject>
+#include <QSocketNotifier>
+
+#include <libudev.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUDeviceHelper : public QObject
+{
+ Q_OBJECT
+ Q_ENUMS(QUDeviceType)
+
+public:
+ enum QUDeviceType {
+ UDev_Unknown = 0x00,
+ UDev_Mouse = 0x01,
+ UDev_Touchpad = 0x02,
+ UDev_Touchscreen = 0x04,
+ UDev_Keyboard = 0x08
+ };
+ Q_DECLARE_FLAGS(QUDeviceTypes, QUDeviceType)
+
+ static QUDeviceHelper *createUDeviceHelper(QUDeviceTypes type, QObject *parent);
+ ~QUDeviceHelper();
+
+ QStringList scanConnectedDevices();
+
+signals:
+ void deviceDetected(const QString &deviceNode, QUDeviceTypes types);
+ void deviceRemoved(const QString &deviceNode, QUDeviceTypes types);
+
+private slots:
+ void handleUDevNotification();
+
+private:
+ QUDeviceHelper(QUDeviceTypes types, struct udev *udev, QObject *parent = 0);
+
+ void startWatching();
+ void stopWatching();
+
+ QUDeviceTypes checkDeviceType(struct udev_device *dev);
+
+ struct udev *m_udev;
+ QUDeviceTypes m_types;
+ struct udev_monitor *m_udevMonitor;
+ int m_udevMonitorFileDescriptor;
+ QSocketNotifier *m_udevSocketNotifier;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QUDeviceHelper::QUDeviceTypes)
+
+QT_END_NAMESPACE
+
+#endif // QUDEVICEHELPER_H
diff --git a/src/platformsupport/udev/udev.pri b/src/platformsupport/udev/udev.pri
index ac3f7df40a..48ad9d36af 100644
--- a/src/platformsupport/udev/udev.pri
+++ b/src/platformsupport/udev/udev.pri
@@ -1,5 +1,5 @@
contains(QT_CONFIG, libudev) {
- HEADERS += $$PWD/qudevhelper_p.h
- SOURCES += $$PWD/qudevhelper.cpp
+ HEADERS += $$PWD/qudevhelper_p.h $$PWD/qudevicehelper_p.h
+ SOURCES += $$PWD/qudevhelper.cpp $$PWD/qudevicehelper.cpp
LIBS += -ludev
}