Logo Search packages:      
Sourcecode: guidance-power-manager version File versions

def guidance-power-manager::PowerManager::_initUI (   self,
  parent 
) [private]

Build dynamic parts of the UI: context menu and tooltip. 

Definition at line 210 of file guidance-power-manager.py.

00210                              :
        """ Build dynamic parts of the UI: context menu and tooltip. """
        disableSuspend = self.config.readEntry("disableSuspend", QVariant(False)).toBool()
        disableHibernate = self.config.readEntry("disableHibernate", QVariant(False)).toBool()
        self.canSuspend = self.powermanager.canSuspend and not disableSuspend
        self.canHibernate = self.powermanager.canHibernate and not disableHibernate

        # Connect some signals.  Updates in the dialogue apply instantly
        self.connect(self.PoweredBrightnessSlider, SIGNAL("valueChanged(int)"), self.changePoweredBrightness)
        self.connect(self.BatteryBrightnessSlider, SIGNAL("valueChanged(int)"), self.changeBatteryBrightness)

        self.tooltip = QFrame()
        self.tooltip.setFrameStyle(QFrame.Box | QFrame.Plain)
        #set widget to use tooltip colours
        palette = self.tooltip.palette()
        palette.setColor(QPalette.Window, palette.color(QPalette.ToolTipBase))
        palette.setColor(QPalette.WindowText, palette.color(QPalette.ToolTipText))
        self.tooltip.setLayout(QVBoxLayout())
        self.systray.setToolTip(self.tooltip)

        self._addBatteryWidgets()

        self._addCpuWidgets()

        # fill actions for LID
        self.lid_act = ['nothing', 'blank', 'suspend', 'hibernate', 'shutdown']
        self.lid_act_def = 0
        # hide LID close actions that are not supported
        if not self.canSuspend:
            self.laptopClosedSuspend.hide()
        if not self.canHibernate:
            self.laptopClosedHibernate.hide()

        # fill in only CPU policies that are supported by HW
        self.cb_freq = []       # list of supported cpu freq policies
        self.cb_freq_def = 0    # always use first policy as default
        if self.powermanager.hasCpuFreqGovernors:
            self.cb_freq = self.powermanager.getSupportedCpuPolicies()
        if len(self.cb_freq) > 0:
            self._initCB(self.PoweredFreqCombo, self.cb_freq, self.freq_name)
            self._initCB(self.BatteryFreqCombo, self.cb_freq, self.freq_name)
        else:
            self.PoweredFreqLabel.hide()
            self.PoweredFreqCombo.hide()
            self.BatteryFreqLabel.hide()
            self.BatteryFreqCombo.hide()

        # fill actions in Idle/Critical battery combo boxes
        self.cb_act = ['nothing']       # list of supported actions (keywords)
        self.cb_act_def_critical = 0    # default action when critical battery
        if self.canSuspend:
            self.cb_act.append('suspend')
        if self.canHibernate:
            self.cb_act.append('hibernate')
            self.cb_act_def_critical = len(self.cb_act) - 1 # hibernate
        self.cb_act.append('shutdown')
        if self.cb_act_def_critical == 0:
            self.cb_act_def_critical = len(self.cb_act) - 1  # shutdown
        self._initCB(self.PoweredIdleCombo, self.cb_act, self.act_name)
        self._initCB(self.BatteryIdleCombo, self.cb_act, self.act_name)
        self._initCB(self.BatteryCriticalCombo, self.cb_act, self.act_name)

        self.connect(self.PoweredIdleCombo,SIGNAL("activated(int)"),self.slotPoweredIdleActivated)
        self.connect(self.BatteryIdleCombo,SIGNAL("activated(int)"),self.slotBatteryIdleActivated)
        self.connect(self.BatteryCriticalCombo,SIGNAL("activated(int)"),self.slotBatteryCriticalActivated)

        # add suspend/hibernate to tray's context menu
        menu = self.systray.contextMenu()
        if self.canSuspend:
            suspendAction = self.systray.actionCollection().addAction("suspend")
            suspendAction.setText(i18n("Suspend"))
            suspendAction.setIcon(QIcon(self.act_icon['suspend']))
            self.connect(suspendAction, SIGNAL("triggered()"), self.suspend)
            menu.addAction(suspendAction)
        if self.canHibernate:
            hibernateAction = self.systray.actionCollection().addAction("hibernate")
            hibernateAction.setText(i18n("Hibernate"))
            hibernateAction.setIcon(QIcon(self.act_icon['hibernate']))
            self.connect(hibernateAction, SIGNAL("triggered()"), self.hibernate)
            menu.addAction(hibernateAction)

        # add list of cpu frequency governors
        if self.powermanager.hasCpuFreqGovernors and len(self.cb_freq) > 0:
            submenu = KMenu(menu)
            actionGroup = QActionGroup(self)
            actionGroup.setExclusive(True)
            currentPolicy = self.powermanager.getCpuPolicy()
            self.policyActions = {}
            for policy in self.cb_freq:
                action = KAction(self.freq_name[policy], actionGroup)
                action.setCheckable(True)
                self.policyActions[policy] = action
                self.connect(action, SIGNAL("triggered()"), self.freq_call[policy])
                submenu.addAction(action)
                if policy == currentPolicy:
                    action.setChecked(True)

            submenu.setTitle(i18n("CPU policy"))
            menu.addMenu(submenu)

        # KGlobalAccel crashes the application in pykde
        # see http://mats.gmd.de/pipermail/pykde/2006-May/013224.html
        #self.globalActions = KGlobalAccel(self)
        #self.suspendShortcut = KShortcut("XF86Sleep")
        #self.hibernateShortcut = KShortcut("XF86Standby")
        #self.hshutdownShortcut = KShortcut("XF86PowerOff")
        #self.globalActions.insert("suspend", i18n("Suspend"), i18n("what's this?"), self.suspendShortcut, #self.suspendShortcut, self.suspend)
        #self.globalActions.updateConnections()

        self.radioButtonIndex = [self.laptopClosedNone, self.laptopClosedBlank, self.laptopClosedSuspend, self.laptopClosedHibernate, self.laptopClosedShutdown]

    def _initBattery(self):


Generated by  Doxygen 1.6.0   Back to index