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