Skip to content

Commit

Permalink
#23: Last active maximized task
Browse files Browse the repository at this point in the history
  • Loading branch information
antroids committed Mar 27, 2024
1 parent 7dc12ee commit 8283776
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 84 deletions.
1 change: 1 addition & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<choices>
<choice name="ActiveTask" />
<choice name="LastActiveTask" />
<choice name="LastActiveMaximized" />
</choices>
<default>0</default>
</entry>
Expand Down
6 changes: 5 additions & 1 deletion package/contents/ui/ActiveTasksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ TaskManager.TasksModel {

enum ActiveTaskSource {
ActiveTask,
LastActiveTask
LastActiveTask,
LastActiveMaximized
}

property ActiveWindow activeWindow
Expand All @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions package/contents/ui/ActiveWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
117 changes: 117 additions & 0 deletions package/contents/ui/PlasmaWindowControlButtonIcon.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* SPDX-FileCopyrightText: 2024 Anton Kharuzhy <[email protected]>
*
* 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
}

}

}

}
87 changes: 7 additions & 80 deletions package/contents/ui/WindowControlButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Expand Down
5 changes: 3 additions & 2 deletions package/contents/ui/config/ConfigBehavior.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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("<p>How to obtain the active task from tasks manager: <br><b>Active task</b>: 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.<br/><b>Last active task</b>: show widget for the last active task after filters applied.</p>")
toolTipText: i18n("<p>How to obtain the active task from tasks manager: <br><b>Active task</b>: 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.<br/><b>Last active task</b>: show widget for the last active task after filters applied.<br/><b>Last active maximized task</b>: show widget for the last active maximized task after filters applied.</p>")
}

}
Expand Down Expand Up @@ -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")
}
Expand Down
1 change: 1 addition & 0 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

}
Expand Down
2 changes: 1 addition & 1 deletion package/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 8283776

Please sign in to comment.