Warning, /office/klevernotes/src/contents/ui/dialogs/FontPickerDialog.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 // SPDX-FileCopyrightText: 2023 Louis Schul <schul9louis@gmail.com>
0003
0004 import QtQuick 2.15
0005 import QtQuick.Layouts 1.15
0006
0007 import org.kde.kirigami 2.19 as Kirigami
0008 import org.kde.kirigamiaddons.formcard 1.0 as FormCard
0009
0010 Kirigami.Dialog {
0011 id: scrollableDialog
0012
0013 property string checkedFamily
0014 property int checkedSize
0015 property var caller
0016
0017 title: i18nc("@title:dialog", "Font selector")
0018
0019 standardButtons: Kirigami.Dialog.Apply | Kirigami.Dialog.Cancel
0020
0021 onCallerChanged: if (caller) {
0022 const familyDefaultIndex = 0
0023 const sizeDefaultIndex = 4
0024 const fontInfo = caller.fontInfo
0025 const familyModelIndex = fontBox.model.indexOf(fontInfo.family)
0026 const sizeModelIndex = sizeBox.model.indexOf(fontInfo.pointSize)
0027
0028 fontBox.currentIndex = familyModelIndex > -1 ? familyModelIndex : familyDefaultIndex
0029 sizeBox.currentIndex = sizeModelIndex > -1 ? sizeModelIndex : sizeDefaultIndex
0030 }
0031 onClosed: {
0032 caller = undefined
0033 }
0034
0035 GridLayout {
0036 rows: 1
0037 columns: 2
0038 FormCard.FormComboBoxDelegate {
0039 id: fontBox
0040
0041 model: Qt.fontFamilies()
0042
0043 Layout.row: 0
0044 Layout.column: 0
0045
0046 onCurrentValueChanged: {
0047 scrollableDialog.checkedFamily = currentValue;
0048 }
0049 }
0050
0051 FormCard.FormComboBoxDelegate {
0052 id: sizeBox
0053
0054 model: [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72]
0055
0056 Layout.row: 0
0057 Layout.column: 1
0058
0059 onCurrentValueChanged: {
0060 scrollableDialog.checkedSize = currentValue
0061 }
0062 }
0063
0064 FormCard.FormSectionText {
0065 id: displayText
0066
0067 text: fontBox.currentValue ? fontBox.currentValue : "Note Sans"
0068 font.family: text
0069 font.pointSize: sizeBox.currentValue ? sizeBox.currentValue : 10
0070
0071 Layout.row: 1
0072 Layout.column: 0
0073 Layout.rowSpan: 2
0074 }
0075 }
0076 }