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