SHARE
TWEET

PanelRight.qml

a guest Jun 4th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Pegasus Frontend
  2. // Copyright (C) 2017-2018  Mátyás Mustoha
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16.  
  17.  
  18. import QtQuick 2.6
  19. import QtMultimedia 5.9
  20.  
  21.  
  22. Item {
  23.     property var game
  24.  
  25.     onGameChanged: {
  26.         videoPreview.stop();
  27.         videoPreview.playlist.clear();
  28.         videoDelay.restart();
  29.     }
  30.  
  31.     // a small delay to avoid loading videos during scrolling
  32.     Timer {
  33.         id: videoDelay
  34.         interval: 250
  35.         onTriggered: {
  36.             if (game && game.assets.videos.length > 0) {
  37.                 for (var i = 0; i < game.assets.videos.length; i++)
  38.                     videoPreview.playlist.addItem(game.assets.videos[i]);
  39.  
  40.                 videoPreview.play();
  41.             }
  42.         }
  43.     }
  44.  
  45.  
  46.     Image {
  47.         id: logo
  48.         width: parent.width
  49.         height: width * 0.35
  50.  
  51.         asynchronous: true
  52.         source: (game && game.assets.logo) || ""
  53.         sourceSize { width: 512; height: 192 }
  54.         fillMode: Image.PreserveAspectFit
  55.  
  56.         // title
  57.         Text {
  58.             color: "#eee"
  59.             text: (game && game.title) || ""
  60.  
  61.             width: parent.width * 0.8
  62.             anchors.centerIn: parent
  63.             wrapMode: Text.WordWrap
  64.             horizontalAlignment: Text.AlignHCenter
  65.  
  66.             font {
  67.                 bold: true
  68.                 pixelSize: vpx(30)
  69.                 capitalization: Font.SmallCaps
  70.                 family: globalFonts.sans
  71.             }
  72.  
  73.             visible: parent.status != Image.Ready && parent.status != Image.Loading
  74.         }
  75.     }
  76.  
  77.     // year -- developer / publisher -- players
  78.     Text {
  79.         id: releaseDetails
  80.         width: parent.width
  81.         wrapMode: Text.WordWrap
  82.         horizontalAlignment: Text.AlignHCenter
  83.  
  84.         anchors.top: logo.bottom
  85.         topPadding: vpx(16)
  86.         bottomPadding: vpx(16)
  87.  
  88.         text: {
  89.             var text_tmp = "";
  90.  
  91.             if (!game)
  92.                 return text_tmp;
  93.  
  94.             if (game.releaseYear > 0)
  95.                 text_tmp += game.releaseYear;
  96.             if (game.developer) {
  97.                 if (text_tmp)
  98.                     text_tmp += " \u2014 ";
  99.  
  100.                 text_tmp += game.developer;
  101.                 if (game.publisher && game.developer !== game.publisher)
  102.                     text_tmp += " / " + game.publisher;
  103.             }
  104.             return text_tmp;
  105.         }
  106.         color: "#eee"
  107.         font {
  108.             pixelSize: vpx(18)
  109.             family: globalFonts.sans
  110.         }
  111.  
  112.         visible: text
  113.     }
  114.  
  115.     Text {
  116.         id: summary
  117.         width: parent.width
  118.         wrapMode: Text.WordWrap
  119.  
  120.         anchors.top: releaseDetails.bottom
  121.         topPadding: vpx(20)
  122.         bottomPadding: vpx(40)
  123.  
  124.         text: game ? (game.summary || game.description) : ""
  125.         color: "#eee"
  126.         font {
  127.             pixelSize: vpx(16)
  128.             family: globalFonts.sans
  129.         }
  130.         maximumLineCount: 4
  131.         elide: Text.ElideRight
  132.  
  133.         visible: text
  134.     }
  135.  
  136.     Rectangle {
  137.         id: videoBox
  138.         color: "#000"
  139.         border { color: "#444"; width: 1 }
  140.  
  141.         anchors.top: summary.bottom
  142.         anchors.bottom: parent.bottom
  143.  
  144.         width: parent.width
  145.         radius: vpx(4)
  146.  
  147.         visible: (game && (game.assets.videos.length || game.assets.screenshots.length)) || false
  148.  
  149.         Video {
  150.             id: videoPreview
  151.             visible: playlist.itemCount > 0
  152.  
  153.             anchors { fill: parent; margins: 1 }
  154.             fillMode: VideoOutput.PreserveAspectFit
  155.             volume: 0.3
  156.             playlist: Playlist {
  157.                 playbackMode: Playlist.Loop
  158.             }
  159.         }
  160.  
  161.         Image {
  162.             visible: !videoPreview.visible
  163.  
  164.             anchors { fill: parent; margins: 1 }
  165.             fillMode: Image.PreserveAspectFit
  166.  
  167.             source: (game && game.assets.screenshots.length && game.assets.screenshots[0]) || ""
  168.             sourceSize { width: 512; height: 512 }
  169.             asynchronous: true
  170.         }
  171.     }
  172. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top