Commit daf612a4 authored by Dan Leinir Turthra Jensen's avatar Dan Leinir Turthra Jensen 🌈
Browse files

Adapt more KCMs to using Kirigami.ActionToolbar for their footer actions

After getting the Icons KCM set up using an ActionToolbar for the row of
buttons at the bottom of the KCM, it seemed like a good idea to adapt
that method for more of the KCMs. This is the first of those patches,
and it adapts the Colors, Cursor Theme, Desktop Theme, Global Theme, and
Style KCMs to using an ActionToolbar (and consequently allowing them to
scale their UI more correctly).
parent 12dadab7
......@@ -310,21 +310,53 @@ KCM.GridViewKCM {
}
}
RowLayout {
Layout.alignment: Qt.AlignRight
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18n("Install from File...")
icon.name: "document-import"
onTriggered: fileDialogLoader.active = true
},
Kirigami.Action {
text: i18n("Get New Color Schemes...")
icon.name: "get-hot-new-stuff"
onTriggered: { newStuffPage.open(); }
}
]
}
}
QtControls.Button {
text: i18n("Install from File...")
icon.name: "document-import"
onClicked: fileDialogLoader.active = true
Loader {
id: newStuffPage
// Use this function to open the dialog. It seems roundabout, but this ensures
// that the dialog is not constructed until we want it to be shown the first time,
// since it will initialise itself on the first load (which causes it to phone
// home) and we don't want that until the user explicitly asks for it.
function open() {
if (item) {
item.open();
} else {
active = true;
}
}
onLoaded: {
item.open();
}
active: false
asynchronous: true
NewStuff.Button {
id: newStuffButton
text: i18n("Get New Color Schemes...")
configFile: "colorschemes.knsrc"
viewMode: NewStuff.Page.ViewMode.Tiles
onChangedEntriesChanged: kcm.reloadModel(newStuffButton.changedEntries);
sourceComponent: NewStuff.Dialog {
configFile: "colorschemes.knsrc"
viewMode: NewStuff.Page.ViewMode.Tiles
Connections {
target: newStuffPage.item
function onChangedEntriesChanged() {
kcm.reloadModel(newStuffPage.item.changedEntries);
}
}
}
}
......
......@@ -21,7 +21,7 @@ import QtQuick.Window 2.2 // for Screen
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.2 as QtControls
import QtQuick.Dialogs 1.1 as QtDialogs
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.5 as Kirigami
import org.kde.newstuff 1.62 as NewStuff
import org.kde.kcm 1.3 as KCM
......@@ -91,87 +91,101 @@ KCM.GridViewKCM {
RowLayout {
id: row1
//spacer
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
RowLayout {
id: comboLayout
KCM.SettingStateBinding {
configObject: kcm.cursorThemeSettings
settingName: "cursorSize"
extraEnabledConditions: kcm.canResize
}
KCM.SettingStateBinding {
configObject: kcm.cursorThemeSettings
settingName: "cursorSize"
extraEnabledConditions: kcm.canResize
QtControls.Label {
text: i18n("Size:")
}
QtControls.ComboBox {
id: sizeCombo
model: kcm.sizesModel
textRole: "display"
currentIndex: kcm.cursorSizeIndex(kcm.cursorThemeSettings.cursorSize);
onActivated: {
kcm.cursorThemeSettings.cursorSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex);
kcm.preferredSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex);
}
QtControls.Label {
text: i18n("Size:")
}
QtControls.ComboBox {
id: sizeCombo
model: kcm.sizesModel
textRole: "display"
currentIndex: kcm.cursorSizeIndex(kcm.cursorThemeSettings.cursorSize);
onActivated: {
kcm.cursorThemeSettings.cursorSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex);
kcm.preferredSize = kcm.cursorSizeFromIndex(sizeCombo.currentIndex);
}
delegate: QtControls.ItemDelegate {
id: sizeComboDelegate
readonly property int size: parseInt(model.display)
delegate: QtControls.ItemDelegate {
id: sizeComboDelegate
readonly property int size: parseInt(model.display)
width: parent.width
highlighted: ListView.isCurrentItem
text: model.display
contentItem: RowLayout {
Kirigami.Icon {
source: model.decoration
smooth: true
Layout.preferredWidth: sizeComboDelegate.size / Screen.devicePixelRatio
Layout.preferredHeight: sizeComboDelegate.size / Screen.devicePixelRatio
visible: valid && sizeComboDelegate.size > 0
}
QtControls.Label {
Layout.fillWidth: true
color: sizeComboDelegate.highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
text: model[sizeCombo.textRole]
elide: Text.ElideRight
}
width: parent.width
highlighted: ListView.isCurrentItem
text: model.display
contentItem: RowLayout {
Kirigami.Icon {
source: model.decoration
smooth: true
Layout.preferredWidth: sizeComboDelegate.size / Screen.devicePixelRatio
Layout.preferredHeight: sizeComboDelegate.size / Screen.devicePixelRatio
visible: valid && sizeComboDelegate.size > 0
}
QtControls.Label {
Layout.fillWidth: true
color: sizeComboDelegate.highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
text: model[sizeCombo.textRole]
elide: Text.ElideRight
}
}
}
}
RowLayout {
parent: footerLayout.x + footerLayout.width - comboLayout.width > width ? row1 : row2
QtControls.Button {
icon.name: "document-import"
text: i18n("&Install from File...")
onClicked: fileDialogLoader.active = true;
enabled: kcm.canInstall
}
NewStuff.Button {
id: newStuffButton
enabled: kcm.canInstall
text: i18n("&Get New Cursors...")
configFile: "xcursor.knsrc"
viewMode: NewStuff.Page.ViewMode.Tiles
onChangedEntriesChanged: kcm.ghnsEntriesChanged(newStuffButton.changedEntries);
}
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18n("&Install from File...")
icon.name: "document-import"
onTriggered: fileDialogLoader.active = true
enabled: kcm.canInstall
},
Kirigami.Action {
text: i18n("&Get New Cursors...")
icon.name: "get-hot-new-stuff"
onTriggered: { newStuffPage.open(); }
enabled: kcm.canInstall
}
]
}
}
RowLayout {
id: row2
visible: children.length > 1
//spacer
Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
Loader {
id: newStuffPage
// Use this function to open the dialog. It seems roundabout, but this ensures
// that the dialog is not constructed until we want it to be shown the first time,
// since it will initialise itself on the first load (which causes it to phone
// home) and we don't want that until the user explicitly asks for it.
function open() {
if (item) {
item.open();
} else {
active = true;
}
}
onLoaded: {
item.open();
}
active: false
asynchronous: true
sourceComponent: NewStuff.Dialog {
configFile: "xcursor.knsrc"
viewMode: NewStuff.Page.ViewMode.Tiles
Connections {
target: newStuffPage.item
onChangedEntriesChanged: kcm.ghnsEntriesChanged(newStuffPage.item.changedEntries);
}
}
}
......
......@@ -175,21 +175,53 @@ KCM.GridViewKCM {
}
}
RowLayout {
Layout.alignment: Qt.AlignRight
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18n("Install from File...")
icon.name: "document-import"
onTriggered: fileDialogLoader.active = true
},
Kirigami.Action {
text: i18n("Get New Plasma Styles...")
icon.name: "get-hot-new-stuff"
onTriggered: { newStuffPage.open(); }
}
]
}
}
QtControls.Button {
text: i18n("Install from File...")
icon.name: "document-import"
onClicked: fileDialogLoader.active = true;
Loader {
id: newStuffPage
// Use this function to open the dialog. It seems roundabout, but this ensures
// that the dialog is not constructed until we want it to be shown the first time,
// since it will initialise itself on the first load (which causes it to phone
// home) and we don't want that until the user explicitly asks for it.
function open() {
if (item) {
item.open();
} else {
active = true;
}
}
onLoaded: {
item.open();
}
active: false
asynchronous: true
NewStuff.Button {
id: newStuffButton
text: i18n("Get New Plasma Styles...")
configFile: "plasma-themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.load();
sourceComponent: NewStuff.Dialog {
configFile: "plasma-themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
Connections {
target: newStuffPage.item.engine.engine
function onSignalEntryEvent(entry, event) {
kcm.load();
}
}
}
}
......
......@@ -20,7 +20,7 @@ import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import QtQuick.Controls 2.3 as QtControls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.5 as Kirigami
import org.kde.newstuff 1.62 as NewStuff
import org.kde.kconfig 1.0 // for KAuthorized
import org.kde.kcm 1.3 as KCM
......@@ -85,14 +85,50 @@ KCM.GridViewKCM {
text: i18n("Use desktop layout from theme")
onCheckedChanged: kcm.resetDefaultLayout = checked;
}
Item {
Layout.fillWidth: true
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18n("Get New Global Themes...")
icon.name: "get-hot-new-stuff"
onTriggered: { newStuffPage.open(); }
}
]
}
}
}
Loader {
id: newStuffPage
// Use this function to open the dialog. It seems roundabout, but this ensures
// that the dialog is not constructed until we want it to be shown the first time,
// since it will initialise itself on the first load (which causes it to phone
// home) and we don't want that until the user explicitly asks for it.
function open() {
if (item) {
item.open();
} else {
active = true;
}
NewStuff.Button {
text: i18n("Get New Global Themes...")
configFile: "lookandfeel.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.reloadModel();
}
onLoaded: {
item.open();
}
active: false
asynchronous: true
sourceComponent: NewStuff.Dialog {
configFile: "lookandfeel.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
Connections {
target: newStuffPage.item.engine.engine
function onSignalEntryEvent(entry, event) {
kcm.reloadModel();
}
}
}
}
......
......@@ -101,23 +101,53 @@ Kirigami.Page {
Layout.fillHeight: true
}
RowLayout {
Item {
Layout.fillWidth: true
}
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18n("Install from File...")
icon.name: "document-import"
onTriggered: fileDialogLoader.active = true
},
Kirigami.Action {
text: i18n("Get New GNOME/GTK Application Styles...")
icon.name: "get-hot-new-stuff"
onTriggered: { newStuffPage.open(); }
}
]
}
}
QtControls.Button {
icon.name: "document-import"
text: i18n("Install from File...")
onClicked: fileDialogLoader.active = true
Loader {
id: newStuffPage
// Use this function to open the dialog. It seems roundabout, but this ensures
// that the dialog is not constructed until we want it to be shown the first time,
// since it will initialise itself on the first load (which causes it to phone
// home) and we don't want that until the user explicitly asks for it.
function open() {
if (item) {
item.open();
} else {
active = true;
}
}
onLoaded: {
item.open();
}
active: false
asynchronous: true
NewStuff.Button {
id: gtkNewStuffButton
text: i18n("Get New GNOME/GTK Application Styles...")
configFile: "gtk_themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
onChangedEntriesChanged: kcm.gtkPage.onGhnsEntriesChanged(gtkNewStuffButton.changedEntries);
sourceComponent: NewStuff.Dialog {
configFile: "gtk_themes.knsrc"
viewMode: NewStuff.Page.ViewMode.Preview
Connections {
target: newStuffPage.item
function onChangedEntriesChanged() {
kcm.gtkPage.onGhnsEntriesChanged(newStuffPage.item.changedEntries);
}
}
}
}
......
......@@ -21,7 +21,7 @@
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.3 as QtControls
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kcm 1.3 as KCM
import org.kde.private.kcms.style 1.0 as Private
......@@ -122,10 +122,11 @@ KCM.GridViewKCM {
RowLayout {
Layout.alignment: Qt.AlignLeft
QtControls.Button {
QtControls.ToolButton {
id: effectSettingsButton
text: i18n("Configure Icons and Toolbars")
icon.name: "configure-toolbars" // proper icon?
flat: false
checkable: true
checked: effectSettingsPopupLoader.item && effectSettingsPopupLoader.item.opened
onClicked: {
......@@ -133,13 +134,17 @@ KCM.GridViewKCM {
effectSettingsPopupLoader.item.open();
}
}
QtControls.Button {
id: gtkSettingsButton
visible: kcm.gtkConfigKdedModuleLoaded
text: i18n("Configure GNOME/GTK Application Style...")
icon.name: "configure"
onClicked: root.openGtkStyleSettings()
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
visible: kcm.gtkConfigKdedModuleLoaded
text: i18n("Configure GNOME/GTK Application Style...")
icon.name: "configure"
onTriggered: root.openGtkStyleSettings()
}
]
}
}
}
......
Supports Markdown
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