MauiKit Controls

FontPickerDialog.qml
1/*
2 * Copyright 2020 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 */
19
20import QtQuick
21import QtQuick.Controls
22import QtQuick.Layouts
23
24import org.mauikit.controls 1.3 as Maui
25
26/**
27 * @inherit SettingsDialog
28 * @brief The Mauikit FontPicker component wrapped inside a popup dialog for convenience.
29 * @see FontPicker
30 *
31 * This controls inherits from MauiKit SettingsDialog, to checkout its inherited properties refer to docs.
32 *
33 * The control has two `actions` predefined: accept and reject/cancel.
34 * The cancel action discards changes and closes the dialog, while the accept one emits the `accepted(var font)` signal with the modified font as the argument.
35 * @see accepted
36 *
37 * @image html Misc/fontpickerdialog.png
38 *
39 * @code
40 * Maui.Page
41 * {
42 * anchors.fill: parent
43 * Maui.Controls.showCSD: true
44 *
45 * Button
46 * {
47 * anchors.centerIn: parent
48 * text: "Font Picker"
49 * onClicked: _fontPickerDialog.open()
50 * }
51 *
52 * Maui.FontPickerDialog
53 * {
54 * id: _fontPickerDialog
55 * }
56 * }
57 * @endcode
58 *
59 * <a href="https://invent.kde.org/maui/mauikit/-/blob/qt6-2/examples/FontPickerDialog.qml">You can find a more complete example at this link.</a>
60 *
61 */
62Maui.PopupPage
63{
64 id: control
66 /**
67 * @brief The current font object selected.
68 * @property font FontPickerDialog::mfont
69 */
70 property alias mfont : _picker.mfont
71
72 /**
73 * @brief An alias to expose the font picker model and its properties.
74 * @see FontModel
75 * @property FontModel FontPickerDialog::model
76 */
77 readonly property alias model : _picker.model
78
79 title: i18n("Fonts")
81 /**
82 * @brief Emitted when the accepted action/button is triggered.
83 * @param font The modified font object.
84 */
85 signal accepted(var font)
86
88 {
89 id: _picker
90 Layout.fillWidth: true
91 }
92
93 actions: [
94 Action
95 {
96 text: i18n("Cancel")
97
98 onTriggered:
99 {
100 control.close()
101 }
102 },
103
104 Action
105 {
106 text: i18n("Accept")
107 onTriggered:
108 {
109 control.accepted(_picker.mfont)
110 }
111 }
112 ]
113
114}
A custom control use to pick a font and its properties.
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.