eric7/HelpViewer/HelpBookmarksImportDialog.py

branch
eric7
changeset 8902
ba9b8c6e4928
equal deleted inserted replaced
8901:adc47f306e51 8902:ba9b8c6e4928
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
13 from EricWidgets.EricPathPicker import EricPathPickerModes
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 """
22 def __init__(self, parent=None):
23 """
24 Constructor
25
26 @param parent reference to the parent widget (defaults to None)
27 @type QWidget (optional)
28 """
29 super().__init__(parent)
30 self.setupUi(self)
31
32 self.bookmarksPicker.setMode(EricPathPickerModes.OPEN_FILE_MODE)
33 self.bookmarksPicker.setFilters(
34 self.tr("eric Bookmarks Files (*.json);;All Files (*)"))
35 self.bookmarksPicker.textChanged.connect(self.__updateOkButton)
36
37 msh = self.minimumSizeHint()
38 self.resize(max(self.width(), msh.width()), msh.height())
39
40 self.__updateOkButton()
41
42 @pyqtSlot()
43 def __updateOkButton(self):
44 """
45 Private method to update the state of the OK button.
46 """
47 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(
48 bool(self.bookmarksPicker.text()))
49
50 def getData(self):
51 """
52 Public method to retrieve the entered data.
53
54 @return tuple containing a flag indicating to replace the existing
55 bookmarks and the path of the bookmarks file to be imported
56 @rtype tuple of (bool, str)
57 """
58 return (
59 self.replaceCheckBox.isChecked(),
60 self.bookmarksPicker.path(),
61 )

eric ide

mercurial