diff --git a/package/contents/config/main.xml b/package/contents/config/main.xml index d5bdb7f..18810dd 100644 --- a/package/contents/config/main.xml +++ b/package/contents/config/main.xml @@ -108,6 +108,7 @@ + 0 diff --git a/package/contents/ui/ActiveTasksModel.qml b/package/contents/ui/ActiveTasksModel.qml index 6895b24..4e29c96 100644 --- a/package/contents/ui/ActiveTasksModel.qml +++ b/package/contents/ui/ActiveTasksModel.qml @@ -11,7 +11,8 @@ TaskManager.TasksModel { enum ActiveTaskSource { ActiveTask, - LastActiveTask + LastActiveTask, + LastActiveMaximized } property ActiveWindow activeWindow @@ -35,6 +36,7 @@ TaskManager.TasksModel { activeTaskIndex = filterTask(activeTask) ? activeTask : getInvalidIndex(); break; case ActiveTasksModel.ActiveTaskSource.LastActiveTask: + case ActiveTasksModel.ActiveTaskSource.LastActiveMaximized: activeTaskIndex = hasIndex(0, 0) && filterTask(getFirstRowIndex()) ? getFirstRowIndex() : getInvalidIndex(); break; } @@ -59,6 +61,7 @@ TaskManager.TasksModel { filterByVirtualDesktop: plasmoid.configuration.widgetActiveTaskFilterByVirtualDesktop filterHidden: true filterMinimized: true + filterNotMaximized: plasmoid.configuration.widgetActiveTaskSource == ActiveTasksModel.ActiveTaskSource.LastActiveMaximized onDataChanged: function(from, to, roles) { if (hasActiveWindow && activeTaskIndex >= from && activeTaskIndex <= to) updateActiveTaskIndex(); @@ -95,6 +98,7 @@ TaskManager.TasksModel { fullScreenable = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsFullScreenable) || false; fullScreen = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsFullScreen) || false; resizable = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsResizable) || false; + active = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsActive) || false; appName = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.AppName); genericAppName = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.GenericAppName); decoration = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.Decoration); diff --git a/package/contents/ui/ActiveWindow.qml b/package/contents/ui/ActiveWindow.qml index ab1cb08..d2ea27f 100644 --- a/package/contents/ui/ActiveWindow.qml +++ b/package/contents/ui/ActiveWindow.qml @@ -41,6 +41,7 @@ QtObject { property bool fullScreenable: false property bool fullScreen: false property bool resizable: false + property bool active: false property var appName property var genericAppName property var decoration diff --git a/package/contents/ui/PlasmaWindowControlButtonIcon.qml b/package/contents/ui/PlasmaWindowControlButtonIcon.qml new file mode 100644 index 0000000..1f02b92 --- /dev/null +++ b/package/contents/ui/PlasmaWindowControlButtonIcon.qml @@ -0,0 +1,117 @@ +/* + * SPDX-FileCopyrightText: 2024 Anton Kharuzhy + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import QtCore +import QtQuick +import QtQuick.Controls +import QtQuick.Effects +import QtQuick.Shapes +import org.kde.kirigami as Kirigami + +Item { + id: iconRoot + + property bool active: true + property bool hovered: false + property bool pressed: false + property bool toggled: false + property alias source: icon.source + + anchors.fill: parent + + Shape { + id: iconBackground + + layer.enabled: true + anchors.fill: parent + opacity: hovered ? 0.25 : pressed || toggled ? 0.15 : 0 + + ShapePath { + startX: 0 + startY: height / 2 + fillGradient: radialGradient + strokeColor: "transparent" + + PathArc { + x: width + y: height / 2 + radiusX: iconBackground.width / 2 + radiusY: height / 2 + useLargeArc: true + } + + PathArc { + x: 0 + y: height / 2 + radiusX: iconBackground.width / 2 + radiusY: height / 2 + useLargeArc: true + } + + } + + RadialGradient { + id: radialGradient + + centerX: iconBackground.width / 2 + centerY: iconBackground.height / 2 + centerRadius: iconBackground.width / 2 + focalX: centerX + focalY: centerY + + GradientStop { + position: 0 + color: Kirigami.Theme.textColor + } + + GradientStop { + position: 1 + color: "transparent" + } + + } + + Behavior on opacity { + NumberAnimation { + duration: button.animationDuration + } + + } + + } + + Kirigami.Icon { + id: icon + + anchors.fill: parent + } + + MultiEffect { + anchors.fill: source + source: icon + blurEnabled: true + blurMax: 8 + brightness: hovered ? 0.6 : pressed || toggled ? 0.3 : 0 + blur: hovered ? 4 : pressed || toggled ? 2 : 0 + saturation: active ? 0 : -0.5 + + Behavior on blur { + NumberAnimation { + duration: button.animationDuration + } + + } + + Behavior on brightness { + NumberAnimation { + duration: button.animationDuration + } + + } + + } + +} diff --git a/package/contents/ui/WindowControlButton.qml b/package/contents/ui/WindowControlButton.qml index 3e49889..aeb2ae3 100644 --- a/package/contents/ui/WindowControlButton.qml +++ b/package/contents/ui/WindowControlButton.qml @@ -331,86 +331,13 @@ Item { Component { id: fallbackButtonIcon - Item { - anchors.fill: parent - - Kirigami.Icon { - id: icon - - anchors.fill: parent - source: fallbackIcon - } - - MultiEffect { - id: iconEffects - - anchors.fill: source - source: icon - blurEnabled: true - blurMax: 8 - states: [ - State { - name: "hover" - when: isHoveredButtonState(button.iconState) - - PropertyChanges { - target: iconEffects - brightness: 0.8 - blur: 4 - } - - }, - State { - name: "pressed" - when: isPressedButtonState(button.iconState) - - PropertyChanges { - target: iconEffects - brightness: 0.6 - blur: 4 - } - - }, - State { - name: "toggled" - when: isToggledButtonState(button.iconState) - - PropertyChanges { - target: iconEffects - brightness: 0.6 - blur: 4 - } - - }, - State { - name: "deactivated" - when: isDeactivatedButtonState(button.iconState) - - PropertyChanges { - target: iconEffects - brightness: -0.5 - saturation: -1 - } - - } - ] - - Behavior on blur { - NumberAnimation { - duration: button.animationDuration - } - - } - - Behavior on brightness { - NumberAnimation { - duration: button.animationDuration - } - - } - - } - + PlasmaWindowControlButtonIcon { + source: fallbackIcon + hovered: isHoveredButtonState(button.iconState) + toggled: isToggledButtonState(button.iconState) + pressed: isPressedButtonState(button.iconState) + active: isActiveButtonState(button.iconState) + enabled: !isDeactivatedButtonState(button.iconState) } } diff --git a/package/contents/ui/config/ConfigBehavior.qml b/package/contents/ui/config/ConfigBehavior.qml index 351ac9d..241f114 100644 --- a/package/contents/ui/config/ConfigBehavior.qml +++ b/package/contents/ui/config/ConfigBehavior.qml @@ -72,11 +72,11 @@ KCM.SimpleKCM { ComboBox { id: widgetActiveTaskSource - model: [i18n("Active task"), i18n("Last active task")] + model: [i18n("Active task"), i18n("Last active task"), i18n("Last active maximized task")] } KCM.ContextualHelpButton { - toolTipText: i18n("

How to obtain the active task from tasks manager:
Active task: current active task after filtering. The widget will be disabled if the current active task is on another screen, regardless whether there are another tasks on this screen or not.
Last active task: show widget for the last active task after filters applied.

") + toolTipText: i18n("

How to obtain the active task from tasks manager:
Active task: current active task after filtering. The widget will be disabled if the current active task is on another screen, regardless whether there are another tasks on this screen or not.
Last active task: show widget for the last active task after filters applied.
Last active maximized task: show widget for the last active maximized task after filters applied.

") } } @@ -117,6 +117,7 @@ KCM.SimpleKCM { CheckBox { id: widgetActiveTaskFilterNotMaximized + enabled: widgetActiveTaskSource.currentIndex !== ActiveTasksModel.ActiveTaskSource.LastActiveMaximized Kirigami.FormData.label: i18n("Disable for not maximized:") text: i18n("enabled") } diff --git a/package/contents/ui/main.qml b/package/contents/ui/main.qml index 8215b23..24e92ae 100644 --- a/package/contents/ui/main.qml +++ b/package/contents/ui/main.qml @@ -169,6 +169,7 @@ PlasmoidItem { } enabled: tasksModel.hasActiveWindow && tasksModel.activeWindow.actionSupported(getAction()) toggled: tasksModel.hasActiveWindow && tasksModel.activeWindow.buttonToggled(modelData.windowControlButtonType) + active: tasksModel.hasActiveWindow && tasksModel.activeWindow.active } } diff --git a/package/metadata.json b/package/metadata.json index 736e3a4..00eaf1b 100644 --- a/package/metadata.json +++ b/package/metadata.json @@ -12,7 +12,7 @@ "Id": "com.github.antroids.application-title-bar", "Name": "Application Title Bar", "License": "GPL-3.0+", - "Version": "0.4.3", + "Version": "0.4.4", "Website": "https://github.com/antroids/application-title-bar", "FormFactors": [ "desktop"