diff --git a/activeshellpackage/package/contents/explorer/CommonBrowser.qml b/activeshellpackage/package/contents/explorer/CommonBrowser.qml index 54e4e839..f93f276d 100644 --- a/activeshellpackage/package/contents/explorer/CommonBrowser.qml +++ b/activeshellpackage/package/contents/explorer/CommonBrowser.qml @@ -1,40 +1,40 @@ /* * Copyright 2014 Antonis Tsiapaliokas * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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. */ import QtQuick 2.0 -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.plasma.private.mobileshell 0.2 as MobileShell -MobileComponents.IconGrid { +MobileShell.IconGrid { id: commonList property int currentIndex: 0 signal closeRequested() property bool isApplicationExplorer: false onCloseRequested: main.closed() onCurrentIndexChanged: { currentPage = Math.max(0, Math.floor(currentIndex/pageSize)) } delegateWidth: Math.floor(commonList.width / Math.max(Math.floor(commonList.width / (units.gridUnit*12)), 3)) delegateHeight: delegateWidth / 1.6 anchors.fill: parent model: isApplicationExplorer ? applicationsModel : widgetExplorer.widgetsModel delegate: CommonDelegate {} } diff --git a/activeshellpackage/package/contents/explorer/ResourceBrowser.qml b/activeshellpackage/package/contents/explorer/ResourceBrowser.qml index 16c22e72..a1bededa 100644 --- a/activeshellpackage/package/contents/explorer/ResourceBrowser.qml +++ b/activeshellpackage/package/contents/explorer/ResourceBrowser.qml @@ -1,68 +1,68 @@ /* * Copyright 2010 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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. */ import QtQuick 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.plasma.private.mobileshell 0.2 as MobileShell -MobileComponents.IconGrid { +MobileShell.IconGrid { id: resultsGrid anchors.fill: parent property string resourceType: "" delegateWidth: Math.floor(resultsGrid.width / Math.max(Math.floor(resultsGrid.width / (units.gridUnit*12)), 3)) delegateHeight: delegateWidth / 1.6 delegate: Item { width: resultsGrid.delegateWidth height: resultsGrid.delegateHeight PlasmaCore.FrameSvgItem { id: highlightFrame imagePath: "widgets/viewitem" prefix: "normal" width: resultsGrid.delegateWidth height: resultsGrid.delegateHeight Behavior on opacity { NumberAnimation {duration: 250} } } - MobileComponents.ResourceDelegate { + ResourceDelegate { id: resourceDelegate resourceType: resultsGrid.resourceType width: parent.width height: parent.height onClicked: { for (var i = 0; i < selectedItemModel.count; i++) { if (model.url == selectedItemModel.get(i).resourceName) { selectedItemModel.remove(selectedItemModel.get(i)) highlightFrame.prefix= "normal" return } } var item = new Object() item["resourceName"] = String(model.url) item["resourceType"] = resultsGrid.resourceType selectedItemModel.append(item) highlightFrame.prefix= "selected+hover" } } } } diff --git a/activeshellpackage/package/contents/views/ApplicationList.qml b/activeshellpackage/package/contents/views/ApplicationList.qml index cf60e295..d70a2f7e 100644 --- a/activeshellpackage/package/contents/views/ApplicationList.qml +++ b/activeshellpackage/package/contents/views/ApplicationList.qml @@ -1,98 +1,98 @@ /* * Copyright 2014 Antonis Tsiapaliokas * * 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 2.010-1301, USA. */ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.plasma.private.mobileshell 0.2 as MobileShell Item { id: root PlasmaCore.DataModel { id: applicationData dataSource: PlasmaCore.DataSource { engine: "apps" connectedSources: sources } } PlasmaCore.SortFilterModel { id: filterModel sourceModel: applicationData sortRole: "ApplicationNameRole" filterRegExp: searchApplicationField.text } Column { id: col spacing: units.largeSpacing anchors { fill: parent left: parent.left right: parent.right top: parent.top } PlasmaComponents.TextField{ id: searchApplicationField width: parent.width / 12 anchors.horizontalCenter: parent.horizontalCenter } - MobileComponents.IconGrid { + MobileShell.IconGrid { id: applicationsList property int currentIndex: 0 onCurrentIndexChanged: { currentPage = Math.max(0, Math.floor(currentIndex/pageSize)) } height: parent.height - searchApplicationField.height width: parent.width delegateWidth: Math.floor(applicationsList.width / Math.max(Math.floor(applicationsList.width / (units.gridUnit*12)), 3)) delegateHeight: delegateWidth / 1.6 model: filterModel delegate: MouseArea { width: applicationsList.delegateWidth height: applicationsList.delegateHeight PlasmaCore.IconItem { id: applicationIcon source: model.iconName width: parent.width / 1.6 height: parent.height / 1.6 anchors.horizontalCenter: parent.horizontalCenter anchors.top: parent.top } PlasmaComponents.Label { anchors.bottom: parent.bottom text: model.name anchors.horizontalCenter: parent.horizontalCenter anchors.top: applicationIcon.bottom } onClicked: { applicationsList.currentIndex = (applicationsList.currentPage * applicationsList.pageSize) + index applicationData.runApplication(model.menuId) } } } } } diff --git a/applications/filebrowser/package/contents/ui/BrowserFrame.qml b/applications/filebrowser/package/contents/ui/BrowserFrame.qml index 2f063ec4..65f85046 100644 --- a/applications/filebrowser/package/contents/ui/BrowserFrame.qml +++ b/applications/filebrowser/package/contents/ui/BrowserFrame.qml @@ -1,310 +1,310 @@ /* * Copyright 2011 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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. */ import QtQuick 2.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.extras 2.0 as PlasmaExtras -import org.kde.plasma.mobilecomponents 0.2 as MobileComponents +import org.kde.plasma.private.mobileshell 0.2 as MobileShell import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.private.folder 0.1 as Folder import org.kde.draganddrop 2.0 Item { id: browserFrame anchors.fill: parent property url resourceInstance ListModel { id: selectedModel signal modelCleared } Folder.Positioner { id: positioner folderModel: folderModel } Folder.ItemViewAdapter { id: viewAdapter adapterView: resultsGrid adapterModel: positioner Component.onCompleted: { folderModel.sourceModel.viewAdapter = viewAdapter; } } Connections { target: resultsGrid onCountChanged: { selectedModel.clear() selectedModel.modelCleared() } } //BUG: For some reason onCountChanged doesn't get binded directly in ListModel Connections { target: selectedModel onCountChanged: { var thumbnails = new Array() var labels = new Array() var mimeTypes = new Array() var newUrls = new Array() for (var i = 0; i < selectedModel.count; ++i) { newUrls[i] = selectedModel.get(i).url thumbnails[i] = selectedModel.get(i).decoration labels[i] = selectedModel.get(i).display mimeTypes[i] = selectedModel.get(i).resourceType } dragArea.mimeData.urls = newUrls dragArea.mimeTypes = mimeTypes dragArea.thumbnails = thumbnails dragArea.labels = labels } } Connections { target: balooDataModel.sourceModel onQueryChanged: selectedModel.clear() } //This pinch area is for selection PinchArea { id: pinchArea anchors { fill: parent leftMargin: 0 } property bool selecting: false property int selectingX property int selectingY pinch.target: parent function resetSelection() { selectedModel.modelCleared() selectedModel.clear() selectionRect.x = -1 selectionRect.y = -1 selectionRect.width = 0 selectionRect.height = 0 } onPinchStarted: { //hotspot to start select procedures print("point1: " + pinch.point1.x + " " + pinch.point1.y) print("Selecting") selecting = true selectingX = pinch.point2.x selectingY = pinch.point2.y selectionRect.opacity = 0.4 } onPinchUpdated: { //only one point if (pinch.point1.x == pinch.point2.x) { return } selectionRect.x = Math.min(pinch.point1.x, pinch.point2.x) selectionRect.y = Math.min(pinch.point1.y, pinch.point2.y) selectionRect.width = Math.abs(pinch.point2.x - pinch.point1.x) selectionRect.height = Math.abs(pinch.point2.y - pinch.point1.y) if (selecting) { print("Selected" + resultsGrid.childAt(pinch.point2.x, pinch.point2.y)) selectingX = pinch.point2.x selectingY = pinch.point2.y } } onPinchFinished: { selectionRect.opacity = 0 selecting = false } Rectangle { id: selectionRect color: theme.highlightColor opacity: 0.4 Behavior on opacity { NumberAnimation { duration: 250 easing.type: Easing.InOutQuad } } } DragArea { id: dragArea anchors.fill: parent property variant labels property variant thumbnails property variant mimeTypes //startDragDistance: 200 enabled: false mimeData { source: parent } onDrop: enabled = false delegate: Item { width: 250 height: 250 opacity: 0.7 Repeater { model: Math.min(4, dragArea.labels.length) ResourceDelegate { resourceType: dragArea.mimeTypes[index] property string label: dragArea.labels.length == 1 ? dragArea.labels[index] : "" property variant thumbnail: dragArea.thumbnails[index] anchors.centerIn: parent width: 200 height: 200/1.6 transformOrigin: Item.Bottom rotation: (dragArea.labels.length > 1 ? 20 : 0) -20*index z: -index smooth: true } } } MouseEventListener { anchors.fill: parent property int startY: 0 onPressed: startY = mouse.y onPositionChanged: { if (selectedModel.count > 0 && Math.abs(mouse.y - startY) > 100) { dragArea.enabled = true } } onReleased: { //are we outside the listview area? if (resultsGrid.childAt(mouse.x, mouse.y).delegate === undefined && selectionRect.width == 0) { selectedModel.clear() selectedModel.modelCleared() } dragArea.enabled = false } Connections { target: fileBrowserRoot.model onCountChanged: pinchArea.resetSelection() onModelReset: pinchArea.resetSelection() } - MobileComponents.IconGrid { + MobileShell.IconGrid { id: resultsGrid delegateWidth: Math.floor(resultsGrid.width / Math.max(Math.floor(resultsGrid.width / (units.gridUnit*12)), 3)) delegateHeight: delegateWidth / 1.6 anchors.fill: parent clip: false model: fileBrowserRoot.model == folderModel ? positioner : fileBrowserRoot.model onCurrentPageChanged: pinchArea.resetSelection() delegate: Item { id: resourceDelegate width: resultsGrid.delegateWidth height: resultsGrid.delegateHeight PlasmaCore.FrameSvgItem { id: highlightFrame imagePath: "widgets/viewitem" prefix: "selected+hover" anchors.fill: parent property real delegateX: resourceDelegate.x + resourceDelegate.parent.parent.x - resultsGrid.contentX property real delegateY: resourceDelegate.y property bool contains: delegateX+resourceDelegate.width > selectionRect.x && delegateY+resourceDelegate.height > selectionRect.y && delegateX < selectionRect.x+selectionRect.width && delegateY < selectionRect.y+selectionRect.height opacity: 0 /*Behavior on opacity { NumberAnimation {duration: 250} }*/ onContainsChanged: { if (contains) { selectedModel.append(model) opacity = 1 if (selectedModel.count == 1) { resourceInstance = model.url; } else { resourceInstance = ""; } } else { if (resourceInstance === model.url) { resourceInstance = ""; } for (var i = 0; i < selectedModel.count; ++i) { if ((model.url && model.url == selectedModel.get(i).url)) { opacity = 0 selectedModel.remove(i) if (selectedModel.count == 1) { resourceInstance = selectedModel.get(0).url; } return } } } } } Connections { target: selectedModel onModelCleared: highlightFrame.opacity = 0 } ResourceDelegate { anchors.fill: parent resourceType: { if (fileBrowserRoot.model.sourceModel.query !== undefined) { var type =resultsGrid.model.sourceModel.query.type type = type.replace("File/", "") return type } else if (model.resourceType !== undefined){ return model.resourceType } else { return "FileDataObject" } } width: resultsGrid.delegateWidth height: resultsGrid.delegateHeight onPressed: { if (selectedModel.count > 0 && highlightFrame.opacity > 0) { dragArea.enabled = true } } onPressAndHold: highlightFrame.contains = !highlightFrame.contains onClicked: { openResource(model) } } Component.onCompleted: { for (var i = 0; i < selectedModel.count; ++i) { if ((model.url && model.url == selectedModel.get(i).url)) { highlightFrame.opacity = 1 return } } } } } } } } } diff --git a/components/mobilecomponents/CMakeLists.txt b/components/mobilecomponents/CMakeLists.txt index f7c5b487..dc2bdb32 100644 --- a/components/mobilecomponents/CMakeLists.txt +++ b/components/mobilecomponents/CMakeLists.txt @@ -1,26 +1,24 @@ project(mobilecomponents) set(mobilecomponents_SRCS mobilecomponentsplugin.cpp ) add_library(mobilecomponentsplugin SHARED ${mobilecomponents_SRCS}) target_link_libraries(mobilecomponentsplugin Qt5::Core Qt5::Qml Qt5::Quick) install(TARGETS mobilecomponentsplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/mobilecomponents) install(DIRECTORY qml/ DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/mobilecomponents) #TODO: install the plasmaless version at build time #TODO: use the same way qquickcontrols2 uses to select if possible FILE(GLOB platformspecific ${PROJECT_SOURCE_DIR}/plasmatheme/*) install(FILES ${platformspecific} DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/mobilecomponents) -add_subdirectory(private) - kpackage_install_package(example org.kde.plasma.mobile.gallery genericqml) install(FILES example/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.plasma.mobile.gallery.desktop) diff --git a/components/mobilecomponents/example/contents/ui/MainPage.qml b/components/mobilecomponents/example/contents/ui/MainPage.qml index 495bf02a..2f069f14 100644 --- a/components/mobilecomponents/example/contents/ui/MainPage.qml +++ b/components/mobilecomponents/example/contents/ui/MainPage.qml @@ -1,118 +1,114 @@ /* * Copycontext 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 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 Library General Public License for more details * * You should have received a copy of the GNU Library 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. */ import QtQuick 2.1 import QtQuick.Controls 1.4 as Controls import QtQuick.Layouts 1.2 import org.kde.plasma.mobilecomponents 0.2 as MobileComponents MobileComponents.Page { anchors.fill:parent color: MobileComponents.Theme.viewBackgroundColor contextualActions: [ Controls.Action { text:"Action 1" iconName: "document-decrypt" onTriggered: print("Action 1 clicked") }, Controls.Action { text:"Action 2" iconName: "document-share" }, Controls.Action { text:"Checkabke" checkable: true iconName: "dashboard-show" } ] Timer { id: refreshRequestTimer interval: 3000 onTriggered: scrollView.requestingRefresh = false } MobileComponents.RefreshableScrollView { id: scrollView anchors.fill:parent onRefreshRequested: refreshRequestTimer.running = true ListView { id: mainListView model: ListModel { ListElement { text: "Button" component: "Button" } ListElement { text: "CheckBox" component: "CheckBox" } ListElement { text: "Radio Button" component: "RadioButton" } ListElement { text: "Progress Bar" component: "ProgressBar" } ListElement { text: "Slider" component: "Slider" } ListElement { text: "Switch" component: "Switch" } ListElement { text: "Text Field" component: "TextField" } - ListElement { - text: "Icon Grid" - component: "IconGrid" - } } delegate: MobileComponents.ListItemWithActions { enabled: true MobileComponents.Label { enabled: true text: model.text } property Item ownPage onClicked: { root.pageStack.pop(root.initialPage); if (!model.component) { return; } ownPage = root.pageStack.push(Qt.resolvedUrl("gallery/" + model.component + "Gallery.qml")); } checked: root.pageStack.currentPage == ownPage actions: [ Controls.Action { iconName: "document-decrypt" onTriggered: print("Action 1 clicked") }, Controls.Action { iconName: "mail-reply-sender" }] } } } } diff --git a/components/mobilecomponents/example/contents/ui/gallery/IconGridGallery.qml b/components/mobilecomponents/example/contents/ui/gallery/IconGridGallery.qml deleted file mode 100644 index f0a919f4..00000000 --- a/components/mobilecomponents/example/contents/ui/gallery/IconGridGallery.qml +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copycontext 2015 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library 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. - */ - -import QtQuick 2.1 -import QtQuick.Layouts 1.2 -import org.kde.plasma.mobilecomponents 0.2 -import org.kde.plasma.core 2.0 as PlasmaCore - -Page { - Layout.fillWidth: true - - Heading { - id: heading - text: "Icon Grid" - anchors { - left: parent.left - top: parent.top - leftMargin: Units.smallSpacing - } - } - IconGrid { - id: grid - anchors { - left: parent.left - right: parent.right - top: heading.bottom - bottom: parent.bottom - } - - model: PlasmaCore.DataModel { - dataSource: PlasmaCore.DataSource { - engine: "apps" - connectedSources: sources - } - } - delegate: Item { - width: grid.delegateWidth - height: grid.delegateHeight - Item { - anchors { - fill: parent - margins: units.gridUnit - } - Icon { - anchors { - horizontalCenter: parent.horizontalCenter - top: parent.top - } - width: Units.iconSizes.huge - height: width - source: model.iconName - } - Label { - text: model.name - elide: Text.ElideRight - horizontalAlignment: Text.AlignHCenter - anchors { - left: parent.left - right: parent.right - top: parent.bottom - } - } - } - } - } -} diff --git a/components/mobilecomponents/private/CMakeLists.txt b/components/mobilecomponents/private/CMakeLists.txt deleted file mode 100644 index b7771dd9..00000000 --- a/components/mobilecomponents/private/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ - -set(mobilecomponentsprivate_SRCS - mobilecomponentsprivateplugin.cpp - pagedproxymodel.cpp - ) - -add_library(mobilecomponentsprivateplugin SHARED ${mobilecomponentsprivate_SRCS}) -target_link_libraries(mobilecomponentsprivateplugin Qt5::Core Qt5::Qml Qt5::Quick) - -install(TARGETS mobilecomponentsprivateplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/mobilecomponents/private) - - -install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/mobilecomponents/private/) - - diff --git a/components/mobilecomponents/private/mobilecomponentsprivateplugin.cpp b/components/mobilecomponents/private/mobilecomponentsprivateplugin.cpp deleted file mode 100644 index 79dcb281..00000000 --- a/components/mobilecomponents/private/mobilecomponentsprivateplugin.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2009 by Alan Alpert - * Copyright 2010 by Ménard Alexis - * Copyright 2015 by Marco Martin - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library 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 "mobilecomponentsprivateplugin.h" - -#include -#include -#include -#include -#include "pagedproxymodel.h" - - -void MobileComponentsPrivatePlugin::registerTypes(const char *uri) -{ - Q_ASSERT(uri == QLatin1String("org.kde.plasma.mobilecomponents.private")); - - qmlRegisterType(uri, 0, 2, "PagedProxyModel"); -} - - -#include "mobilecomponentsprivateplugin.moc" - diff --git a/components/mobilecomponents/private/mobilecomponentsprivateplugin.h b/components/mobilecomponents/private/mobilecomponentsprivateplugin.h deleted file mode 100644 index 68565128..00000000 --- a/components/mobilecomponents/private/mobilecomponentsprivateplugin.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2009 by Alan Alpert - * Copyright 2010 by Ménard Alexis - * Copyright 2015 by Marco Martin - - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 Library General Public License for more details - * - * You should have received a copy of the GNU Library 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 MOBILECOMPONENTSPRIVATEPLUGIN_H -#define MOBILECOMPONENTSPRIVATEPLUGIN_H - -#include -#include - -class MobileComponentsPrivatePlugin : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") - -public: - void registerTypes(const char *uri); - -}; - -#endif diff --git a/components/mobilecomponents/private/qmldir b/components/mobilecomponents/private/qmldir deleted file mode 100644 index 83c06056..00000000 --- a/components/mobilecomponents/private/qmldir +++ /dev/null @@ -1,3 +0,0 @@ -module org.kde.plasma.mobilecomponents.private -plugin mobilecomponentsprivateplugin - diff --git a/components/mobilecomponents/qml/qmldir b/components/mobilecomponents/qml/qmldir index 999f823e..75255730 100644 --- a/components/mobilecomponents/qml/qmldir +++ b/components/mobilecomponents/qml/qmldir @@ -1,21 +1,20 @@ module org.kde.plasma.mobilecomponents #plugin mobilecomponentsplugin singleton Units 0.2 Units.qml singleton Theme 0.2 Theme.qml -IconGrid 0.2 IconGrid.qml OverlayDrawer 0.2 OverlayDrawer.qml SplitDrawer 0.2 SplitDrawer.qml ActionGroup 0.2 ActionGroup.qml ApplicationWindow 0.2 ApplicationWindow.qml ContextDrawer 0.2 ContextDrawer.qml GlobalDrawer 0.2 GlobalDrawer.qml Page 0.2 Page.qml Icon 0.2 Icon.qml Label 0.2 Label.qml Heading 0.2 Heading.qml ListItem 0.2 ListItem.qml BasicListItem 0.2 BasicListItem.qml ListItemWithActions 0.2 ListItemWithActions.qml RefreshableScrollView 0.2 RefreshableScrollView.qml diff --git a/components/mobileshellprivate/CMakeLists.txt b/components/mobileshellprivate/CMakeLists.txt index 3f92b9e4..50e89527 100644 --- a/components/mobileshellprivate/CMakeLists.txt +++ b/components/mobileshellprivate/CMakeLists.txt @@ -1,15 +1,16 @@ project(mobileshellprivate) set(mobileshellprivate_SRCS mobileshellprivateplugin.cpp fullscreenpanel.cpp + pagedproxymodel.cpp ) add_library(plasmamobileshellprivateplugin SHARED ${mobileshellprivate_SRCS}) target_link_libraries(plasmamobileshellprivateplugin Qt5::Core Qt5::Widgets Qt5::Qml Qt5::Quick KF5::Declarative KF5::Plasma KF5::I18n KF5::KIOCore KF5::KIOWidgets KF5::Activities KF5::WindowSystem KF5::WaylandClient) install(TARGETS plasmamobileshellprivateplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) -install(FILES qmldir DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) +install(FILES qmldir IconGrid.qml DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/mobileshell) diff --git a/components/mobilecomponents/qml/IconGrid.qml b/components/mobileshellprivate/IconGrid.qml similarity index 99% rename from components/mobilecomponents/qml/IconGrid.qml rename to components/mobileshellprivate/IconGrid.qml index 1a6acbc1..aabeff32 100644 --- a/components/mobilecomponents/qml/IconGrid.qml +++ b/components/mobileshellprivate/IconGrid.qml @@ -1,238 +1,238 @@ /* Copyright 2010 Marco Martin This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.mobilecomponents 0.2 -import org.kde.plasma.mobilecomponents.private 0.2 +import org.kde.plasma.private.mobileshell 2.0 Item { id: main property Component delegate property QtObject model property int pageSize: Math.floor(iconView.width / main.delegateWidth) * Math.floor(iconView.height / main.delegateHeight) property int delegateWidth: Units.iconSizes.huge + Units.gridUnit * 2 property int delegateHeight: Units.iconSizes.huge + Units.gridUnit * 2 property alias currentPage: iconView.currentIndex property int pagesCount: Math.ceil(model.count / pageSize) property int count: model.count property alias contentX: iconView.contentX clip: true function positionViewAtIndex(index) { iconView.positionViewAtIndex(index / pageSize, ListView.Beginning) } Timer { id: resizeTimer running: true interval: 100 onTriggered: { main.pageSize = Math.floor(iconView.width / main.delegateWidth) * Math.floor(iconView.height / main.delegateHeight) if (iconView.currentItem) { iconView.currentItem.width = iconView.width iconView.currentItem.height = iconView.height } } } ListView { id: iconView objectName: "iconView" pressDelay: 200 cacheBuffer: Units.gridUnit * 8 highlightMoveDuration: Units.shortDuration anchors.fill: parent onWidthChanged: resizeTimer.restart() onHeightChanged: resizeTimer.restart() model: main.model ? Math.ceil(main.model.count/main.pageSize) : 0 highlightRangeMode: ListView.StrictlyEnforceRange orientation: ListView.Horizontal snapMode: ListView.SnapOneItem boundsBehavior: Flickable.DragOverBounds signal clicked(string url) delegate: Component { Item { id: delegatePage //Explicitly *not* bind the properties for performance reasons Component.onCompleted: { width = iconView.width height = iconView.height //iconView.cacheBuffer = iconView.width } Flow { id: iconFlow width: iconRepeater.suggestedWidth anchors { horizontalCenter: parent.horizontalCenter top: parent.top bottom: parent.bottom } property int orientation: ListView.Horizontal PagedProxyModel { id: pagedProxyModel sourceModel: main.model currentPage: model.index pageSize: main.pageSize } Repeater { id: iconRepeater model: pagedProxyModel property int columns: Math.min(count, Math.floor(delegatePage.width / main.delegateWidth)) property int suggestedWidth: main.delegateWidth * columns //property int suggestedHeight: main.delegateHeight*Math.floor(count/columns) delegate: main.delegate } } } } } Loader { id: scrollArea visible: main.model && Math.ceil(main.model.count/main.pageSize) > 1 anchors { left: parent.left right: parent.right bottom: parent.bottom } height: Math.max(16, iconView.height - Math.floor(iconView.height / delegateHeight) * delegateHeight) property int pageCount: main.model ? Math.ceil(main.model.count/main.pageSize) : 0 sourceComponent: pageCount > 1 ? ((pageCount * 20 > width) ? scrollDotComponent : dotsRow) : undefined function setViewIndex(index) { //animate only if near if (Math.abs(iconView.currentIndex - index) > 1) { iconView.positionViewAtIndex(index, ListView.Beginning) } else { iconView.currentIndex = index } } Component { id: scrollDotComponent MouseArea { anchors.fill: parent property int pendingIndex: 0 Rectangle { id: barRectangle color: Theme.textColor height: 4 radius: 2 anchors { left: parent.left right: parent.right verticalCenter: parent.verticalCenter leftMargin: (parent.width / pageCount / 2) rightMargin: (parent.width / pageCount / 2) } } Rectangle { color: Theme.textColor height: 8 width: height radius: 4 anchors.verticalCenter: parent.verticalCenter x: parent.width / (pageCount / (iconView.currentIndex+1)) - (parent.width / pageCount / 2) - 4 Behavior on x { NumberAnimation { duration: Units.shortDuration easing.type: Easing.InOutQuad } } } function setViewIndexFromMouse(x) { pendingIndex = Math.min(pageCount, Math.round(pageCount / (barRectangle.width / Math.max(x - barRectangle.x, 1)))) viewPositionTimer.restart() } onPressed: setViewIndexFromMouse(mouse.x) onPositionChanged: setViewIndexFromMouse(mouse.x) Timer { id: viewPositionTimer interval: 200 onTriggered: setViewIndex(pendingIndex) } } } Component { id: dotsRow Item { Row { anchors.centerIn: parent spacing: units.gridUnit Repeater { model: scrollArea.pageCount Rectangle { width: 6 height: 6 scale: iconView.currentIndex == index ? 1.5 : 1 radius: 5 smooth: true opacity: iconView.currentIndex == index ? 0.8: 0.4 color: Theme.textColor Behavior on scale { NumberAnimation { duration: units.shortDuration easing.type: Easing.InOutQuad } } Behavior on opacity { NumberAnimation { duration: units.shortDuration easing.type: Easing.InOutQuad } } MouseArea { anchors { fill: parent margins: Units.gridUnit / 2 } onClicked: { setViewIndex(index) } } } } } } } } } diff --git a/components/mobileshellprivate/mobileshellprivateplugin.cpp b/components/mobileshellprivate/mobileshellprivateplugin.cpp index cf9a8a5c..f4246f51 100644 --- a/components/mobileshellprivate/mobileshellprivateplugin.cpp +++ b/components/mobileshellprivate/mobileshellprivateplugin.cpp @@ -1,34 +1,36 @@ /* Copyright 2015 Marco Martin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "mobileshellprivateplugin.h" #include "fullscreenpanel.h" +#include "pagedproxymodel.h" #include void PlasmaMobileShellPrivatePlugin::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.plasma.private.mobileshell")); qmlRegisterType(uri, 2, 0, "FullScreenPanel"); + qmlRegisterType(uri, 2, 0, "PagedProxyModel"); } diff --git a/components/mobilecomponents/private/pagedproxymodel.cpp b/components/mobileshellprivate/pagedproxymodel.cpp similarity index 100% rename from components/mobilecomponents/private/pagedproxymodel.cpp rename to components/mobileshellprivate/pagedproxymodel.cpp diff --git a/components/mobilecomponents/private/pagedproxymodel.h b/components/mobileshellprivate/pagedproxymodel.h similarity index 100% rename from components/mobilecomponents/private/pagedproxymodel.h rename to components/mobileshellprivate/pagedproxymodel.h diff --git a/components/mobileshellprivate/qmldir b/components/mobileshellprivate/qmldir index c88ad12c..1421b72f 100644 --- a/components/mobileshellprivate/qmldir +++ b/components/mobileshellprivate/qmldir @@ -1,2 +1,3 @@ module org.kde.plasma.private.mobileshell plugin plasmamobileshellprivateplugin +IconGrid 2.0 IconGrid.qml