5447cef2d8
The context property version is slower to access and won't be supported in Qt6. Let's port away from it and use the singleton version instead. Here was my full process for making this change: 1. Made the change with `find . -name '*.qml' | xargs perl -pi -e 's/units\./PlasmaCore\.Units\./g'` 2. Verified no more occurrences with `grep -r " units."` 3. Made sure this didn't change any comments in a silly way by inspecting the output of `git diff | grep "+ " | grep "//"` 4. Manually inspected the full git diff to make sure there were no other unintentional or silly changes (there were none) 5. verified that all changed files have the PlasmaCore import with the correct name with `for FILE in `git status | grep modified | cut -d ":" -f 3`; do grep -q "as PlasmaCore" $FILE || echo "$FILE needs the PlasmaCore import"; done` (one needed the import)
85 lines
2.3 KiB
QML
85 lines
2.3 KiB
QML
/*
|
|
SPDX-FileCopyrightText: 2015 Sebastian Kügler <sebas@kde.org>
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
*/
|
|
|
|
import QtQuick 2.3
|
|
import QtQuick.Layouts 1.1
|
|
import QtQuick.Controls 1.0 as QtControls
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
|
import org.kde.plasma.extras 2.0 as PlasmaExtras
|
|
|
|
Item {
|
|
|
|
// Initial size of the window in gridUnits
|
|
width: PlasmaCore.Units.gridUnit * 28
|
|
height: PlasmaCore.Units.gridUnit * 20
|
|
|
|
// We use a ColumnLayout to position and size the individual items
|
|
ColumnLayout {
|
|
|
|
// Our ColumnLayout is fills the parent item with a bit of margin
|
|
anchors {
|
|
fill: parent
|
|
margins: PlasmaCore.Units.largeSpacing
|
|
}
|
|
|
|
spacing: PlasmaCore.Units.gridUnit
|
|
|
|
// A title on top
|
|
PlasmaExtras.Heading {
|
|
level: 1 // from 1 to 5; level 1 is the size used for titles
|
|
text: i18n("Hello Plasma World!")
|
|
}
|
|
|
|
// The central area is a rectangle
|
|
Rectangle {
|
|
// The id is used to reference this item from the
|
|
// button's onClicked function
|
|
id: colorRect
|
|
|
|
// It's supposed to grow in both direction
|
|
Layout.fillWidth: true
|
|
Layout.fillHeight: true
|
|
}
|
|
|
|
// A button to change the color to blue or green
|
|
QtControls.Button {
|
|
|
|
// The button is aligned to the right
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
// The button's label, ready for translations
|
|
text: i18n("Change Color")
|
|
|
|
onClicked: {
|
|
// Simply switch colors of the rectangle around
|
|
if (colorRect.color != "#b0c4de") {
|
|
colorRect.color = "#b0c4de"; // lightsteelblue
|
|
} else {
|
|
colorRect.color = "lightgreen";
|
|
}
|
|
// This message will end up being printed to the terminal
|
|
print("Color is now " + colorRect.color);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Overlay everything with a decorative, large, translucent icon
|
|
PlasmaCore.IconItem {
|
|
|
|
// We use an anchor layout and dpi-corrected sizing
|
|
width: PlasmaCore.Units.iconSizes.large * 4
|
|
height: width
|
|
anchors {
|
|
left: parent.left
|
|
bottom: parent.bottom
|
|
}
|
|
|
|
source: "akregator"
|
|
opacity: 0.1
|
|
}
|
|
}
|