MauiKit Accounts

AccountsMenuItem.qml
1/*
2 * Copyright 2018 Camilo Higuita <milo.h@aol.com>
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 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 */
19import QtQuick
20
21import QtQuick.Controls
22import QtQuick.Layouts
23
24import org.mauikit.controls as Maui
25import org.mauikit.accounts as MA
26
27/**
28 * @inherit QtQuick.Controls.MenuItem
29 * @brief A MenuItem entry to list the available accounts and for launching the accounts dialog.
30 *
31 * @image html accountsmenuitem.png "Accounts menu entry"
32 *
33 * @code
34 * Maui.Page
35 * {
36 * anchors.fill: parent
37 *
38 * Maui.Controls.showCSD: true
39 *
40 * headBar.leftContent: Maui.ToolButtonMenu
41 * {
42 * icon.name: "application-menu"
43 * MA.AccountsMenuItem {}
44 *
45 * MenuSeparator {}
46 *
47 * MenuItem
48 * {
49 * text: "About"
50 * onTriggered: root.about()
51 * }
52 * }
53 * }
54 * @endcode
55 */
56MenuItem
57{
58 MA.AccountsDialog
59 {
60 id: _accountsDialog
61 }
62
63 contentItem: ColumnLayout
64 {
65 id: _accountLayout
66
67 spacing: Maui.Style.defaultSpacing
68
69 Repeater
70 {
71 id: _accountsListing
72
73 model: Maui.BaseModel
74 {
75 list: MA.Accounts
76 }
77
78 delegate: MenuItem
79 {
80 Layout.fillWidth: true
81
82 checked: MA.Accounts.currentAccountIndex === index
83 icon.name: "amarok_artist"
84 text: model.user
85
86 onClicked: MA.Accounts.currentAccountIndex = index
87 }
88
89 Component.onCompleted:
90 {
91 if(_accountsListing.count > 0)
92 MA.Accounts.currentAccountIndex = 0
93 }
94 }
95
96 Button
97 {
98 Layout.alignment: Qt.AlignCenter
99 Layout.fillWidth: true
100 text: i18nd("mauikitaccounts","Accounts")
101 icon.name: "list-add-user"
102 onClicked:
103 {
104 _accountsDialog.open()
105 }
106 }
107 }
108}
109
110
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:10:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.