Skip to content

Commit

Permalink
Merge pull request #1128 from nstelter-slac/fullscreen_correct_text
Browse files Browse the repository at this point in the history
ENH: make main window menubar action for 'Enter Fullscreen' toggle to 'Exit Fullscreen' when in fullscreen view.
  • Loading branch information
jbellister-slac authored Dec 10, 2024
2 parents 1b3c197 + 998c561 commit f54c462
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pydm/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os import path

from qtpy.QtWidgets import QApplication, QMainWindow, QFileDialog, QAction, QMessageBox
from qtpy.QtCore import Qt, QTimer, Slot, QSize, QLibraryInfo
from qtpy.QtCore import Qt, QTimer, Slot, QSize, QLibraryInfo, QCoreApplication
from qtpy.QtGui import QKeySequence
from .utilities import IconFont, find_file, establish_widget_connections, close_widget_connections
from .pydm_ui import Ui_MainWindow
Expand Down Expand Up @@ -479,10 +479,14 @@ def set_font_size(self, old, new):

@Slot(bool)
def enter_fullscreen(self, checked=False):
# for supporting localization (the main window menu-items all support this)
_translate = QCoreApplication.translate
if self.isFullScreen():
self.showNormal()
self.ui.actionEnter_Fullscreen.setText(_translate("MainWindow", "Enter Fullscreen"))
else:
self.showFullScreen()
self.ui.actionEnter_Fullscreen.setText(_translate("MainWindow", "Exit Fullscreen"))

@Slot(bool)
def show_connections(self, checked):
Expand Down
17 changes: 17 additions & 0 deletions pydm/tests/test_main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,20 @@ def test_reload_display(wrapped_compile_ui: MagicMock, qapp: PyDMApplication) ->
assert wrapped_compile_ui.call_count == 2
finally:
clear_compiled_ui_file_cache()


def test_menubar_text(qapp: PyDMApplication) -> None:
"""Verify main-window displays expected text in its menubar dropdown items"""
# only testing text update of "Enter/Exit Fullscreen" menu-item for now, this can be expanded later
display = Display(parent=None)

qapp.make_main_window()
qapp.main_window.set_display_widget(display)

action = qapp.main_window.ui.actionEnter_Fullscreen
# make sure we start in not fullscreen view
qapp.main_window.showNormal()
assert action.text() == "Enter Fullscreen"
# click the menu-item to go into fullscreen view
action.trigger()
assert action.text() == "Exit Fullscreen"

0 comments on commit f54c462

Please sign in to comment.