Welcome to mirror list, hosted at ThFree Co, Russian Federation.

PackageCard.qml « qml « resources « Marketplace « plugins - github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: db1a0874e1a5044eb8b96b6e8cd3246be4fe5042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (c) 2021 Ultimaker B.V.
// Cura is released under the terms of the LGPLv3 or higher.

import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.1

import UM 1.6 as UM
import Cura 1.6 as Cura

Rectangle
{
    property alias packageData: packageCardHeader.packageData
    property alias manageableInListView: packageCardHeader.showManageButtons

    height: childrenRect.height
    color: UM.Theme.getColor("main_background")
    radius: UM.Theme.getSize("default_radius").width

    PackageCardHeader
    {
        id: packageCardHeader

        Item
        {
            id: shortDescription

            anchors.fill: parent

            Label
            {
                id: descriptionLabel
                width: parent.width
                property real lastLineWidth: 0; //Store the width of the last line, to properly position the elision.

                text: packageData.description
                textFormat: Text.PlainText //Must be plain text, or we won't get onLineLaidOut signals. Don't auto-detect!
                font: UM.Theme.getFont("default")
                color: UM.Theme.getColor("text")
                maximumLineCount: 2
                wrapMode: Text.Wrap
                elide: Text.ElideRight
                visible: text !== ""

                onLineLaidOut:
                {
                    if(truncated && line.isLast)
                    {
                        let max_line_width = parent.width - readMoreButton.width - fontMetrics.advanceWidth("… ") - 2 * UM.Theme.getSize("default_margin").width;
                        if(line.implicitWidth > max_line_width)
                        {
                            line.width = max_line_width;
                        }
                        else
                        {
                            line.width = line.implicitWidth - fontMetrics.advanceWidth("…"); //Truncate the ellipsis. We're adding this ourselves.
                        }
                        descriptionLabel.lastLineWidth = line.implicitWidth;
                    }
                }
            }
            Label
            {
                id: tripleDotLabel
                anchors.left: parent.left
                anchors.leftMargin: descriptionLabel.lastLineWidth
                anchors.bottom: descriptionLabel.bottom

                text: "… "
                font: descriptionLabel.font
                color: descriptionLabel.color
                visible: descriptionLabel.truncated && descriptionLabel.text !== ""
            }
            Cura.TertiaryButton
            {
                id: readMoreButton
                anchors.right: parent.right
                anchors.bottom: descriptionLabel.bottom
                height: fontMetrics.height //Height of a single line.

                text: catalog.i18nc("@info", "Read more")
                iconSource: UM.Theme.getIcon("LinkExternal")

                visible: descriptionLabel.truncated && descriptionLabel.text !== ""
                enabled: visible
                leftPadding: UM.Theme.getSize("default_margin").width
                rightPadding: UM.Theme.getSize("wide_margin").width
                textFont: descriptionLabel.font
                isIconOnRightSide: true

                onClicked: Qt.openUrlExternally(packageData.marketplaceURL)
            }
        }
    }

    FontMetrics
    {
        id: fontMetrics
        font: UM.Theme.getFont("default")
    }
}