eric6/Preferences/ConfigurationPages/ViewmanagerPage.py

changeset 6942
2602857055c5
parent 6645
ad476851d7e0
child 7229
53054eb5b15a
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2006 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the Viewmanager configuration page.
8 """
9
10 from __future__ import unicode_literals
11
12 from PyQt5.QtCore import pyqtSlot
13
14 from E5Gui.E5Application import e5App
15
16 from .ConfigurationPageBase import ConfigurationPageBase
17 from .Ui_ViewmanagerPage import Ui_ViewmanagerPage
18
19 import Preferences
20
21
22 class ViewmanagerPage(ConfigurationPageBase, Ui_ViewmanagerPage):
23 """
24 Class implementing the Viewmanager configuration page.
25 """
26 def __init__(self):
27 """
28 Constructor
29 """
30 super(ViewmanagerPage, self).__init__()
31 self.setupUi(self)
32 self.setObjectName("ViewmanagerPage")
33
34 # set initial values
35 self.pluginManager = e5App().getObject("PluginManager")
36 self.viewmanagers = \
37 self.pluginManager.getPluginDisplayStrings("viewmanager")
38 self.windowComboBox.clear()
39 currentVm = Preferences.getViewManager()
40
41 keys = sorted(self.viewmanagers.keys())
42 for key in keys:
43 self.windowComboBox.addItem(
44 self.tr(self.viewmanagers[key]), key)
45 currentIndex = self.windowComboBox.findText(
46 self.tr(self.viewmanagers[currentVm]))
47 self.windowComboBox.setCurrentIndex(currentIndex)
48 self.on_windowComboBox_activated(currentIndex)
49
50 self.tabViewGroupBox.setTitle(
51 self.tr(self.viewmanagers["tabview"]))
52
53 self.filenameLengthSpinBox.setValue(
54 Preferences.getUI("TabViewManagerFilenameLength"))
55 self.filenameOnlyCheckBox.setChecked(
56 Preferences.getUI("TabViewManagerFilenameOnly"))
57 self.recentFilesSpinBox.setValue(
58 Preferences.getUI("RecentNumber"))
59
60 def save(self):
61 """
62 Public slot to save the Viewmanager configuration.
63 """
64 vm = self.windowComboBox.itemData(
65 self.windowComboBox.currentIndex())
66 Preferences.setViewManager(vm)
67 Preferences.setUI(
68 "TabViewManagerFilenameLength",
69 self.filenameLengthSpinBox.value())
70 Preferences.setUI(
71 "TabViewManagerFilenameOnly",
72 self.filenameOnlyCheckBox.isChecked())
73 Preferences.setUI(
74 "RecentNumber",
75 self.recentFilesSpinBox.value())
76
77 @pyqtSlot(int)
78 def on_windowComboBox_activated(self, index):
79 """
80 Private slot to show a preview of the selected workspace view type.
81
82 @param index index of selected workspace view type (integer)
83 """
84 workspace = \
85 self.windowComboBox.itemData(self.windowComboBox.currentIndex())
86 pixmap = \
87 self.pluginManager.getPluginPreviewPixmap("viewmanager", workspace)
88
89 self.previewPixmap.setPixmap(pixmap)
90 self.tabViewGroupBox.setEnabled(workspace == "tabview")
91
92
93 def create(dlg):
94 """
95 Module function to create the configuration page.
96
97 @param dlg reference to the configuration dialog
98 @return reference to the instantiated page (ConfigurationPageBase)
99 """
100 page = ViewmanagerPage()
101 return page

eric ide

mercurial