Preferences/ConfigurationPages/HelpInterfacePage.py

Fri, 01 Nov 2013 15:48:48 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Fri, 01 Nov 2013 15:48:48 +0100
branch
Py2 comp.
changeset 3058
0a02c433f52d
parent 3057
10516539f238
parent 3025
67064c71df21
child 3145
a9de05d4a22f
permissions
-rw-r--r--

Merge with default branch after fixed indentation issues.

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

"""
Module implementing the Interface configuration page (variant for web browser).
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtCore import pyqtSlot
from PyQt4.QtGui import QStyleFactory

from E5Gui.E5Completers import E5FileCompleter
from E5Gui import E5FileDialog

from .ConfigurationPageBase import ConfigurationPageBase
from .Ui_HelpInterfacePage import Ui_HelpInterfacePage

import Preferences
import Utilities


class HelpInterfacePage(ConfigurationPageBase, Ui_HelpInterfacePage):
    """
    Class implementing the Interface configuration page (variant for web
    browser).
    """
    def __init__(self):
        """
        Constructor
        """
        super(HelpInterfacePage, self).__init__()
        self.setupUi(self)
        self.setObjectName("InterfacePage")
        
        self.styleSheetCompleter = E5FileCompleter(self.styleSheetEdit)
        
        # set initial values
        self.__populateStyleCombo()
        self.styleSheetEdit.setText(Preferences.getUI("StyleSheet"))
    
    def save(self):
        """
        Public slot to save the Interface configuration.
        """
        # save the style settings
        styleIndex = self.styleComboBox.currentIndex()
        style = self.styleComboBox.itemData(styleIndex)
        Preferences.setUI("Style", style)
        Preferences.setUI(
            "StyleSheet",
            self.styleSheetEdit.text())
    
    def __populateStyleCombo(self):
        """
        Private method to populate the style combo box.
        """
        curStyle = Preferences.getUI("Style")
        styles = sorted(list(QStyleFactory.keys()))
        self.styleComboBox.addItem(self.trUtf8('System'), "System")
        for style in styles:
            self.styleComboBox.addItem(style, style)
        currentIndex = self.styleComboBox.findData(curStyle)
        if currentIndex == -1:
            currentIndex = 0
        self.styleComboBox.setCurrentIndex(currentIndex)
        
    @pyqtSlot()
    def on_styleSheetButton_clicked(self):
        """
        Private method to select the style sheet file via a dialog.
        """
        file = E5FileDialog.getOpenFileName(
            self,
            self.trUtf8("Select style sheet file"),
            self.styleSheetEdit.text(),
            self.trUtf8(
                "Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;"
                "All files (*)"))
        
        if file:
            self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
    

def create(dlg):
    """
    Module function to create the configuration page.
    
    @param dlg reference to the configuration dialog
    @return reference to the instantiated page (ConfigurationPageBase)
    """
    page = HelpInterfacePage()
    return page

eric ide

mercurial