eric6/WebBrowser/Feeds/FeedEditDialog.py

Sat, 27 Feb 2021 12:08:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 27 Feb 2021 12:08:23 +0100
changeset 8138
169e65a6787c
parent 7923
91e843545d9a
child 8143
2c730d5fd177
permissions
-rw-r--r--

Shell: added functionality to show a prompt when the main client process has exited (e.g. a script ended).

1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7923
91e843545d9a Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2011 - 2021 Detlev Offenbach <detlev@die-offenbachs.de>
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to edit feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
10 from PyQt5.QtCore import pyqtSlot, QUrl
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
11 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 from .Ui_FeedEditDialog import Ui_FeedEditDialog
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 class FeedEditDialog(QDialog, Ui_FeedEditDialog):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 Class implementing a dialog to edit feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 def __init__(self, urlString, title, parent=None):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 Constructor
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
24 @param urlString feed URL (string)
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
25 @param title feed title (string)
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 @param parent reference to the parent widget (QWidget)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2302
diff changeset
28 super(FeedEditDialog, self).__init__(parent)
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 self.setupUi(self)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(False)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 self.titleEdit.setText(title)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 self.urlEdit.setText(urlString)
3366
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
35
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
36 msh = self.minimumSizeHint()
6084bb3c3911 Made some changes to have a bunch of dialogs with correct sizes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
37 self.resize(max(self.width(), msh.width()), msh.height())
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 def __setOkButton(self):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 Private slot to enable or disable the OK button.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 enable = True
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 enable = enable and bool(self.titleEdit.text())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 urlString = self.urlEdit.text()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 enable = enable and bool(urlString)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 if urlString:
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 url = QUrl(urlString)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 enable = enable and bool(url.scheme())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 enable = enable and bool(url.host())
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 @pyqtSlot(str)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 def on_titleEdit_textChanged(self, txt):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 Private slot to handle changes of the feed title.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 @param txt new feed title (string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 self.__setOkButton()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 @pyqtSlot(str)
2954
bf0215fe12d1 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
66 def on_urlEdit_textChanged(self, txt):
1415
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 Private slot to handle changes of the feed URL.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 @param txt new feed URL (string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.__setOkButton()
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 def getData(self):
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 Public method to get the entered feed data.
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 @return tuple of two strings giving the feed URL and feed title
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 (string, string)
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 """
28fa9633d57e Added a dialog to show RSS feeds.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 return (self.urlEdit.text(), self.titleEdit.text())

eric ide

mercurial