mirror of
https://github.com/kbumsik/VirtScreen.git
synced 2025-02-14 12:21:50 +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
|
||||
|
||||
import os, re
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtGui import QIcon, QCursor
|
||||
from PyQt5.QtCore import pyqtSlot, Qt
|
||||
from PyQt5.QtWidgets import (QAction, QApplication, QCheckBox, QComboBox,
|
||||
QDialog, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||
|
@ -320,6 +320,15 @@ class Window(QDialog):
|
|||
if self.isVisible():
|
||||
self.hide()
|
||||
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()
|
||||
elif reason == QSystemTrayIcon.MiddleClick:
|
||||
self.showMessage()
|
||||
|
|
Loading…
Reference in a new issue