|
1 # -*- coding: utf-8 -*- |
|
2 |
|
3 # Copyright (c) 2012 Detlev Offenbach <detlev@die-offenbachs.de> |
|
4 # |
|
5 |
|
6 """ |
|
7 Module implementing the synchronization shared directory settings wizard page. |
|
8 """ |
|
9 |
|
10 from PyQt4.QtCore import pyqtSlot |
|
11 from PyQt4.QtGui import QWizardPage, QFileDialog |
|
12 |
|
13 from E5Gui import E5FileDialog |
|
14 |
|
15 from . import SyncGlobals |
|
16 |
|
17 from .Ui_SyncDirectorySettingsPage import Ui_SyncDirectorySettingsPage |
|
18 |
|
19 import Preferences |
|
20 import Utilities |
|
21 |
|
22 |
|
23 class SyncDirectorySettingsPage(QWizardPage, Ui_SyncDirectorySettingsPage): |
|
24 """ |
|
25 Class implementing the shared directory host settings wizard page. |
|
26 """ |
|
27 def __init__(self, parent=None): |
|
28 """ |
|
29 Constructor |
|
30 |
|
31 @param parent reference to the parent widget (QWidget) |
|
32 """ |
|
33 super().__init__(parent) |
|
34 self.setupUi(self) |
|
35 |
|
36 self.directoryEdit.setText(Preferences.getHelp("SyncDirectoryPath")) |
|
37 |
|
38 self.directoryEdit.textChanged.connect(self.completeChanged) |
|
39 |
|
40 def nextId(self): |
|
41 """ |
|
42 Public method returning the ID of the next wizard page. |
|
43 |
|
44 @return next wizard page ID (integer) |
|
45 """ |
|
46 # save the settings |
|
47 Preferences.setHelp("SyncDirectoryPath", |
|
48 Utilities.toNativeSeparators(self.directoryEdit.text())) |
|
49 |
|
50 return SyncGlobals.PageCheck |
|
51 |
|
52 def isComplete(self): |
|
53 """ |
|
54 Public method to check the completeness of the page. |
|
55 |
|
56 @return flag indicating completeness (boolean) |
|
57 """ |
|
58 return self.directoryEdit.text() != "" |
|
59 |
|
60 @pyqtSlot() |
|
61 def on_directoryButton_clicked(self): |
|
62 """ |
|
63 Private slot to select the shared directory via a directory selection dialog. |
|
64 """ |
|
65 directory = E5FileDialog.getExistingDirectory( |
|
66 self, |
|
67 self.trUtf8("Shared Directory"), |
|
68 self.directoryEdit.text(), |
|
69 QFileDialog.Options(QFileDialog.Option(0))) |
|
70 |
|
71 if directory: |
|
72 self.directoryEdit.setText(Utilities.toNativeSeparators(directory)) |