src/eric7/WebBrowser/Feeds/FeedEditDialog.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9473
3f23dbf37dbe
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
15 15
16 class FeedEditDialog(QDialog, Ui_FeedEditDialog): 16 class FeedEditDialog(QDialog, Ui_FeedEditDialog):
17 """ 17 """
18 Class implementing a dialog to edit feed data. 18 Class implementing a dialog to edit feed data.
19 """ 19 """
20
20 def __init__(self, urlString, title, parent=None): 21 def __init__(self, urlString, title, parent=None):
21 """ 22 """
22 Constructor 23 Constructor
23 24
24 @param urlString feed URL (string) 25 @param urlString feed URL (string)
25 @param title feed title (string) 26 @param title feed title (string)
26 @param parent reference to the parent widget (QWidget) 27 @param parent reference to the parent widget (QWidget)
27 """ 28 """
28 super().__init__(parent) 29 super().__init__(parent)
29 self.setupUi(self) 30 self.setupUi(self)
30 31
31 self.buttonBox.button( 32 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(False)
32 QDialogButtonBox.StandardButton.Ok).setEnabled(False) 33
33
34 self.titleEdit.setText(title) 34 self.titleEdit.setText(title)
35 self.urlEdit.setText(urlString) 35 self.urlEdit.setText(urlString)
36 36
37 msh = self.minimumSizeHint() 37 msh = self.minimumSizeHint()
38 self.resize(max(self.width(), msh.width()), msh.height()) 38 self.resize(max(self.width(), msh.width()), msh.height())
39 39
40 def __setOkButton(self): 40 def __setOkButton(self):
41 """ 41 """
42 Private slot to enable or disable the OK button. 42 Private slot to enable or disable the OK button.
43 """ 43 """
44 enable = True 44 enable = True
45 45
46 enable = enable and bool(self.titleEdit.text()) 46 enable = enable and bool(self.titleEdit.text())
47 47
48 urlString = self.urlEdit.text() 48 urlString = self.urlEdit.text()
49 enable = enable and bool(urlString) 49 enable = enable and bool(urlString)
50 if urlString: 50 if urlString:
51 url = QUrl(urlString) 51 url = QUrl(urlString)
52 enable = enable and bool(url.scheme()) 52 enable = enable and bool(url.scheme())
53 enable = enable and bool(url.host()) 53 enable = enable and bool(url.host())
54 54
55 self.buttonBox.button( 55 self.buttonBox.button(QDialogButtonBox.StandardButton.Ok).setEnabled(enable)
56 QDialogButtonBox.StandardButton.Ok).setEnabled(enable) 56
57
58 @pyqtSlot(str) 57 @pyqtSlot(str)
59 def on_titleEdit_textChanged(self, txt): 58 def on_titleEdit_textChanged(self, txt):
60 """ 59 """
61 Private slot to handle changes of the feed title. 60 Private slot to handle changes of the feed title.
62 61
63 @param txt new feed title (string) 62 @param txt new feed title (string)
64 """ 63 """
65 self.__setOkButton() 64 self.__setOkButton()
66 65
67 @pyqtSlot(str) 66 @pyqtSlot(str)
68 def on_urlEdit_textChanged(self, txt): 67 def on_urlEdit_textChanged(self, txt):
69 """ 68 """
70 Private slot to handle changes of the feed URL. 69 Private slot to handle changes of the feed URL.
71 70
72 @param txt new feed URL (string) 71 @param txt new feed URL (string)
73 """ 72 """
74 self.__setOkButton() 73 self.__setOkButton()
75 74
76 def getData(self): 75 def getData(self):
77 """ 76 """
78 Public method to get the entered feed data. 77 Public method to get the entered feed data.
79 78
80 @return tuple of two strings giving the feed URL and feed title 79 @return tuple of two strings giving the feed URL and feed title
81 (string, string) 80 (string, string)
82 """ 81 """
83 return (self.urlEdit.text(), self.titleEdit.text()) 82 return (self.urlEdit.text(), self.titleEdit.text())

eric ide

mercurial