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