LibraryView.qml 46.8 KB
Newer Older
1 2 3 4
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.2
import QtQuick.Layouts 1.3
5
import Athenaeum 1.0
librebob's avatar
librebob committed
6 7 8 9 10 11

Page {
    id: libraryView

    background: Rectangle {
        anchors.fill: parent
12
        color: Material.background
librebob's avatar
librebob committed
13 14 15
    }
    header: ToolBar {
        id: toolBar
librebob's avatar
librebob committed
16
        Rectangle {
librebob's avatar
librebob committed
17
            anchors.fill: parent
librebob's avatar
librebob committed
18 19 20 21 22 23 24
            color: Material.background
            TextField {
                id: searchField
                leftPadding: 10
                rightPadding: 10
                anchors.bottom: parent.bottom
                width: listView.width
librebob's avatar
librebob committed
25 26
                background: Rectangle {
                    anchors.fill: parent
27
                    color: Material.background
librebob's avatar
librebob committed
28
                }
29
                color: Material.foreground
librebob's avatar
librebob committed
30
                placeholderText: qsTr('Search %L1 Games...').arg(library.filter.length)
librebob's avatar
librebob committed
31
                onTextChanged: {
32 33
                    library.searchValue = text
                    window.search()
librebob's avatar
librebob committed
34 35 36 37 38 39 40 41
                }
                Keys.onEscapePressed: {
                    text = ''
                }
            }
            Label {
                anchors.centerIn: parent
                color: Material.foreground
42
                text: qsTr('Library')
librebob's avatar
librebob committed
43 44
            }
            ToolButton {
librebob's avatar
librebob committed
45 46
                height: parent.height
                anchors.right: parent.right
librebob's avatar
librebob committed
47 48
                contentItem: Text {
                        text: qsTr("")
49
                        color: Material.foreground
librebob's avatar
librebob committed
50 51 52 53
                        horizontalAlignment: Text.AlignHCenter
                        verticalAlignment: Text.AlignVCenter
                }

54 55 56 57
                onClicked: menu.open()
                Menu {
                    id: menu
                    MenuItem {
58
                        text: qsTr('Settings')
59
                        onTriggered: stackView.push(settingsView)
60
                    }
61 62 63 64
                    MenuItem {
                        text: qsTr('Check For Updates')
                        onTriggered: window.checkAll()
                    }
65
                    MenuItem {
66
                        text: qsTr('Update All')
67
                        onTriggered: window.updateAll()
68 69
                    }
                    MenuItem {
70
                        text: qsTr('Exit')
71 72 73 74 75 76 77 78 79 80 81 82 83
                        onTriggered: library.processingCount > 0 ? confirmExit.open() : Qt.quit()
                        Popup {
                            id: confirmExit
                             background: Rectangle {
                                anchors.fill: parent
                                color: Material.background
                            }
                            x: Math.round((parent.width - width) / 2)
                            y: Math.round((parent.height - height) / 2)
                            parent: stackView
                            dim: true
                            modal: true
                            contentItem: Column {
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
                                Text {
                                    anchors.horizontalCenter: parent.horizontalCenter
                                    color: Material.foreground
                                    font.pixelSize: 20
                                    text: qsTr('You have operations pending.')
                                }
                                Row {
                                    topPadding: 20
                                    spacing: 20
                                    anchors.horizontalCenter: parent.horizontalCenter
                                    Button {
                                        MouseArea {
                                            id: exitPopupMouseArea
                                            anchors.fill: parent
                                            hoverEnabled: true
                                            onClicked: {
                                                Qt.quit()
101
                                            }
102 103 104 105 106 107 108
                                        }
                                        contentItem: Text {
                                            color: Material.background
                                            text: qsTr('Close Anyway')
                                            horizontalAlignment: Text.AlignHCenter
                                            verticalAlignment: Text.AlignVCenter
                                        }
109

110 111 112 113
                                        background: Rectangle {
                                            implicitWidth: 100
                                            implicitHeight: 40
                                            color: exitPopupMouseArea.containsMouse ? Material.color(Material.Grey, theme == Material.Dark ? Material.Shade600 : Material.Shade400) : Material.primary
114
                                        }
115 116 117 118 119 120 121 122 123 124 125 126 127 128
                                    }
                                    Button {
                                        contentItem: Text {
                                            color: Material.background
                                            text: qsTr('Cancel')
                                            horizontalAlignment: Text.AlignHCenter
                                            verticalAlignment: Text.AlignVCenter
                                        }
                                        MouseArea {
                                            id: cancelExitPopupMouseArea
                                            anchors.fill: parent
                                            hoverEnabled: true
                                            onClicked: {
                                                confirmExit.close()
129 130
                                            }
                                        }
131 132 133 134 135
                                        background: Rectangle {
                                            implicitWidth: 100
                                            implicitHeight: 40
                                            color: cancelExitPopupMouseArea.containsMouse ? Material.color(Material.Grey, theme == Material.Dark ? Material.Shade600 : Material.Shade400) : Material.primary
                                        }
136 137
                                    }
                                }
138
                            }
139
                        }
140 141
                    }
                }
librebob's avatar
librebob committed
142 143 144
            }
        }
    }
librebob's avatar
librebob committed
145
    /* Game List */
librebob's avatar
librebob committed
146 147 148 149
    ComboBox {
        id: filterCombo
        width: 200
        anchors.top: parent.top
150 151 152
        onModelChanged: {
            currentIndex = getFilterIndex(library.filterValue)
        }
librebob's avatar
librebob committed
153 154
        currentIndex: getFilterIndex(library.filterValue)
        function getFilterIndex(key) {
155 156 157 158 159 160 161 162 163 164 165 166 167
            switch(key) {
                case 'installed':
                    return 1;
                case 'recent':
                    return 2;
                case 'new':
                    return 3;
                case 'has_updates':
                    return 4;
                case 'processing':
                    return 5;
                default:
                    return 0;
librebob's avatar
librebob committed
168
            }
169
        }
librebob's avatar
librebob committed
170 171 172 173 174 175 176 177
        model: [
            qsTr('All Games (%L1)').arg(library.games.length),
            qsTr('Installed (%L1)').arg(library.installedCount),
            qsTr('Recent (%L1)').arg(library.recentCount),
            qsTr('New (%L1)').arg(library.newCount),
            qsTr('Has Updates (%L1)').arg(library.hasUpdatesCount),
            qsTr('Processing (%L1)').arg(library.processingCount)
        ]
178 179 180 181
        validator: IntValidator {
            top: 5
            bottom: 0
        }
librebob's avatar
librebob committed
182
        onActivated: {
183 184
            library.filterValue = getFilterKey(index)
            window.filter()
librebob's avatar
librebob committed
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
            searchField.text = ''
            function getFilterKey(index) {
                switch(index) {
                    case 1:
                        return 'installed';
                    case 2:
                        return 'recent';
                    case 3:
                        return 'new';
                    case 4:
                        return 'has_updates';
                    case 5:
                        return 'processing';
                    default:
                        return 'all';
                }
            }
        }
    }
librebob's avatar
librebob committed
204 205
    ListView {
        id: listView
librebob's avatar
librebob committed
206
        anchors.top: filterCombo.bottom
librebob's avatar
librebob committed
207
        anchors.bottom: parent.bottom
208
        model: library.filter
librebob's avatar
librebob committed
209 210 211
        width: 200
        ScrollBar.vertical: ScrollBar { }
        boundsBehavior: Flickable.StopAtBounds
librebob's avatar
librebob committed
212
        keyNavigationEnabled: true
213
        // focus: true
librebob's avatar
librebob committed
214
        clip:true
215 216 217

        onModelChanged: {
            currentIndex = library.getIndexForCurrentGame()
librebob's avatar
librebob committed
218
        }
219

librebob's avatar
librebob committed
220 221
        delegate: Component {
            id: delegateComponent
222
            Rectangle {
librebob's avatar
librebob committed
223 224
                anchors.left: parent.left
                anchors.right: parent.right
librebob's avatar
librebob committed
225
                height: 35
librebob's avatar
librebob committed
226
                id: rect
librebob's avatar
librebob committed
227
                border.color: ListView.isCurrentItem || itemMouseArea.containsMouse ? Material.accent : tr
librebob's avatar
librebob committed
228 229 230 231
                border.width: 1
                MouseArea {
                    anchors.fill: parent
                    onClicked: {
232 233
                        listView.currentIndex = index
                        window.indexUpdated(index)
234
                        listView.forceActiveFocus()
librebob's avatar
librebob committed
235 236 237 238
                    }
                    id: itemMouseArea
                    hoverEnabled: true
                }
239
                // color: ListView.isCurrentItem ? Material.accent : itemMouseArea.containsMouse ? Material.accent : Material.background
librebob's avatar
librebob committed
240
                color: tr
librebob's avatar
librebob committed
241
                Rectangle {
librebob's avatar
librebob committed
242 243 244
                    id: gameIcon
                    anchors.top: parent.top
                    anchors.bottom: parent.bottom
librebob's avatar
librebob committed
245 246 247
                    anchors.margins: 1
                    width: parent.height
                    height: parent.height
248
                    color: tr
librebob's avatar
librebob committed
249 250 251 252 253 254
                    Image {
                        anchors.fill: parent
                        anchors.margins: 5
                        fillMode: Image.PreserveAspectFit
                        source: iconSmall
                    }
librebob's avatar
librebob committed
255 256
                }
                Text {
257 258
                    // color: parent.ListView.isCurrentItem ? Material.background : itemMouseArea.containsMouse ? Material.background : Material.foreground
                    color: Material.foreground
librebob's avatar
librebob committed
259 260
                    clip: true
                    width: parent.width
librebob's avatar
librebob committed
261 262
                    anchors.left: gameIcon.right
                    anchors.top: parent.top
librebob's avatar
librebob committed
263
                    anchors.bottom: parent.bottom
264
                    anchors.right: parent.right
librebob's avatar
librebob committed
265
                    text: name
librebob's avatar
librebob committed
266 267 268 269
                    anchors.topMargin: 5
                    anchors.rightMargin: 5
                    anchors.bottomMargin: 5
                    verticalAlignment: Text.AlignVCenter
librebob's avatar
librebob committed
270
                }
271
                BusyIndicator {
272
                    visible: true
273 274 275 276 277 278
                    height: parent.height
                    width: parent.height
                    id: gameProcessing
                    anchors.right: parent.right
                    running: processing
                }
279 280 281 282 283 284 285 286 287 288
                Rectangle {
                    visible: false
                    height: parent.height
                    width: parent.height
                    anchors.right: parent.right
                    color: tr
                    Rectangle {
                        width: childrenRect.width
                        height: childrenRect.height
                        anchors.centerIn: parent
289
                        //color: sel
290 291 292 293 294
                        radius: 3
                        Text {
                            text: qsTr('New')
                            font.pixelSize: 12
                            padding: 3
295
                            //color: tc
296 297 298
                        }
                    }
                }
librebob's avatar
librebob committed
299 300 301
            }
        }
    }
librebob's avatar
librebob committed
302
    /* Game Detail Pane */
303
    Rectangle {
librebob's avatar
librebob committed
304 305 306
        anchors.left: listView.right
        anchors.right: parent.right
        anchors.top: parent.top
307
        anchors.bottom: parent.bottom
308
        color: Material.background
309 310 311 312 313 314 315
        ScrollView {
            anchors.fill: parent
            contentHeight: col.height
            contentWidth: parent.width
            Column {
                id: col
                width: parent.width
librebob's avatar
librebob committed
316
                spacing: 40
librebob's avatar
librebob committed
317
                /* Header */
librebob's avatar
librebob committed
318 319 320 321 322
                Rectangle {
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.rightMargin: 40
                    anchors.leftMargin: 40
librebob's avatar
librebob committed
323

324
                    color: Material.background
librebob's avatar
librebob committed
325
                    height: childrenRect.height + 40
librebob's avatar
librebob committed
326

librebob's avatar
librebob committed
327 328
                    Rectangle {
                        anchors.top: parent.top
librebob's avatar
librebob committed
329
                        anchors.left: parent.left
librebob's avatar
librebob committed
330 331 332
                        anchors.right: gameTitle.left
                        // anchors.bottom: parent.bottom
                        anchors.topMargin: 40
librebob's avatar
librebob committed
333

librebob's avatar
librebob committed
334 335 336
                        width: 128
                        height: 128
                        id: gameLogo
librebob's avatar
librebob committed
337

338
                        color: Material.primary
librebob's avatar
librebob committed
339 340 341 342 343 344
                        radius: 10
                        Image {
                            id: img
                            anchors.fill: parent
                            fillMode: Image.PreserveAspectFit
                            source: library.currentGame.iconLarge
librebob's avatar
librebob committed
345
                        }
librebob's avatar
librebob committed
346 347 348 349 350 351 352
                    }
                    Text {
                        id: gameTitle
                        anchors.top: parent.top
                        anchors.left: gameLogo.right
                        anchors.right: parent.right
                        anchors.topMargin: 40
librebob's avatar
librebob committed
353

librebob's avatar
librebob committed
354
                        leftPadding: 20
librebob's avatar
librebob committed
355

356
                        color: Material.foreground
librebob's avatar
librebob committed
357
                        text: library.currentGame.name
librebob's avatar
librebob committed
358 359


librebob's avatar
librebob committed
360 361 362
                        fontSizeMode: Text.VerticalFit
                        font.pixelSize: 48
                        minimumPixelSize: 30;
librebob's avatar
librebob committed
363

librebob's avatar
librebob committed
364
                        elide: Label.ElideRight
librebob's avatar
librebob committed
365

librebob's avatar
librebob committed
366 367 368 369 370 371 372 373 374
                        horizontalAlignment: Text.AlignLeft
                        wrapMode: Text.WordWrap
                    }
                    Text {
                        id: gameSummary
                        anchors.top: gameTitle.bottom
                        anchors.left: gameLogo.right
                        anchors.right: parent.right
                        leftPadding: 20
librebob's avatar
librebob committed
375

376
                        color: Material.foreground
librebob's avatar
librebob committed
377
                        text: library.currentGame.summary
librebob's avatar
librebob committed
378

librebob's avatar
librebob committed
379 380 381 382
                        fontSizeMode: Text.VerticalFit
                        font.pixelSize: 16
                        minimumPixelSize: 10;
                        elide: Label.ElideRight
librebob's avatar
librebob committed
383

librebob's avatar
librebob committed
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
                        horizontalAlignment: Text.AlignLeft
                        wrapMode: Text.WordWrap
                    }
                    Row {
                        anchors.top: gameSummary.bottom
                        anchors.left: gameLogo.right
                        anchors.right: parent.right
                        spacing: 5
                        leftPadding: 20
                        topPadding: 10
                        Button {
                            visible: !library.currentGame.installed
                            enabled: !library.currentGame.processing
                            onClicked: {
                                window.installGame(library.currentGame.id)
                            }
400 401 402 403 404 405 406 407 408 409 410
                            contentItem: Text {
                                enabled: !library.currentGame.processing
                                color: Material.background
                                text: qsTr('Install')
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
                            }
                            background: Rectangle {
                                implicitWidth: 100
                                implicitHeight: 40
                                color: library.currentGame.processing ? Material.color(Material.Grey, theme == Material.Dark ? Material.Shade600 : Material.Shade400) : Material.primary
411
                            }
librebob's avatar
librebob committed
412
                        }
librebob's avatar
librebob committed
413 414 415 416 417 418
                        Button {
                            visible:  library.currentGame.installed
                            enabled: !library.currentGame.playing
                            onClicked: {
                                window.playGame(library.currentGame.id)
                            }
419 420 421 422 423
                            contentItem: Text {
                                color: Material.background
                                text: qsTr('Play')
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
424
                            }
librebob's avatar
librebob committed
425 426 427
                            background: Rectangle {
                                implicitWidth: 100
                                implicitHeight: 40
428
                                color: library.currentGame.playing ? Material.color(Material.LightGreen, Material.Shade400) : Material.accent
429
                            }
librebob's avatar
librebob committed
430
                        }
431 432 433 434 435 436
                        Button {
                            visible: library.currentGame.hasUpdate && library.currentGame.installed
                            enabled: !library.currentGame.playing && !library.currentGame.processing
                            onClicked: {
                                window.updateGame(library.currentGame.id)
                            }
437 438 439 440 441 442
                            contentItem: Text {
                                color: Material.background
                                text: qsTr('Update')
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
                            }
443 444 445
                            background: Rectangle {
                                implicitWidth: 100
                                implicitHeight: 40
446
                                color: Material.primary
447 448
                            }
                        }
librebob's avatar
librebob committed
449
                        Button {
450 451 452 453 454 455
                            contentItem: Text {
                                color: Material.background
                                text: qsTr('Uninstall')
                                horizontalAlignment: Text.AlignHCenter
                                verticalAlignment: Text.AlignVCenter
                            }
librebob's avatar
librebob committed
456 457 458 459 460 461
                            visible: library.currentGame.installed
                            enabled: !library.currentGame.processing
                            MouseArea {
                                id: uninstallMouseArea
                                anchors.fill: parent
                                hoverEnabled: true
462
                                onClicked: {
463 464 465 466 467
                                    uninstallPopup.open()
                                }
                            }
                            Popup {
                                id: uninstallPopup
468 469
                                // parent: Overlay.overlay
                                parent: stackView
470 471
                                background: Rectangle {
                                    anchors.fill: parent
librebob's avatar
librebob committed
472
                                    color: Material.background
473 474 475 476 477 478 479 480 481 482
                                }
                                x: Math.round((parent.width - width) / 2)
                                y: Math.round((parent.height - height) / 2)
                                modal: true
                                dim: true
                                focus: true
                                contentItem: Column {
                                    id: uninstallDialog
                                    Text {
                                        anchors.horizontalCenter: parent.horizontalCenter
483
                                        color: Material.foreground
484
                                        font.pixelSize: 20
485
                                        text: qsTr('Are you sure?')
486 487 488 489 490 491
                                    }
                                    Row {
                                        topPadding: 20
                                        spacing: 20
                                        anchors.horizontalCenter: parent.horizontalCenter
                                        Button {
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
                                            MouseArea {
                                                id: uninstallPopupMouseArea
                                                anchors.fill: parent
                                                hoverEnabled: true
                                                onClicked: {
                                                    window.uninstallGame(library.currentGame.id)
                                                    uninstallPopup.close()
                                                }
                                            }
                                            contentItem: Text {
                                                color: Material.background
                                                text: qsTr('Yes')
                                                horizontalAlignment: Text.AlignHCenter
                                                verticalAlignment: Text.AlignVCenter
                                            }

                                            background: Rectangle {
                                                implicitWidth: 100
                                                implicitHeight: 40
                                                color: uninstallPopupMouseArea.containsMouse ? Material.color(Material.Grey, theme == Material.Dark ? Material.Shade600 : Material.Shade400) : Material.primary
512 513 514
                                            }
                                        }
                                        Button {
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532
                                            contentItem: Text {
                                                color: Material.background
                                                text: qsTr('Cancel')
                                                horizontalAlignment: Text.AlignHCenter
                                                verticalAlignment: Text.AlignVCenter
                                            }
                                            MouseArea {
                                                id: cancelPopupMouseArea
                                                anchors.fill: parent
                                                hoverEnabled: true
                                                onClicked: {
                                                    uninstallPopup.close()
                                                }
                                            }
                                            background: Rectangle {
                                                implicitWidth: 100
                                                implicitHeight: 40
                                                color: cancelPopupMouseArea.containsMouse ? Material.color(Material.Grey, theme == Material.Dark ? Material.Shade600 : Material.Shade400) : Material.primary
533 534 535
                                            }
                                        }
                                    }
536
                                }
librebob's avatar
librebob committed
537
                            }
librebob's avatar
librebob committed
538 539 540
                            background: Rectangle {
                                implicitWidth: 100
                                implicitHeight: 40
541
                                color: uninstallMouseArea.containsMouse ? Material.color(Material.Pink) : Material.primary
librebob's avatar
librebob committed
542 543
                            }
                        }
544
                    }
librebob's avatar
librebob committed
545
                }
librebob's avatar
librebob committed
546
                /* Logs */
547 548 549 550 551
                Rectangle {
                    anchors.left: parent.left
                    anchors.right: parent.right
                    anchors.rightMargin: 40
                    anchors.leftMargin: 40
552
                    color: "black"
553
                    height: 160
librebob's avatar
librebob committed
554
                    visible: library.currentGame.error || library.currentGame.processing || (settings.alwaysShowLogs && library.currentGame.installed)
555 556 557

                    Flickable {
                        id: testFlick
558
                        anchors.fill: parent
559 560 561 562 563 564 565 566 567 568 569

                        // ScrollBar.vertical: ScrollBar {
                        //     policy: ScrollBar.AlwaysOn }
                        clip: true
                        boundsBehavior: Flickable.StopAtBounds

                        TextArea {
                            id: ta
                            onContentHeightChanged: {
                                testFlick.contentY = (contentHeight <= 150 ? 0 : contentHeight - 150)
                            }
570
                            color: "white"
571 572
                            readOnly: true
                            text: library.currentGame.log
573 574 575 576
                            background: Rectangle {
                                anchors.fill: parent
                                color: "black"
                            }
577 578 579
                        }
                    }
                }
librebob's avatar
librebob committed
580
                /* Screenshots */
581 582 583 584 585
                Column {
                    width: parent.width
                    clip: true
                    Rectangle {
                        visible: library.currentGame.screenshots.length
librebob's avatar
librebob committed
586 587 588 589 590 591
                        // width: parent.width
                        anchors.left: parent.left
                        anchors.right: parent.right
                        anchors.rightMargin: 40
                        anchors.leftMargin: 40
                        clip: true
592
                        // height: childrenRect.height > 300 ? 300 : childrenRect.height
librebob's avatar
librebob committed
593
                        height: 300 + carousel.height
594
                        color: "black"
595 596 597 598 599
                        BusyIndicator {
                            id: previewLoadingIndicator
                            anchors.centerIn: parent
                            running: largeView.progress != 1.0
                        }
600
                        Image {
librebob's avatar
librebob committed
601 602 603 604 605 606 607 608
                            anchors.centerIn: parent
                            width: parent.width + 100
                            height: parent.height + 100
                            fillMode: Image.PreserveAspectCrop
                            source:  visible ? (library.currentGame.screenshots[carousel.currentIndex] ? library.currentGame.screenshots[carousel.currentIndex].thumbUrl : '') : ''
                            opacity: 0.6
                        }
                        Image {
librebob's avatar
librebob committed
609
                            id: largeView
librebob's avatar
librebob committed
610 611
                            anchors.left: parent.left
                            anchors.right: parent.right
612
                            fillMode: Image.PreserveAspectFit
613
                            // width: parent.width
librebob's avatar
librebob committed
614 615 616
                            // anchors.fill:
                            height: 300
                            source: visible ? (library.currentGame.screenshots[carousel.currentIndex] ? library.currentGame.screenshots[carousel.currentIndex].sourceUrl : '') : ''
617 618 619 620 621 622 623 624 625 626 627
                            MouseArea {
                                anchors.centerIn: parent
                                width: parent.paintedWidth
                                height: parent.paintedHeight
                                onClicked: {
                                    fullscreenPreview.open()
                                }
                            }
                        }
                        Popup {
                            id: fullscreenPreview
628 629 630 631 632 633
                            // parent: Overlay.overlay
                            x: Math.round((stackView.width - width) / 2)
                            y: Math.round((stackView.height - height) / 2)
                            parent: stackView
                            width: stackView.width
                            height: stackView.height
634 635 636 637 638 639 640 641 642
                            dim: true
                            modal: true
                            MouseArea {
                                anchors.fill: parent
                                onClicked: {
                                    fullscreenPreview.close()
                                }
                            }
                            background: Image {
librebob's avatar
librebob committed
643
                                id: bgImage
644 645
                                fillMode: Image.PreserveAspectFit
                                anchors.centerIn: parent
646
                                width: sourceSize.width > parent.width ? parent.width : sourceSize.width
librebob's avatar
librebob committed
647
                                height: parent.height
648 649
                                source: largeView.source
                            }
librebob's avatar
librebob committed
650
                        }
librebob's avatar
librebob committed
651
                        Rectangle {
librebob's avatar
librebob committed
652 653
                            width: parent.width
                            height: 50
librebob's avatar
librebob committed
654
                            anchors.bottom: parent.bottom
librebob's avatar
librebob committed
655
                            opacity: 0.7
656
                            color: "black"
librebob's avatar
librebob committed
657 658
                            ListView {
                                id: carousel
librebob's avatar
librebob committed
659
                                anchors.horizontalCenter: parent.horizontalCenter
librebob's avatar
librebob committed
660 661 662 663 664 665 666 667 668 669 670 671
                                clip: true
                                width: contentWidth
                                height: parent.height

                                model: library.currentGame.screenshots
                                orientation: ListView.Horizontal
                                spacing: 5
                                boundsBehavior: Flickable.StopAtBounds
                                // ScrollBar.horizontal: ScrollBar { }
                                delegate: Rectangle {
                                    height: parent.height
                                    width: 100
librebob's avatar
librebob committed
672
                                    color: Material.background
librebob's avatar
librebob committed
673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688
                                    Image {
                                        anchors.fill: parent
                                        anchors.margins: 1
                                        // height: parent.height
                                        // width: parent.width
                                        fillMode: Image.PreserveAspectFit
                                        source: thumbUrl
                                    }
                                    MouseArea {
                                        anchors.fill: parent
                                        onClicked: {
                                            carousel.currentIndex = index
                                        }
                                        hoverEnabled: true
                                        id: thumbMouseArea
                                    }
librebob's avatar
librebob committed
689
                                    border.color: ListView.isCurrentItem ? Material.accent : thumbMouseArea.containsMouse ? Material.foreground : Material.primary
librebob's avatar
librebob committed
690 691
                                }
                            }
librebob's avatar
librebob committed
692 693 694
                        }
                    }
                }
librebob's avatar
librebob committed
695
                /* Body */
librebob's avatar
librebob committed
696
                Grid {
librebob's avatar
librebob committed
697
                    id: bodyGrid
librebob's avatar
librebob committed
698 699 700
                    columns: 2
                    width: parent.width
                    Column {
librebob's avatar
librebob committed
701 702 703 704 705
                        id: desc
                        width: parent.width - miscInfo.width
                        anchors.bottomMargin: 40

                        /* Description */
706
                        Text {
librebob's avatar
librebob committed
707
                            visible: library.currentGame.description
708
                            id: descHeading
librebob's avatar
librebob committed
709
                            width: parent.width
710 711 712 713 714 715 716 717
                            leftPadding: 50
                            rightPadding: 40
                            topPadding: 10
                            bottomPadding: 20
                            color: Material.foreground
                            font.pixelSize: 24
                            text: qsTr('Description')
                            wrapMode: Text.WrapAnywhere
librebob's avatar
librebob committed
718 719
                        }
                        Text {
librebob's avatar
librebob committed
720 721
                            visible: library.currentGame.description
                            leftPadding: 50
librebob's avatar
librebob committed
722
                            rightPadding: 40
librebob's avatar
librebob committed
723 724 725
                            topPadding: 0
                            bottomPadding: 10
                            width: parent.width
726
                            color: Material.foreground
librebob's avatar
librebob committed
727 728 729 730 731 732
                            textFormat: Text.RichText
                            font.pixelSize: 16
                            text: library.currentGame.description
                            wrapMode: Text.WordWrap
                        }
                        /* Releases */
733 734
                        Text {
                            id: releaseHeading
librebob's avatar
librebob committed
735
                            visible: library.currentGame.releases.length
736 737 738 739
                            leftPadding: 50
                            rightPadding: 40
                            topPadding: 10
                            bottomPadding: 20
librebob's avatar
librebob committed
740
                            width: parent.width
741 742 743 744
                            color: Material.foreground
                            font.pixelSize: 24
                            text: qsTr('Releases')
                            wrapMode: Text.WrapAnywhere
librebob's avatar
librebob committed
745 746
                        }
                        ListView {
librebob's avatar
librebob committed
747 748
                            visible: library.currentGame.releases.length
                            model: library.currentGame.releases
librebob's avatar
librebob committed
749 750
                            width: parent.width
                            height: contentHeight
librebob's avatar
librebob committed
751
                            spacing: 10
librebob's avatar
librebob committed
752 753
                            delegate: Column {
                                width: parent.width
librebob's avatar
librebob committed
754 755 756
                                function formatTimestamp(ts) {
                                    var t = new Date( 0 );
                                    t.setSeconds(ts);
757
                                    return t.toLocaleDateString();
librebob's avatar
librebob committed
758 759 760 761 762 763
                                }
                                Flow {
                                    width: parent.width
                                    spacing: 10
                                    leftPadding: 50
                                    Text {
764
                                        color: Material.foreground
librebob's avatar
librebob committed
765
                                        font.pixelSize: 20
766
                                        text: qsTr('Version %1').arg(version)
librebob's avatar
librebob committed
767 768 769
                                        wrapMode: Text.WrapAnywhere
                                    }
                                    Text {
770
                                        color: Material.foreground
librebob's avatar
librebob committed
771 772 773 774 775
                                        font.pixelSize: 20
                                        text: formatTimestamp(timestamp)
                                        wrapMode: Text.WrapAnywhere
                                    }
                                }
librebob's avatar
librebob committed
776
                                Text {
librebob's avatar
librebob committed
777
                                    leftPadding: 50
librebob's avatar
librebob committed
778
                                    rightPadding: 40
librebob's avatar
librebob committed
779 780 781
                                    topPadding: 10
                                    bottomPadding: 10
                                    width: parent.width
782
                                    color: Material.foreground
librebob's avatar
librebob committed
783
                                    font.pixelSize: 16
librebob's avatar
librebob committed
784
                                    text: description
librebob's avatar
librebob committed
785 786 787 788 789
                                    wrapMode: Text.WrapAnywhere
                                }
                            }
                        }
                    }
librebob's avatar
librebob committed
790 791 792 793
                    /* Links and Categories */
                    Rectangle {
                        width: 200
                        id: miscInfo
794
                        color: tr
librebob's avatar
librebob committed
795 796 797 798
                        // height:  Math.max(libraryView.height - bodyGrid.y - 35 , Math.max(desc.height, lists.height))
                        height: lists.height
                        Column {
                            id: lists
799
                            width: parent.width
librebob's avatar
librebob committed
800 801 802 803 804 805 806 807 808 809
                            bottomPadding: 40
                            // anchors.left: desc.right
                            // anchors.right: parent.right
                            Text {
                                visible: library.currentGame.developerName
                                leftPadding: 10
                                rightPadding: 50
                                topPadding: 10
                                bottomPadding: 10
                                width: parent.width
810
                                color: Material.foreground
librebob's avatar
librebob committed
811
                                font.pixelSize: 16
812
                                text: qsTr('Developer')
librebob's avatar
librebob committed
813 814 815 816 817
                                wrapMode: Text.WrapAnywhere
                                Rectangle {
                                    anchors.right: parent.right
                                    anchors.left: parent.left
                                    anchors.bottom: parent.bottom
818 819
                                    height: 1
                                    color: tr
820
                                    border.color: Material.accent
librebob's avatar
librebob committed
821 822
                                    anchors.rightMargin: 40
                                }
823
                            }
librebob's avatar
librebob committed
824 825 826 827 828 829
                            Text {
                                visible: library.currentGame.developerName
                                leftPadding: 10
                                rightPadding: 50
                                topPadding: 5
                                bottomPadding: 5
830
                                width: parent.width
831
                                color: Material.foreground
librebob's avatar
librebob committed
832 833 834 835 836 837 838 839 840 841 842
                                font.pixelSize: 12
                                text: library.currentGame.developerName
                                wrapMode: Text.WordWrap
                            }
                            Text {
                                visible: library.currentGame.license
                                leftPadding: 10
                                rightPadding: 50
                                topPadding: 10
                                bottomPadding: 10
                                width: parent.width
843
                                color: Material.foreground
librebob's avatar
librebob committed
844
                                font.pixelSize: 16
845
                                text: qsTr('License')
librebob's avatar
librebob committed
846 847 848 849 850 851
                                wrapMode: Text.WrapAnywhere
                                Rectangle {
                                    anchors.right: parent.right
                                    anchors.left: parent.left
                                    anchors.bottom: parent.bottom
                                    height:1
852
                                    color: tr
853
                                    border.color: Material.accent
librebob's avatar
librebob committed
854
                                    anchors.rightMargin: 40
855
                                }
librebob's avatar
librebob committed
856 857 858 859 860 861 862 863
                            }
                            Text {
                                visible: library.currentGame.license
                                leftPadding: 10
                                rightPadding: 50
                                topPadding: 5
                                bottomPadding: 5
                                width: parent.width
864
                                color: Material.foreground
librebob's avatar
librebob committed
865 866 867 868 869 870 871 872 873 874
                                font.pixelSize: 12
                                text: library.currentGame.license
                                wrapMode: Text.WordWrap
                            }
                            Text {
                                leftPadding: 10
                                rightPadding: 50
                                topPadding: 10
                                bottomPadding: 10
                                width: parent.width
875
                                color: Material.foreground
librebob's avatar
librebob committed
876
                                font.pixelSize: 16
877
                                text: qsTr('Links')
librebob's avatar
librebob committed
878 879 880 881 882 883
                                wrapMode: Text.WrapAnywhere
                                Rectangle {
                                    anchors.right: parent.right
                                    anchors.left: parent.left
                                    anchors.bottom: parent.bottom
                                    height:1
884
                                    color: tr
885
                                    border.color: Material.accent
librebob's avatar
librebob committed
886 887 888 889 890 891 892 893 894 895
                                    anchors.rightMargin: 40
                                }
                            }
                            ListView {
                                model: library.currentGame.urls
                                width: parent.width
                                height: contentHeight
                                id: linksList
                                delegate: Column {
                                    width: parent.width
896
                                    Button {
librebob's avatar
librebob committed
897 898 899
                                        leftPadding: 10
                                        rightPadding: 50
                                        topPadding: 5
900
                                        // bottomPadding: index+1 < linksList.count ? 0 : 5
901 902 903 904 905 906 907 908
                                        MouseArea {
                                            anchors.fill: parent
                                            hoverEnabled: true
                                            cursorShape: Qt.PointingHandCursor
                                            onClicked: {
                                                Qt.openUrlExternally(url)
                                            }
                                        }
909 910 911 912 913 914 915
                                        contentItem: Row {
                                            Image {
                                                width: 14
                                                source: 'icons/' + icon
                                                fillMode: Image.PreserveAspectFit
                                            }
                                            Text {
librebob's avatar
librebob committed
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935
                                                function getTitle(type) {
                                                    switch(type) {
                                                        case 'homepage':
                                                            return qsTr('Homepage');
                                                        case 'bugtracker':
                                                            return qsTr('Bug Tracker');
                                                        case 'help':
                                                            return qsTr('Help');
                                                        case 'faq':
                                                            return qsTr('FAQ');
                                                        case 'donation':
                                                            return qsTr('Donate');
                                                        case 'translate':
                                                            return qsTr('Translation');
                                                        case 'unknown':
                                                            return qsTr('Unknown');
                                                        case 'manifest':
                                                            return qsTr('Manifest');
                                                    }
                                                }
936 937
                                                leftPadding: 5
                                                font.pixelSize: 12
librebob's avatar
librebob committed
938
                                                text: getTitle(type)
939
                                                color: Material.foreground
940 941 942 943
                                            }
                                        }
                                        background: Rectangle {
                                            anchors.fill: parent
944
                                            color: tr
945
                                        }
librebob's avatar
librebob committed
946
                                    }
947
                                }
948 949
                            }
                            Text {
librebob's avatar
librebob committed
950 951
                                leftPadding: 10
                                rightPadding: 50
952 953
                                topPadding: 10
                                bottomPadding: 10
librebob's avatar
librebob committed
954
                                width: parent.width
955
                                color: Material.foreground
956
                                font.pixelSize: 16
957
                                text: qsTr('Categories')
958
                                wrapMode: Text.WrapAnywhere
librebob's avatar
librebob committed
959 960 961 962 963
                                Rectangle {
                                    anchors.right: parent.right
                                    anchors.left: parent.left
                                    anchors.bottom: parent.bottom
                                    height:1
964
                                    color: tr
965
                                    border.color: Material.accent
librebob's avatar
librebob committed
966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981
                                    anchors.rightMargin: 40
                                }
                            }
                            ListView {
                                model: library.currentGame.categories
                                width: parent.width
                                height: contentHeight
                                id: categoriesList
                                delegate: Column {
                                    width: parent.width
                                    Text {
                                        leftPadding: 10
                                        rightPadding: 50
                                        topPadding: 5
                                        bottomPadding: index+1 < categoriesList.count ? 0 : 5
                                        width: parent.width
982
                                        color: Material.foreground
librebob's avatar
librebob committed
983 984 985 986 987
                                        font.pixelSize: 12
                                        text: library.currentGame.categories[index]
                                        wrapMode: Text.WrapAnywhere
                                    }
                                }
988 989 990 991
                            }
                        }
                    }
                }
992
            }
librebob's avatar
librebob committed
993 994
        }
    }
librebob's avatar
librebob committed
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
    Connections {
        target: library
        function getMessage(action) {
            switch(action) {
                case 'install':
                    return qsTr('Installed successfully.');
                case 'uninstall':
                    return qsTr('Uninstalled successfully.');
                case 'update':
                    return qsTr('Updated successfully.');
                case 'error':
                    return qsTr('An error occurred.');
            }
        }
        onDisplayNotification: {
            if (settings.notificationsEnabled) {
                window.notify(library.games[index].name, getMessage(action), library.games[index].iconLarge)
            }
        }
    }
librebob's avatar
librebob committed
1015
}