158 act.menu() is None and \ |
161 act.menu() is None and \ |
159 self.index(act).isValid(): |
162 self.index(act).isValid(): |
160 menu = QMenu() |
163 menu = QMenu() |
161 v = act.data() |
164 v = act.data() |
162 |
165 |
163 menu.addAction( |
166 act2 = menu.addAction(self.tr("Open")) |
164 self.tr("Open"), |
167 act2.setData(v) |
165 self.__openBookmark).setData(v) |
168 act2.triggered.connect( |
166 menu.addAction( |
169 lambda: self.__openBookmark(act2)) |
167 self.tr("Open in New Tab\tCtrl+LMB"), |
170 act2 = menu.addAction(self.tr("Open in New Tab\tCtrl+LMB")) |
168 self.__openBookmarkInNewTab).setData(v) |
171 act2.setData(v) |
169 menu.addAction( |
172 act2.triggered.connect( |
170 self.tr("Open in New Window"), |
173 lambda: self.__openBookmarkInNewTab(act2)) |
171 self.__openBookmarkInNewWindow).setData(v) |
174 act2 = menu.addAction(self.tr("Open in New Window")) |
172 menu.addAction( |
175 act2.setData(v) |
173 self.tr("Open in New Private Window"), |
176 act2.triggered.connect( |
174 self.__openBookmarkInPrivateWindow).setData(v) |
177 lambda: self.__openBookmarkInNewWindow(act2)) |
|
178 act2 = menu.addAction(self.tr("Open in New Private Window")) |
|
179 act2.setData(v) |
|
180 act2.triggered.connect( |
|
181 lambda: self.__openBookmarkInPrivateWindow(act2)) |
175 menu.addSeparator() |
182 menu.addSeparator() |
176 |
183 |
177 menu.addAction( |
184 act2 = menu.addAction(self.tr("Remove")) |
178 self.tr("Remove"), |
185 act2.setData(v) |
179 self.__removeBookmark).setData(v) |
186 act2.triggered.connect(lambda: self.__removeBookmark(act2)) |
180 menu.addSeparator() |
187 menu.addSeparator() |
181 |
188 |
182 menu.addAction( |
189 act2 = menu.addAction(self.tr("Properties...")) |
183 self.tr("Properties..."), |
190 act2.setData(v) |
184 self.__edit).setData(v) |
191 act2.triggered.connect(lambda: self.__edit(act2)) |
185 |
192 |
186 execAct = menu.exec_(QCursor.pos()) |
193 execAct = menu.exec_(QCursor.pos()) |
187 if execAct is not None: |
194 if execAct is not None: |
188 self.close() |
195 self.close() |
189 parent = self.parent() |
196 parent = self.parent() |
190 while parent is not None and isinstance(parent, QMenu): |
197 while parent is not None and isinstance(parent, QMenu): |
191 parent.close() |
198 parent.close() |
192 parent = parent.parent() |
199 parent = parent.parent() |
193 |
200 |
194 def __openBookmark(self): |
201 def __openBookmark(self, act): |
195 """ |
202 """ |
196 Private slot to open a bookmark in the current browser tab. |
203 Private slot to open a bookmark in the current browser tab. |
197 """ |
204 |
198 idx = self.index(self.sender()) |
205 @param act reference to the triggering action |
|
206 @type QAction |
|
207 """ |
|
208 idx = self.index(act) |
199 |
209 |
200 self.openUrl.emit( |
210 self.openUrl.emit( |
201 idx.data(BookmarksModel.UrlRole), |
211 idx.data(BookmarksModel.UrlRole), |
202 idx.data(Qt.DisplayRole)) |
212 idx.data(Qt.DisplayRole)) |
203 self.__updateVisitCount(idx) |
213 self.__updateVisitCount(idx) |
204 |
214 |
205 def __openBookmarkInNewTab(self): |
215 def __openBookmarkInNewTab(self, act): |
206 """ |
216 """ |
207 Private slot to open a bookmark in a new browser tab. |
217 Private slot to open a bookmark in a new browser tab. |
208 """ |
218 |
209 idx = self.index(self.sender()) |
219 @param act reference to the triggering action |
|
220 @type QAction |
|
221 """ |
|
222 idx = self.index(act) |
210 |
223 |
211 self.newTab.emit( |
224 self.newTab.emit( |
212 idx.data(BookmarksModel.UrlRole), |
225 idx.data(BookmarksModel.UrlRole), |
213 idx.data(Qt.DisplayRole)) |
226 idx.data(Qt.DisplayRole)) |
214 self.__updateVisitCount(idx) |
227 self.__updateVisitCount(idx) |
215 |
228 |
216 def __openBookmarkInNewWindow(self): |
229 def __openBookmarkInNewWindow(self, act): |
217 """ |
230 """ |
218 Private slot to open a bookmark in a new window. |
231 Private slot to open a bookmark in a new window. |
219 """ |
232 |
220 idx = self.index(self.sender()) |
233 @param act reference to the triggering action |
|
234 @type QAction |
|
235 """ |
|
236 idx = self.index(act) |
221 url = idx.data(BookmarksModel.UrlRole) |
237 url = idx.data(BookmarksModel.UrlRole) |
222 |
238 |
223 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
239 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
224 WebBrowserWindow.mainWindow().newWindow(url) |
240 WebBrowserWindow.mainWindow().newWindow(url) |
225 self.__updateVisitCount(idx) |
241 self.__updateVisitCount(idx) |
226 |
242 |
227 def __openBookmarkInPrivateWindow(self): |
243 def __openBookmarkInPrivateWindow(self, act): |
228 """ |
244 """ |
229 Private slot to open a bookmark in a new private window. |
245 Private slot to open a bookmark in a new private window. |
230 """ |
246 |
231 idx = self.index(self.sender()) |
247 @param act reference to the triggering action |
|
248 @type QAction |
|
249 """ |
|
250 idx = self.index(act) |
232 url = idx.data(BookmarksModel.UrlRole) |
251 url = idx.data(BookmarksModel.UrlRole) |
233 |
252 |
234 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
253 from WebBrowser.WebBrowserWindow import WebBrowserWindow |
235 WebBrowserWindow.mainWindow().newPrivateWindow(url) |
254 WebBrowserWindow.mainWindow().newPrivateWindow(url) |
236 self.__updateVisitCount(idx) |
255 self.__updateVisitCount(idx) |
237 |
256 |
238 def __removeBookmark(self): |
257 def __removeBookmark(self, act): |
239 """ |
258 """ |
240 Private slot to remove a bookmark. |
259 Private slot to remove a bookmark. |
241 """ |
260 |
242 idx = self.index(self.sender()) |
261 @param act reference to the triggering action |
|
262 @type QAction |
|
263 """ |
|
264 idx = self.index(act) |
243 self.removeEntry(idx) |
265 self.removeEntry(idx) |
244 |
266 |
245 def __edit(self): |
267 def __edit(self, act): |
246 """ |
268 """ |
247 Private slot to edit a bookmarks properties. |
269 Private slot to edit a bookmarks properties. |
|
270 |
|
271 @param act reference to the triggering action |
|
272 @type QAction |
248 """ |
273 """ |
249 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
274 from .BookmarkPropertiesDialog import BookmarkPropertiesDialog |
250 |
275 |
251 idx = self.index(self.sender()) |
276 idx = self.index(act) |
252 node = self.model().node(idx) |
277 node = self.model().node(idx) |
253 dlg = BookmarkPropertiesDialog(node) |
278 dlg = BookmarkPropertiesDialog(node) |
254 dlg.exec_() |
279 dlg.exec_() |
255 |
280 |
256 ############################################################################## |
281 ############################################################################## |