示例#1
0
    def __init__(self, qnotero):
        """
        Constructor

        Arguments:
        qnotero -- a Qnotero instance
        """

        QSystemTrayIcon.__init__(self, qnotero)
        self.qnotero = qnotero
        self.menu = QMenu()
        self.re_init()
        self.activated.connect(self.activate)
示例#2
0
 def eventFilter(self, source: 'QObject', e: 'QEvent') -> bool:
     if (e.type() == QtCore.QEvent.ContextMenu and source is
             self.ui.listWidgetResults):
         contextMenu = QMenu(self)
         actCopyAuthordate = contextMenu.addAction(u"Copy author(s) and year")
         actCopyDOI = contextMenu.addAction(u"Copy DOI")
         actCopyTitle = contextMenu.addAction(u"Copy title")
         actCopyAbs = contextMenu.addAction(u"Copy abstract")
         actCopyRef = contextMenu.addAction(u"Copy Reference")
         action = contextMenu.exec_(self.mapToGlobal(e.pos()))
         item = source.itemAt(e.pos())
         if (action is None) or (item is None):
             return True
         clipboard = QtGui.QApplication.clipboard()
         clipboard.clear(mode=clipboard.Clipboard)
         if action is actCopyAuthordate:
             clipboard.setText(item.zoteroItem.author_date_format(), mode=clipboard.Clipboard)
             return True
         elif action is actCopyDOI:
             if item.zoteroItem.doi is not None:
                 clipboard.setText(item.zoteroItem.doi, mode=clipboard.Clipboard)
             return True
         elif action is actCopyTitle:
             title = item.zoteroItem.format_title()
             if title is not None:
                 clipboard.setText(title, mode=clipboard.Clipboard)
             return True
         elif action is actCopyAbs:
             if item.zoteroItem.abstract is not None:
                 clipboard.setText(item.zoteroItem.abstract, mode=clipboard.Clipboard)
             return True
         elif action is actCopyRef:
             clipboard.setText(item.zoteroItem.full_format(), mode=clipboard.Clipboard)
             return True
     return QMainWindow.eventFilter(self, source, e)
示例#3
0
    def __init__(self, qnotero):
        """
		Constructor
		
		Arguments:
		qnotero -- a Qnotero instance
		"""

        QSystemTrayIcon.__init__(self, qnotero)
        self.qnotero = qnotero
        self.updateIcon()
        self.menu = QMenu()
        self.menu.addAction(self.qnotero.theme.icon("qnotero"), "Show",
                            self.qnotero.popUp)
        self.menu.addAction(self.qnotero.theme.icon("preferences"),
                            "Preferences", self.qnotero.preferences)
        self.menu.addAction(self.qnotero.theme.icon("close"), "Close",
                            self.qnotero.close)
        self.setContextMenu(self.menu)
        self.activated.connect(self.activate)
        self.listenerActivated.connect(self.activate)
示例#4
0
class SysTray(QSystemTrayIcon):

    """The Qnotero system tray icon"""

    listenerActivated = pyqtSignal()

    def __init__(self, qnotero):

        """
        Constructor

        Arguments:
        qnotero -- a Qnotero instance
        """

        QSystemTrayIcon.__init__(self, qnotero)
        self.qnotero = qnotero
        self.menu = QMenu()
        self.re_init()
        self.activated.connect(self.activate)
        self.listenerActivated.connect(self.activate)

    def activate(self, reason=None):

        """
        Handle clicks on the systray icon

        Keyword arguments:
        reason -- the reason for activation (default=None)
        """
        print("sysTray.activate(): Activating qnotero reason: %s" % reason)
        if reason == QSystemTrayIcon.Context or (platform.system() == 'Darwin' and reason is not None):
            print("sysTray.activate(): Exiting wthout activate Qnotero")
            return
        if self.qnotero.isVisible():
            self.qnotero.popDown()
        else:
            self.qnotero.popUp()

    def re_init(self):
        self.setIcon(self.qnotero.theme.icon("qnotero", ".png"))
        self.menu.clear()
        self.menu.addAction(self.qnotero.theme.icon("show"), "Show",	self.qnotero.popUp)
        self.menu.addAction(self.qnotero.theme.icon("preferences"),	"Preferences", self.qnotero.preferences)
        self.menu.addAction(self.qnotero.theme.icon("close"), "Close", self.qnotero.close)
        self.setContextMenu(self.menu)
示例#5
0
class SysTray(QSystemTrayIcon):

	"""The Qnotero system tray icon"""

	listenerActivated = pyqtSignal()
	
	def __init__(self, qnotero):
	
		"""
		Constructor
		
		Arguments:
		qnotero -- a Qnotero instance
		"""
	
		QSystemTrayIcon.__init__(self, qnotero)
		self.qnotero = qnotero		
		self.updateIcon()
		self.menu = QMenu()
		self.menu.addAction(self.qnotero.theme.icon("qnotero"), "Show",
			self.qnotero.popUp)
		self.menu.addAction(self.qnotero.theme.icon("preferences"),
			"Preferences", self.qnotero.preferences)
		self.menu.addAction(self.qnotero.theme.icon("close"), "Close",
			self.qnotero.close)
		self.setContextMenu(self.menu)
		self.activated.connect(self.activate)
		self.listenerActivated.connect(self.activate)

	def updateIcon(self):

		"""
		Reloads the systray icon according to the current settings
		"""
		
		iconName = self.qnotero.iconName
		overrideIconExt = None if self.qnotero.isThemeIcon else ''
		self.setIcon(self.qnotero.theme.icon(iconName, overrideIconExt))

	def activate(self, reason=None):
	
		"""
		Handle clicks on the systray icon
		
		Keyword arguments:
		reason -- the reason for activation (default=None)
		"""
		
		if reason == QSystemTrayIcon.Context:
			return		
		if self.qnotero.isVisible():
			self.qnotero.popDown()
		else:
			self.qnotero.popUp()
示例#6
0
class SysTray(QSystemTrayIcon):
    """The Qnotero system tray icon"""

    listenerActivated = pyqtSignal()

    def __init__(self, qnotero):
        """
		Constructor
		
		Arguments:
		qnotero -- a Qnotero instance
		"""

        QSystemTrayIcon.__init__(self, qnotero)
        self.qnotero = qnotero
        self.updateIcon()
        self.menu = QMenu()
        self.menu.addAction(self.qnotero.theme.icon("qnotero"), "Show",
                            self.qnotero.popUp)
        self.menu.addAction(self.qnotero.theme.icon("preferences"),
                            "Preferences", self.qnotero.preferences)
        self.menu.addAction(self.qnotero.theme.icon("close"), "Close",
                            self.qnotero.close)
        self.setContextMenu(self.menu)
        self.activated.connect(self.activate)
        self.listenerActivated.connect(self.activate)

    def updateIcon(self):
        """
		Reloads the systray icon according to the current settings
		"""

        iconName = self.qnotero.iconName
        overrideIconExt = None if self.qnotero.isThemeIcon else ''
        self.setIcon(self.qnotero.theme.icon(iconName, overrideIconExt))

    def activate(self, reason=None):
        """
		Handle clicks on the systray icon
		
		Keyword arguments:
		reason -- the reason for activation (default=None)
		"""

        if reason == QSystemTrayIcon.Context:
            return
        if self.qnotero.isVisible():
            self.qnotero.popDown()
        else:
            self.qnotero.popUp()
示例#7
0
	def __init__(self, qnotero):
	
		"""
		Constructor
		
		Arguments:
		qnotero -- a Qnotero instance
		"""
	
		QSystemTrayIcon.__init__(self, qnotero)
		self.qnotero = qnotero		
		self.updateIcon()
		self.menu = QMenu()
		self.menu.addAction(self.qnotero.theme.icon("qnotero"), "Show",
			self.qnotero.popUp)
		self.menu.addAction(self.qnotero.theme.icon("preferences"),
			"Preferences", self.qnotero.preferences)
		self.menu.addAction(self.qnotero.theme.icon("close"), "Close",
			self.qnotero.close)
		self.setContextMenu(self.menu)
		self.activated.connect(self.activate)
		self.listenerActivated.connect(self.activate)