Preferences/ConfigurationPages/ViewmanagerPage.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 -*-

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

"""
Module implementing the Viewmanager configuration page.
"""

from __future__ import unicode_literals    # __IGNORE_WARNING__

from PyQt4.QtCore import pyqtSlot

from E5Gui.E5Application import e5App

from .ConfigurationPageBase import ConfigurationPageBase
from .Ui_ViewmanagerPage import Ui_ViewmanagerPage

import Preferences


class ViewmanagerPage(ConfigurationPageBase, Ui_ViewmanagerPage):
    """
    Class implementing the Viewmanager configuration page.
    """
    def __init__(self):
        """
        Constructor
        """
        super(ViewmanagerPage, self).__init__()
        self.setupUi(self)
        self.setObjectName("ViewmanagerPage")
        
        # set initial values
        self.pluginManager = e5App().getObject("PluginManager")
        self.viewmanagers = \
            self.pluginManager.getPluginDisplayStrings("viewmanager")
        self.windowComboBox.clear()
        currentVm = Preferences.getViewManager()
        
        keys = sorted(self.viewmanagers.keys())
        for key in keys:
            self.windowComboBox.addItem(
                self.trUtf8(self.viewmanagers[key]), key)
        currentIndex = self.windowComboBox.findText(
            self.trUtf8(self.viewmanagers[currentVm]))
        self.windowComboBox.setCurrentIndex(currentIndex)
        self.on_windowComboBox_activated(currentIndex)
        
        self.tabViewGroupBox.setTitle(
            self.trUtf8(self.viewmanagers["tabview"]))
        
        self.filenameLengthSpinBox.setValue(
            Preferences.getUI("TabViewManagerFilenameLength"))
        self.filenameOnlyCheckBox.setChecked(
            Preferences.getUI("TabViewManagerFilenameOnly"))
        self.recentFilesSpinBox.setValue(
            Preferences.getUI("RecentNumber"))
        
    def save(self):
        """
        Public slot to save the Viewmanager configuration.
        """
        vm = self.windowComboBox.itemData(
            self.windowComboBox.currentIndex())
        Preferences.setViewManager(vm)
        Preferences.setUI(
            "TabViewManagerFilenameLength",
            self.filenameLengthSpinBox.value())
        Preferences.setUI(
            "TabViewManagerFilenameOnly",
            self.filenameOnlyCheckBox.isChecked())
        Preferences.setUI(
            "RecentNumber",
            self.recentFilesSpinBox.value())
        
    @pyqtSlot(int)
    def on_windowComboBox_activated(self, index):
        """
        Private slot to show a preview of the selected workspace view type.
        
        @param index index of selected workspace view type (integer)
        """
        workspace = \
            self.windowComboBox.itemData(self.windowComboBox.currentIndex())
        pixmap = \
            self.pluginManager.getPluginPreviewPixmap("viewmanager", workspace)
        
        self.previewPixmap.setPixmap(pixmap)
        self.tabViewGroupBox.setEnabled(workspace == "tabview")
    

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 = ViewmanagerPage()
    return page

eric ide

mercurial