当前位置: 首页>>代码示例>>Python>>正文


Python LeapSettings.get_autostart_eip方法代码示例

本文整理汇总了Python中leap.bitmask.config.leapsettings.LeapSettings.get_autostart_eip方法的典型用法代码示例。如果您正苦于以下问题:Python LeapSettings.get_autostart_eip方法的具体用法?Python LeapSettings.get_autostart_eip怎么用?Python LeapSettings.get_autostart_eip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在leap.bitmask.config.leapsettings.LeapSettings的用法示例。


在下文中一共展示了LeapSettings.get_autostart_eip方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: EIPPreferencesWindow

# 需要导入模块: from leap.bitmask.config.leapsettings import LeapSettings [as 别名]
# 或者: from leap.bitmask.config.leapsettings.LeapSettings import get_autostart_eip [as 别名]
class EIPPreferencesWindow(QtGui.QDialog):
    """
    Window that displays the EIP preferences.
    """
    def __init__(self, parent):
        """
        :param parent: parent object of the EIPPreferencesWindow.
        :parent type: QWidget
        """
        QtGui.QDialog.__init__(self, parent)
        self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic")

        self._settings = LeapSettings()

        # Load UI
        self.ui = Ui_EIPPreferences()
        self.ui.setupUi(self)
        self.ui.lblProvidersGatewayStatus.setVisible(False)
        self.ui.lblAutoStartEIPStatus.setVisible(False)

        # Connections
        self.ui.cbProvidersGateway.currentIndexChanged[unicode].connect(
            self._populate_gateways)

        self.ui.cbGateways.currentIndexChanged[unicode].connect(
            lambda x: self.ui.lblProvidersGatewayStatus.setVisible(False))

        self.ui.cbProvidersEIP.currentIndexChanged[unicode].connect(
            lambda x: self.ui.lblAutoStartEIPStatus.setVisible(False))

        self.ui.cbAutoStartEIP.toggled.connect(
            lambda x: self.ui.lblAutoStartEIPStatus.setVisible(False))

        self.ui.pbSaveAutoStartEIP.clicked.connect(self._save_auto_start_eip)

        self._add_configured_providers()

        # Load auto start EIP settings
        self.ui.cbAutoStartEIP.setChecked(self._settings.get_autostart_eip())
        default_provider = self._settings.get_defaultprovider()
        idx = self.ui.cbProvidersEIP.findText(default_provider)
        self.ui.cbProvidersEIP.setCurrentIndex(idx)

    def _save_auto_start_eip(self):
        """
        SLOT
        TRIGGER:
            self.ui.cbAutoStartEIP.toggled

        Saves the automatic start of EIP user preference.
        """
        default_provider = self.ui.cbProvidersEIP.currentText()
        enabled = self.ui.cbAutoStartEIP.isChecked()

        self._settings.set_autostart_eip(enabled)
        self._settings.set_defaultprovider(default_provider)

        self.ui.lblAutoStartEIPStatus.show()
        logger.debug('Auto start EIP saved: {0} {1}.'.format(
            default_provider, enabled))

    def _set_providers_gateway_status(self, status, success=False,
                                      error=False):
        """
        Sets the status label for the gateway change.

        :param status: status message to display, can be HTML
        :type status: str
        :param success: is set to True if we should display the
                        message as green
        :type success: bool
        :param error: is set to True if we should display the
                        message as red
        :type error: bool
        """
        if success:
            status = "<font color='green'><b>%s</b></font>" % (status,)
        elif error:
            status = "<font color='red'><b>%s</b></font>" % (status,)

        self.ui.lblProvidersGatewayStatus.setVisible(True)
        self.ui.lblProvidersGatewayStatus.setText(status)

    def _add_configured_providers(self):
        """
        Add the client's configured providers to the providers combo boxes.
        """
        self.ui.cbProvidersGateway.clear()
        self.ui.cbProvidersEIP.clear()
        providers = self._settings.get_configured_providers()
        if not providers:
            self.ui.gbAutomaticEIP.setEnabled(False)
            self.ui.gbGatewaySelector.setEnabled(False)
            return

        for provider in providers:
            self.ui.cbProvidersGateway.addItem(provider)
            self.ui.cbProvidersEIP.addItem(provider)

    def _save_selected_gateway(self, provider):
#.........这里部分代码省略.........
开发者ID:bneg,项目名称:bitmask_client,代码行数:103,代码来源:eip_preferenceswindow.py


注:本文中的leap.bitmask.config.leapsettings.LeapSettings.get_autostart_eip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。