diff --git a/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml b/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml --- a/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml +++ b/wallpapers/image/imagepackage/contents/ui/WallpaperDelegate.qml @@ -22,190 +22,102 @@ import QtGraphicalEffects 1.0 import org.kde.kquickcontrolsaddons 2.0 import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.kirigami 2.4 as Kirigami +import org.kde.kcm 1.1 as KCM -MouseArea { +KCM.GridDelegate { id: wallpaperDelegate - width: wallpapersGrid.cellWidth - height: wallpapersGrid.cellHeight - + property alias color: backgroundRect.color property bool selected: (wallpapersGrid.currentIndex == index) opacity: model.pendingDeletion ? 0.5 : 1 + + toolTip: model.author.length > 0 ? i18nd("plasma_applet_org.kde.image", "%1 by %2", model.display, model.author) : model.display hoverEnabled: true - GridView.onIsCurrentItemChanged: { - if (GridView.isCurrentItem) { - cfg_Image = model.path - } - } - - //note: this *doesn't* use system colors since it represent a - //skeymorphic photograph rather than a widget - Rectangle { - id: background - color: "white" - anchors { - fill: parent - margins: units.smallSpacing - } - opacity: 0.8 - Rectangle { - id: backgroundRect - color: cfg_Color - anchors { - fill: parent - margins: units.smallSpacing * 2 - } - QIconItem { - anchors.centerIn: parent - width: units.iconSizes.large - height: width - icon: "view-preview" - visible: !walliePreview.visible - } - - QPixmapItem { - id: blurBackgroundSource - visible: cfg_Blur - anchors.fill: parent - smooth: true - pixmap: model.screenshot - fillMode: QPixmapItem.PreserveAspectCrop - } - - FastBlur { - visible: cfg_Blur - anchors.fill: parent - source: blurBackgroundSource - radius: 4 - } - - QPixmapItem { - id: walliePreview - anchors.fill: parent - visible: model.screenshot != null - smooth: true - pixmap: model.screenshot - fillMode: { - if (cfg_FillMode == Image.Stretch) { - return QPixmapItem.Stretch; - } else if (cfg_FillMode == Image.PreserveAspectFit) { - return QPixmapItem.PreserveAspectFit; - } else if (cfg_FillMode == Image.PreserveAspectCrop) { - return QPixmapItem.PreserveAspectCrop; - } else if (cfg_FillMode == Image.Tile) { - return QPixmapItem.Tile; - } else if (cfg_FillMode == Image.TileVertically) { - return QPixmapItem.TileVertically; - } else if (cfg_FillMode == Image.TileHorizontally) { - return QPixmapItem.TileHorizontally; - } - return QPixmapItem.PreserveAspectFit; - } - } - PlasmaComponents.ToolButton { - anchors { - top: parent.top - right: parent.right - margins: units.smallSpacing - } - iconSource: "list-remove" - tooltip: i18nd("plasma_wallpaper_org.kde.image", "Remove wallpaper") - flat: false - visible: model.removable && !model.pendingDeletion - onClicked: { - imageWallpaper.wallpaperModel.setPendingDeletion(index, true); - if (wallpapersGrid.currentIndex === index) { - wallpapersGrid.currentIndex = (index + 1) % wallpapersGrid.count; - } - } - opacity: wallpaperDelegate.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } - } - } - - PlasmaComponents.ToolButton { - anchors { - top: parent.top - left: parent.left - margins: units.smallSpacing - } - iconSource: "document-open-folder" - tooltip: i18nd("plasma_wallpaper_org.kde.image", "Open Containing Folder") - flat: false - onClicked: imageWallpaper.wallpaperModel.openContainingFolder(index) - opacity: wallpaperDelegate.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } - } - } - - PlasmaComponents.ToolButton { - anchors { - top: parent.top - right: parent.right - margins: units.smallSpacing - } - iconSource: "edit-undo" - tooltip: i18nd("plasma_wallpaper_org.kde.image", "Restore wallpaper") - flat: false - visible: model.pendingDeletion - onClicked: imageWallpaper.wallpaperModel.setPendingDeletion(index, !model.pendingDeletion) - opacity: wallpaperDelegate.containsMouse ? 1 : 0 - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } + actions: [ + Kirigami.Action { + icon.name: "document-open-folder" + tooltip: i18nd("plasma_applet_org.kde.image", "Open Containing Folder") + onTriggered: imageWallpaper.wallpaperModel.openContainingFolder(index) + }, + Kirigami.Action { + icon.name: "edit-undo" + visible: model.pendingDeletion + tooltip: i18nd("plasma_applet_org.kde.image", "Restore wallpaper") + onTriggered: imageWallpaper.wallpaperModel.setPendingDeletion(index, !model.pendingDeletion) + }, + Kirigami.Action { + icon.name: "edit-delete" + tooltip: i18nd("plasma_applet_org.kde.image", "Remove Wallpaper") + visible: model.removable && !model.pendingDeletion + onTriggered: { + imageWallpaper.wallpaperModel.setPendingDeletion(index, true); + if (wallpapersGrid.currentIndex === index) { + wallpapersGrid.currentIndex = (index + 1) % wallpapersGrid.count; } } } - } - - Rectangle { - opacity: selected ? 1.0 : 0 - anchors.fill: background - border.width: units.smallSpacing * 2 - border.color: syspal.highlight - color: "transparent" - Behavior on opacity { - PropertyAnimation { - duration: units.longDuration - easing.type: Easing.OutQuad - } + ] + + thumbnail: Rectangle { + id: backgroundRect + color: cfg_Color + anchors.fill: parent + + QIconItem { + anchors.centerIn: parent + width: units.iconSizes.large + height: width + icon: "view-preview" + visible: !walliePreview.visible } - } + QPixmapItem { + id: blurBackgroundSource + visible: cfg_Blur + anchors.fill: parent + smooth: true + pixmap: model.screenshot + fillMode: QPixmapItem.PreserveAspectCrop + } - Timer { - interval: 1000 // FIXME TODO: Use platform value for tooltip activation delay. - - running: wallpaperDelegate.containsMouse && !pressed && model.display + FastBlur { + visible: cfg_Blur + anchors.fill: parent + source: blurBackgroundSource + radius: 4 + } - onTriggered: { - if (model.author) { - Tooltip.showText(wallpaperDelegate, Qt.point(wallpaperDelegate.mouseX, wallpaperDelegate.mouseY), - i18nd("plasma_wallpaper_org.kde.image", "%1 by %2", model.display, model.author)); - } else { - Tooltip.showText(wallpaperDelegate, Qt.point(wallpaperDelegate.mouseX, wallpaperDelegate.mouseY), - model.display); + QPixmapItem { + id: walliePreview + anchors.fill: parent + visible: model.screenshot != null + smooth: true + pixmap: model.screenshot + fillMode: { + if (cfg_FillMode == Image.Stretch) { + return QPixmapItem.Stretch; + } else if (cfg_FillMode == Image.PreserveAspectFit) { + return QPixmapItem.PreserveAspectFit; + } else if (cfg_FillMode == Image.PreserveAspectCrop) { + return QPixmapItem.PreserveAspectCrop; + } else if (cfg_FillMode == Image.Tile) { + return QPixmapItem.Tile; + } else if (cfg_FillMode == Image.TileVertically) { + return QPixmapItem.TileVertically; + } else if (cfg_FillMode == Image.TileHorizontally) { + return QPixmapItem.TileHorizontally; + } + return QPixmapItem.PreserveAspectFit; } } } onClicked: { - wallpapersGrid.currentIndex = index + cfg_Image = model.path; wallpapersGrid.forceActiveFocus(); } - - onExited: Tooltip.hideText() } diff --git a/wallpapers/image/imagepackage/contents/ui/config.qml b/wallpapers/image/imagepackage/contents/ui/config.qml --- a/wallpapers/image/imagepackage/contents/ui/config.qml +++ b/wallpapers/image/imagepackage/contents/ui/config.qml @@ -19,6 +19,7 @@ import QtQuick 2.5 import QtQuick.Controls 1.0 as QtControls +import QtQuick.Controls 2.3 as QtControls2 import QtQuick.Dialogs 1.1 as QtDialogs import QtQuick.Layouts 1.0 import QtQuick.Window 2.0 // for Screen @@ -28,6 +29,7 @@ import org.kde.kquickcontrolsaddons 2.0 import org.kde.kconfig 1.0 // for KAuthorized import org.kde.draganddrop 2.0 as DragDrop +import org.kde.kcm 1.1 as KCM ColumnLayout { id: root @@ -249,10 +251,11 @@ text: i18nd("plasma_wallpaper_org.kde.image","Seconds") } } - QtControls.ScrollView { + QtControls2.ScrollView { + id: foldersScroll Layout.fillHeight: true; Layout.fillWidth: true - frameVisible: true + Component.onCompleted: foldersScroll.background.visible = true; ListView { id: slidePathsView anchors.margins: 4 @@ -278,70 +281,17 @@ Component { id: thumbnailsComponent - QtControls.ScrollView { + KCM.GridView { + id: wallpapersGrid anchors.fill: parent - frameVisible: true - highlightOnFocus: true; - - Component.onCompleted: { - //replace the current binding on the scrollbar that makes it visible when content doesn't fit - - //otherwise we adjust gridSize when we hide the vertical scrollbar and - //due to layouting that can make everything adjust which changes the contentWidth/height which - //changes our scrollbars and we continue being stuck in a loop - - //looks better to not have everything resize anyway. - //BUG: 336301 - __verticalScrollBar.visible = true - } - - GridView { - id: wallpapersGrid - model: imageWallpaper.wallpaperModel - currentIndex: -1 - focus: true - - cellWidth: Math.floor(wallpapersGrid.width / Math.max(Math.floor(wallpapersGrid.width / (units.gridUnit*12)), 3)) - cellHeight: Math.round(cellWidth / (imageWallpaper.targetSize.width / imageWallpaper.targetSize.height)) - - anchors.margins: 4 - boundsBehavior: Flickable.StopAtBounds - - delegate: WallpaperDelegate { - color: cfg_Color - } - - onContentHeightChanged: { - wallpapersGrid.currentIndex = imageWallpaper.wallpaperModel.indexOf(cfg_Image); - wallpapersGrid.positionViewAtIndex(wallpapersGrid.currentIndex, GridView.Visible) - } - - Keys.onPressed: { - if (count < 1) { - return; - } - - if (event.key == Qt.Key_Home) { - currentIndex = 0; - } else if (event.key == Qt.Key_End) { - currentIndex = count - 1; - } - } - - Keys.onLeftPressed: moveCurrentIndexLeft() - Keys.onRightPressed: moveCurrentIndexRight() - Keys.onUpPressed: moveCurrentIndexUp() - Keys.onDownPressed: moveCurrentIndexDown() - - Connections { - target: imageWallpaper - onCustomWallpaperPicked: { - wallpapersGrid.currentIndex = 0; - cfg_Image = path; - } - } - + //that min is needed as the module will be populated in an async way + //and only on demand so we can't ensure it already exists + view.currentIndex: Math.min(imageWallpaper.wallpaperModel.indexOf(cfg_Image), imageWallpaper.wallpaperModel.count-1) + //kill the space for label under thumbnails + view.model: imageWallpaper.wallpaperModel + view.delegate: WallpaperDelegate { + color: cfg_Color } } }