eric7/WebBrowser/Navigation/ReloadStopButton.py

Thu, 30 Dec 2021 11:17:58 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 30 Dec 2021 11:17:58 +0100
branch
eric7
changeset 8881
54e42bc2437a
parent 8358
144a6b854f70
permissions
-rw-r--r--

Updated copyright for 2022.

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
8881
54e42bc2437a Updated copyright for 2022.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8358
diff changeset
3 # Copyright (c) 2017 - 2022 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
8318
962bce857696 Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8312
diff changeset
10 from PyQt6.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
8358
144a6b854f70 Sorted the eric specific extensions into packages named like the corresponding PyQt packages (i.e. EricCore,EricGui and EricWidgets).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8356
diff changeset
12 from EricWidgets.EricToolButton import EricToolButton
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
8356
68ec9c3d4de5 Renamed the modules and classes of the E5Gui package to have the prefix 'Eric' instead of 'E5'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8318
diff changeset
17 class ReloadStopButton(EricToolButton):
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 """
8218
7c09585bd960 Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 8143
diff changeset
34 super().__init__(parent)
5734
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")
8143
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
37 self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly)
2c730d5fd177 Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7923
diff changeset
38 self.setFocusPolicy(Qt.FocusPolicy.NoFocus)
5734
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