예제 #1
0
 def updateLife(self):
     percentage = system.get_battery_percentage()
     text_percentage = str(percentage) + "%"
     self.setText(text_percentage)
     percent = tr("Power remaining: %s%s")
     ac = system.is_on_ac()
     self.setToolTip(percent % (text_percentage, " (AC)" if ac else ""))
     if ac:
         self.setIcon(complete_icon("charging"))
         return
     if percentage >= 40:
         self.setIcon(complete_icon("battery"))
     elif percentage >= 10:
         self.setIcon(complete_icon("battery-caution"))
     else:
         self.setIcon(complete_icon("dialog-warning"))
예제 #2
0
 def __init__(self, *args, **kwargs):
     super(BatteryAction, self).__init__(*args, **kwargs)
     self.setToolTip(tr("Power"))
     if system.battery:
         self.updateLife()
         self.timer.timeout.connect(self.updateLife)
         if not self.timer.isActive():
             self.timer.start(5000)
     elif system.is_on_ac():
         self.setIcon(complete_icon("charging"))
         self.setText(tr("AC"))
         self.setToolTip(tr("System is running on AC power"))
     else:
         self.setIcon(complete_icon("dialog-warning"))
         self.setText(tr("N/A"))
         self.setToolTip(tr("Battery not detected"))
예제 #3
0
 def __init__(self, *args, **kwargs):
     super(BatteryAction, self).__init__(*args, **kwargs)
     self.setToolTip(tr("Power"))
     if system.battery:
         self.updateLife()
         self.timer.timeout.connect(self.updateLife)
         if not self.timer.isActive():
             self.timer.start(5000)
     elif system.is_on_ac():
         self.setIcon(complete_icon("charging"))
         self.setText(tr("AC"))
         self.setToolTip(tr("System is running on AC power"))
     else:
         self.setIcon(complete_icon("dialog-warning"))
         self.setText(tr("N/A"))
         self.setToolTip(tr("Battery not detected"))
예제 #4
0
 def updateLife(self):
     percentage = system.get_battery_percentage()
     text_percentage = str(percentage) + "%"
     self.setText(text_percentage)
     percent = tr("Power remaining: %s%s")
     ac = system.is_on_ac()
     self.setToolTip(percent % (text_percentage, " (AC)" if ac else ""))
     if ac:
         self.setIcon(complete_icon("charging"))
         return
     if percentage >= 40:
         self.setIcon(complete_icon("battery"))
     elif percentage >= 10:
         self.setIcon(complete_icon("battery-caution"))
     else:
         self.setIcon(complete_icon("dialog-warning"))