AssistantEric/ConfigurationPages/AutoCompletionEricPage.py

Sun, 28 May 2023 14:33:51 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 28 May 2023 14:33:51 +0200
branch
eric7
changeset 204
abe45b434e6c
parent 201
1770e4b702a9
child 210
6b1440b975df
permissions
-rw-r--r--

Fixed a few bugs and code style issues.

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

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

"""
Module implementing the Eric Autocompletion configuration page.
"""

from AssistantEric.Assistant import AcsAPIs, AcsDocument, AcsProject
from eric7.Preferences.ConfigurationPages.ConfigurationPageBase import (
    ConfigurationPageBase,
)

from .Ui_AutoCompletionEricPage import Ui_AutoCompletionEricPage


class AutoCompletionEricPage(ConfigurationPageBase, Ui_AutoCompletionEricPage):
    """
    Class implementing the Eric Autocompletion configuration page.
    """

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

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

        self.__plugin = plugin

        # set initial values
        self.autocompletionCheckBox.setChecked(
            self.__plugin.getPreferences("AutoCompletionEnabled")
        )

        acSource = self.__plugin.getPreferences("AutoCompletionSource")
        self.apisCheckBox.setChecked(acSource & AcsAPIs)
        self.documentCheckBox.setChecked(acSource & AcsDocument)
        self.projectCheckBox.setChecked(acSource & AcsProject)

        self.hierarchyCheckBox.setChecked(
            self.__plugin.getPreferences("AutoCompletionFollowHierarchy")
        )

    def save(self):
        """
        Public slot to save the Eric Autocompletion configuration.
        """
        self.__plugin.setPreferences(
            "AutoCompletionEnabled", self.autocompletionCheckBox.isChecked()
        )

        acSource = 0
        if self.apisCheckBox.isChecked():
            acSource |= AcsAPIs
        if self.documentCheckBox.isChecked():
            acSource |= AcsDocument
        if self.projectCheckBox.isChecked():
            acSource |= AcsProject
        self.__plugin.setPreferences("AutoCompletionSource", acSource)

        self.__plugin.setPreferences(
            "AutoCompletionFollowHierarchy", self.hierarchyCheckBox.isChecked()
        )

eric ide

mercurial