|
@@ -1,20 +1,26 @@
|
|
1
|
+#!/usr/bin/env python3
|
|
2
|
+
|
1
|
3
|
# CaseLights Linux Qt System Tray client
|
2
|
4
|
# depends on:
|
3
|
5
|
# - python-pyqt5
|
4
|
6
|
# - python-pyserial
|
5
|
7
|
|
6
|
|
-import sys
|
|
8
|
+import sys
|
|
9
|
+import os.path
|
7
|
10
|
import serial, serial.tools, serial.tools.list_ports
|
8
|
11
|
from PyQt5 import QtWidgets, QtGui, QtCore
|
9
|
12
|
from PyQt5.QtWidgets import QSystemTrayIcon, QAction, QMenu
|
10
|
13
|
from PyQt5.QtGui import QIcon, QPixmap
|
11
|
14
|
from PyQt5.QtCore import QCoreApplication, QSettings
|
12
|
15
|
|
13
|
|
-class CaseLights():
|
|
16
|
+class CaseLights():
|
14
|
17
|
name = "CaseLights"
|
15
|
18
|
vendor = "xythobuz"
|
16
|
19
|
version = "0.1"
|
17
|
20
|
|
|
21
|
+ iconPath = "/usr/share/pixmaps/"
|
|
22
|
+ iconName = "caselights_icon.png"
|
|
23
|
+
|
18
|
24
|
staticColors = [
|
19
|
25
|
[ "Off", "0", "0", "0", None ],
|
20
|
26
|
[ "Red", "255", "0", "0", None ],
|
|
@@ -25,7 +31,6 @@ class CaseLights():
|
25
|
31
|
|
26
|
32
|
usedPort = None
|
27
|
33
|
serial = None
|
28
|
|
-
|
29
|
34
|
menu = None
|
30
|
35
|
portMenu = None
|
31
|
36
|
portActions = None
|
|
@@ -44,10 +49,6 @@ class CaseLights():
|
44
|
49
|
if self.usedPort is not None:
|
45
|
50
|
self.connect()
|
46
|
51
|
|
47
|
|
- pic = QPixmap(32, 32)
|
48
|
|
- pic.load("icon.png")
|
49
|
|
- icon = QIcon(pic)
|
50
|
|
-
|
51
|
52
|
self.menu = QMenu()
|
52
|
53
|
|
53
|
54
|
colorMenu = QMenu("&Colors")
|
|
@@ -72,11 +73,25 @@ class CaseLights():
|
72
|
73
|
self.quitAction.triggered.connect(self.exit)
|
73
|
74
|
self.menu.addAction(self.quitAction)
|
74
|
75
|
|
|
76
|
+ iconPathName = ""
|
|
77
|
+ if os.path.isfile(self.iconName):
|
|
78
|
+ iconPathName = self.iconName
|
|
79
|
+ elif os.path.isfile(self.iconPath + self.iconName):
|
|
80
|
+ iconPathName = self.iconPath + self.iconName
|
|
81
|
+ else:
|
|
82
|
+ print("no icon found")
|
|
83
|
+
|
|
84
|
+ icon = QIcon()
|
|
85
|
+ if iconPathName is not "":
|
|
86
|
+ pic = QPixmap(32, 32)
|
|
87
|
+ pic.load(iconPathName)
|
|
88
|
+ icon = QIcon(pic)
|
|
89
|
+
|
75
|
90
|
trayIcon = QSystemTrayIcon(icon)
|
76
|
91
|
trayIcon.setToolTip(self.name + " " + self.version)
|
77
|
92
|
trayIcon.setContextMenu(self.menu)
|
78
|
93
|
trayIcon.setVisible(True)
|
79
|
|
-
|
|
94
|
+
|
80
|
95
|
sys.exit(app.exec_())
|
81
|
96
|
|
82
|
97
|
def exit(self):
|