Commit 6400fc16 authored by Fushan Wen's avatar Fushan Wen 💬
Browse files

wallpapers/potd: Port to `Kirigami.SelectableLabel`

Depends on frameworks/kirigami!541
parent a4f5384c
Pipeline #178569 passed with stage
in 3 minutes and 51 seconds
/*
SPDX-FileCopyrightText: 2011 Marco Martin <notmart@gmail.com>
SPDX-FileCopyrightText: 2014, 2019 Kai Uwe Broulik <kde@privat.broulik.de>
SPDX-FileCopyrightText: 2022 Fushan Wen <qydwhotmail@gmail.com>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
import QtQuick 2.15
import QtQuick.Controls 2.15 as QQC2
import org.kde.kirigami 2.15 as Kirigami
QQC2.ScrollView {
id: bodyTextContainer
property alias text: bodyText.text
property alias horizontalAlignment: bodyText.horizontalAlignment
property alias bold: bodyText.font.bold
property alias fontPointSize: bodyText.font.pointSize
contentHeight: Math.min(bodyText.implicitHeight, Kirigami.Units.gridUnit * 5)
QQC2.TextArea {
id: bodyText
leftPadding: 0
rightPadding: 0
topPadding: 0
bottomPadding: 0
background: Item {}
readOnly: true
wrapMode: Text.Wrap
textFormat: TextEdit.PlainText
// Orca will automatically read the text, so no need to set the text in description
Accessible.name: bodyTextContainer.Kirigami.FormData.label || ""
Accessible.selectableText: true
HoverHandler {
cursorShape: Qt.IBeamCursor
}
}
}
......@@ -6,9 +6,10 @@
import QtQuick 2.5
import QtQuick.Controls 2.8 as QQC2
import QtQuick.Layouts 1.15
import org.kde.kquickcontrols 2.0 as KQC2
import org.kde.kirigami 2.5 as Kirigami
import org.kde.kirigami 2.20 as Kirigami
import org.kde.plasma.wallpapers.potd 1.0
......@@ -241,26 +242,41 @@ Kirigami.FormLayout {
Kirigami.FormData.isSection: false
}
SelectableLabel {
id: titleLabel
Row {
// HACK: If Kirigami.FormData.label is put inside a TextArea,
// the label will not align with text in the TextArea.
Kirigami.FormData.label: i18nc("@label", "Title:")
contentWidth: wallpaperPreview.implicitWidth * 1.5
visible: wallpaperPreview.visible && text.length > 0
text: PotdProviderModelInstance.title
bold: true
Kirigami.SelectableLabel {
id: titleLabel
Layout.fillWidth: true
Layout.maximumWidth: wallpaperPreview.implicitWidth * 1.5
visible: wallpaperPreview.visible && PotdProviderModelInstance.title.length > 0
font.bold: true
text: PotdProviderModelInstance.title
Accessible.name: titleLabel.Kirigami.FormData.label
}
}
Item {
Kirigami.FormData.isSection: false
}
SelectableLabel {
id: authorLabel
Row {
Kirigami.FormData.label: i18nc("@label", "Author:")
contentWidth: titleLabel.contentWidth
visible: wallpaperPreview.visible && text.length > 0
text: PotdProviderModelInstance.author
bold: false
Kirigami.SelectableLabel {
id: authorLabel
Layout.fillWidth: true
Layout.maximumWidth: titleLabel.Layout.maximumWidth
visible: wallpaperPreview.visible && PotdProviderModelInstance.author.length > 0
text: PotdProviderModelInstance.author
Accessible.name: authorLabel.Kirigami.FormData.label
}
}
Kirigami.InlineMessage {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment