From d28ae74d212baba2c12bbb61c43a4bf348cd0153 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 23 Sep 2014 19:40:50 -0500 Subject: Convert remaining modules to TQt3 This relates to Bug 1995 --- powermanager/guidance-power-manager.py | 99 +++++++++++++++++-------------- powermanager/guidance_power_manager_ui.ui | 68 ++++++++++----------- powermanager/notify.ui | 10 ++-- powermanager/tooltip.ui | 4 +- 4 files changed, 97 insertions(+), 84 deletions(-) (limited to 'powermanager') diff --git a/powermanager/guidance-power-manager.py b/powermanager/guidance-power-manager.py index cef7e52..aeccf2f 100755 --- a/powermanager/guidance-power-manager.py +++ b/powermanager/guidance-power-manager.py @@ -22,8 +22,8 @@ Specification at https://wiki.kubuntu.org/KubuntuPowerManagement Issues: - We have to keep polling HAL rather than listening for signals because the Python DBUS bindings - don't have Qt mainloop integration - - Written in Python so will be slow to load up, will probably port to C++ Qt 4.2 in future + don't have TQt mainloop integration + - Written in Python so will be slow to load up, will probably port to C++ TQt 4.2 in future - Should also handle UPS and bluetooth batteries - systray applet should be hidden if no battery, but then how do you suspend if no battery? (ksmserver integration please) @@ -32,8 +32,21 @@ Issues: - dcop calls need patch to dcopexport.py, already submitted upstream """ -import os import sys +import os +import os.path +# Trinity-specific paths +tqt_modules = [] +for m_path in sys.path: + if os.path.exists(os.path.join(m_path, 'sip4_tqt')): + m_sip_dir = os.path.join(m_path, 'sip4_tqt') + tqt_modules.insert(0, m_sip_dir) + if os.path.exists(os.path.join(m_path, 'python_tqt')): + m_pyqt_dir = os.path.join(m_path, 'python_tqt') + tqt_modules.insert(0, m_pyqt_dir) +for m_path in tqt_modules: + sys.path.insert(0, m_path) + import subprocess import dbus @@ -69,7 +82,7 @@ class Notify(NotifyWidget): def setCaption(self,caption): """ Text to show in bold letters. """ - self.Caption.setText(QString("")+caption+QString("")) + self.Caption.setText(TQString("")+caption+QString("")) def setText(self,msg): """" Set actual notification message. """ @@ -87,7 +100,7 @@ class PowerManager(PowerManagerUI): # therefore, it gets our parent as parent. self.systray = KSystemTray(parent) self.icon = "battery-charging-100" - self.systray.setPixmap(QPixmap(UserIcon(self.icon))) + self.systray.setPixmap(TQPixmap(UserIcon(self.icon))) self.connect(self.systray, SIGNAL("quitSelected()"), self.quit) # Configuration filename @@ -110,7 +123,7 @@ class PowerManager(PowerManagerUI): # Polling: evil. can't receive signals in python-dbus unless we have a glib mainloop, # so we need to poll - self.pollTimer = QTimer(self) + self.pollTimer = TQTimer(self) self.connect(self.pollTimer, SIGNAL("timeout()"), self.poll) self.pollTimer.start(POLL_INTERVAL) # 5 second poll, maybe make this configurable self.poll(False) @@ -136,20 +149,20 @@ class PowerManager(PowerManagerUI): self.LaptopLidRadios.setEnabled(False) def _initCB(self, combo, options, values): - """ Initialize QComboBox with proper values from provided options. """ + """ Initialize TQComboBox with proper values from provided options. """ combo.clear() for option in options: combo.insertItem(values[option]) def _getCB(self, combo, options): - """ Get current item from QComboBox from config file (string) value. """ + """ Get current item from TQComboBox from config file (string) value. """ try: return options[combo.currentItem()] except IndexError: return "" def _setCB(self, combo, options, default, value): - """ Set current item in QComboBox from string value. """ + """ Set current item in TQComboBox from string value. """ try: num = options.index(value) except ValueError: @@ -158,14 +171,14 @@ class PowerManager(PowerManagerUI): combo.setCurrentItem(num) def _getRB(self, radios, options): - """ Get current item from QRadioButton from config file (string) value. """ + """ Get current item from TQRadioButton from config file (string) value. """ try: return options[radios.selectedId()] except IndexError: return "" def _setRB(self, radios, options, default, value): - """ Set current item in QRadioButton from string value. """ + """ Set current item in TQRadioButton from string value. """ try: num = options.index(value) except ValueError: @@ -250,9 +263,9 @@ class PowerManager(PowerManagerUI): self.connect(self.BatteryBrightnessSlider, SIGNAL("valueChanged(int)"), self.changeBatteryBrightness) #Add a blank tooltip, the tooltipgroup signals are then used for our KPassivePopup - toolTipGroup = QToolTipGroup(self.systray) - QToolTip.add(self.systray, "", toolTipGroup, "blah") - self.connect(toolTipGroup, SIGNAL("showTip(const QString&)"), self.showTip) + toolTipGroup = TQToolTipGroup(self.systray) + TQToolTip.add(self.systray, "", toolTipGroup, "blah") + self.connect(toolTipGroup, SIGNAL("showTip(const TQString&)"), self.showTip) self.connect(toolTipGroup, SIGNAL("removeTip()"), self.hideTip) # Popup tooltip showing battery level @@ -353,7 +366,7 @@ class PowerManager(PowerManagerUI): # And change the icon in the systray, remove the restore option # This way, we're basically becoming a systray applet, you can # hibernate and suspend from - self.systray.setPixmap(QPixmap(UserIcon(self.icon))) + self.systray.setPixmap(TQPixmap(UserIcon(self.icon))) if self.powermanager.hasAC: self.wasOnBattery = self.powermanager.onBattery() @@ -368,8 +381,8 @@ class PowerManager(PowerManagerUI): self.PoweredBrightnessSlider.setValue(self.config.readNumEntry("poweredBrightness", brightness_high)) #default highest tt_text = "Every step increases or decreases the brightness by %i%%" % int(100/brightness_high) - QToolTip.add(self.BatteryBrightnessSlider, tt_text) - QToolTip.add(self.PoweredBrightnessSlider, tt_text) + TQToolTip.add(self.BatteryBrightnessSlider, tt_text) + TQToolTip.add(self.PoweredBrightnessSlider, tt_text) self.lockScreenOnResume.setChecked(self.config.readBoolEntry("lockOnResume", True)) @@ -418,7 +431,7 @@ class PowerManager(PowerManagerUI): self.config.sync() def quit(self): - """ Quit application. """ + """ TQuit application. """ kapp.quit() def showTip(self, text=""): @@ -457,7 +470,7 @@ class PowerManager(PowerManagerUI): value=self.BatteryBrightnessSlider.value()*100/self.BatteryBrightnessSlider.maxValue() else: value=self.PoweredBrightnessSlider.value()*100/self.PoweredBrightnessSlider.maxValue() - return QString(str(value)) + return TQString(str(value)) def hideTip(self): """ Hide the tooltip.""" @@ -599,15 +612,15 @@ class PowerManager(PowerManagerUI): oldIcon = self.icon self.icon = self._getIcon() if self.icon != oldIcon: - self.systray.setPixmap(QPixmap(UserIcon(self.icon))) - self.BattPixmap.setPixmap(QPixmap(UserIcon(self.icon))) + self.systray.setPixmap(TQPixmap(UserIcon(self.icon))) + self.BattPixmap.setPixmap(TQPixmap(UserIcon(self.icon))) def notify(self, msg, icon=None): """ Send a notification popup. """ if icon: - icon = QPixmap(icon) + icon = TQPixmap(icon) else: - icon = QPixmap(SmallIcon("messagebox_info")) + icon = TQPixmap(SmallIcon("messagebox_info")) try: del self.warningPopup except: @@ -615,7 +628,7 @@ class PowerManager(PowerManagerUI): self.warningPopup = KPassivePopup(self.systray) label = Notify(self.warningPopup, msg, icon) self.warningPopup.setView(label) - position = QPoint(5,5) + position = TQPoint(5,5) self.warningPopup.show(position) def poll(self,notify=True): @@ -728,20 +741,20 @@ class PowerManager(PowerManagerUI): if self.act_call[action] != None: note = i18n("Laptop lid is closed, %1 now.").arg(self.act_notify[action]) self.notify(note, self.act_icon[action]) - QTimer.singleShot(2000, self.act_call[action]) + TQTimer.singleShot(2000, self.act_call[action]) else: self.powermanager.lidClosedState = False def _addBatteryWidgets(self): """ Adds progressbars to show battery status to the tooltip.""" - BattLayout = QHBoxLayout(None,0,6,"BattLayout") + BattLayout = TQHBoxLayout(None,0,6,"BattLayout") - self.BattPixmap = QLabel(self.tooltip,"BattLabLayout") - self.BattPixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.BattPixmap.sizePolicy().hasHeightForWidth())) - self.BattPixmap.setPixmap(QPixmap(UserIcon(self.icon))) + self.BattPixmap = TQLabel(self.tooltip,"BattLabLayout") + self.BattPixmap.setSizePolicy(TQSizePolicy(TQSizePolicy.Fixed,TQSizePolicy.Fixed,0,0,self.BattPixmap.sizePolicy().hasHeightForWidth())) + self.BattPixmap.setPixmap(TQPixmap(UserIcon(self.icon))) self.BattPixmap.setScaledContents(1) BattLayout.addWidget(self.BattPixmap) - self.BattMainLabel = QLabel(self.tooltip,"BattMainLabel") + self.BattMainLabel = TQLabel(self.tooltip,"BattMainLabel") self.BattMainLabel.setText(i18n("Battery:")) BattLayout.addWidget(self.BattMainLabel) @@ -754,13 +767,13 @@ class PowerManager(PowerManagerUI): self.BattProgress = {} i = 1 for batt in self.powermanager.batteries: - self.BattLayout[batt] = QHBoxLayout(None,0,6,"BattBarLayout") - self.BattLabel[batt] = QLabel(self.tooltip,"BattLabel") + self.BattLayout[batt] = TQHBoxLayout(None,0,6,"BattBarLayout") + self.BattLabel[batt] = TQLabel(self.tooltip,"BattLabel") if len(self.powermanager.batteries) > 1: self.BattLabel[batt].setText(i18n("Battery %i" % i)) self.BattLayout[batt].addWidget(self.BattLabel[batt]) self.BattProgress[batt] = KProgress(self.tooltip,"BattProgress") - self.BattProgress[batt].setMinimumSize(QSize(200,0)) + self.BattProgress[batt].setMinimumSize(TQSize(200,0)) self.BattLayout[batt].addWidget(self.BattProgress[batt]) self.tooltip.layout().addLayout(self.BattLayout[batt]) i += 1 @@ -791,14 +804,14 @@ class PowerManager(PowerManagerUI): if len(self.powermanager.cpus) == 0: return - LabelLayout = QHBoxLayout(None,0,6,"layout5") + LabelLayout = TQHBoxLayout(None,0,6,"layout5") - self.CpuPixmap = QLabel(self.tooltip,"CpuPixmap") - self.CpuPixmap.setSizePolicy(QSizePolicy(QSizePolicy.Fixed,QSizePolicy.Fixed,0,0,self.CpuPixmap.sizePolicy().hasHeightForWidth())) - self.CpuPixmap.setPixmap(QPixmap(UserIcon("processor"))) + self.CpuPixmap = TQLabel(self.tooltip,"CpuPixmap") + self.CpuPixmap.setSizePolicy(TQSizePolicy(TQSizePolicy.Fixed,TQSizePolicy.Fixed,0,0,self.CpuPixmap.sizePolicy().hasHeightForWidth())) + self.CpuPixmap.setPixmap(TQPixmap(UserIcon("processor"))) self.CpuPixmap.setScaledContents(1) LabelLayout.addWidget(self.CpuPixmap) - self.CpuMainLabel = QLabel(self.tooltip,"CpuMainLabel") + self.CpuMainLabel = TQLabel(self.tooltip,"CpuMainLabel") self.CpuMainLabel.setText(i18n("CPU Frequency:")) LabelLayout.addWidget(self.CpuMainLabel) @@ -811,8 +824,8 @@ class PowerManager(PowerManagerUI): self.CpuProgress = {} i = 1 for cpu in self.powermanager.cpus: - self.CpuLayout[cpu] = QHBoxLayout(None,0,6,"layout2") - self.CpuLabel[cpu] = QLabel(self.tooltip,"CpuLabel") + self.CpuLayout[cpu] = TQHBoxLayout(None,0,6,"layout2") + self.CpuLabel[cpu] = TQLabel(self.tooltip,"CpuLabel") if len(self.powermanager.cpus) > 1: self.CpuLabel[cpu].setText(i18n("Processor %i" % i)) self.CpuLayout[cpu].addWidget(self.CpuLabel[cpu]) @@ -967,7 +980,7 @@ class PowerManager(PowerManagerUI): note = i18n("You are about to run out of battery power, %1 now.").arg(self.act_notify[action]) self.notify(note, self.act_icon[action]) if self.act_call[action] != None: - QTimer.singleShot(2000, self.act_call[action]) + TQTimer.singleShot(2000, self.act_call[action]) else: self.powermanager.criticalBatteryState = False if currentLevel <= warningLevel and self.batt_level < CHARGE_LEVEL_THRESHOLD: @@ -998,7 +1011,7 @@ class PowerManager(PowerManagerUI): if idlesec > idleTime: note = i18n("System idle for at least %1 minutes, %2 now.").arg(idleTime).arg(self.act_notify[action]) self.notify(note, self.act_icon[action]) - QTimer.singleShot(2000, self.act_call[action]) + TQTimer.singleShot(2000, self.act_call[action]) @@ -1113,7 +1126,7 @@ if __name__ == "__main__": aboutdata.addAuthor("Sebastian Kügler", "Developer", "sebas@kde.org","http://vizZzion.org") aboutdata.addAuthor("Jonathan Riddell", "Developer", "jriddell@ubuntu.com") aboutdata.addAuthor("Luka Renko", "Developer", "lure@kubuntu.org") - aboutdata.setProgramLogo(QImage("power-manager.png")) + aboutdata.setProgramLogo(TQImage("power-manager.png")) TDECmdLineArgs.init(sys.argv, aboutdata) #kapp = KUniqueApplication(True, True, False) #kapp = TDEApplication() diff --git a/powermanager/guidance_power_manager_ui.ui b/powermanager/guidance_power_manager_ui.ui index 77aa884..f8c1eba 100644 --- a/powermanager/guidance_power_manager_ui.ui +++ b/powermanager/guidance_power_manager_ui.ui @@ -1,6 +1,6 @@ PowerManagerUI - + PowerManagerUI @@ -22,7 +22,7 @@ unnamed - + GeneralSettingsBox @@ -33,7 +33,7 @@ unnamed - + lockScreenOnResume @@ -43,7 +43,7 @@ - + MainsPoweredBox @@ -62,7 +62,7 @@ unnamed - + layout17 @@ -70,7 +70,7 @@ unnamed - + PoweredBrightnessLabel @@ -78,7 +78,7 @@ Brightness - + PoweredBrightnessSlider @@ -112,7 +112,7 @@ - + layout13 @@ -137,7 +137,7 @@ - + PoweredIdleLabel @@ -145,7 +145,7 @@ When the system is idle for more than - + PoweredIdleTime @@ -159,14 +159,14 @@ To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action. - + PoweredIdleCombo - + layout13_2_2 @@ -191,7 +191,7 @@ - + PoweredFreqLabel @@ -199,7 +199,7 @@ CPU frequency scaling policy - + PoweredFreqCombo @@ -208,7 +208,7 @@ - + BatteryBox @@ -227,7 +227,7 @@ unnamed - + layout16 @@ -235,7 +235,7 @@ unnamed - + BatteryBrightnessLabel @@ -243,7 +243,7 @@ Brightness - + BatteryBrightnessSlider @@ -268,7 +268,7 @@ - + layout14 @@ -276,12 +276,12 @@ unnamed - + BatteryIdleCombo - + BatteryIdleLabel @@ -289,12 +289,12 @@ When the system is idle for more than - + BatteryCriticalCombo - + BatteryCriticalLabel @@ -302,7 +302,7 @@ When battery remaining time drops below - + BatteryIdleTime @@ -316,7 +316,7 @@ To prevent data loss or other damage, you can have the system suspend or hibernate, so you don't run accidentally out of battery power. Configure the number of minutes below which the machine will run the configured action. - + CriticalRemainTime @@ -366,7 +366,7 @@ - + layout13_2 @@ -391,7 +391,7 @@ - + BatteryFreqLabel @@ -399,7 +399,7 @@ CPU frequency scaling policy - + BatteryFreqCombo @@ -408,7 +408,7 @@ - + LaptopLidRadios @@ -433,7 +433,7 @@ 5 - + laptopClosedNone @@ -441,7 +441,7 @@ Do nothing - + laptopClosedBlank @@ -449,7 +449,7 @@ Lock screen - + laptopClosedSuspend @@ -463,7 +463,7 @@ Suspend is a sleep state, the system will consume only very little energy when suspended - + laptopClosedHibernate @@ -477,7 +477,7 @@ Hibernate or "Suspend to Disk" is a deep sleepstate, allowing the system to power off completely - + laptopClosedShutdown diff --git a/powermanager/notify.ui b/powermanager/notify.ui index ebf2950..affbec2 100644 --- a/powermanager/notify.ui +++ b/powermanager/notify.ui @@ -1,6 +1,6 @@ NotifyWidget - + NotifyWidgetUI @@ -33,7 +33,7 @@ unnamed - + Icon @@ -52,7 +52,7 @@ true - + Text @@ -60,7 +60,7 @@ - + Caption @@ -70,6 +70,6 @@ -QPixmap +TQPixmap diff --git a/powermanager/tooltip.ui b/powermanager/tooltip.ui index 6055110..a120920 100644 --- a/powermanager/tooltip.ui +++ b/powermanager/tooltip.ui @@ -1,7 +1,7 @@ ToolTip Python:from tdeui import * - + ToolTip @@ -48,6 +48,6 @@ ToolTip_destroyed( TQObject * ) -QPixmap +TQPixmap -- cgit v1.2.1