2019-10-22 10:52:53 +00:00
|
|
|
/*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
|
2019-10-22 10:52:53 +00:00
|
|
|
*
|
2021-03-01 20:03:25 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2019-10-22 10:52:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.12
|
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
|
import QtQml.Models 2.12
|
|
|
|
|
|
2021-04-09 20:59:05 +00:00
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
2019-10-22 10:52:53 +00:00
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
|
|
|
|
|
|
|
|
DrawerBackground {
|
|
|
|
|
id: fullContainer
|
|
|
|
|
property Item applet
|
|
|
|
|
property ObjectModel fullRepresentationModel
|
|
|
|
|
property ListView fullRepresentationView
|
2021-04-09 20:59:05 +00:00
|
|
|
|
|
|
|
|
backgroundColor: (applet.backgroundHints === PlasmaCore.Types.NoBackground) ? "transparent" : Kirigami.ColorUtils.adjustColor(PlasmaCore.Theme.backgroundColor, {"alpha": 0.8*255})
|
2020-09-01 15:40:09 +00:00
|
|
|
visible: shouldBeVisible
|
2021-04-09 20:59:05 +00:00
|
|
|
|
2020-09-01 15:40:09 +00:00
|
|
|
property bool shouldBeVisible: applet && (applet.status != PlasmaCore.Types.HiddenStatus && applet.status != PlasmaCore.Types.PassiveStatus)
|
2021-04-09 20:59:05 +00:00
|
|
|
|
2019-10-22 10:52:53 +00:00
|
|
|
height: parent.height
|
2021-03-09 12:52:17 +00:00
|
|
|
width: visible ? quickSettings.width : 0
|
2019-10-22 10:52:53 +00:00
|
|
|
Layout.minimumHeight: applet && applet.switchHeight
|
2020-09-01 15:40:09 +00:00
|
|
|
onShouldBeVisibleChanged: fullContainer.visible = fullContainer.shouldBeVisible
|
|
|
|
|
|
2021-02-25 17:01:57 +00:00
|
|
|
Component.onCompleted: visibleChanged();
|
2020-02-27 07:06:16 +00:00
|
|
|
onVisibleChanged: {
|
2019-10-22 10:52:53 +00:00
|
|
|
if (visible) {
|
|
|
|
|
for (var i = 0; i < fullRepresentationModel.count; ++i) {
|
|
|
|
|
if (fullRepresentationModel.get(i) === this) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fullRepresentationModel.append(this);
|
|
|
|
|
fullRepresentationView.forceLayout();
|
|
|
|
|
|
|
|
|
|
fullRepresentationView.currentIndex = ObjectModel.index;
|
2021-02-25 17:01:57 +00:00
|
|
|
fullRepresentationView.positionViewAtIndex(ObjectModel.index, ListView.Contain)
|
2019-10-22 10:52:53 +00:00
|
|
|
} else if (ObjectModel.index >= 0) {
|
|
|
|
|
fullRepresentationModel.remove(ObjectModel.index);
|
|
|
|
|
fullRepresentationView.forceLayout();
|
|
|
|
|
}
|
2020-09-01 15:40:09 +00:00
|
|
|
if (!shouldBeVisible) {
|
|
|
|
|
visible = false;
|
|
|
|
|
}
|
2019-10-22 10:52:53 +00:00
|
|
|
}
|
|
|
|
|
Connections {
|
|
|
|
|
target: fullContainer.applet
|
2021-02-25 17:01:57 +00:00
|
|
|
function onActivated() {
|
2019-10-22 10:52:53 +00:00
|
|
|
if (!visible) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
fullRepresentationView.currentIndex = ObjectModel.index;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-25 17:01:57 +00:00
|
|
|
Connections {
|
|
|
|
|
target: fullContainer.applet.fullRepresentationItem
|
|
|
|
|
function onParentChanged() {
|
|
|
|
|
fullContainer.applet.fullRepresentationItem.parent = fullContainer;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-10-22 10:52:53 +00:00
|
|
|
}
|