1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
/*
SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
SPDX-License-Identifier: LGPL-2.0-only
*/
import QtQuick 2.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.5 as Kirigami
import org.kde.newstuff 1.91 as NewStuff
import org.kde.kcm 1.3 as KCM
import org.kde.private.kcm_cursortheme 1.0
KCM.GridViewKCM {
id: root
KCM.ConfigModule.quickHelp: i18n("This module lets you choose the mouse cursor theme.")
view.model: kcm.cursorsModel
view.delegate: Delegate {}
view.currentIndex: kcm.cursorThemeIndex(kcm.cursorThemeSettings.cursorTheme);
view.onCurrentIndexChanged: {
kcm.cursorThemeSettings.cursorTheme = kcm.cursorThemeFromIndex(view.currentIndex)
view.positionViewAtIndex(view.currentIndex, view.GridView.Beginning);
}
Component.onCompleted: {
view.positionViewAtIndex(view.currentIndex, GridView.Beginning);
}
KCM.SettingStateBinding {
configObject: kcm.cursorThemeSettings
settingName: "cursorTheme"
extraEnabledConditions: !kcm.downloadingFile
}
DropArea {
anchors.fill: parent
onEntered: {
if (!drag.hasUrls) {
drag.accepted = false;
}
}
onDropped: kcm.installThemeFromFile(drop.urls[0])
}
footer: ColumnLayout {
id: footerLayout
Kirigami.InlineMessage {
id: infoLabel
Layout.fillWidth: true
showCloseButton: true
Connections {
target: kcm
function onShowSuccessMessage(message) {
infoLabel.type = Kirigami.MessageType.Positive;
infoLabel.text = message;
infoLabel.visible = true;
}
function onShowInfoMessage(message) {
infoLabel.type = Kirigami.MessageType.Information;
infoLabel.text = message;
infoLabel.visible = true;
}
function onShowErrorMessage(message) {
infoLabel.type = Kirigami.MessageType.Error;
infoLabel.text = message;
infoLabel.visible = true;
}
}
}
RowLayout {
id: row1
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);
}
KCM.SettingStateBinding {
configObject: kcm.cursorThemeSettings
settingName: "cursorSize"
extraEnabledConditions: kcm.canResize
}
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
}
}
}
}
Kirigami.ActionToolBar {
flat: false
alignment: Qt.AlignRight
actions: [
Kirigami.Action {
text: i18nc("@action:button", "&Configure Launch Feedback…")
icon.name: "preferences-desktop-launch-feedback"
onTriggered: {
const component = Qt.createComponent("LaunchFeedbackDialog.qml");
component.incubateObject(root, {
"parent": root,
});
component.destroy();
}
},
Kirigami.Action {
text: i18n("&Install from File…")
icon.name: "document-import"
onTriggered: fileDialogLoader.active = true
enabled: kcm.canInstall
},
NewStuff.Action {
text: i18n("&Get New Cursors…")
configFile: "xcursor.knsrc"
onEntryEvent: function (entry, event) {
if (event == NewStuff.Entry.StatusChangedEvent) {
kcm.ghnsEntryChanged(entry);
}
}
}
]
}
}
}
Loader {
id: fileDialogLoader
active: false
sourceComponent: QtDialogs.FileDialog {
title: i18n("Open Theme")
folder: shortcuts.home
nameFilters: [ i18n("Cursor Theme Files (*.tar.gz *.tar.bz2)") ]
Component.onCompleted: open()
onAccepted: {
kcm.installThemeFromFile(fileUrls[0])
fileDialogLoader.active = false
}
onRejected: {
fileDialogLoader.active = false
}
}
}
}
|