Commit 2e2cfa89 authored by Nate Graham's avatar Nate Graham 🔩

[Kicker] Modernize settings window

Summary: Port Kicker's settings window to Kirigami+FormLayout and QQC2.

Test Plan:
{F6787481}

All features tested and still work.

Reviewers: #vdg, #plasma, hein, GB_2

Reviewed By: #vdg, #plasma, hein, GB_2

Subscribers: GB_2, plasma-devel

Tags: #plasma

Maniphest Tasks: T10586

Differential Revision: https://phabricator.kde.org/D20743
parent 3024920b
......@@ -24,7 +24,7 @@ import org.kde.plasma.configuration 2.0
ConfigModel {
ConfigCategory {
name: i18n("General")
icon: "kde"
icon: "preferences-desktop-plasma"
source: "ConfigGeneral.qml"
}
}
......@@ -17,24 +17,21 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . *
***************************************************************************/
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.0
import QtQuick 2.5
import QtQuick.Controls 2.5
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.kquickcontrolsaddons 2.0 as KQuickAddons
import org.kde.draganddrop 2.0 as DragDrop
import org.kde.kirigami 2.5 as Kirigami
import org.kde.plasma.private.kicker 0.1 as Kicker
Item {
Kirigami.FormLayout {
id: configGeneral
width: childrenRect.width
height: childrenRect.height
anchors.left: parent.left
anchors.right: parent.right
property bool isDash: (plasmoid.pluginName === "org.kde.plasma.kickerdash")
......@@ -54,222 +51,193 @@ Item {
property alias cfg_useExtraRunners: useExtraRunners.checked
property alias cfg_alignResultsToBottom: alignResultsToBottom.checked
ColumnLayout {
anchors.left: parent.left
RowLayout {
spacing: units.smallSpacing
Button {
id: iconButton
Label {
text: i18n("Icon:")
}
Kirigami.FormData.label: i18n("Icon:")
Button {
id: iconButton
Layout.minimumWidth: previewFrame.width + units.smallSpacing * 2
Layout.maximumWidth: Layout.minimumWidth
Layout.minimumHeight: previewFrame.height + units.smallSpacing * 2
Layout.maximumHeight: Layout.minimumWidth
DragDrop.DropArea {
id: dropArea
property bool containsAcceptableDrag: false
anchors.fill: parent
onDragEnter: {
// Cannot use string operations (e.g. indexOf()) on "url" basic type.
var urlString = event.mimeData.url.toString();
// This list is also hardcoded in KIconDialog.
var extensions = [".png", ".xpm", ".svg", ".svgz"];
containsAcceptableDrag = urlString.indexOf("file:///") === 0 && extensions.some(function (extension) {
return urlString.indexOf(extension) === urlString.length - extension.length; // "endsWith"
});
if (!containsAcceptableDrag) {
event.ignore();
}
}
onDragLeave: containsAcceptableDrag = false
onDrop: {
if (containsAcceptableDrag) {
// Strip file:// prefix, we already verified in onDragEnter that we have only local URLs.
iconDialog.setCustomButtonImage(event.mimeData.url.toString().substr("file://".length));
}
containsAcceptableDrag = false;
}
}
implicitWidth: previewFrame.width + units.smallSpacing * 2
implicitHeight: previewFrame.height + units.smallSpacing * 2
KQuickAddons.IconDialog {
id: iconDialog
// Just to provide some visual feedback when dragging;
// cannot have checked without checkable enabled
checkable: true
checked: dropArea.containsAcceptableDrag
function setCustomButtonImage(image) {
cfg_customButtonImage = image || cfg_icon || "start-here-kde"
cfg_useCustomButtonImage = true;
}
onPressed: iconMenu.opened ? iconMenu.close() : iconMenu.open()
onIconNameChanged: setCustomButtonImage(iconName);
}
DragDrop.DropArea {
id: dropArea
// just to provide some visual feedback, cannot have checked without checkable enabled
checkable: true
checked: dropArea.containsAcceptableDrag
onClicked: {
checked = Qt.binding(function() { // never actually allow it being checked
return iconMenu.status === PlasmaComponents.DialogStatus.Open || dropArea.containsAcceptableDrag;
})
property bool containsAcceptableDrag: false
iconMenu.open(0, height)
}
anchors.fill: parent
PlasmaCore.FrameSvgItem {
id: previewFrame
anchors.centerIn: parent
imagePath: plasmoid.location === PlasmaCore.Types.Vertical || plasmoid.location === PlasmaCore.Types.Horizontal
? "widgets/panel-background" : "widgets/background"
width: units.iconSizes.large + fixedMargins.left + fixedMargins.right
height: units.iconSizes.large + fixedMargins.top + fixedMargins.bottom
PlasmaCore.IconItem {
anchors.centerIn: parent
width: units.iconSizes.large
height: width
source: cfg_useCustomButtonImage ? cfg_customButtonImage : cfg_icon
}
}
}
onDragEnter: {
// Cannot use string operations (e.g. indexOf()) on "url" basic type.
var urlString = event.mimeData.url.toString();
// QQC Menu can only be opened at cursor position, not a random one
PlasmaComponents.ContextMenu {
id: iconMenu
visualParent: iconButton
// This list is also hardcoded in KIconDialog.
var extensions = [".png", ".xpm", ".svg", ".svgz"];
containsAcceptableDrag = urlString.indexOf("file:///") === 0 && extensions.some(function (extension) {
return urlString.indexOf(extension) === urlString.length - extension.length; // "endsWith"
});
PlasmaComponents.MenuItem {
text: i18nc("@item:inmenu Open icon chooser dialog", "Choose...")
icon: "document-open-folder"
onClicked: iconDialog.open()
if (!containsAcceptableDrag) {
event.ignore();
}
PlasmaComponents.MenuItem {
text: i18nc("@item:inmenu Reset icon to default", "Clear Icon")
icon: "edit-clear"
onClicked: {
cfg_useCustomButtonImage = false;
}
}
onDragLeave: containsAcceptableDrag = false
onDrop: {
if (containsAcceptableDrag) {
// Strip file:// prefix, we already verified in onDragEnter that we have only local URLs.
iconDialog.setCustomButtonImage(event.mimeData.url.toString().substr("file://".length));
}
containsAcceptableDrag = false;
}
}
GroupBox {
Layout.fillWidth: true
KQuickAddons.IconDialog {
id: iconDialog
title: i18n("Behavior")
function setCustomButtonImage(image) {
cfg_customButtonImage = image || cfg_icon || "start-here-kde"
cfg_useCustomButtonImage = true;
}
flat: true
onIconNameChanged: setCustomButtonImage(iconName);
}
ColumnLayout {
RowLayout {
Label {
text: i18n("Show applications as:")
}
PlasmaCore.FrameSvgItem {
id: previewFrame
anchors.centerIn: parent
imagePath: plasmoid.location === PlasmaCore.Types.Vertical || plasmoid.location === PlasmaCore.Types.Horizontal
? "widgets/panel-background" : "widgets/background"
width: units.iconSizes.large + fixedMargins.left + fixedMargins.right
height: units.iconSizes.large + fixedMargins.top + fixedMargins.bottom
PlasmaCore.IconItem {
anchors.centerIn: parent
width: units.iconSizes.large
height: width
source: cfg_useCustomButtonImage ? cfg_customButtonImage : cfg_icon
}
}
Menu {
id: iconMenu
ComboBox {
id: appNameFormat
// Appear below the button
y: +parent.height
Layout.fillWidth: true
onClosed: iconButton.checked = false;
model: [i18n("Name only"), i18n("Description only"), i18n("Name (Description)"), i18n("Description (Name)")]
}
MenuItem {
text: i18nc("@item:inmenu Open icon chooser dialog", "Choose...")
icon.name: "document-open-folder"
onClicked: iconDialog.open()
}
MenuItem {
text: i18nc("@item:inmenu Reset icon to default", "Clear Icon")
icon.name: "edit-clear"
onClicked: {
cfg_icon = "start-here-kde"
cfg_useCustomButtonImage = false
}
}
}
}
CheckBox {
id: limitDepth
visible: !isDash
Item {
Kirigami.FormData.isSection: true
}
text: i18n("Flatten menu to a single level")
}
ComboBox {
id: appNameFormat
CheckBox {
id: alphaSort
Kirigami.FormData.label: i18n("Show applications as:")
text: i18n("Sort alphabetically")
}
}
}
model: [i18n("Name only"), i18n("Description only"), i18n("Name (Description)"), i18n("Description (Name)")]
}
GroupBox {
Layout.fillWidth: true
Item {
Kirigami.FormData.isSection: true
}
title: i18n("Categories")
CheckBox {
id: alphaSort
flat: true
Kirigami.FormData.label: i18n("Behavior:")
ColumnLayout {
RowLayout {
Label {
text: i18n("Show:")
}
text: i18n("Sort applications alphabetically")
}
ComboBox {
id: recentOrdering
CheckBox {
id: limitDepth
Layout.fillWidth: true
visible: !isDash
model: [i18n("Recently used"), i18n("Often used")]
}
}
text: i18n("Flatten sub-menus to a single level")
}
CheckBox {
id: showRecentApps
text: recentOrdering.currentIndex == 0
? i18n("Show recent applications")
: i18n("Show often used applications")
}
Item {
Kirigami.FormData.isSection: true
}
CheckBox {
id: showRecentDocs
CheckBox {
id: showRecentApps
text: recentOrdering.currentIndex == 0
? i18n("Show recent documents")
: i18n("Show often used documents")
}
Kirigami.FormData.label: i18n("Show categories:")
CheckBox {
id: showRecentContacts
text: recentOrdering.currentIndex == 0
? i18n("Recent applications")
: i18n("Often used applications")
}
text: recentOrdering.currentIndex == 0
? i18n("Show recent contacts")
: i18n("Show often used contacts")
}
}
}
CheckBox {
id: showRecentDocs
GroupBox {
Layout.fillWidth: true
text: recentOrdering.currentIndex == 0
? i18n("Recent documents")
: i18n("Often used documents")
}
title: i18n("Search")
CheckBox {
id: showRecentContacts
flat: true
text: recentOrdering.currentIndex == 0
? i18n("Recent contacts")
: i18n("Often used contacts")
}
ColumnLayout {
CheckBox {
id: useExtraRunners
ComboBox {
id: recentOrdering
text: i18n("Expand search to bookmarks, files and emails")
}
Kirigami.FormData.label: i18n("Sort items in categories by:")
model: [i18nc("@item:inlistbox Sort items in categories by [Recently used | Often used]", "Recently used"), i18nc("@item:inlistbox Sort items in categories by [Recently used | Ofetn used]", "Often used")]
}
CheckBox {
id: alignResultsToBottom
Item {
Kirigami.FormData.isSection: true
}
visible: !isDash
CheckBox {
id: useExtraRunners
text: i18n("Align search results to bottom")
}
}
}
Kirigami.FormData.label: i18n("Search:")
text: i18n("Expand search to bookmarks, files and emails")
}
CheckBox {
id: alignResultsToBottom
visible: !isDash
text: i18n("Align search results to bottom")
}
}
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