2015-08-25 18:08:27 +02:00
|
|
|
/*
|
2020-08-13 21:08:54 +02:00
|
|
|
SPDX-FileCopyrightText: 2015 Sebastian Kügler <sebas@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
*/
|
2015-08-25 18:08:27 +02:00
|
|
|
|
|
|
|
import QtQuick 2.3
|
|
|
|
import QtQuick.Layouts 1.1
|
2017-02-11 15:37:17 +01:00
|
|
|
import QtQuick.Controls 1.0 as QtControls
|
2015-08-25 18:08:27 +02:00
|
|
|
|
|
|
|
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
|
2021-03-05 20:22:42 +01:00
|
|
|
width: PlasmaCore.Units.gridUnit * 28
|
|
|
|
height: PlasmaCore.Units.gridUnit * 20
|
2015-08-25 18:08:27 +02:00
|
|
|
|
|
|
|
// 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
|
2021-03-05 20:22:42 +01:00
|
|
|
margins: PlasmaCore.Units.largeSpacing
|
2015-08-25 18:08:27 +02:00
|
|
|
}
|
|
|
|
|
2021-03-05 20:22:42 +01:00
|
|
|
spacing: PlasmaCore.Units.gridUnit
|
2015-08-25 18:08:27 +02:00
|
|
|
|
|
|
|
// A title on top
|
2020-02-12 16:32:53 +01:00
|
|
|
PlasmaExtras.Heading {
|
|
|
|
level: 1 // from 1 to 5; level 1 is the size used for titles
|
2015-08-25 18:08:27 +02:00
|
|
|
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
|
2017-02-11 15:37:17 +01:00
|
|
|
QtControls.Button {
|
2015-08-25 18:08:27 +02:00
|
|
|
|
|
|
|
// 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
|
2021-03-05 20:22:42 +01:00
|
|
|
width: PlasmaCore.Units.iconSizes.large * 4
|
2015-08-25 18:08:27 +02:00
|
|
|
height: width
|
|
|
|
anchors {
|
|
|
|
left: parent.left
|
|
|
|
bottom: parent.bottom
|
|
|
|
}
|
|
|
|
|
|
|
|
source: "akregator"
|
|
|
|
opacity: 0.1
|
|
|
|
}
|
|
|
|
}
|