Bring Configure Window to Top when Opened from System Tray

- Previously the window could get hidden behind other app windows when
  user clicked configure from the system tray
This commit is contained in:
Debanjum Singh Solanky 2022-08-20 23:38:43 +03:00
parent 1c122a8a91
commit 8098b8c3a8
2 changed files with 9 additions and 2 deletions

View file

@ -6,7 +6,7 @@ import webbrowser
# External Packages
from PyQt6 import QtGui, QtWidgets
from PyQt6.QtCore import QThread, QObject, pyqtSignal
from PyQt6.QtCore import Qt, QThread, QObject, pyqtSignal
# Internal Packages
from src.configure import configure_server
@ -273,6 +273,13 @@ class MainWindow(QtWidgets.QMainWindow):
window_rectangle.moveCenter(screen_center)
self.move(window_rectangle.topLeft().x(), 25)
def show_on_top(self):
"Bring Window on Top"
self.show()
self.setWindowState(Qt.WindowState.WindowActive)
self.activateWindow() # For Bringing to Top on Windows
self.raise_() # For Bringing to Top from Minimized State on OSX
class SettingsLoader(QObject):
"Load Settings Thread"

View file

@ -25,7 +25,7 @@ def create_system_tray(gui: QtWidgets.QApplication, main_window: QtWidgets.QMain
menu = QtWidgets.QMenu()
menu_actions = [
('Search', lambda: webbrowser.open(f'http://{state.host}:{state.port}/')),
('Configure', main_window.show),
('Configure', main_window.show_on_top),
('Quit', gui.quit),
]