Skip to content

Commit

Permalink
#19 Context menu added
Browse files Browse the repository at this point in the history
  • Loading branch information
antroids committed Mar 20, 2024
1 parent 5210644 commit e8331c0
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
7 changes: 7 additions & 0 deletions package/contents/ui/ActiveTasksModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ TaskManager.TasksModel {
keepBelow = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsKeepBelow) || false;
hasAppMenu = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.ApplicationMenuServiceName) || false;
onAllVirtualDesktops = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsOnAllVirtualDesktops) || false;
fullScreenable = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsFullScreenable) || false;
fullScreen = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsFullScreen) || false;
resizable = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.IsResizable) || false;
appName = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.AppName);
genericAppName = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.GenericAppName);
decoration = tasksModel.data(activeTaskIndex, TaskManager.AbstractTasksModel.Decoration);
Expand All @@ -101,6 +104,10 @@ TaskManager.TasksModel {
return tasksModel.requestToggleShaded(activeTaskIndex);
case ActiveWindow.Action.Activate:
return tasksModel.requestActivate(activeTaskIndex);
case ActiveWindow.Action.FullScreen:
return tasksModel.requestToggleFullScreen(activeTaskIndex);
case ActiveWindow.Action.Resize:
return tasksModel.requestResize(activeTaskIndex);
}
}
}
Expand Down
11 changes: 10 additions & 1 deletion package/contents/ui/ActiveWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ QtObject {
Help,
Menu,
AppMenu,
Activate
Activate,
FullScreen,
Resize
}

property bool minimizable: false
Expand All @@ -36,6 +38,9 @@ QtObject {
property bool onAllVirtualDesktops: false
property bool keepAbove: false
property bool keepBelow: false
property bool fullScreenable: false
property bool fullScreen: false
property bool resizable: false
property var appName
property var genericAppName
property var decoration
Expand All @@ -57,6 +62,10 @@ QtObject {
return shadeable;
case ActiveWindow.Action.AppMenu:
return hasAppMenu;
case ActiveWindow.Action.Fullscreen:
return fullScreenable;
case ActiveWindow.Action.Resize:
return resizable;
default:
return true;
}
Expand Down
61 changes: 61 additions & 0 deletions package/contents/ui/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import QtQuick.Layouts
import org.kde.kirigami as Kirigami
import org.kde.plasma.components as PlasmaComponents
import org.kde.plasma.core as PlasmaCore
import org.kde.plasma.extras as PlasmaExtras
import org.kde.plasma.plasmoid
import org.kde.taskmanager as TaskManager
import "utils.js" as Utils
Expand All @@ -35,6 +36,66 @@ PlasmoidItem {

kWinConfig.invokeKWinShortcut(shortcut);
}
Plasmoid.contextualActions: [
PlasmaCore.Action {
text: i18n("Ma&ximize")
enabled: tasksModel.activeWindow.maximizable
checked: tasksModel.activeWindow.maximized
icon.name: "window-maximize"
checkable: true
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.Maximize)
},
PlasmaCore.Action {
text: i18n("Mi&nimize")
enabled: tasksModel.activeWindow.minimizable
icon.name: "window-minimize"
checkable: false
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.Minimize)
},
PlasmaCore.Action {
text: i18n("Keep &Above Others")
checked: tasksModel.activeWindow.keepAbove
icon.name: "window-keep-above"
checkable: true
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.KeepAbove)
},
PlasmaCore.Action {
text: i18n("Keep &Below Others")
checked: tasksModel.activeWindow.keepBelow
icon.name: "window-keep-below"
checkable: true
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.KeepBelow)
},
PlasmaCore.Action {
text: i18n("&Fullscreen")
enabled: tasksModel.activeWindow.fullScreenable
checked: tasksModel.activeWindow.fullScreen
icon.name: "view-fullscreen"
checkable: true
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.FullScreen)
},
PlasmaCore.Action {
text: i18n("&Move")
icon.name: "transform-move"
enabled: tasksModel.activeTask.movable
checkable: false
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.Move)
},
PlasmaCore.Action {
text: i18n("&Resize")
icon.name: "image-resize-symbolic"
enabled: tasksModel.activeTask.resizable
checkable: false
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.Resize)
},
PlasmaCore.Action {
text: i18n("&Close")
icon.name: "window-close"
enabled: tasksModel.activeTask.closable
checkable: false
onTriggered: tasksModel.activeWindow.actionCall(ActiveWindow.Action.Close)
}
]

Component {
id: widgetElementLoaderDelegate
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.0",
"Version": "0.4.1",
"Website": "https://github.com/antroids/application-title-bar",
"FormFactors": [
"desktop"
Expand Down

0 comments on commit e8331c0

Please sign in to comment.