ソースを参照

open context menu also with left click on tray icon

Thomas Buck 3年前
コミット
62e8a630f2
1個のファイルの変更6行の追加1行の削除
  1. 6
    1
      src/octotray.py

+ 6
- 1
src/octotray.py ファイルの表示

@@ -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 = []

読み込み中…
キャンセル
保存