WebBrowser/Feeds/FeedsManager.py

changeset 5038
df7103c3f2a6
parent 4913
e16573640cb8
child 5389
9b1c800daff3
equal deleted inserted replaced
5037:b2b37d7c0791 5038:df7103c3f2a6
29 class FeedsManager(QDialog, Ui_FeedsManager): 29 class FeedsManager(QDialog, Ui_FeedsManager):
30 """ 30 """
31 Class implementing a RSS feeds manager dialog. 31 Class implementing a RSS feeds manager dialog.
32 32
33 @signal openUrl(QUrl, str) emitted to open a URL in the current tab 33 @signal openUrl(QUrl, str) emitted to open a URL in the current tab
34 @signal newUrl(QUrl, str) emitted to open a URL in a new tab 34 @signal newTab(QUrl, str) emitted to open a URL in a new tab
35 @signal newBackgroundTab(QUrl, str) emitted to open a URL in a new
36 background tab
37 @signal newWindow(QUrl, str) emitted to open a URL in a new window
38 @signal newPrivateWindow(QUrl, str) emitted to open a URL in a new
39 private window
35 """ 40 """
36 openUrl = pyqtSignal(QUrl, str) 41 openUrl = pyqtSignal(QUrl, str)
37 newUrl = pyqtSignal(QUrl, str) 42 newTab = pyqtSignal(QUrl, str)
43 newBackgroundTab = pyqtSignal(QUrl, str)
44 newWindow = pyqtSignal(QUrl, str)
45 newPrivateWindow = pyqtSignal(QUrl, str)
38 46
39 UrlStringRole = Qt.UserRole 47 UrlStringRole = Qt.UserRole
40 ErrorDataRole = Qt.UserRole + 1 48 ErrorDataRole = Qt.UserRole + 1
41 49
42 def __init__(self, parent=None): 50 def __init__(self, parent=None):
339 menu = QMenu() 347 menu = QMenu()
340 menu.addAction( 348 menu.addAction(
341 self.tr("&Open"), self.__openMessageInCurrentTab) 349 self.tr("&Open"), self.__openMessageInCurrentTab)
342 menu.addAction( 350 menu.addAction(
343 self.tr("Open in New &Tab"), self.__openMessageInNewTab) 351 self.tr("Open in New &Tab"), self.__openMessageInNewTab)
352 menu.addAction(
353 self.tr("Open in New &Background Tab"),
354 self.__openMessageInNewBackgroundTab)
355 menu.addAction(
356 self.tr("Open in New &Window"), self.__openMessageInNewWindow)
357 menu.addAction(
358 self.tr("Open in New Pri&vate Window"),
359 self.__openMessageInPrivateWindow)
344 menu.addSeparator() 360 menu.addSeparator()
345 menu.addAction(self.tr("&Copy URL to Clipboard"), 361 menu.addAction(self.tr("&Copy URL to Clipboard"),
346 self.__copyUrlToClipboard) 362 self.__copyUrlToClipboard)
347 menu.exec_(QCursor.pos()) 363 menu.exec_(QCursor.pos())
348 else: 364 else:
361 @param column column of the activation (integer) 377 @param column column of the activation (integer)
362 """ 378 """
363 if self.feedsTree.indexOfTopLevelItem(itm) != -1: 379 if self.feedsTree.indexOfTopLevelItem(itm) != -1:
364 return 380 return
365 381
366 self.__openMessage( 382 if QApplication.keyboardModifiers() & Qt.ControlModifier:
367 QApplication.keyboardModifiers() & 383 self.__openMessageInNewTab()
368 Qt.ControlModifier == Qt.ControlModifier) 384 elif QApplication.keyboardModifiers() & Qt.ShiftModifier:
385 self.__openMessageInNewWindow()
386 else:
387 self.__openMessageInCurrentTab()
369 388
370 def __openMessageInCurrentTab(self): 389 def __openMessageInCurrentTab(self):
371 """ 390 """
372 Private slot to open a feed message in the current browser tab. 391 Private slot to open a feed message in the current browser tab.
373 """ 392 """
374 self.__openMessage(False) 393 self.__openMessage()
375 394
376 def __openMessageInNewTab(self): 395 def __openMessageInNewTab(self):
377 """ 396 """
378 Private slot to open a feed message in a new browser tab. 397 Private slot to open a feed message in a new browser tab.
379 """ 398 """
380 self.__openMessage(True) 399 self.__openMessage(newTab=True)
381 400
382 def __openMessage(self, newTab): 401 def __openMessageInNewBackgroundTab(self):
402 """
403 Private slot to open a feed message in a new background tab.
404 """
405 self.__openMessage(newTab=True, background=True)
406
407 def __openMessageInNewWindow(self):
408 """
409 Private slot to open a feed message in a new browser window.
410 """
411 self.__openMessage(newWindow=True)
412
413 def __openMessageInPrivateWindow(self):
414 """
415 Private slot to open a feed message in a new private browser window.
416 """
417 self.__openMessage(newWindow=True, privateWindow=True)
418
419 def __openMessage(self, newTab=False, background=False,
420 newWindow=False, privateWindow=False):
383 """ 421 """
384 Private method to open a feed message. 422 Private method to open a feed message.
385 423
386 @param newTab flag indicating to open the feed message in a new tab 424 @param newTab flag indicating to open the feed message in a new tab
387 (boolean) 425 @type bool
426 @param background flag indicating to open the bookmark in a new
427 background tab
428 @type bool
429 @param newWindow flag indicating to open the bookmark in a new window
430 @type bool
431 @param privateWindow flag indicating to open the bookmark in a new
432 private window
433 @type bool
388 """ 434 """
389 itm = self.feedsTree.currentItem() 435 itm = self.feedsTree.currentItem()
390 if itm is None: 436 if itm is None:
391 return 437 return
392 438
393 urlString = itm.data(0, FeedsManager.UrlStringRole) 439 urlString = itm.data(0, FeedsManager.UrlStringRole)
394 if urlString: 440 if urlString:
395 title = itm.text(0) 441 title = itm.text(0)
396 442
397 if newTab: 443 if newTab:
398 self.newUrl.emit(QUrl(urlString), title) 444 if background:
445 self.newBackgroundTab.emit(QUrl(urlString), title)
446 else:
447 self.newTab.emit(QUrl(urlString), title)
448 elif newWindow:
449 if privateWindow:
450 self.newPrivateWindow.emit(QUrl(urlString), title)
451 else:
452 self.newWindow.emit(QUrl(urlString), title)
399 else: 453 else:
400 self.openUrl.emit(QUrl(urlString), title) 454 self.openUrl.emit(QUrl(urlString), title)
401 else: 455 else:
402 errorString = itm.data(0, FeedsManager.ErrorDataRole) 456 errorString = itm.data(0, FeedsManager.ErrorDataRole)
403 if errorString: 457 if errorString:

eric ide

mercurial