def screen_refresh_rate_for_monitor(cls, monitor): try: from fsui.qt import init_qt qapplication = init_qt() except AttributeError: return 0 else: for i, screen in enumerate(qapplication.screens()): print("Screen {0} refresh rate (Qt) = {1}".format( i, screen.refreshRate())) index = cls.screen_index_for_monitor(monitor) screen = qapplication.screens()[index] if windows or macosx: return int(round(screen.refreshRate())) refresh_rate_tool = RefreshRateTool() screens = refresh_rate_tool.screens_xrandr() rect = cls.screen_rect_for_monitor(monitor) # from pprint import pprint # pprint(screens) for screen in screens: print("Screen {} refresh rate (Xrandr) = {}".format( screen, screens[screen]["refresh_rate"])) for screen in screens: if rect == screen: return screens[screen]["refresh_rate"] return 0
def screen_refresh_rate_for_monitor(cls, monitor): try: from fsui.qt import init_qt qapplication = init_qt() except AttributeError: return 0 else: for i, screen in enumerate(qapplication.screens()): print("Screen {0} refresh rate (Qt) = {1}".format( i, screen.refreshRate())) index = cls.screen_index_for_monitor(monitor) screen = qapplication.screens()[index] if System.windows or System.macos: return int(round(screen.refreshRate())) refresh_rate_tool = RefreshRateTool() screens = refresh_rate_tool.screens_xrandr() rect = cls.screen_rect_for_monitor(monitor) for screen in screens: print("Screen {} refresh rate (Xrandr) = {}".format( screen, screens[screen]["refresh_rate"])) for screen in screens: if rect == screen: return screens[screen]["refresh_rate"] return 0
def app_main(appname=None): print("prefs") # FIXME: Create QApplication only so we can show error messages if anything # goes wrong? qapplication = init_qt() print("FIXME: Saira - read from proper data location") # We need to wait until Qt is initialized before we can show warnings try: _app_main_1() except Exception as e: # We should be able to show a Qt error message dialog at least now # pylint: disable=no-name-in-module from PyQt5.QtWidgets import QMessageBox message = ( f"An error of type {type(e).__name__} occurred during startup." "\n\n" "Please see the log file(s) for actual error messages and stack " "traces." ) QMessageBox.critical(None, "Software Failure", message) raise # FIXME: Here? install_exception_display_function() # _app_main_2 runs with software_failure decorator _app_main_2(qapplication, appname)
def app_main(): print("prefs") qapplication = init_qt() print("FIXME: Saira - read from proper data location") with open( os.path.expanduser( "~/openretro/git/fsemu/data/SairaCondensed-Medium.ttf" ), "rb", ) as f: QFontDatabase.addApplicationFontFromData(f.read()) with open( os.path.expanduser( "~/openretro/git/fsemu/data/SairaCondensed-Medium.ttf" ), "rb", ) as f: QFontDatabase.addApplicationFontFromData(f.read()) with open( os.path.expanduser( "~/openretro/git/fsemu/data/SairaCondensed-SemiBold.ttf" ), "rb", ) as f: QFontDatabase.addApplicationFontFromData(f.read()) with open( os.path.expanduser( "~/openretro/git/fsemu/data/SairaCondensed-Bold.ttf" ), "rb", ) as f: QFontDatabase.addApplicationFontFromData(f.read()) initialize_qt_style(qapplication) from launcher.launcherapp import LauncherApp launcherapp = LauncherApp() # from launcher.ui.launcherwindow import LauncherWindow # launcherwindow = LauncherWindow() # launcherwindow.show() # window = PrefsWindow(app) # window.show() app = Application() from system.wsopen import wsopen wsopen("SYS:Prefs/WHDLoad") qapplication.exec_()
def __init__(self, parent): super().__init__(parent, "") try: from fsui.qt import init_qt qapplication = init_qt() except AttributeError: pass else: for screen in qapplication.screens(): screen.geometryChanged.connect(self.on_screen_change) screen.refreshRateChanged.connect(self.on_screen_change) qapplication.screenAdded.connect(self.on_screen_added) SettingsBehavior(self, ["fullscreen", "monitor", "assume_refresh_rate"])
def _screens(cls): screens = [] try: from fsui.qt import init_qt qapplication = init_qt() desktop = qapplication.desktop() except AttributeError: # no QApplication, probably not running via QT # FIXME: log warning pass else: for i in range(desktop.screenCount()): geometry = desktop.screenGeometry(i) screens.append([geometry.x(), i, geometry]) return screens
def screen_geometry(): q_app = init_qt() desktop = q_app.desktop() screens = [] for i in range(desktop.screenCount()): geom = desktop.screenGeometry(i) screens.append([geom.x(), i, geom]) screens.sort() if monitor() == "left": mon = 0 elif monitor() == "middle-right": mon = 2 elif monitor() == "right": mon = 3 else: # middle-left mon = 1 display = round(mon / 3 * (len(screens) - 1)) geom = screens[display][2] return geom.x(), geom.y(), geom.width(), geom.height()
def screen_rects(): # FIXME: Move qt code to fsui screens = [] try: from fsui.qt import init_qt qapplication = init_qt() except AttributeError: pass else: for screen in qapplication.screens(): geometry = screen.geometry() screen = { "x": geometry.x(), "y": geometry.y(), "w": geometry.width(), "h": geometry.height(), } screens.append((screen["x"], screen)) # Sort screens by x coordinate screens.sort() return [screen[1] for screen in screens]