Commit 0fbaa4ed authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

Revert "applets/{showdesktop,minimizeall}: unify applet code"

This reverts commit d84a8d72
parent 00f4b7e1
Pipeline #205983 passed with stage
in 2 minutes and 55 seconds
#! /usr/bin/env bash
$XGETTEXT `find . -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.plasma.minimizeall.pot
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name=""/>
<group name="General">
<entry name="icon" type="String">
<default>user-desktop</default>
</entry>
</group>
</kcfg>
/*
SPDX-FileCopyrightText: 2015 Sebastian Kügler <sebas@kde.org>
SPDX-FileCopyrightText: 2016 Anthony Fieroni <bvbfan@abv.bg>
SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.7
import QtQuick.Layouts 1.1
import org.kde.plasma.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.taskmanager 0.1 as TaskManager
MouseArea {
id: root
readonly property bool inPanel: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge, PlasmaCore.Types.LeftEdge]
.includes(Plasmoid.location)
property bool active: false
// list of persistentmodelindexes from task manager model of clients minimised by us
property var minimizedClients: []
Plasmoid.icon: Plasmoid.configuration.icon
Plasmoid.title: i18n("Minimize all Windows")
Plasmoid.toolTipSubText: i18n("Show the desktop by minimizing all windows")
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
Layout.minimumWidth: PlasmaCore.Units.gridUnit
Layout.minimumHeight: PlasmaCore.Units.gridUnit
Layout.maximumWidth: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1
Plasmoid.onActivated: toggleActive()
onClicked: Plasmoid.activated()
hoverEnabled: true
activeFocusOnTab: true
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Space:
case Qt.Key_Enter:
case Qt.Key_Return:
case Qt.Key_Select:
Plasmoid.activated();
break;
}
}
Accessible.name: Plasmoid.title
Accessible.description: Plasmoid.toolTipSubText
Accessible.role: Accessible.Button
function activate() {
const clients = [];
for (let i = 0 ; i < tasksModel.count; i++) {
const idx = tasksModel.makeModelIndex(i);
if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsHidden)) {
tasksModel.requestToggleMinimized(idx);
clients.push(tasksModel.makePersistentModelIndex(i));
}
}
root.minimizedClients = clients;
root.active = true;
}
function deactivate() {
root.active = false;
for (let i = 0 ; i < root.minimizedClients.length; i++) {
const idx = root.minimizedClients[i];
// client deleted, do nothing
if (!idx.valid) {
continue;
}
// if the user has restored it already, do nothing
if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsHidden)) {
continue;
}
tasksModel.requestToggleMinimized(idx);
}
root.minimizedClients = [];
}
function toggleActive() {
if (root.active) {
deactivate();
} else {
activate();
}
}
TaskManager.TasksModel {
id: tasksModel
sortMode: TaskManager.TasksModel.SortDisabled
groupMode: TaskManager.TasksModel.GroupDisabled
}
Connections {
target: tasksModel
enabled: root.active
function onActiveTaskChanged() {
if (tasksModel.activeTask.valid) { // to suppress changing focus to non windows, such as the desktop
root.active = false;
root.minimizedClients = [];
}
}
function onVirtualDesktopChanged() {
deactivate();
}
function onActivityChanged() {
deactivate();
}
}
PlasmaCore.IconItem {
anchors.fill: parent
active: root.containsMouse
source: Plasmoid.icon
}
// also activate when dragging an item over the plasmoid so a user can easily drag data to the desktop
DropArea {
anchors.fill: parent
onEntered: activateTimer.start()
onExited: activateTimer.stop()
}
Timer {
id: activateTimer
interval: 250 // to match TaskManager
onTriggered: Plasmoid.activated()
}
PlasmaCore.FrameSvgItem {
property var containerMargins: {
let item = this;
while (item.parent) {
item = item.parent;
if (item.isAppletContainer) {
return item.getMargins;
}
}
return undefined;
}
anchors {
fill: parent
property bool returnAllMargins: true
// The above makes sure margin is returned even for side margins
// that would be otherwise turned off.
topMargin: containerMargins ? -containerMargins('top', returnAllMargins) : 0
leftMargin: containerMargins ? -containerMargins('left', returnAllMargins) : 0
rightMargin: containerMargins ? -containerMargins('right', returnAllMargins) : 0
bottomMargin: containerMargins ? -containerMargins('bottom', returnAllMargins) : 0
}
imagePath: "widgets/tabbar"
prefix: {
let prefix;
switch (Plasmoid.location) {
case PlasmaCore.Types.LeftEdge:
prefix = "west-active-tab";
break;
case PlasmaCore.Types.TopEdge:
prefix = "north-active-tab";
break;
case PlasmaCore.Types.RightEdge:
prefix = "east-active-tab";
break;
default:
prefix = "south-active-tab";
}
if (!hasElementPrefix(prefix)) {
prefix = "active-tab";
}
return prefix;
}
opacity: root.active ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.shortDuration
easing.type: Easing.InOutQuad
}
}
}
function action_showdesktop() {
showdesktop.toggleDesktop();
}
Component.onCompleted: {
Plasmoid.setAction("showdesktop", i18nc("@action", "Show Desktop"))
}
}
......@@ -137,6 +137,5 @@
"X-Plasma-MainScript": "ui/main.qml",
"X-Plasma-Provides": [
"org.kde.plasma.windowmanagement"
],
"X-Plasma-RootPath": "org.kde.plasma.showdesktop"
]
}
/*
SPDX-FileCopyrightText: 2015 Sebastian Kügler <sebas@kde.org>
SPDX-FileCopyrightText: 2016 Anthony Fieroni <bvbfan@abv.bg>
SPDX-FileCopyrightText: 2018 David Edmundson <davidedmundson@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.15
import org.kde.plasma.plasmoid 2.0
import org.kde.taskmanager 0.1 as TaskManager
QtObject {
id: component
readonly property QtObject tasksModel: TaskManager.TasksModel {
sortMode: TaskManager.TasksModel.SortDisabled
groupMode: TaskManager.TasksModel.GroupDisabled
}
readonly property Connections activeTaskChangedConnection: Connections {
target: tasksModel
enabled: component.active
function onActiveTaskChanged() {
if (tasksModel.activeTask.valid) { // to suppress changing focus to non windows, such as the desktop
component.active = false;
component.minimizedClients = [];
}
}
function onVirtualDesktopChanged() {
component.deactivate();
}
function onActivityChanged() {
component.deactivate();
}
}
/**
* Whether the "minimize all" effect is activated
*/
property bool active: false
/**
* List of persistent model indexes from task manager model of
* clients minimized by us
*/
property var minimizedClients: []
function activate() {
const clients = [];
for (let i = 0 ; i < tasksModel.count; i++) {
const idx = tasksModel.makeModelIndex(i);
if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsHidden)) {
tasksModel.requestToggleMinimized(idx);
clients.push(tasksModel.makePersistentModelIndex(i));
}
}
component.minimizedClients = clients;
component.active = true;
}
function deactivate() {
component.active = false;
for (let i = 0 ; i < component.minimizedClients.length; i++) {
const idx = component.minimizedClients[i];
// client deleted, do nothing
if (!idx.valid) {
continue;
}
// if the user has restored it already, do nothing
if (!tasksModel.data(idx, TaskManager.AbstractTasksModel.IsHidden)) {
continue;
}
tasksModel.requestToggleMinimized(idx);
}
component.minimizedClients = [];
}
function toggleActive() {
if (component.active) {
deactivate();
} else {
activate();
}
}
}
......@@ -20,27 +20,9 @@ MouseArea {
readonly property bool inPanel: [PlasmaCore.Types.TopEdge, PlasmaCore.Types.RightEdge, PlasmaCore.Types.BottomEdge, PlasmaCore.Types.LeftEdge]
.includes(Plasmoid.location)
/**
* @c true if the current applet is Minimize All, @c false if the
* current applet is Show Desktop.
*/
readonly property bool isMinimizeAll: Plasmoid.pluginName === "org.kde.plasma.minimizeall"
Plasmoid.icon: Plasmoid.configuration.icon
Plasmoid.title: {
if (isMinimizeAll) {
return i18n("Minimize all Windows");
}
return i18n("Peek at Desktop");
}
Plasmoid.toolTipSubText: {
if (isMinimizeAll) {
return i18n("Show the desktop by minimizing all windows");
}
return i18n("Temporarily reveals the Desktop by moving open windows into screen corners");
}
Plasmoid.title: i18n("Peek at Desktop")
Plasmoid.toolTipSubText: i18n("Temporarily reveals the Desktop by moving open windows into screen corners")
Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
......@@ -51,19 +33,12 @@ MouseArea {
Layout.maximumWidth: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1
Layout.maximumHeight: inPanel ? PlasmaCore.Units.iconSizeHints.panel : -1
activeFocusOnTab: true
hoverEnabled: true
Plasmoid.onActivated: {
if (isMinimizeAll) {
minimizeAllComponent.item.toggleActive();
return;
}
showdesktop.toggleDesktop();
}
Plasmoid.onActivated: showdesktop.toggleDesktop()
onClicked: Plasmoid.activated();
hoverEnabled: true
activeFocusOnTab: true
Keys.onPressed: {
switch (event.key) {
case Qt.Key_Space:
......@@ -74,23 +49,11 @@ MouseArea {
break;
}
}
Accessible.name: Plasmoid.title
Accessible.description: Plasmoid.toolTipSubText
Accessible.role: Accessible.Button
ShowDesktop {
id: showdesktop
}
Loader {
id: minimizeAllComponent
active: root.isMinimizeAll
asynchronous: true
source: "MinimizeAllComponent.qml"
}
ShowDesktop { id: showdesktop }
PlasmaCore.IconItem {
anchors.fill: parent
......@@ -135,7 +98,7 @@ MouseArea {
bottomMargin: containerMargins ? -containerMargins('bottom', returnAllMargins) : 0
}
imagePath: "widgets/tabbar"
visible: opacity > 0
visible: fromCurrentTheme && opacity > 0
prefix: {
let prefix;
switch (Plasmoid.location) {
......@@ -156,14 +119,7 @@ MouseArea {
}
return prefix;
}
opacity: {
if (isMinimizeAll) {
return minimizeAllComponent.item.active ? 1 : 0;
}
return showdesktop.showingDesktop ? 1 : 0;
}
opacity: showdesktop.showingDesktop ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.shortDuration
......@@ -176,12 +132,7 @@ MouseArea {
showdesktop.minimizeAll();
}
function action_showdesktop() {
showdesktop.toggleDesktop();
}
Component.onCompleted: {
Plasmoid.setAction("minimizeall", i18nc("@action", "Minimize All Windows"));
Plasmoid.setAction("showdesktop", i18nc("@action", "Show Desktop"));
Plasmoid.setAction("minimizeall", i18nc("@action", "Minimize All Windows"))
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment