Advertisement
neochapay

Untitled

Feb 3rd, 2022
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.35 KB | None | 0 0
  1. /****************************************************************************************
  2. **
  3. ** Copyright (C) 2020-2021 Chupligin Sergey <neochapay@gmail.com>
  4. ** All rights reserved.
  5. **
  6. ** You may use this file under the terms of BSD license as follows:
  7. **
  8. ** Redistribution and use in source and binary forms, with or without
  9. ** modification, are permitted provided that the following conditions are met:
  10. ** * Redistributions of source code must retain the above copyright
  11. ** notice, this list of conditions and the following disclaimer.
  12. ** * Redistributions in binary form must reproduce the above copyright
  13. ** notice, this list of conditions and the following disclaimer in the
  14. ** documentation and/or other materials provided with the distribution.
  15. ** * Neither the name of the author nor the
  16. ** names of its contributors may be used to endorse or promote products
  17. ** derived from this software without specific prior written permission.
  18. **
  19. ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  20. ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  21. ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  22. ** DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR
  23. ** ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  24. ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  25. ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  26. ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. **
  30. ****************************************************************************************/
  31.  
  32. import QtQuick 2.6
  33. import QtQuick.Layouts 1.0
  34.  
  35. import MeeGo.QOfono 0.2
  36.  
  37. import org.nemomobile.lipstick 0.1
  38.  
  39. Row {
  40. id: simIndicator
  41. spacing: Theme.itemSpacingExtraSmall
  42.  
  43. property var modems: []
  44.  
  45. width: childrenRect.width
  46. height: parent.height
  47.  
  48. OfonoManager {
  49. id: ofonoManager
  50. onModemsChanged: {
  51. recalcModel()
  52. }
  53. Component.onCompleted: {
  54. recalcModel()
  55. }
  56.  
  57. function recalcModel() {
  58. simIndicator.modems = [];
  59. for(var i = 0; i < ofonoManager.modems.length; i++) {
  60. simIndicator.modems.push(modems[i]);
  61. }
  62. simRepeater.model = simIndicator.modems;
  63. }
  64. }
  65.  
  66.  
  67. Layout.fillWidth: true
  68. Layout.fillHeight: true
  69.  
  70. Repeater{
  71. id: simRepeater
  72.  
  73. model: simIndicator.modems
  74.  
  75. height: parent.height
  76. width: parent.height*ofonoManager.modems.length
  77.  
  78. delegate: StatusbarItem {
  79. id: cellStatus
  80. width: simIndicator.height
  81. height: simIndicator.height
  82.  
  83. source: "/usr/share/lipstick-glacier-home-qt5/qml/theme/nosim.png"
  84. iconSize: simIndicator.height
  85. iconSizeHeight: simIndicator.height
  86.  
  87. OfonoNetworkRegistration{
  88. id: cellularRegistrationStatus
  89. modemPath: modelData
  90.  
  91. onStatusChanged: {
  92. recalcIcon()
  93. }
  94.  
  95. onStrengthChanged: {
  96. recalcIcon()
  97. }
  98. }
  99.  
  100. function recalcIcon() {
  101. console.log("================================="+cellularRegistrationStatus.strength)
  102. // TODO FIXUP enabling/Disabling
  103. /*if(!model.enabled) {
  104. cellStatus.source = "/usr/share/lipstick-glacier-home-qt5/qml/theme/disabled-sim.png"
  105. } else */if(!cellularRegistrationStatus.status) {
  106. cellStatus.source = "/usr/share/lipstick-glacier-home-qt5/qml/theme/nosim.png"
  107. } else if(cellularRegistrationStatus.strength > 20){
  108. cellStatus.source = "/usr/share/lipstick-glacier-home-qt5/qml/theme/icon_signal_" + Math.ceil(cellularRegistrationStatus.strength/20) + ".png"
  109. } else {
  110. cellStatus.source = "/usr/share/lipstick-glacier-home-qt5/qml/theme/icon_signal_0.png"
  111. }
  112. }
  113. }
  114. }
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement