Changeset View
Changeset View
Standalone View
Standalone View
src/kcm/package/contents/ui/RenameAccountDialog.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2020 Dan Leinir Turthra Jensen <admin@leinir.dk> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.12 | ||||
21 | import QtQuick.Controls 2.12 as Controls | ||||
22 | import QtQuick.Layouts 1.12 | ||||
23 | | ||||
24 | import org.kde.kirigami 2.7 as Kirigami | ||||
25 | | ||||
26 | import org.kde.kaccounts 1.2 as KAccounts | ||||
27 | | ||||
28 | MessageBoxSheet { | ||||
29 | id: component | ||||
30 | title: i18nc("The title for a dialog which lets you set the human-readable name of an account", "Rename Account") | ||||
31 | property int accountId | ||||
32 | property string currentDisplayName | ||||
33 | signal accountRenamed() | ||||
34 | onSheetOpenChanged: { | ||||
35 | if (sheetOpen === true) { | ||||
36 | newAccountDisplayName.text = currentDisplayName; | ||||
37 | } | ||||
38 | } | ||||
39 | contentItem: Kirigami.FormLayout { | ||||
40 | Layout.preferredWidth: Kirigami.Units.gridUnit * 10 | ||||
41 | Layout.margins: Kirigami.Units.largeSpacing | ||||
42 | Controls.TextField { | ||||
43 | id: newAccountDisplayName | ||||
44 | Kirigami.FormData.label: i18nc("Label for the text field used to enter a new human-readable name for an account", "Enter the new name of the account") | ||||
45 | } | ||||
46 | } | ||||
47 | actions: [ | ||||
48 | Kirigami.Action { | ||||
49 | enabled: newAccountDisplayName.text.length > 0 && newAccountDisplayName.text !== component.currentDisplayName | ||||
50 | text: i18nc("Text of a button which will cause the human-readable name of an account to be set to a text specified by the user", "Set Account Name") | ||||
51 | onTriggered: { | ||||
52 | var job = accountDisplayNameJob.createObject(component, { "accountId": component.accountId, "displayName": newAccountDisplayName.text }) | ||||
53 | job.start(); | ||||
54 | } | ||||
55 | Component { | ||||
56 | id: accountDisplayNameJob | ||||
57 | KAccounts.ChangeAccountDisplayNameJob { | ||||
58 | onFinished: component.accountRenamed() | ||||
59 | } | ||||
60 | } | ||||
61 | } | ||||
62 | ] | ||||
63 | } |