eric6/WebBrowser/Navigation/ReloadStopButton.py

Mon, 12 Oct 2020 19:28:42 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 19:28:42 +0200
changeset 7781
607a6098cb44
parent 7533
88261c96484b
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some more code cleanup.

5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2017 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a button alternating between reload and stop.
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from PyQt5.QtCore import pyqtSlot, pyqtSignal, Qt
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5734
diff changeset
11
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5734
diff changeset
12 from E5Gui.E5ToolButton import E5ToolButton
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import UI.PixmapCache
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16
5745
4f4316e83318 -- added a super menu to modernize the look & feel
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5734
diff changeset
17 class ReloadStopButton(E5ToolButton):
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19 Class implementing a button alternating between reload and stop.
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 @signal reloadClicked() emitted to initiate a reload action
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 @signal stopClicked() emitted to initiate a stop action
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24 reloadClicked = pyqtSignal()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 stopClicked = pyqtSignal()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 def __init__(self, parent=None):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 Constructor
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 @param parent reference to the parent widget
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @type QWidget
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 super(ReloadStopButton, self).__init__(parent)
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 self.setObjectName("navigation_reloadstop_button")
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 self.setToolButtonStyle(Qt.ToolButtonIconOnly)
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 self.setFocusPolicy(Qt.NoFocus)
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 self.setAutoRaise(True)
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 self.__loading = False
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 self.clicked.connect(self.__buttonClicked)
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45 self.__updateButton()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47 @pyqtSlot()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 def __buttonClicked(self):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Private slot handling a user clicking the button.
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 if self.__loading:
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 self.stopClicked.emit()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 else:
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 self.reloadClicked.emit()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 @pyqtSlot()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 def __updateButton(self):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 Private slot to update the button.
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 if self.__loading:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
63 self.setIcon(UI.PixmapCache.getIcon("stopLoading"))
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.setToolTip(self.tr("Stop loading"))
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 else:
7533
88261c96484b Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
66 self.setIcon(UI.PixmapCache.getIcon("reload"))
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.setToolTip(self.tr("Reload the current screen"))
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 def setLoading(self, loading):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 Public method to set the loading state.
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @param loading flag indicating the new loading state
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @type bool
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 self.__loading = loading
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__updateButton()

eric ide

mercurial