MqttMonitor/ConfigurationPage/MqttPage.py

Mon, 24 Oct 2022 18:01:45 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 24 Oct 2022 18:01:45 +0200
branch
eric7
changeset 127
8982ef7b7d67
parent 123
3d7e63ed4fd1
child 129
9d54bf366323
permissions
-rw-r--r--

Adapted the import statements to the new structure.

# -*- coding: utf-8 -*-

# Copyright (c) 2021 - 2022 Detlev Offenbach <detlev@die-offenbachs.de>
#

"""
Module implementing the MQTT Monitor configuration page.
"""

from eric7.Preferences.ConfigurationPages.ConfigurationPageBase import (
    ConfigurationPageBase,
)

from .Ui_MqttPage import Ui_MqttPage

from ..MqttProtocols import MqttProtocols


class MqttPage(ConfigurationPageBase, Ui_MqttPage):
    """
    Class implementing the MQTT Monitor configuration page.
    """

    def __init__(self, plugin):
        """
        Constructor

        @param plugin reference to the plugin object
        @type RefactoringRopePlugin
        """
        ConfigurationPageBase.__init__(self)
        self.setupUi(self)
        self.setObjectName("MqttPage")

        self.__plugin = plugin

        # set initial values
        protocol = self.__plugin.getPreferences("DefaultProtocol")
        self.mqttv31Button.setChecked(protocol == MqttProtocols.MQTTv31)
        self.mqttv311Button.setChecked(protocol == MqttProtocols.MQTTv311)
        self.mqttv5Button.setChecked(protocol == MqttProtocols.MQTTv5)
        self.recentBrokersSpinBox.setValue(
            self.__plugin.getPreferences("RecentBrokersNumber")
        )
        self.recentTopicsSpinBox.setValue(
            self.__plugin.getPreferences("RecentTopicsNumber")
        )

    def save(self):
        """
        Public slot to save the Rope Autocompletion configuration.
        """
        if self.mqttv31Button.isChecked():
            protocol = MqttProtocols.MQTTv31
        elif self.mqttv311Button.isChecked():
            protocol = MqttProtocols.MQTTv311
        elif self.mqttv5Button.isChecked():
            protocol = MqttProtocols.MQTTv5
        else:
            # should never happen
            protocol = MqttProtocols.MQTTv311

        self.__plugin.setPreferences("DefaultProtocol", protocol)
        self.__plugin.setPreferences(
            "RecentBrokersNumber", self.recentBrokersSpinBox.value()
        )
        self.__plugin.setPreferences(
            "RecentTopicsNumber", self.recentTopicsSpinBox.value()
        )

eric ide

mercurial