Guest User

Untitled

a guest
Apr 5th, 2014
8
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /******************************************************************************
  2. * *
  3. * HungerMeter - consumption measuring tool for SailfishOS *
  4. * Copyright (C) 2014 by Michal Hrusecky <Michal@Hrusecky.net> *
  5. * *
  6. * This program is free software: you can redistribute it and/or modify *
  7. * it under the terms of the GNU General Public License as published by *
  8. * the Free Software Foundation, either version 3 of the License, or *
  9. * (at your option) any later version. *
  10. * *
  11. * This program is distributed in the hope that it will be useful, *
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  14. * GNU General Public License for more details. *
  15. * *
  16. * You should have received a copy of the GNU General Public License *
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>. *
  18. * *
  19. ******************************************************************************/
  20.  
  21. import QtQuick 2.0
  22. import Sailfish.Silica 1.0
  23.  
  24. CoverBackground {
  25. id: coverPage
  26.  
  27. Timer {
  28. id: pageTimer
  29. interval: 1000;
  30. running: true;
  31. repeat: true
  32. onTriggered: {
  33. coverCurText.text = hunger.avg_text(app.cur_time)
  34. coverAvgText.text = hunger.avg_text(app.avg_time)
  35. coverLongText.text = hunger.long_text()
  36. interval = app.cur_time * 1000
  37. coverPercentage.text = hunger.bat_cur_pr()
  38. }
  39. }
  40. Column {
  41. x: Theme.paddingLarge
  42. y: Theme.paddingMedium
  43. width: parent.width - 2 * Theme.paddingLarge
  44. spacing: Theme.paddingSmall
  45. Label {
  46. text: qsTr("Now") + (app.show_int?(" (" + app.cur_time + " s):"):":")
  47. width: parent.width
  48. color: Theme.secondaryColor
  49. horizontalAlignment: Text.AlignLeft
  50. font.pixelSize: Theme.fontSizeMedium
  51. }
  52. Label {
  53. id: coverCurText
  54. text: ""
  55. width: parent.width
  56. horizontalAlignment: Text.AlignRight
  57. font.pixelSize: Theme.fontSizeLarge
  58. }
  59. Label {
  60. text: qsTr("Avg") + (app.show_int?(" (" + app.avg_time + " s):"):":")
  61. width: parent.width
  62. color: Theme.secondaryColor
  63. horizontalAlignment: Text.AlignLeft
  64. font.pixelSize: Theme.fontSizeMedium
  65. }
  66. Label {
  67. id: coverAvgText
  68. width: parent.width
  69. horizontalAlignment: Text.AlignRight
  70. text: ""
  71. font.pixelSize: Theme.fontSizeLarge
  72. }
  73.  
  74. Label {
  75. text: {
  76. if(percOnCover == false) {
  77. (app.show_int?"":qsTr("Long ")) + qsTr("Avg") + (app.show_int?(" (" + app.long_avg + " h):"):":")
  78. } else {
  79. "Battery:"
  80. console.log("CIAO")
  81. }
  82. }
  83. width: parent.width
  84. color: Theme.secondaryColor
  85. horizontalAlignment: Text.AlignLeft
  86. font.pixelSize: Theme.fontSizeMedium
  87. }
  88. Label {
  89. text: coverPercentage
  90. width: parent.width
  91. horizontalAlignment: Text.AlignRight
  92. font.pixelSize: Theme.fontSizeLarge
  93. }
  94. }
  95. }
RAW Paste Data