ApplicationPage.qml 8.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 *   Copyright (C) 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library/Lesser General Public License
 *   version 2, or (at your option) any later version, as published by the
 *   Free Software Foundation
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library/Lesser General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

20
import QtQuick 2.1
21
import QtQuick.Controls 1.1
22 23
import QtQuick.Window 2.1
import QtQuick.Layouts 1.1
24
import QtGraphicalEffects 1.0
25
import org.kde.kquickcontrolsaddons 2.0
26
import org.kde.discover 1.0
27
import org.kde.discover.app 1.0
Aleix Pol Gonzalez's avatar
Port  
Aleix Pol Gonzalez committed
28
import org.kde.kirigami 2.0 as Kirigami
29
import "navigation.js" as Navigation
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
30

31
DiscoverPage {
32 33 34
    id: appInfo
    property QtObject application: null
    clip: true
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
35

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
36 37
    title: application.name

38 39
    background: Rectangle { color: Kirigami.Theme.viewBackgroundColor }

40 41 42 43 44
    ReviewsPage {
        id: reviewsSheet
        model: reviewsModel
    }

45
    pageOverlay: Item {
46 47 48 49 50 51 52 53 54 55 56
        Rectangle {
            color: Kirigami.Theme.viewBackgroundColor
            anchors.fill: layo
        }
        RowLayout {
            Binding {
                target: appInfo
                property: "bottomPadding"
                value: layo.height + Kirigami.Units.largeSpacing
            }
            id: layo
57
            anchors {
58
                left: parent.left
59 60
                right: parent.right
                bottom: parent.bottom
61
            }
62 63 64 65 66 67
            Kirigami.BasicListItem {
                implicitWidth: contentItem.implicitWidth + leftPadding + rightPadding
                separatorVisible: false
                Layout.fillWidth: false
                icon: "draw-arrow-forward"
                label: i18n("Close Description")
68 69 70
                enabled: appInfo.sClose.enabled
                onClicked: appInfo.sClose.activated()
            }
71

72
            Item {
73 74 75
                Layout.fillWidth: true
            }

76 77
            spacing: 0

78 79 80 81 82 83 84
            ToolButton {
                Layout.minimumWidth: Kirigami.Units.gridUnit * 10
                visible: application.isInstalled && application.canExecute
                text: i18n("Launch")
                onClicked: application.invokeApplication()
            }

85 86
            InstallApplicationButton {
                application: appInfo.application
87
                flat: true
88 89 90 91 92
                Layout.minimumWidth: Kirigami.Units.gridUnit * 10
            }
        }
        Kirigami.Separator {
            anchors {
93 94 95
                left: layo.left
                right: layo.right
                top: layo.top
96 97
            }
            z: 4000
98 99 100
        }
    }

101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    Kirigami.OverlaySheet {
        id: originsOverlay
        bottomPadding: Kirigami.Units.largeSpacing
        topPadding: Kirigami.Units.largeSpacing
        ListView {
            model: ResourcesProxyModel {
                allBackends: true
                resourcesUrl: appInfo.application.url
            }
            delegate: Kirigami.BasicListItem {
                label: displayOrigin
                checkable: checked
                checked: appInfo.application == model.application
                onClicked: if(index>=0) {
                    var res = model.application
                    console.assert(res)
                    window.stack.pop()
                    Navigation.openApplication(res)
                }
            }
        }
    }

124
    ColumnLayout {
125 126
        RowLayout {
            Layout.fillWidth: true
127
            spacing: Kirigami.Units.gridUnit
128
            Kirigami.Icon {
129 130 131
                Layout.preferredHeight: 128
                Layout.preferredWidth: 128

132
                source: appInfo.application.icon
133
                Layout.alignment: Qt.AlignVCenter
134 135 136
            }
            ColumnLayout {
                id: conts
137

138
                Layout.fillWidth: true
139
                Layout.fillHeight: true
140 141 142
                Layout.topMargin: Kirigami.Units.largeSpacing
                Layout.bottomMargin: Kirigami.Units.largeSpacing
                spacing: 0
143

144 145 146 147 148
                Heading {
                    id: title
                    text: appInfo.application.name
                    Layout.fillWidth: true
                    elide: Text.ElideRight
149
                }
150 151
                Rectangle {
                    color: Kirigami.Theme.linkColor
152
                    Layout.fillWidth: true
153
                    height: 1
154
                }
155 156 157 158 159 160 161
                Label {
                    Layout.fillWidth: true
                    text: appInfo.application.comment
                    wrapMode: Text.WordWrap
                    elide: Text.ElideRight
                    maximumLineCount: 1
                }
162 163 164 165 166 167 168 169 170 171 172
                Label {
                    Layout.fillWidth: true
                    elide: Text.ElideRight
                    text: appInfo.application.categoryDisplay
                    color: Kirigami.Theme.linkColor
                }

                Item {
                    Layout.fillWidth: true
                    Layout.fillHeight: true
                }
173 174 175 176 177 178
                Label {
                    text: i18n("Version: %1", appInfo.application.isInstalled ? appInfo.application.installedVersion : appInfo.application.availableVersion)
                }
                Label {
                    text: i18n("Size: %1", appInfo.application.sizeDescription)
                }
179 180 181 182 183 184 185 186 187
                RowLayout {
                    Label {
                        text: i18n("Source: ")
                    }
                    LinkButton {
                        text: appInfo.application.displayOrigin
                        onClicked: originsOverlay.open()
                    }
                }
188 189 190
                Label {
                    visible: text.length>0
                    text: appInfo.application.license ? i18n("License: %1", appInfo.application.license) : ""
191
                }
192 193
            }
        }
194

195
        ApplicationScreenshots {
196
            Layout.fillWidth: true
197
            resource: appInfo.application
198
            page: appInfo
199
        }
200

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
201 202
        Heading {
            text: i18n("Description")
203
            Layout.fillWidth: true
204
            visible: appInfo.application.longDescription.length > 0
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
205 206 207 208 209 210
        }
        Label {
            Layout.fillWidth: true
            horizontalAlignment: Text.AlignJustify
            wrapMode: Text.WordWrap
            text: appInfo.application.longDescription
211
        }
212

213
        RowLayout {
214
            visible: button.text.length > 0
215 216 217 218
            Label {
                text: i18n("Homepage: ")
            }
            LinkButton {
219
                id: button
220 221 222
                text: application.homepage
                onClicked: Qt.openUrlExternally(application.homepage)
            }
223 224
        }

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
225 226
        LinkButton {
            id: addonsButton
227
            text: i18n("Addons")
228
            visible: addonsView.containsAddons
229
            onClicked: addonsView.sheetOpen = true
230
        }
231

Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
232
        LinkButton {
233 234 235 236 237 238
            text: i18n("Review")
            onClicked: reviewsSheet.openReviewDialog()
            visible: !commentsButton.visible
        }
        LinkButton {
            id: commentsButton
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
239
            readonly property QtObject rating: appInfo.application.rating
240
            visible: rating && rating.ratingCount>0 && reviewsModel.count
241
            text: i18n("Show comments (%1)...", rating ? reviewsModel.count : 0)
242 243 244 245 246

            ReviewsModel {
                id: reviewsModel
                resource: appInfo.application
            }
247

248
            onClicked: {
249
                reviewsSheet.open()
250
            }
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
251 252 253 254 255 256
        }

        Item {
            height: addonsButton.height
            width: 5
        }
257
    }
Aleix Pol Gonzalez's avatar
Aleix Pol Gonzalez committed
258

259 260 261 262 263
    readonly property var addons: AddonsView {
        id: addonsView
        application: appInfo.application
        parent: overlay
    }
Jonathan Thomas's avatar
Jonathan Thomas committed
264
}