diff --git a/wallpapers/image/imagepackage/contents/config/main.xml b/wallpapers/image/imagepackage/contents/config/main.xml --- a/wallpapers/image/imagepackage/contents/config/main.xml +++ b/wallpapers/image/imagepackage/contents/config/main.xml @@ -8,7 +8,7 @@ - false + false @@ -34,6 +34,17 @@ 1000 + + false + + + + 40 + + + + 400 + diff --git a/wallpapers/image/imagepackage/contents/ui/WindowModel.qml b/wallpapers/image/imagepackage/contents/ui/WindowModel.qml new file mode 100644 --- /dev/null +++ b/wallpapers/image/imagepackage/contents/ui/WindowModel.qml @@ -0,0 +1,68 @@ +import QtQuick 2.1 +import QtQuick.Controls 1.0 +import QtQuick.Layouts 1.3 +import QtQuick.Window 2.1 +import org.kde.plasma.core 2.0 as PlasmaCore + +import org.kde.taskmanager 0.1 as TaskManager + +Item { + property alias screenGeometry: tasksModel.screenGeometry + property bool noWindowActive: true + property bool currentWindowMaximized: false + property bool isActiveWindowPinned: false + + TaskManager.VirtualDesktopInfo { id: virtualDesktopInfo } + TaskManager.ActivityInfo { id: activityInfo } + TaskManager.TasksModel { + id: tasksModel + sortMode: TaskManager.TasksModel.SortVirtualDesktop + groupMode: TaskManager.TasksModel.GroupDisabled + + activity: activityInfo.currentActivity + virtualDesktop: virtualDesktopInfo.currentDesktop + screenGeometry: wallpaper.screenGeometry // Warns "Unable to assign [undefined] to QRect" during init, but works thereafter. + + filterByActivity: true + filterByVirtualDesktop: true + filterByScreen: true + + onActiveTaskChanged: { + // console.log('tasksModel.onActiveTaskChanged') + updateActiveWindowInfo() + } + onDataChanged: { + // console.log('tasksModel.onDataChanged') + updateActiveWindowInfo() + } + Component.onCompleted: { + // console.log('tasksModel.Component.onCompleted') + activeWindowModel.sourceModel = tasksModel + } + } + PlasmaCore.SortFilterModel { + id: activeWindowModel + filterRole: 'IsActive' + filterRegExp: 'true' + onDataChanged: { + // console.log('activeWindowModel.onDataChanged') + updateActiveWindowInfo() + } + onCountChanged: { + // console.log('activeWindowModel.onCountChanged') + updateActiveWindowInfo() + } + } + + + function activeTask() { + return activeWindowModel.get(0) || {} + } + + function updateActiveWindowInfo() { + var actTask = activeTask() + noWindowActive = activeWindowModel.count === 0 || actTask.IsActive !== true + currentWindowMaximized = !noWindowActive && actTask.IsMaximized === true + isActiveWindowPinned = actTask.VirtualDesktop === -1 + } +} 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 @@ -40,6 +40,9 @@ property var cfg_SlidePaths: "" property int cfg_SlideInterval: 0 property var cfg_UncheckedSlides: [] + property int cfg_AnimationDuration: 400 + property int cfg_BlurRadius: 40 + property alias cfg_BlurWallpaper: wallpaperBlurCheckBox.checked function saveConfig() { imageWallpaper.commitDeletion(); @@ -82,6 +85,7 @@ Kirigami.FormLayout { twinFormLayouts: parentLayout + QtControls2.ComboBox { id: resizeComboBox Kirigami.FormData.label: i18nd("plasma_wallpaper_org.kde.image", "Positioning:") @@ -187,6 +191,7 @@ dialogTitle: i18nd("plasma_wallpaper_org.kde.image", "Select Background Color") } } + } Component { @@ -355,6 +360,57 @@ } } + Kirigami.FormLayout { + twinFormLayouts: parentLayout + Row { + id: inactiveBlurRow + spacing: units.largeSpacing / 2 + Kirigami.FormData.label: i18n("Blur on active window:") + QtControls2.CheckBox { + id: wallpaperBlurCheckBox + anchors.verticalCenter: blurRadiusSpinBox.verticalCenter + } + QtControls2.Label { + anchors.verticalCenter: blurRadiusSpinBox.verticalCenter + text: i18n(" by ") + } + QtControls2.SpinBox { + id: blurRadiusSpinBox + value: cfg_BlurRadius + onValueChanged: cfg_BlurRadius = value + stepSize: 1 + from: 1 + to: 400 + editable: true + } + QtControls2.Label { + anchors.verticalCenter: blurRadiusSpinBox.verticalCenter + text: i18n(" over ") + } + QtControls2.SpinBox { + id: animationDurationSpinBox + value: cfg_AnimationDuration + onValueChanged: cfg_AnimationDuration = value + from: 0 + to: 2000000000 + stepSize: 100 + editable: true + + textFromValue: function(value, locale) { + return i18n("%1ms", value) + } + valueFromText: function(text, locale) { + // Number.fromLocaleString() doesn't strip suffix and raises an error. + // return Number.fromLocaleString(locale, text) + + // parseInt does seem to stip non-digit characters, but it probably + // only works with ASCII digits? + return parseInt(text, 10) + } + } + } + } + RowLayout { id: buttonsRow Layout.alignment: Qt.AlignRight | Qt.AlignVCenter diff --git a/wallpapers/image/imagepackage/contents/ui/main.qml b/wallpapers/image/imagepackage/contents/ui/main.qml --- a/wallpapers/image/imagepackage/contents/ui/main.qml +++ b/wallpapers/image/imagepackage/contents/ui/main.qml @@ -27,7 +27,7 @@ QQC2.StackView { id: root - + anchors.fill: parent readonly property string modelImage: imageWallpaper.wallpaperPath readonly property string configuredImage: wallpaper.configuration.Image readonly property int fillMode: wallpaper.configuration.FillMode @@ -48,6 +48,10 @@ function action_open() { Qt.openUrlExternally(modelImage) } + + WindowModel { + id: windowModel + } //private @@ -94,6 +98,9 @@ "color": root.configColor, "blur": root.blur, "opacity": isFirst ? 1: 0}); + var pendingBlur = baseBlur.createObject(root, {"source": pendingImage, + "anchors.fill": pendingImage + }) function replaceWhenLoaded() { if (pendingImage.status !== Image.Loading) { @@ -107,6 +114,16 @@ pendingImage.statusChanged.connect(replaceWhenLoaded); replaceWhenLoaded(); } + + Component { + id: baseBlur + FastBlur { + radius: ((!wallpaper.configuration.BlurWallpaper) || windowModel.noWindowActive) ? 0 : wallpaper.configuration.BlurRadius + Behavior on radius { + NumberAnimation { duration: wallpaper.configuration.BlurAnimationDuration } + } + } + } Component { id: baseImage