Verified Commit 3e0877c9 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

refactor(lookandfeelexplorer): Port almost entire look and feel explorer to QQC2

Test Plan:
{F7822910}
{F7801659}

Reviewers: #vdg, #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: davidedmundson, GB_2, filipf, guoyunhe, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D25778
parent dbded19e
......@@ -20,11 +20,13 @@
import QtQuick 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import org.kde.kirigami 2.0 as Kirigami
import org.kde.kirigami 2.3 as Kirigami
TextField {
id: field
property string key
property string label
Kirigami.FormData.label: label
text: lnfLogic[key]
Layout.minimumWidth: Kirigami.Units.gridUnit * 15
onAccepted: {
......
/*
* Copyright 2015 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import QtQuick 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import org.kde.kirigami 2.0 as Kirigami
Kirigami.Label {
Layout.alignment: Qt.AlignRight
property Item buddy
MouseArea {
anchors.fill: parent
onClicked: buddy.focus = true
}
}
......@@ -19,11 +19,12 @@
import QtQuick 2.3
import QtQuick.Layouts 1.1
import QtQuick.Controls 1.2
import QtQuick.Controls 2.4 as QQC2
import QtQuick.Controls 1.3
import QtQuick.Dialogs 1.2
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.3 as Kirigami
Dialog {
QQC2.Dialog {
id: dialog
property alias pluginName: pluginNameField.text
property alias name: nameField.text
......@@ -36,27 +37,15 @@ Dialog {
property bool canEdit: false
width: 500
x: (parent.width - width) / 2
y: (parent.height - height) / 2
title: i18n("New Theme")
onVisibleChanged: {
nameField.focus = true
}
//all this reimplementing shouldn't be necessary,
//but unfortunately native standard buttons management
//is completely broken
contentItem: Rectangle {
implicitWidth: layout.Layout.minimumWidth + units.smallSpacing*2
implicitHeight: layout.Layout.minimumHeight + units.smallSpacing*2
Keys.onPressed: {
if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
dialog.accept();
} else if (event.key == Qt.Key_Escape) {
dialog.reject();
}
}
SystemPalette {
id: palette
}
......@@ -74,18 +63,12 @@ Dialog {
wrapMode: Text.WordWrap
Layout.fillWidth: true
}
GridLayout {
Kirigami.FormLayout {
Layout.fillWidth: true
columns: 2
columnSpacing: units.smallSpacing
FormLabel {
text: i18n("Theme Plugin Name:")
buddy: pluginNameField
}
TextField {
QQC2.TextField {
id: pluginNameField
Layout.fillWidth: true
Kirigami.FormData.label: i18n("Theme Plugin Name:")
onTextChanged: {
for (var i = 0; i < lnfLogic.lnfList.count; ++i) {
if (pluginNameField.text == lnfLogic.lnfList.get(i).packageNameRole) {
......@@ -98,88 +81,57 @@ Dialog {
dialog.canEdit = true;
}
}
FormLabel {
text: i18n("Theme Name:")
buddy: nameField
}
TextField {
id: nameField
Layout.fillWidth: true
onTextChanged: {
for (var i = 0; i < lnfLogic.lnfList.count; ++i) {
if (nameField.text == lnfLogic.lnfList.get(i).displayRole) {
dialog.canEdit = false;
errorMessage.text = i18n("This theme name already exists");
return;
}
}
errorMessage.text = "";
dialog.canEdit = true;
}
}
FormLabel {
text: i18n("Comment:")
buddy: commentField
QQC2.TextField {
id: "nameField"
Kirigami.FormData.label: i18n("Theme Name:")
}
TextField {
id: commentField
Layout.fillWidth: true
QQC2.TextField {
id: "commentField"
Kirigami.FormData.label: i18n("Comment:")
}
FormLabel {
text: i18n("Author:")
buddy: authorField
QQC2.TextField {
id: "authorField"
Kirigami.FormData.label: i18n("Author:")
}
TextField {
id: authorField
Layout.fillWidth: true
QQC2.TextField {
id: "emailField"
Kirigami.FormData.label: i18n("Email:")
}
FormLabel {
text: i18n("Email:")
buddy: emailField
}
TextField {
id: emailField
Layout.fillWidth: true
QQC2.TextField {
id: "versionField"
Kirigami.FormData.label: i18n("Version:")
}
FormLabel {
text: i18n("License:")
buddy: licenseField
QQC2.TextField {
id: "websiteField"
Kirigami.FormData.label: i18n("Website:")
}
ComboBox {
id: licenseField
Layout.fillWidth: true
Kirigami.FormData.label: i18n("License:")
editable: true
editText: "LGPL 2.1+"
model: ["LGPL 2.1+", "GPL 2+", "GPL 3+", "LGPL 3+", "BSD"]
}
FormLabel {
text: i18n("Website:")
buddy: websiteField
}
TextField {
id: websiteField
Layout.fillWidth: true
}
}
Item {
Layout.fillHeight: true
}
RowLayout {
Layout.alignment: Qt.AlignRight
Button {
text: i18n("OK")
onClicked: dialog.accept()
isDefault: true
enabled: canEdit && nameField.text && authorField.text && emailField.text && websiteField.text
}
Button {
text: i18n("Cancel")
onClicked: dialog.reject()
}
}
}
}
footer: QQC2.DialogButtonBox {
QQC2.Button {
text: i18n("OK ")
enabled: canEdit && nameField.text && authorField.text && emailField.text && websiteField.text
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.AcceptRole
onClicked: dialog.accept()
}
QQC2.Button {
text: i18n("Cancel")
QQC2.DialogButtonBox.buttonRole: QQC2.DialogButtonBox.DestructiveRole
onClicked: dialog.reject()
}
}
onAccepted: {
lnfLogic.createNewTheme(pluginNameField.text, nameField.text, commentField.text, authorField.text, emailField.text, licenseField.editText, websiteField.text);
for (var i = 0; i < lnfLogic.lnfList.count; ++i) {
......
......@@ -19,16 +19,16 @@
import QtQuick 2.0
import QtQuick.Controls 1.3
import QtQuick.Controls 2.0 as QQC2
import QtQuick.Layouts 1.1
import org.kde.draganddrop 2.0 as DragAndDrop
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.kirigami 2.0 as Kirigami
import org.kde.kirigami 2.3 as Kirigami
Kirigami.AbstractApplicationWindow {
id: root
width: units.gridUnit * 65
height: units.gridUnit * 26
width: Kirigami.Units.gridUnit * 50
height: Kirigami.Units.gridUnit * 26
visible: true
Component.onCompleted: {
......@@ -43,12 +43,12 @@ Kirigami.AbstractApplicationWindow {
globalDrawer: Kirigami.GlobalDrawer {
title: i18n("Look And Feel")
titleIcon: "preferences-desktop-theme"
modal: true;
collapsible: false;
collapsed: false;
topContent: ComboBox {
id: themeSelector
anchors {
left: parent.left
right: parent.right
}
Layout.fillWidth: true
model: lnfLogic.lnfList
textRole: "displayRole"
onCurrentIndexChanged: {
......@@ -92,80 +92,60 @@ Kirigami.AbstractApplicationWindow {
}
RowLayout {
enabled: lnfLogic.isWritable
anchors {
fill: parent
margins: 10
margins: Kirigami.Units.largeSpacing
}
GridLayout {
columns: 2
Layout.alignment: Qt.AlignHCenter|Qt.AlignVCenter
FormLabel {
text: i18n("Plugin Name:")
}
Kirigami.Label {
text: lnfLogic.theme
}
FormLabel {
text: i18n("Name:")
buddy: nameField
}
FormField {
key: "name"
}
FormLabel {
text: i18n("Comment:")
buddy: nameField
}
FormField {
key: "comment"
}
FormLabel {
text: i18n("Author:")
buddy: nameField
}
FormField {
key: "author"
}
FormLabel {
text: i18n("Email:")
buddy: nameField
}
FormField {
key: "email"
}
FormLabel {
text: i18n("Version:")
buddy: nameField
}
FormField {
key: "version"
}
FormLabel {
text: i18n("Website:")
buddy: nameField
}
FormField {
key: "website"
}
FormLabel {
text: i18n("License:")
buddy: nameField
}
FormField {
key: "license"
}
Button {
text: i18n("Layout from current Plasma setup")
onClicked: lnfLogic.performLayoutDump = true
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
}
Button {
text: i18n("Defaults from current setup")
onClicked: lnfLogic.performDefaultsDump = true
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
Layout.alignment: Qt.AlignHCenter
ColumnLayout {
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Kirigami.FormLayout {
enabled: lnfLogic.isWritable
QQC2.Label {
text: i18n("Plugin name:") + lnfLogic.theme
}
FormField {
id: formField
label: i18n("Name:")
key: "name"
}
FormField {
label: i18n("Comment:")
key: "comment"
}
FormField {
label: i18n("Author:")
key: "author"
}
FormField {
label: i18n("Email:")
key: "email"
}
FormField {
label: i18n("Version:")
key: "version"
}
FormField {
label: i18n("Website:")
key: "website"
}
FormField {
label: i18n("License:")
key: "license"
}
QQC2.Button {
text: i18n("Layout from current Plasma setup")
onClicked: lnfLogic.performLayoutDump = true
Layout.columnSpan: 2
implicitWidth: formField.width
}
QQC2.Button {
text: i18n("Defaults from current setup")
onClicked: lnfLogic.performDefaultsDump = true
Layout.columnSpan: 2
implicitWidth: formField.width
}
}
}
Connections {
......@@ -181,9 +161,9 @@ Kirigami.AbstractApplicationWindow {
Rectangle {
width: 250
height: 250
Kirigami.Label {
QQC2.Label {
anchors.centerIn: parent
text: i18n("click to open an image")
text: i18n("Click to open an image")
visible: thumbnail.source == ""
}
Image {
......@@ -213,10 +193,11 @@ Kirigami.AbstractApplicationWindow {
}
}
}
Button {
QQC2.Button {
anchors {
right: parent.right
bottom: parent.bottom
margins: Kirigami.Units.largeSpacing
}
text: i18n("Save")
enabled: lnfLogic.needsSave
......
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