SHA256
1
0
forked from pool/discover
discover/0003-Drop-usage-of-templates-from-LinkButton.patch

157 lines
5.4 KiB
Diff

From 7a3b57dfeb0f5afaa2399bcf5de04eea80603df5 Mon Sep 17 00:00:00 2001
From: Aleix Pol <aleixpol@kde.org>
Date: Thu, 15 Sep 2016 18:14:48 +0200
Subject: [PATCH 3/4] Drop usage of templates from LinkButton
---
discover/qml/ApplicationPage.qml | 3 ---
discover/qml/LinkButton.qml | 47 ++++++++++++----------------------------
discover/qml/PageHeader.qml | 34 ++++++++++++++++++++---------
3 files changed, 38 insertions(+), 46 deletions(-)
diff --git a/discover/qml/ApplicationPage.qml b/discover/qml/ApplicationPage.qml
index e7e7bb9..e35f721 100644
--- a/discover/qml/ApplicationPage.qml
+++ b/discover/qml/ApplicationPage.qml
@@ -155,7 +155,6 @@ DiscoverPage {
}
LinkButton {
id: button
- shadow: false
text: application.homepage
onClicked: Qt.openUrlExternally(application.homepage)
}
@@ -163,7 +162,6 @@ DiscoverPage {
LinkButton {
id: addonsButton
- shadow: false
text: i18n("Addons")
visible: addonsView.containsAddons
onClicked: addonsView.opened = true
@@ -173,7 +171,6 @@ DiscoverPage {
readonly property QtObject rating: appInfo.application.rating
visible: rating && rating.ratingCount>0 && reviewsModel.count
text: i18n("Show comments (%1)...", rating ? rating.ratingCount : 0)
- shadow: false
ReviewsModel {
id: reviewsModel
diff --git a/discover/qml/LinkButton.qml b/discover/qml/LinkButton.qml
index 29066dc..d00f0b4 100644
--- a/discover/qml/LinkButton.qml
+++ b/discover/qml/LinkButton.qml
@@ -1,48 +1,29 @@
-import QtQuick 2.6
+import QtQuick 2.2
import QtGraphicalEffects 1.0
-import QtQuick.Templates 2.0 as T
import org.kde.kirigami 1.0
-T.ToolButton {
+Text {
id: control
- property alias shadow: shadow.visible
property Action action: null
text: action ? action.text : ""
enabled: !action || action.enabled
onClicked: if (action) action.trigger()
- implicitWidth: textItem.implicitWidth + leftPadding + rightPadding
- implicitHeight: textItem.implicitHeight + topPadding + bottomPadding
- baselineOffset: contentItem.y + contentItem.baselineOffset
+ font: control.font
+ color: control.shadow ? Theme.highlightedTextColor : Theme.linkColor
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
- readonly property alias textColor: textItem.color
- hoverEnabled: true
+ signal clicked()
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
- onHoveredChanged: {
- textItem.font.underline = hovered && enabled
- }
-
- contentItem: Text {
- id: textItem
- text: control.text
- font: control.font
- color: control.shadow ? Theme.highlightedTextColor : Theme.linkColor
- elide: Text.ElideRight
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- }
+ onContainsMouseChanged: {
+ control.font.underline = containsMouse && control.enabled
+ }
- DropShadow {
- id: shadow
- horizontalOffset: 2
- verticalOffset: 2
- radius: 8.0
- samples: 17
- color: "#f0000000"
- source: textItem
- anchors.fill: textItem
+ onClicked: control.clicked()
}
-
- background: null
}
diff --git a/discover/qml/PageHeader.qml b/discover/qml/PageHeader.qml
index d5a3b7a..7448380 100644
--- a/discover/qml/PageHeader.qml
+++ b/discover/qml/PageHeader.qml
@@ -76,18 +76,32 @@ ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
}
- LinkButton {
+ Item {
Layout.topMargin: Kirigami.Units.smallSpacing*2
Layout.bottomMargin: Kirigami.Units.smallSpacing*2
- shadow: root.background !== ""
- text: titleLabel.text
- font: SystemFonts.titleFont
- onClicked: {
- var flic = root._page.flickable
- if (flic.positionViewAtBeginning)
- flic.positionViewAtBeginning();
- else
- flic.contentY = 0;
+ Layout.preferredHeight: title.paintedHeight
+ Layout.preferredWidth: title.paintedWidth
+ LinkButton {
+ id: title
+ text: titleLabel.text
+ font: SystemFonts.titleFont
+ color: Kirigami.Theme.highlightedTextColor
+ onClicked: {
+ var flic = root._page.flickable
+ if (flic.positionViewAtBeginning)
+ flic.positionViewAtBeginning();
+ else
+ flic.contentY = 0;
+ }
+ }
+ DropShadow {
+ horizontalOffset: 2
+ verticalOffset: 2
+ radius: 8.0
+ samples: 17
+ color: "#f0000000"
+ source: title
+ anchors.fill: title
}
}
}
--
2.10.0