Browse Source

open context menu also with left click on tray icon

Thomas Buck 2 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,7 +19,7 @@ import urllib.request
19 19
 from os import path
20 20
 from PyQt5 import QtWidgets, QtGui, QtCore, QtNetwork
21 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 23
 from PyQt5.QtCore import QCoreApplication, QSettings, QUrl, QTimer, QSize, Qt, QSettings
24 24
 
25 25
 class SettingsWindow(QWidget):
@@ -486,8 +486,13 @@ class OctoTray():
486 486
         self.trayIcon = QSystemTrayIcon(self.icon)
487 487
         self.trayIcon.setToolTip(self.name + " " + self.version)
488 488
         self.trayIcon.setContextMenu(self.menu)
489
+        self.trayIcon.activated.connect(self.showHide)
489 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 496
     def readSettings(self):
492 497
         settings = QSettings(self.vendor, self.name)
493 498
         printers = []

Loading…
Cancel
Save