AssistantEric/ConfigurationPages/AutoCompletionEricPage.py

Thu, 10 Jan 2019 14:20:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 10 Jan 2019 14:20:58 +0100
changeset 152
20a08ac1b1f2
parent 141
ecbf4f8b3a1b
child 156
3e185204e9ec
permissions
-rw-r--r--

Updated copyright for 2019.

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

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

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

from __future__ import unicode_literals

from AssistantEric.Assistant import AcsAPIs, AcsDocument, AcsProject

from 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