Hopefully fixed SevenTasks now.

This commit is contained in:
wackyideas 2022-09-01 18:37:59 +02:00
parent 80e8146d5d
commit 656903bd86
6 changed files with 216 additions and 0 deletions

View file

@ -0,0 +1,94 @@
/*
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.7
import QtQuick.Controls 2.15
import QtQuick.Templates 2.15 as T
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.5 as Kirigami
T.Menu {
id: control
palette: Kirigami.Theme.palette
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding
delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() }
margins: 0
leftPadding: background.margins.left
topPadding: background.margins.top
rightPadding: background.margins.right
bottomPadding: background.margins.bottom
contentItem: ListView {
implicitHeight: contentHeight
property bool hasCheckables: false
property bool hasIcons: false
model: control.contentModel
implicitWidth: {
var maxWidth = 0;
for (var i = 0; i < contentItem.children.length; ++i) {
maxWidth = Math.max(maxWidth, contentItem.children[i].implicitWidth);
}
return maxWidth;
}
interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false
clip: true
currentIndex: control.currentIndex || 0
keyNavigationEnabled: true
keyNavigationWraps: true
T.ScrollBar.vertical: ScrollBar {}
}
Connections {
target: control.contentItem.contentItem
function onChildrenChanged() {
for (var i in control.contentItem.contentItem.children) {
var child = control.contentItem.contentItem.children[i];
if (child.checkable) {
control.contentItem.hasCheckables = true;
}
if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.length > 0)) {
control.contentItem.hasIcons = true;
}
}
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
easing.type: Easing.InOutQuad
duration: PlasmaCore.Units.shortDuration
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1
to: 0
easing.type: Easing.InOutQuad
duration: PlasmaCore.Units.shortDuration
}
}
background: PlasmaCore.FrameSvgItem {
imagePath: "widgets/background"
implicitWidth: PlasmaCore.Units.gridUnit * 8
implicitHeight: PlasmaCore.Units.gridUnit * 2
}
}

View file

@ -0,0 +1,20 @@
/*
SPDX-FileCopyrightText: 2011 Marco Martin <mart@kde.org>
SPDX-FileCopyrightText: 2011 Nokia Corporation and /or its subsidiary(-ies) <qt-info@nokia.com>
This file is part of the Qt Components project.
SPDX-License-Identifier: BSD-3-Clause
*/
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
/**
* Provides a component with list of options that the user can choose from.
*
* All elements of this component are defined in Menu, its base component.
*/
MenuBackend {
id: root
}

View file

@ -0,0 +1,94 @@
/*
SPDX-FileCopyrightText: 2016 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
import QtQuick 2.7
import QtQuick.Controls 2.15
import QtQuick.Templates 2.15 as T
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.5 as Kirigami
T.Menu {
id: control
palette: Kirigami.Theme.palette
implicitWidth: Math.max(background ? background.implicitWidth : 0,
contentItem ? contentItem.implicitWidth + leftPadding + rightPadding : 0)
implicitHeight: Math.max(background ? background.implicitHeight : 0,
contentItem ? contentItem.implicitHeight : 0) + topPadding + bottomPadding
delegate: MenuItem { width: parent.width; onImplicitWidthChanged: control.contentItem.contentItem.childrenChanged() }
margins: 0
leftPadding: background.margins.left
topPadding: background.margins.top
rightPadding: background.margins.right
bottomPadding: background.margins.bottom
contentItem: ListView {
implicitHeight: contentHeight
property bool hasCheckables: false
property bool hasIcons: false
model: control.contentModel
implicitWidth: {
var maxWidth = 0;
for (var i = 0; i < contentItem.children.length; ++i) {
maxWidth = Math.max(maxWidth, contentItem.children[i].implicitWidth);
}
return maxWidth;
}
interactive: ApplicationWindow.window ? contentHeight > ApplicationWindow.window.height : false
clip: true
currentIndex: control.currentIndex || 0
keyNavigationEnabled: true
keyNavigationWraps: true
T.ScrollBar.vertical: ScrollBar {}
}
Connections {
target: control.contentItem.contentItem
function onChildrenChanged() {
for (var i in control.contentItem.contentItem.children) {
var child = control.contentItem.contentItem.children[i];
if (child.checkable) {
control.contentItem.hasCheckables = true;
}
if (child.icon && child.icon.hasOwnProperty("name") && (child.icon.name.length > 0 || child.icon.source.length > 0)) {
control.contentItem.hasIcons = true;
}
}
}
}
enter: Transition {
NumberAnimation {
property: "opacity"
from: 0
to: 1
easing.type: Easing.InOutQuad
duration: PlasmaCore.Units.shortDuration
}
}
exit: Transition {
NumberAnimation {
property: "opacity"
from: 1
to: 0
easing.type: Easing.InOutQuad
duration: PlasmaCore.Units.shortDuration
}
}
background: PlasmaCore.FrameSvgItem {
imagePath: "widgets/background"
implicitWidth: PlasmaCore.Units.gridUnit * 8
implicitHeight: PlasmaCore.Units.gridUnit * 2
}
}

View file

@ -104,6 +104,9 @@ MouseArea {
}
}
ContextMenu {
id: testMenu
}
TaskManager.TasksModel {
id: tasksModel

View file

@ -23,6 +23,8 @@
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipInstance.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ToolTipWindowMouseArea.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/main.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/MenuBackend.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/contents/ui/ContextMenuBackend.qml
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.desktop
/usr/share/plasma/plasmoids/org.kde.plasma.seventasks/metadata.json
/usr/share/metainfo/org.kde.plasma.seventasks.appdata.xml

View file

@ -104,6 +104,9 @@ MouseArea {
}
}
ContextMenu {
id: testMenu
}
TaskManager.TasksModel {
id: tasksModel