48 |
48 |
49 self.setModel(model) |
49 self.setModel(model) |
50 self.setRootIndex(model.nodeIndex( |
50 self.setRootIndex(model.nodeIndex( |
51 self.__mw.bookmarksManager().toolbar())) |
51 self.__mw.bookmarksManager().toolbar())) |
52 |
52 |
53 self.setContextMenuPolicy(Qt.CustomContextMenu) |
53 self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) |
54 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
54 self.customContextMenuRequested.connect(self.__contextMenuRequested) |
55 self.activated.connect(self.__bookmarkActivated) |
55 self.activated.connect(self.__bookmarkActivated) |
56 |
56 |
57 self.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) |
57 self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon) |
58 |
58 |
59 self._build() |
59 self._build() |
60 |
60 |
61 def __rebuild(self): |
61 def __rebuild(self): |
62 """ |
62 """ |
133 Private slot handling the activation of a bookmark. |
133 Private slot handling the activation of a bookmark. |
134 |
134 |
135 @param idx index of the activated bookmark (QModelIndex) |
135 @param idx index of the activated bookmark (QModelIndex) |
136 """ |
136 """ |
137 if idx.isValid(): |
137 if idx.isValid(): |
138 if self._mouseButton == Qt.XButton1: |
138 if self._mouseButton == Qt.MouseButton.XButton1: |
139 self.__mw.currentBrowser().triggerPageAction( |
139 self.__mw.currentBrowser().triggerPageAction( |
140 QWebEnginePage.Back) |
140 QWebEnginePage.WebAction.Back) |
141 elif self._mouseButton == Qt.XButton2: |
141 elif self._mouseButton == Qt.MouseButton.XButton2: |
142 self.__mw.currentBrowser().triggerPageAction( |
142 self.__mw.currentBrowser().triggerPageAction( |
143 QWebEnginePage.Forward) |
143 QWebEnginePage.WebAction.Forward) |
144 elif self._mouseButton == Qt.LeftButton: |
144 elif self._mouseButton == Qt.MouseButton.LeftButton: |
145 if self._keyboardModifiers & Qt.ControlModifier: |
145 if ( |
|
146 self._keyboardModifiers & |
|
147 Qt.KeyboardModifier.ControlModifier |
|
148 ): |
146 self.newTab.emit( |
149 self.newTab.emit( |
147 idx.data(BookmarksModel.UrlRole), |
150 idx.data(BookmarksModel.UrlRole), |
148 idx.data(Qt.DisplayRole)) |
151 idx.data(Qt.ItemDataRole.DisplayRole)) |
149 elif self._keyboardModifiers & Qt.ShiftModifier: |
152 elif ( |
|
153 self._keyboardModifiers & |
|
154 Qt.KeyboardModifier.ShiftModifier |
|
155 ): |
150 self.newWindow.emit( |
156 self.newWindow.emit( |
151 idx.data(BookmarksModel.UrlRole), |
157 idx.data(BookmarksModel.UrlRole), |
152 idx.data(Qt.DisplayRole)) |
158 idx.data(Qt.ItemDataRole.DisplayRole)) |
153 else: |
159 else: |
154 self.openUrl.emit( |
160 self.openUrl.emit( |
155 idx.data(BookmarksModel.UrlRole), |
161 idx.data(BookmarksModel.UrlRole), |
156 idx.data(Qt.DisplayRole)) |
162 idx.data(Qt.ItemDataRole.DisplayRole)) |
157 self.__updateVisitCount(idx) |
163 self.__updateVisitCount(idx) |
158 |
164 |
159 def __openBookmark(self, act): |
165 def __openBookmark(self, act): |
160 """ |
166 """ |
161 Private slot to open a bookmark in the current browser tab. |
167 Private slot to open a bookmark in the current browser tab. |
165 """ |
171 """ |
166 idx = self.index(act) |
172 idx = self.index(act) |
167 |
173 |
168 self.openUrl.emit( |
174 self.openUrl.emit( |
169 idx.data(BookmarksModel.UrlRole), |
175 idx.data(BookmarksModel.UrlRole), |
170 idx.data(Qt.DisplayRole)) |
176 idx.data(Qt.ItemDataRole.DisplayRole)) |
171 self.__updateVisitCount(idx) |
177 self.__updateVisitCount(idx) |
172 |
178 |
173 def __openBookmarkInNewTab(self, act): |
179 def __openBookmarkInNewTab(self, act): |
174 """ |
180 """ |
175 Private slot to open a bookmark in a new browser tab. |
181 Private slot to open a bookmark in a new browser tab. |
179 """ |
185 """ |
180 idx = self.index(act) |
186 idx = self.index(act) |
181 |
187 |
182 self.newTab.emit( |
188 self.newTab.emit( |
183 idx.data(BookmarksModel.UrlRole), |
189 idx.data(BookmarksModel.UrlRole), |
184 idx.data(Qt.DisplayRole)) |
190 idx.data(Qt.ItemDataRole.DisplayRole)) |
185 self.__updateVisitCount(idx) |
191 self.__updateVisitCount(idx) |
186 |
192 |
187 def __openBookmarkInNewWindow(self, act): |
193 def __openBookmarkInNewWindow(self, act): |
188 """ |
194 """ |
189 Private slot to open a bookmark in a new window. |
195 Private slot to open a bookmark in a new window. |
193 """ |
199 """ |
194 idx = self.index(act) |
200 idx = self.index(act) |
195 |
201 |
196 self.newWindow.emit( |
202 self.newWindow.emit( |
197 idx.data(BookmarksModel.UrlRole), |
203 idx.data(BookmarksModel.UrlRole), |
198 idx.data(Qt.DisplayRole)) |
204 idx.data(Qt.ItemDataRole.DisplayRole)) |
199 self.__updateVisitCount(idx) |
205 self.__updateVisitCount(idx) |
200 |
206 |
201 def __openBookmarkInPrivateWindow(self, act): |
207 def __openBookmarkInPrivateWindow(self, act): |
202 """ |
208 """ |
203 Private slot to open a bookmark in a new private window. |
209 Private slot to open a bookmark in a new private window. |