Browse Source

open context menu also with left click on tray icon

Thomas Buck 3 years ago
parent
commit
62e8a630f2
1 changed files with 6 additions and 1 deletions
  1. 6
    1
      src/octotray.py

+ 6
- 1
src/octotray.py View File

19
 from os import path
19
 from os import path
20
 from PyQt5 import QtWidgets, QtGui, QtCore, QtNetwork
20
 from PyQt5 import QtWidgets, QtGui, QtCore, QtNetwork
21
 from PyQt5.QtWidgets import QSystemTrayIcon, QAction, QMenu, QMessageBox, QWidget, QLabel, QVBoxLayout, QHBoxLayout, QDesktopWidget, QSizePolicy, QSlider, QLayout, QTableWidget, QTableWidgetItem, QPushButton
21
 from PyQt5.QtWidgets import QSystemTrayIcon, QAction, QMenu, QMessageBox, QWidget, QLabel, QVBoxLayout, QHBoxLayout, QDesktopWidget, QSizePolicy, QSlider, QLayout, QTableWidget, QTableWidgetItem, QPushButton
22
-from PyQt5.QtGui import QIcon, QPixmap, QImageReader, QDesktopServices, QFontDatabase
22
+from PyQt5.QtGui import QIcon, QPixmap, QImageReader, QDesktopServices, QFontDatabase, QCursor
23
 from PyQt5.QtCore import QCoreApplication, QSettings, QUrl, QTimer, QSize, Qt, QSettings
23
 from PyQt5.QtCore import QCoreApplication, QSettings, QUrl, QTimer, QSize, Qt, QSettings
24
 
24
 
25
 class SettingsWindow(QWidget):
25
 class SettingsWindow(QWidget):
486
         self.trayIcon = QSystemTrayIcon(self.icon)
486
         self.trayIcon = QSystemTrayIcon(self.icon)
487
         self.trayIcon.setToolTip(self.name + " " + self.version)
487
         self.trayIcon.setToolTip(self.name + " " + self.version)
488
         self.trayIcon.setContextMenu(self.menu)
488
         self.trayIcon.setContextMenu(self.menu)
489
+        self.trayIcon.activated.connect(self.showHide)
489
         self.trayIcon.setVisible(True)
490
         self.trayIcon.setVisible(True)
490
 
491
 
492
+    def showHide(self, activationReason):
493
+        if activationReason == QSystemTrayIcon.Trigger:
494
+            self.menu.popup(QCursor.pos())
495
+
491
     def readSettings(self):
496
     def readSettings(self):
492
         settings = QSettings(self.vendor, self.name)
497
         settings = QSettings(self.vendor, self.name)
493
         printers = []
498
         printers = []

Loading…
Cancel
Save