Exemplo n.º 1
0
 def __init__(self):
     QObject.__init__(self)
     documentsLocation = QStandardPaths.writableLocation(
         QStandardPaths.DocumentsLocation)
     self.databaseFile = os.path.join(documentsLocation, "quickpanel.db")
     self._settings = _Settings(self.databaseFile)
     self.globalKey = GlobalKey()
     self.quickPanel = QuickPanel(self)
     self.actionConfigure = QAction(QIcon(":/images/configure.png"), \
             self.tr("&Configure"), self)
     self.actionExit = QAction(QIcon(":/images/close.png"), \
             self.tr("&Exit"), self)
     self.trayIcon = QSystemTrayIcon(QIcon(":/images/angelfish.png"))
     self.contextMenu = QMenu()
     self.contextMenu.addAction(self.actionConfigure)
     self.contextMenu.addAction(self.actionExit)
     self.trayIcon.setContextMenu(self.contextMenu)
     self.actionConfigure.triggered.connect(self.configure)
     self.actionExit.triggered.connect(self.exit)
     self.trayIcon.activated.connect(self.onTrayIconActivated)
Exemplo n.º 2
0
 def __init__(self):
     QObject.__init__(self)
     documentsLocation = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
     self.databaseFile = os.path.join(documentsLocation, "quickpanel.db")
     self._settings = _Settings(self.databaseFile)
     self.globalKey = GlobalKey()
     self.quickPanel = QuickPanel(self)
     self.actionConfigure = QAction(QIcon(":/images/configure.png"), \
             self.trUtf8("&Configure"), self)
     self.actionExit = QAction(QIcon(":/images/close.png"), \
             self.trUtf8("&Exit"), self)
     self.trayIcon = QSystemTrayIcon(QIcon(":/images/angelfish.png"))
     self.contextMenu = QMenu()
     self.contextMenu.addAction(self.actionConfigure)
     self.contextMenu.addAction(self.actionExit)
     self.trayIcon.setContextMenu(self.contextMenu)
     self.actionConfigure.triggered.connect(self.configure)
     self.actionExit.triggered.connect(self.exit)
     self.trayIcon.activated.connect(self.onTrayIconActivated)
Exemplo n.º 3
0
class Platform(QObject):
    def __init__(self):
        QObject.__init__(self)
        documentsLocation = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
        self.databaseFile = os.path.join(documentsLocation, "quickpanel.db")
        self._settings = _Settings(self.databaseFile)
        self.globalKey = GlobalKey()
        self.quickPanel = QuickPanel(self)
        self.actionConfigure = QAction(QIcon(":/images/configure.png"), \
                self.trUtf8("&Configure"), self)
        self.actionExit = QAction(QIcon(":/images/close.png"), \
                self.trUtf8("&Exit"), self)
        self.trayIcon = QSystemTrayIcon(QIcon(":/images/angelfish.png"))
        self.contextMenu = QMenu()
        self.contextMenu.addAction(self.actionConfigure)
        self.contextMenu.addAction(self.actionExit)
        self.trayIcon.setContextMenu(self.contextMenu)
        self.actionConfigure.triggered.connect(self.configure)
        self.actionExit.triggered.connect(self.exit)
        self.trayIcon.activated.connect(self.onTrayIconActivated)

    def start(self):
        self.loadSettings()
        self.trayIcon.show()
        self.quickPanel.initWidgets()
        logger.info("QuickPanel is launched.")
        self.quickPanel.addQuickAccessShortcut(self.trUtf8("Tetrix"), \
                QIcon(":/images/tetrix.png"), self.startTetrix)
        self.quickPanel.addQuickAccessShortcut(self.trUtf8("Hello"), \
                QIcon(":/images/hello.png"), self.sayHello)

    def startTetrix(self):
        if getattr(self, "tetrixWindow", None) is None:
            self.tetrixWindow = TetrixWindow()
        self.tetrixWindow.show()
        self.tetrixWindow.activateWindow()

    def sayHello(self):
        QMessageBox.information(None, self.trUtf8("Say Hello."), \
                self.trUtf8("Hello, world!"))

    def loadSettings(self):
        settings = self.getSettings()
        keyname = settings.value("globalkey", "Alt+`")
        self.keyId = self.globalKey.addHotKey("actionToggleQuickPanel", keyname)
        self.globalKey.catched.connect(self.quickPanel.toggle)

    def saveSettings(self):
        pass

    def configure(self):
        d = ConfigureDialog()
        settings = self.getSettings()
        keyname = settings.value("globalkey", "Alt+`")
        d.setGlobalKey(keyname)
        self.globalKey.removeHotKey(self.keyId)
        try:
            result = getattr(d, "exec")()
        except AttributeError:
            result = getattr(d, "exec_")()
        if result == QDialog.Accepted:
            keyname = d.getGlobalKey()
            settings.setValue("globalkey", keyname)
        self.keyId = self.globalKey.addHotKey("actionToggleQuickPanel", keyname)

    def exit(self):
        self.quickPanel.finalize()
        self.saveSettings()
        self.globalKey.close()
        logger.info("QuickPanel is shutting down.")
        QApplication.instance().quit()

    def onTrayIconActivated(self, reason):
        if reason == QSystemTrayIcon.Trigger:
            self.quickPanel.toggle()

    def getSettings(self):
        return Settings(self._settings)
Exemplo n.º 4
0
class Platform(QObject):
    def __init__(self):
        QObject.__init__(self)
        documentsLocation = QStandardPaths.writableLocation(
            QStandardPaths.DocumentsLocation)
        self.databaseFile = os.path.join(documentsLocation, "quickpanel.db")
        self._settings = _Settings(self.databaseFile)
        self.globalKey = GlobalKey()
        self.quickPanel = QuickPanel(self)
        self.actionConfigure = QAction(QIcon(":/images/configure.png"), \
                self.tr("&Configure"), self)
        self.actionExit = QAction(QIcon(":/images/close.png"), \
                self.tr("&Exit"), self)
        self.trayIcon = QSystemTrayIcon(QIcon(":/images/angelfish.png"))
        self.contextMenu = QMenu()
        self.contextMenu.addAction(self.actionConfigure)
        self.contextMenu.addAction(self.actionExit)
        self.trayIcon.setContextMenu(self.contextMenu)
        self.actionConfigure.triggered.connect(self.configure)
        self.actionExit.triggered.connect(self.exit)
        self.trayIcon.activated.connect(self.onTrayIconActivated)

    def start(self):
        self.loadSettings()
        self.trayIcon.show()
        self.quickPanel.initWidgets()
        logger.info("QuickPanel is launched.")
        self.quickPanel.addQuickAccessShortcut(self.tr("Tetrix"), \
                QIcon(":/images/tetrix.png"), self.startTetrix)
        self.quickPanel.addQuickAccessShortcut(self.tr("Hello"), \
                QIcon(":/images/hello.png"), self.sayHello)

    def startTetrix(self):
        if getattr(self, "tetrixWindow", None) is None:
            self.tetrixWindow = TetrixWindow()
        self.tetrixWindow.show()
        self.tetrixWindow.activateWindow()

    def sayHello(self):
        QMessageBox.information(None, self.tr("Say Hello."), \
                self.tr("Hello, world!"))

    def loadSettings(self):
        settings = self.getSettings()
        keyname = settings.value("globalkey", "Alt+`")
        self.keyId = self.globalKey.addHotKey("actionToggleQuickPanel",
                                              keyname)
        self.globalKey.catched.connect(self.quickPanel.toggle)

    def saveSettings(self):
        pass

    def configure(self):
        d = ConfigureDialog()
        settings = self.getSettings()
        keyname = settings.value("globalkey", "Alt+`")
        d.setGlobalKey(keyname)
        self.globalKey.removeHotKey(self.keyId)
        try:
            result = getattr(d, "exec")()
        except AttributeError:
            result = getattr(d, "exec_")()
        if result == QDialog.Accepted:
            keyname = d.getGlobalKey()
            settings.setValue("globalkey", keyname)
        self.keyId = self.globalKey.addHotKey("actionToggleQuickPanel",
                                              keyname)

    def exit(self):
        self.quickPanel.finalize()
        self.saveSettings()
        self.globalKey.close()
        logger.info("QuickPanel is shutting down.")
        QApplication.instance().quit()

    def onTrayIconActivated(self, reason):
        if reason == QSystemTrayIcon.Trigger:
            self.quickPanel.toggle()

    def getSettings(self):
        return Settings(self._settings)