shift-shell/containments/panel/package/contents/ui/FullContainer.qml
Marco Martin 5da75348f7 Use Plasma Theme and layout fixes
This moves all background rendering of elements in the top sliding panel to use the plasma theme, making full use of themes that can be downloaded from the store, doing so decreases the usage of the Qt.GraphicalEffects import which is slow and not in Qt6. There are some layout and behavioral fixes especially in widescreen mode
2021-06-09 08:44:48 +00:00

70 lines
2.2 KiB
QML

/*
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
import QtQuick 2.12
import QtQuick.Layouts 1.3
import QtQml.Models 2.12
import org.kde.kirigami 2.12 as Kirigami
import org.kde.plasma.core 2.0 as PlasmaCore
DrawerBackground {
id: fullContainer
property Item applet
property ObjectModel fullRepresentationModel
property ListView fullRepresentationView
visible: shouldBeVisible
property bool shouldBeVisible: applet && (applet.status != PlasmaCore.Types.HiddenStatus && applet.status != PlasmaCore.Types.PassiveStatus)
height: parent.height
width: visible ? quickSettings.width : 0
Layout.minimumHeight: applet && applet.switchHeight
onShouldBeVisibleChanged: fullContainer.visible = fullContainer.shouldBeVisible
Component.onCompleted: visibleChanged();
onVisibleChanged: {
if (visible) {
for (var i = 0; i < fullRepresentationModel.count; ++i) {
if (fullRepresentationModel.get(i) === this) {
return;
}
}
if (applet && applet.pluginName == "org.kde.plasma.notifications") {
fullRepresentationModel.insert(0, this);
} else {
fullRepresentationModel.append(this);
}
fullRepresentationView.forceLayout();
fullRepresentationView.currentIndex = ObjectModel.index;
fullRepresentationView.positionViewAtIndex(ObjectModel.index, ListView.Contain)
} else if (ObjectModel.index >= 0) {
fullRepresentationModel.remove(ObjectModel.index);
fullRepresentationView.forceLayout();
}
if (!shouldBeVisible) {
visible = false;
}
}
Connections {
target: fullContainer.applet
function onActivated() {
if (!visible) {
return;
}
fullRepresentationView.currentIndex = ObjectModel.index;
}
}
Connections {
target: fullContainer.applet.fullRepresentationItem
function onParentChanged() {
fullContainer.applet.fullRepresentationItem.parent = fullContainer;
}
}
}