Commit c2640f83 authored by Marco Martin's avatar Marco Martin

Port applet/containment configs to qqc2

Summary:
port the applet config dialogs and containments to
QtQuickControls2 and Kirigami modernizing it,
using form layouts, Headings and inline messages.
look is almost the same modulo fixing some misalignments and following
the hig more closely

BUG: 401472
FIXED-IN: 5.15.0

Test Plan:
looked at every wallpaper plugin and
loaded the config dialog of many applets

Reviewers: #plasma, #vdg, broulik, ngraham

Reviewed By: #vdg, ngraham

Subscribers: abetts, ngraham, apol, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D17211
parent 2460a8aa
......@@ -18,10 +18,11 @@
import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Window 2.2
import org.kde.kquickcontrolsaddons 2.0
import org.kde.kirigami 2.5 as Kirigami
MouseArea {
id: delegate
......@@ -32,7 +33,7 @@ MouseArea {
Layout.fillWidth: true
hoverEnabled: true
property bool current: (model.kcm && main.currentItem.kcm && model.kcm == main.currentItem.kcm) || (model.source == main.sourceFile)
property bool current: (model.kcm && pageStack.currentItem.kcm && model.kcm == pageStack.currentItem.kcm) || (model.source == pageStack.sourceFile)
//END properties
//BEGIN functions
......@@ -41,19 +42,19 @@ MouseArea {
return;
}
if (typeof(categories.currentItem) !== "undefined") {
main.invertAnimations = (categories.currentItem.y > delegate.y);
pageStack.invertAnimations = (categories.currentItem.y > delegate.y);
categories.currentItem = delegate;
}
if (model.source) {
main.sourceFile = model.source;
pageStack.sourceFile = model.source;
} else if (model.kcm) {
main.sourceFile = "";
main.sourceFile = Qt.resolvedUrl("ConfigurationKcmPage.qml");
main.currentItem.kcm = model.kcm;
pageStack.sourceFile = "";
pageStack.sourceFile = Qt.resolvedUrl("ConfigurationKcmPage.qml");
pageStack.currentItem.kcm = model.kcm;
} else {
main.sourceFile = "";
pageStack.sourceFile = "";
}
main.title = model.name
pageStack.title = model.name
}
//END functions
......@@ -65,7 +66,7 @@ MouseArea {
return;
}
//print("model source: " + model.source + " " + main.sourceFile);
//print("model source: " + model.source + " " + pageStack.sourceFile);
if (applyButton.enabled) {
messageDialog.delegate = delegate;
messageDialog.open();
......@@ -84,7 +85,7 @@ MouseArea {
//BEGIN UI components
Rectangle {
anchors.fill: parent
color: syspal.highlight
color: Kirigami.Theme.highlightColor
opacity: { // try to match Breeze style hover handling
var active = categoriesScroll.activeFocus && Window.active
if (current) {
......@@ -133,7 +134,7 @@ MouseArea {
text: model.name
wrapMode: Text.Wrap
horizontalAlignment: Text.AlignHCenter
color: current && categoriesScroll.activeFocus ? syspal.highlightedText : syspal.text
color: current && categoriesScroll.activeFocus ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
Behavior on color {
ColorAnimation {
duration: units.longDuration
......
......@@ -17,7 +17,7 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0
Item {
......@@ -114,7 +114,7 @@ Item {
}
pluginsCombo.initialized = true;
}
onCurrentIndexChanged: {
onActivated: {
if (initialized && configDialog.containmentActionConfigModel.get(currentIndex).pluginName != pluginName) {
configDialog.currentContainmentActionsModel.update(index, action, configDialog.containmentActionConfigModel.get(currentIndex).pluginName);
}
......@@ -130,7 +130,7 @@ Item {
Layout.row: index
QtControls.Button {
iconName: "configure"
icon.name: "configure"
width: height
enabled: model.hasConfigurationInterface
onClicked: {
......@@ -138,14 +138,14 @@ Item {
}
}
QtControls.Button {
iconName: "dialog-information"
icon.name: "dialog-information"
width: height
onClicked: {
configDialog.currentContainmentActionsModel.showAbout(index, this);
}
}
QtControls.Button {
iconName: "list-remove"
icon.name: "list-remove"
width: height
onClicked: {
configDialog.currentContainmentActionsModel.remove(index);
......@@ -155,7 +155,6 @@ Item {
}
MouseEventInputButton {
anchors.left: parent.left
defaultText: i18nd("plasma_shell_org.kde.plasma.desktop", "Add Action");
onEventStringChanged: {
configDialog.currentContainmentActionsModel.append(eventString, "org.kde.contextmenu");
......
......@@ -18,16 +18,17 @@
import QtQuick 2.0
import org.kde.plasma.configuration 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.1
import org.kde.kconfig 1.0 // for KAuthorized
import org.kde.plasma.private.shell 2.0 as ShellPrivate // for WallpaperPlugin
import org.kde.kirigami 2.5 as Kirigami
ColumnLayout {
id: root
property int formAlignment: wallpaperComboBox.x + (units.largeSpacing/2)
property int formAlignment: wallpaperComboBox.Kirigami.ScenePosition.x - root.Kirigami.ScenePosition.x + (units.largeSpacing/2)
property string currentWallpaper: ""
property string containmentPlugin: ""
signal configurationChanged
......@@ -53,6 +54,7 @@ ColumnLayout {
var data = configDialog.containmentPluginsConfigModel.get(i);
if (configDialog.containmentPlugin == data.pluginName) {
pluginComboBox.currentIndex = i
pluginComboBox.activated(i);
break;
}
}
......@@ -61,32 +63,68 @@ ColumnLayout {
var data = configDialog.wallpaperConfigModel.get(i);
if (configDialog.currentWallpaper == data.pluginName) {
wallpaperComboBox.currentIndex = i
wallpaperComboBox.activated(i);
break;
}
}
}
Row {
spacing: units.largeSpacing / 2
visible: pluginComboBox.count > 1
QtControls.Label {
width: formAlignment - units.largeSpacing
anchors.verticalCenter: pluginComboBox.verticalCenter
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:")
horizontalAlignment: Text.AlignRight
}
Kirigami.InlineMessage {
visible: plasmoid.immutable || animating
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout cannot be changed while widgets are locked")
showCloseButton: true
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.smallSpacing
Layout.rightMargin: Kirigami.Units.smallSpacing
}
Kirigami.FormLayout {
Layout.fillWidth: true
QtControls.ComboBox {
id: pluginComboBox
Layout.preferredWidth: Math.max(implicitWidth, wallpaperComboBox.implicitWidth)
Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout:")
enabled: !plasmoid.immutable
model: configDialog.containmentPluginsConfigModel
width: theme.mSize(theme.defaultFont).width * 24
textRole: "name"
onCurrentIndexChanged: {
onActivated: {
var model = configDialog.containmentPluginsConfigModel.get(currentIndex)
root.containmentPlugin = model.pluginName
root.configurationChanged()
}
}
RowLayout {
Layout.fillWidth: true
visible: !switchContainmentWarning.visible
Kirigami.FormData.label: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Type:")
QtControls.ComboBox {
id: wallpaperComboBox
Layout.preferredWidth: Math.max(implicitWidth, pluginComboBox.implicitWidth)
model: configDialog.wallpaperConfigModel
width: theme.mSize(theme.defaultFont).width * 24
textRole: "name"
onActivated: {
var model = configDialog.wallpaperConfigModel.get(currentIndex)
root.currentWallpaper = model.pluginName
configDialog.currentWallpaper = model.pluginName
main.sourceFile = model.source
root.configurationChanged()
}
}
QtControls.Button {
icon.name: "get-hot-new-stuff"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Plugins...")
visible: KAuthorized.authorize("ghns")
onClicked: wallpaperPlugin.getNewWallpaperPlugin(this)
Layout.preferredHeight: wallpaperComboBox.height
ShellPrivate.WallpaperPlugin {
id: wallpaperPlugin
}
}
}
}
ColumnLayout {
......@@ -110,55 +148,11 @@ ColumnLayout {
property: "enabled"
value: !switchContainmentWarning.visible
}
Item {
Layout.fillHeight: true
}
}
QtControls.Label {
Layout.fillWidth: true
visible: plasmoid.immutable
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Layout cannot be changed while widgets are locked")
wrapMode: Text.Wrap
}
Row {
visible: !switchContainmentWarning.visible
id: wallpaperRow
spacing: units.largeSpacing / 2
Item {
width: units.largeSpacing
height: parent.height
}
QtControls.Label {
anchors.verticalCenter: wallpaperComboBox.verticalCenter
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Wallpaper Type:")
}
QtControls.ComboBox {
id: wallpaperComboBox
model: configDialog.wallpaperConfigModel
width: theme.mSize(theme.defaultFont).width * 24
textRole: "name"
onCurrentIndexChanged: {
var model = configDialog.wallpaperConfigModel.get(currentIndex)
root.currentWallpaper = model.pluginName
configDialog.currentWallpaper = model.pluginName
main.sourceFile = model.source
root.configurationChanged()
}
}
QtControls.Button {
iconName: "get-hot-new-stuff"
text: i18nd("plasma_shell_org.kde.plasma.desktop", "Get New Wallpaper Plugins...")
visible: KAuthorized.authorize("ghns")
onClicked: wallpaperPlugin.getNewWallpaperPlugin(this)
ShellPrivate.WallpaperPlugin {
id: wallpaperPlugin
}
}
Item {
Layout.fillHeight: true
visible: switchContainmentWarning.visible
}
Item {
......@@ -169,10 +163,8 @@ ColumnLayout {
id: main
Layout.fillHeight: true;
anchors {
left: parent.left;
right: parent.right;
}
Layout.fillWidth: true;
visible: !switchContainmentWarning.visible
// Bug 360862: if wallpaper has no config, sourceFile will be ""
......@@ -188,11 +180,7 @@ ColumnLayout {
props["cfg_" + key] = wallpaperConfig[key]
}
var newItem = push({
item: Qt.resolvedUrl(sourceFile),
replace: true,
properties: props
})
var newItem = replace(Qt.resolvedUrl(sourceFile), props)
for (var key in wallpaperConfig) {
var changedSignal = newItem["cfg_" + key + "Changed"]
......
......@@ -17,7 +17,6 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import org.kde.plasma.core 2.0 as PlasmaCore
Item {
......
......@@ -17,14 +17,12 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0
import org.kde.kquickcontrols 2.0
Item {
id: root
width: childrenRect.width
height: childrenRect.height
signal configurationChanged
function saveConfig() {
......
......@@ -17,7 +17,7 @@
*/
import QtQuick 2.0
import QtQuick.Controls 1.0 as QtControls
import QtQuick.Controls 2.3 as QtControls
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment