mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-13 19:21:50 +02:00
feat(main_window): add launcher menu and functionality to show launcher
This commit is contained in:
@ -70,12 +70,43 @@ class BECMainWindow(BECWidget, QMainWindow):
|
||||
def _fetch_theme(self) -> str:
|
||||
return self.app.theme.theme
|
||||
|
||||
def _get_launcher_from_qapp(self):
|
||||
"""
|
||||
Get the launcher from the QApplication instance.
|
||||
"""
|
||||
from bec_widgets.applications.launch_window import LaunchWindow
|
||||
|
||||
qapp = QApplication.instance()
|
||||
widgets = qapp.topLevelWidgets()
|
||||
widgets = [w for w in widgets if isinstance(w, LaunchWindow)]
|
||||
if widgets:
|
||||
return widgets[0]
|
||||
return None
|
||||
|
||||
def _show_launcher(self):
|
||||
"""
|
||||
Show the launcher if it exists.
|
||||
"""
|
||||
launcher = self._get_launcher_from_qapp()
|
||||
if launcher:
|
||||
launcher.show()
|
||||
launcher.activateWindow()
|
||||
launcher.raise_()
|
||||
|
||||
def _setup_menu_bar(self):
|
||||
"""
|
||||
Setup the menu bar for the main window.
|
||||
"""
|
||||
menu_bar = self.menuBar()
|
||||
|
||||
##########################################
|
||||
# Launch menu
|
||||
launch_menu = menu_bar.addMenu("New")
|
||||
|
||||
open_launcher_action = QAction("Open Launcher", self)
|
||||
launch_menu.addAction(open_launcher_action)
|
||||
open_launcher_action.triggered.connect(self._show_launcher)
|
||||
|
||||
########################################
|
||||
# Theme menu
|
||||
theme_menu = menu_bar.addMenu("Theme")
|
||||
|
Reference in New Issue
Block a user