|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2007 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the Plugin Manager configuration page. |
|
8 """ |
|
9 |
|
10 import os |
|
11 |
|
12 from PyQt4.QtCore import QDir, pyqtSlot |
|
13 from PyQt4.QtGui import QFileDialog |
|
14 |
|
15 from E4Gui.E4Completers import E4DirCompleter |
|
16 |
|
17 from ConfigurationPageBase import ConfigurationPageBase |
|
18 from Ui_PluginManagerPage import Ui_PluginManagerPage |
|
19 |
|
20 import Preferences |
|
21 import Utilities |
|
22 |
|
23 class PluginManagerPage(ConfigurationPageBase, Ui_PluginManagerPage): |
|
24 """ |
|
25 Class implementing the Plugin Manager configuration page. |
|
26 """ |
|
27 def __init__(self): |
|
28 """ |
|
29 Constructor |
|
30 """ |
|
31 ConfigurationPageBase.__init__(self) |
|
32 self.setupUi(self) |
|
33 self.setObjectName("PluginManagerPage") |
|
34 |
|
35 self.downloadDirCompleter = E4DirCompleter(self.downloadDirEdit) |
|
36 |
|
37 # set initial values |
|
38 self.activateExternalPluginsCheckBox.setChecked(\ |
|
39 Preferences.getPluginManager("ActivateExternal")) |
|
40 self.downloadDirEdit.setText(\ |
|
41 Preferences.getPluginManager("DownloadPath")) |
|
42 |
|
43 def save(self): |
|
44 """ |
|
45 Public slot to save the Viewmanager configuration. |
|
46 """ |
|
47 Preferences.setPluginManager("ActivateExternal", |
|
48 int(self.activateExternalPluginsCheckBox.isChecked())) |
|
49 Preferences.setPluginManager("DownloadPath", |
|
50 self.downloadDirEdit.text()) |
|
51 |
|
52 @pyqtSlot() |
|
53 def on_downloadDirButton_clicked(self): |
|
54 """ |
|
55 Private slot to handle the directory selection via dialog. |
|
56 """ |
|
57 directory = QFileDialog.getExistingDirectory(\ |
|
58 self, |
|
59 self.trUtf8("Select plugins download directory"), |
|
60 self.downloadDirEdit.text(), |
|
61 QFileDialog.Options(QFileDialog.ShowDirsOnly)) |
|
62 |
|
63 if directory: |
|
64 dn = Utilities.toNativeSeparators(directory) |
|
65 while dn.endswith(os.sep): |
|
66 dn = dn[:-1] |
|
67 self.downloadDirEdit.setText(dn) |
|
68 |
|
69 def create(dlg): |
|
70 """ |
|
71 Module function to create the configuration page. |
|
72 |
|
73 @param dlg reference to the configuration dialog |
|
74 """ |
|
75 page = PluginManagerPage() |
|
76 return page |