src/eric7/WebBrowser/Navigation/ReloadStopButton.py

Tue, 18 Oct 2022 16:06:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 18 Oct 2022 16:06:21 +0200
branch
eric7
changeset 9413
80c06d472826
parent 9221
bf71ee032bb4
child 9473
3f23dbf37dbe
permissions
-rw-r--r--

Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.

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
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
12 from eric7.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
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
14 from eric7.EricGui import EricPixmapCache
5734
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.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
20
5734
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 """
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
24
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 reloadClicked = pyqtSignal()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 stopClicked = pyqtSignal()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
27
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 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
29 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
30 Constructor
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
31
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 @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
33 @type QWidget
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34 """
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
35 super().__init__(parent)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
36
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 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
38 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
39 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
40 self.setAutoRaise(True)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
41
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 self.__loading = False
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
43
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 self.clicked.connect(self.__buttonClicked)
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
45
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 self.__updateButton()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
47
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 @pyqtSlot()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 def __buttonClicked(self):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51 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
52 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53 if self.__loading:
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 self.stopClicked.emit()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 else:
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 self.reloadClicked.emit()
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
57
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 @pyqtSlot()
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59 def __updateButton(self):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 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
62 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63 if self.__loading:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
64 self.setIcon(EricPixmapCache.getIcon("stopLoading"))
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 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
66 else:
9413
80c06d472826 Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9221
diff changeset
67 self.setIcon(EricPixmapCache.getIcon("reload"))
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 self.setToolTip(self.tr("Reload the current screen"))
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
69
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 def setLoading(self, loading):
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 Public method to set the loading state.
9221
bf71ee032bb4 Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 9209
diff changeset
73
5734
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @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
75 @type bool
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
76 """
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
77 self.__loading = loading
d8b99b5fa673 United the stop and reload buttons of the navigation bar.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 self.__updateButton()

eric ide

mercurial