Advertisement
manticore010

20.04-OsdItem.qml

Mar 30th, 2024
144
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.00 KB | Software | 0 0
  1. import QtQuick 2.0
  2. import org.kde.plasma.core 2.0 as PlasmaCore
  3. import org.kde.plasma.components 2.0 as PlasmaComponents
  4. import org.kde.plasma.extras 2.0 as PlasmaExtra
  5. import QtQuick.Window 2.2
  6.  
  7. Item {
  8.     property QtObject rootItem
  9.     height: Math.min(units.gridUnit * 15, Screen.desktopAvailableHeight / 5)
  10.     width: height
  11.  
  12.     //  /--------------------\
  13.     //  |      spacing       |
  14.     //  | /----------------\ |
  15.     //  | |                | |
  16.     //  | |      icon      | |
  17.     //  | |                | |
  18.     //  | |                | |
  19.     //  | \----------------/ |
  20.     //  |      spacing       |
  21.     //  | [progressbar/text] |
  22.     //  |      spacing       |
  23.     //  \--------------------/
  24.  
  25.     PlasmaCore.IconItem {
  26.         id: icon
  27.  
  28.         height: parent.height - Math.max(progressBar.height, label.height)
  29.                               - ((units.smallSpacing/2) * 3) //it's an svg
  30.         width: parent.width
  31.  
  32.         source: rootItem.icon
  33.     }
  34.  
  35.     PlasmaComponents.ProgressBar {
  36.         id: progressBar
  37.  
  38.         anchors {
  39.             bottom: parent.bottom
  40.             left: parent.left
  41.             right: parent.right
  42.             margins: Math.floor(units.smallSpacing / 2)
  43.         }
  44.  
  45.         visible: rootItem.showingProgress
  46.         minimumValue: 0
  47.         maximumValue: 100
  48.  
  49.         value: Number(rootItem.osdValue)
  50.     }
  51.     PlasmaExtra.Heading {
  52.         id: label
  53.         anchors {
  54.             bottom: parent.bottom
  55.             left: parent.left
  56.             right: parent.right
  57.             margins: Math.floor(units.smallSpacing / 2)
  58.         }
  59.  
  60.         visible: !rootItem.showingProgress
  61.         text: rootItem.showingProgress ? "" : (rootItem.osdValue ? rootItem.osdValue : "")
  62.         horizontalAlignment: Text.AlignHCenter
  63.         wrapMode: Text.WordWrap
  64.         maximumLineCount: 2
  65.         elide: Text.ElideLeft
  66.         minimumPointSize: theme.defaultFont.pointSize
  67.         fontSizeMode: Text.HorizontalFit
  68.         textFormat: Text.PlainText
  69.     }
  70. }
  71.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement