diff --git a/containments/desktop/package/contents/ui/AppletAppearance.qml b/containments/desktop/package/contents/ui/AppletAppearance.qml --- a/containments/desktop/package/contents/ui/AppletAppearance.qml +++ b/containments/desktop/package/contents/ui/AppletAppearance.qml @@ -102,7 +102,7 @@ onPressAndHold: { if (!plasmoid.immutable && plasmoid.configuration.pressToMove) { - if (!dragMouseArea.dragging && !systemSettings.isDrag(pressX, pressY, mouse.x, mouse.y)) { + if (!dragMouseArea.dragging && !root.isDrag(pressX, pressY, mouse.x, mouse.y)) { showAppletHandle = true; dragMouseArea.dragging = true; diff --git a/containments/desktop/package/contents/ui/ConfigIcons.qml b/containments/desktop/package/contents/ui/ConfigIcons.qml --- a/containments/desktop/package/contents/ui/ConfigIcons.qml +++ b/containments/desktop/package/contents/ui/ConfigIcons.qml @@ -18,7 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.4 import QtQuick.Controls 1.0 import QtQuick.Dialogs 1.1 import QtQuick.Layouts 1.0 @@ -56,10 +56,6 @@ property alias cfg_iconSize: iconSize.value property alias cfg_textLines: textLines.value - Desktop.SystemSettings { - id: systemSettings - } - IconDialog { id: iconDialog onIconNameChanged: cfg_icon = iconName || "folder" @@ -321,7 +317,7 @@ CheckBox { id: selectionMarkers - visible: systemSettings.singleClick() + visible: Qt.styleHints.singleClickActivation text: i18n("Selection markers") } diff --git a/containments/desktop/package/contents/ui/FolderItemDelegate.qml b/containments/desktop/package/contents/ui/FolderItemDelegate.qml --- a/containments/desktop/package/contents/ui/FolderItemDelegate.qml +++ b/containments/desktop/package/contents/ui/FolderItemDelegate.qml @@ -324,7 +324,7 @@ FolderItemActionButton { id: selectionButton - visible: plasmoid.configuration.selectionMarkers && systemSettings.singleClick() + visible: plasmoid.configuration.selectionMarkers && Qt.styleHints.singleClickActivation opacity: (visible && impl.hovered) ? 1.0 : 0.0 element: model.selected ? "remove" : "add" diff --git a/containments/desktop/package/contents/ui/FolderView.qml b/containments/desktop/package/contents/ui/FolderView.qml --- a/containments/desktop/package/contents/ui/FolderView.qml +++ b/containments/desktop/package/contents/ui/FolderView.qml @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -import QtQuick 2.3 +import QtQuick 2.4 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 @@ -244,14 +244,14 @@ var pos = mapToItem(hoveredItem.actionsOverlay, mouse.x, mouse.y); if (!(pos.x <= hoveredItem.actionsOverlay.width && pos.y <= hoveredItem.actionsOverlay.height)) { - if (systemSettings.singleClick() || doubleClickInProgress) { + if (Qt.styleHints.singleClickActivation || doubleClickInProgress) { var func = root.useListViewMode && (mouse.button == Qt.LeftButton) && hoveredItem.isDir ? dir.cd : dir.run; func(positioner.map(gridView.currentIndex)); hoveredItem = null; } else { doubleClickInProgress = true; - doubleClickTimer.interval = systemSettings.doubleClickInterval(); + doubleClickTimer.interval = Qt.styleHints.mouseDoubleClickInterval; doubleClickTimer.start(); } } @@ -315,7 +315,7 @@ } // Drag initiation. - if (pressX != -1 && systemSettings.isDrag(pressX, pressY, mouse.x, mouse.y)) { + if (pressX != -1 && root.isDrag(pressX, pressY, mouse.x, mouse.y)) { if (pressedItem != null && dir.isSelected(positioner.map(pressedItem.index))) { pressedItem.toolTip.hideToolTip(); dragX = mouse.x; diff --git a/containments/desktop/package/contents/ui/main.qml b/containments/desktop/package/contents/ui/main.qml --- a/containments/desktop/package/contents/ui/main.qml +++ b/containments/desktop/package/contents/ui/main.qml @@ -19,7 +19,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * ***************************************************************************/ -import QtQuick 2.0 +import QtQuick 2.4 import QtQuick.Layouts 1.1 import org.kde.plasma.plasmoid 2.0 @@ -227,6 +227,11 @@ return height; } + function isDrag(fromX, fromY, toX, toY) { + var length = Math.abs(fromX - toX) + Math.abs(fromY - toY); + return length >= Qt.styleHints.startDragDistance; + } + onDragEnter: { if (isContainment && plasmoid.immutable && !(isFolder && FolderTools.isFileDrag(event))) { event.ignore(); @@ -381,10 +386,6 @@ imagePath: "widgets/configuration-icons" } - Desktop.SystemSettings { - id: systemSettings - } - KQuickControlsAddons.EventGenerator { id: eventGenerator } diff --git a/containments/desktop/plugins/desktop/CMakeLists.txt b/containments/desktop/plugins/desktop/CMakeLists.txt --- a/containments/desktop/plugins/desktop/CMakeLists.txt +++ b/containments/desktop/plugins/desktop/CMakeLists.txt @@ -1,7 +1,6 @@ set(desktopplugin_SRCS desktopplugin.cpp infonotification.cpp - systemsettings.cpp ) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/private/desktopcontainment/desktop) diff --git a/containments/desktop/plugins/desktop/desktopplugin.cpp b/containments/desktop/plugins/desktop/desktopplugin.cpp --- a/containments/desktop/plugins/desktop/desktopplugin.cpp +++ b/containments/desktop/plugins/desktop/desktopplugin.cpp @@ -19,14 +19,12 @@ #include "desktopplugin.h" #include "infonotification.h" -#include "systemsettings.h" #include void DesktopPlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.private.desktopcontainment.desktop")); qmlRegisterType(uri, 0, 1, "InfoNotification"); - qmlRegisterType(uri, 0, 1, "SystemSettings"); } diff --git a/containments/desktop/plugins/desktop/systemsettings.h b/containments/desktop/plugins/desktop/systemsettings.h deleted file mode 100644 --- a/containments/desktop/plugins/desktop/systemsettings.h +++ /dev/null @@ -1,44 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2014 by Eike Hein * - * * - * 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 . * - ***************************************************************************/ - -#ifndef SYSTEMSETTINGS_H -#define SYSTEMSETTINGS_H - -#include - -class QWidget; - -class SystemSettings : public QObject -{ - Q_OBJECT - - public: - SystemSettings(QObject *parent = 0); - ~SystemSettings(); - - Q_INVOKABLE bool singleClick() const; - Q_INVOKABLE int doubleClickInterval() const; - Q_INVOKABLE bool isDrag(int oldX, int oldY, int newX, int newY) const; - - private: - QWidget *m_widget; - -}; - -#endif diff --git a/containments/desktop/plugins/desktop/systemsettings.cpp b/containments/desktop/plugins/desktop/systemsettings.cpp deleted file mode 100644 --- a/containments/desktop/plugins/desktop/systemsettings.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2014 by Eike Hein * - * * - * 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 "systemsettings.h" - -#include -#include -#include -#include - -SystemSettings::SystemSettings(QObject *parent) : QObject(parent), - m_widget(new QWidget()) -{ - m_widget->resize(0, 0); - m_widget->hide(); -} - -SystemSettings::~SystemSettings() -{ - delete m_widget; -} - -bool SystemSettings::singleClick() const -{ - // FIXME TODO: Check back for whether this eventually got added to - // QGuiApplication::styleHints() / Qt.styleHints. - return m_widget->style()->styleHint(QStyle::SH_ItemView_ActivateItemOnSingleClick); -} - -int SystemSettings::doubleClickInterval() const -{ - return QGuiApplication::styleHints()->mouseDoubleClickInterval(); -} - -bool SystemSettings::isDrag(int oldX, int oldY, int newX, int newY) const -{ - // FIXME TODO: QGuiApplication::styleHints() will be available as - // Qt.styleHints in QML starting with Qt 5.5. - return ((QPoint(oldX, oldY) - QPoint(newX, newY)).manhattanLength() >= QGuiApplication::styleHints()->startDragDistance()); -}