mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-03-09 15:40:18 +00:00
Trayicon: Widget shows on the nearest coner to the tray icon
This commit is contained in:
parent
60b61c49bc
commit
6a50f724d2
1 changed files with 10 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import os, re
|
import os, re
|
||||||
from PyQt5.QtGui import QIcon
|
from PyQt5.QtGui import QIcon, QCursor
|
||||||
from PyQt5.QtCore import pyqtSlot, Qt
|
from PyQt5.QtCore import pyqtSlot, Qt
|
||||||
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
|
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
|
||||||
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||||
|
|
@ -320,6 +320,15 @@ class Window(QDialog):
|
||||||
if self.isVisible():
|
if self.isVisible():
|
||||||
self.hide()
|
self.hide()
|
||||||
else:
|
else:
|
||||||
|
# move the widget to one of 4 coners of the primary display,
|
||||||
|
# depending on the current mouse cursor.
|
||||||
|
screen = QApplication.desktop().screenGeometry()
|
||||||
|
x_mid = screen.width() / 2
|
||||||
|
y_mid = screen.height() / 2
|
||||||
|
cursor = QCursor().pos()
|
||||||
|
x = (screen.width() - self.width()) if (cursor.x() > x_mid) else 0
|
||||||
|
y = (screen.height() - self.height()) if (cursor.y() > y_mid) else 0
|
||||||
|
self.move(x, y)
|
||||||
self.showNormal()
|
self.showNormal()
|
||||||
elif reason == QSystemTrayIcon.MiddleClick:
|
elif reason == QSystemTrayIcon.MiddleClick:
|
||||||
self.showMessage()
|
self.showMessage()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue