15 |
15 |
16 |
16 |
17 class ReloadStopButton(EricToolButton): |
17 class ReloadStopButton(EricToolButton): |
18 """ |
18 """ |
19 Class implementing a button alternating between reload and stop. |
19 Class implementing a button alternating between reload and stop. |
20 |
20 |
21 @signal reloadClicked() emitted to initiate a reload action |
21 @signal reloadClicked() emitted to initiate a reload action |
22 @signal stopClicked() emitted to initiate a stop action |
22 @signal stopClicked() emitted to initiate a stop action |
23 """ |
23 """ |
|
24 |
24 reloadClicked = pyqtSignal() |
25 reloadClicked = pyqtSignal() |
25 stopClicked = pyqtSignal() |
26 stopClicked = pyqtSignal() |
26 |
27 |
27 def __init__(self, parent=None): |
28 def __init__(self, parent=None): |
28 """ |
29 """ |
29 Constructor |
30 Constructor |
30 |
31 |
31 @param parent reference to the parent widget |
32 @param parent reference to the parent widget |
32 @type QWidget |
33 @type QWidget |
33 """ |
34 """ |
34 super().__init__(parent) |
35 super().__init__(parent) |
35 |
36 |
36 self.setObjectName("navigation_reloadstop_button") |
37 self.setObjectName("navigation_reloadstop_button") |
37 self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
38 self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonIconOnly) |
38 self.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
39 self.setFocusPolicy(Qt.FocusPolicy.NoFocus) |
39 self.setAutoRaise(True) |
40 self.setAutoRaise(True) |
40 |
41 |
41 self.__loading = False |
42 self.__loading = False |
42 |
43 |
43 self.clicked.connect(self.__buttonClicked) |
44 self.clicked.connect(self.__buttonClicked) |
44 |
45 |
45 self.__updateButton() |
46 self.__updateButton() |
46 |
47 |
47 @pyqtSlot() |
48 @pyqtSlot() |
48 def __buttonClicked(self): |
49 def __buttonClicked(self): |
49 """ |
50 """ |
50 Private slot handling a user clicking the button. |
51 Private slot handling a user clicking the button. |
51 """ |
52 """ |
52 if self.__loading: |
53 if self.__loading: |
53 self.stopClicked.emit() |
54 self.stopClicked.emit() |
54 else: |
55 else: |
55 self.reloadClicked.emit() |
56 self.reloadClicked.emit() |
56 |
57 |
57 @pyqtSlot() |
58 @pyqtSlot() |
58 def __updateButton(self): |
59 def __updateButton(self): |
59 """ |
60 """ |
60 Private slot to update the button. |
61 Private slot to update the button. |
61 """ |
62 """ |
63 self.setIcon(UI.PixmapCache.getIcon("stopLoading")) |
64 self.setIcon(UI.PixmapCache.getIcon("stopLoading")) |
64 self.setToolTip(self.tr("Stop loading")) |
65 self.setToolTip(self.tr("Stop loading")) |
65 else: |
66 else: |
66 self.setIcon(UI.PixmapCache.getIcon("reload")) |
67 self.setIcon(UI.PixmapCache.getIcon("reload")) |
67 self.setToolTip(self.tr("Reload the current screen")) |
68 self.setToolTip(self.tr("Reload the current screen")) |
68 |
69 |
69 def setLoading(self, loading): |
70 def setLoading(self, loading): |
70 """ |
71 """ |
71 Public method to set the loading state. |
72 Public method to set the loading state. |
72 |
73 |
73 @param loading flag indicating the new loading state |
74 @param loading flag indicating the new loading state |
74 @type bool |
75 @type bool |
75 """ |
76 """ |
76 self.__loading = loading |
77 self.__loading = loading |
77 self.__updateButton() |
78 self.__updateButton() |