Tue, 18 Oct 2022 16:06:21 +0200
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
8902 | 1 | # -*- coding: utf-8 -*- |
2 | ||
3 | # Copyright (c) 2022 Detlev Offenbach <detlev@die-offenbachs.de> | |
4 | # | |
5 | ||
6 | """ | |
7 | Module implementing a dialog to enter the bookmarks import parameters. | |
8 | """ | |
9 | ||
10 | from PyQt6.QtCore import pyqtSlot | |
11 | from PyQt6.QtWidgets import QDialog, QDialogButtonBox | |
12 | ||
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9256
diff
changeset
|
13 | from eric7.EricWidgets.EricPathPicker import EricPathPickerModes |
8902 | 14 | |
15 | from .Ui_HelpBookmarksImportDialog import Ui_HelpBookmarksImportDialog | |
16 | ||
17 | ||
18 | class HelpBookmarksImportDialog(QDialog, Ui_HelpBookmarksImportDialog): | |
19 | """ | |
20 | Class implementing a dialog to enter the bookmarks import parameters. | |
21 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | |
8902 | 23 | def __init__(self, parent=None): |
24 | """ | |
25 | Constructor | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
26 | |
8902 | 27 | @param parent reference to the parent widget (defaults to None) |
28 | @type QWidget (optional) | |
29 | """ | |
30 | super().__init__(parent) | |
31 | self.setupUi(self) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
32 | |
8902 | 33 | self.bookmarksPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE) |
34 | self.bookmarksPicker.setFilters( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
35 | self.tr("eric Bookmarks Files (*.json);;All Files (*)") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
36 | ) |
8902 | 37 | self.bookmarksPicker.textChanged.connect(self.__updateOkButton) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
38 | |
8902 | 39 | msh = self.minimumSizeHint() |
40 | self.resize(max(self.width(), msh.width()), msh.height()) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
41 | |
8902 | 42 | self.__updateOkButton() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
43 | |
8902 | 44 | @pyqtSlot() |
45 | def __updateOkButton(self): | |
46 | """ | |
47 | Private method to update the state of the OK button. | |
48 | """ | |
49 | self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled( | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
50 | bool(self.bookmarksPicker.text()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
51 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
52 | |
8902 | 53 | def getData(self): |
54 | """ | |
55 | Public method to retrieve the entered data. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
56 | |
8902 | 57 | @return tuple containing a flag indicating to replace the existing |
58 | bookmarks and the path of the bookmarks file to be imported | |
59 | @rtype tuple of (bool, str) | |
60 | """ | |
61 | return ( | |
62 | self.replaceCheckBox.isChecked(), | |
9256
67603066f0a6
Fixed issues caused by using EricPathPicker.paths() method.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
63 | self.bookmarksPicker.text(), |
8902 | 64 | ) |