def __init__(self, parent, option): super().__init__(parent) self.option = option self.set_min_size((40, 30)) # FIXME: Filter on options? # get_settings(self).add_listener(self, [self.option]) self.color = Color(0, 0, 0) self.bordercolor = Color(0x666666) # self.cornercolor = Color(0xff0000) self.on_setting(self.option, get_settings(self).get(self.option)) get_settings(self).add_listener(self)
def on_activate(self): if self.dialog is not None: self.dialog.raise_() self.dialog.activateWindow() return from fsui.qt import QColorDialog # FIXME: Use accessor funtion get_qwindow # print("Initial color", Color.from_hex(get_settings(self).get(self.option))) # dialog = QColorDialog( # Color.from_hex(get_settings(self).get(self.option)), # parent=get_window(self)._real_window, # ) self.dialog = QColorDialog(parent=get_window(self)._qwidget) # dialog.setOption(QColorDialog.ShowAlphaChannel) self.dialog.setOption(QColorDialog.NoButtons) self.dialog.setOption(QColorDialog.DontUseNativeDialog) # Setting initial color only seems to work after setting options. # Calling this method earlier (or setting initial color in constructor) # seems to be ignored causing black color to be pre-selected. self.dialog.setCurrentColor( Color.from_hex(get_settings(self).get(self.option))) # dialog.colorSelected.connect(self.__color_selected) self.dialog.currentColorChanged.connect(self.__current_color_changed) self.dialog.destroyed.connect(self.__dialog_destroyed) # self.dialog.setAttribute(Qt.WA_DeleteOnClose) self.dialog.installEventFilter(self) self.dialog.show()
def __init__(self, parent=None, *, options=None): autoParent = False if parent is None: parent = ParentStack.top() autoParent = True super().__init__(parent, gettext("Reset to defaults")) self.activated.connect(self.__on_reset_to_defaults) settings = get_settings(self) self.remove_listener = settings.add_listener(self) # FIXME: Implement # self.destroy.connect(settings.add_listener(self)) if autoParent: parent.layout.add(self) # Add automatically discovered settings optionsOnPanel = None while parent and optionsOnPanel is None: parent = parent.getParent() optionsOnPanel = getattr(parent, "optionsOnPanel", None) options = options or [] if optionsOnPanel is not None: options.extend(optionsOnPanel) # for optionName in optionsOnPanel: # self.options[optionName] = settings.get(optionName) self.options = {option: settings.get(option) for option in options} self.update_enabled_state()
def __init__(self, parent): # FIXME: Should go via gscontext and not settings # or maybe via settings but with a window id/prefix text = get_settings(self).get("config_search") super().__init__(parent, text=text, clearbutton=True, placeholder=gettext("Search"))
def __init__(self, parent, warning): super().__init__(parent) self.warning_function = warning[0] self.options = { option: get_settings(self).get(option) for option in warning[1] } # self._last_options = None # text = gettext( # "Option {name} is overridden by current configuration".format( # name=name # ) # ) get_settings(self).add_listener(self) # self.set_tooltip(text) # self.set_background_color(fsui.Color(0xff0000)) # print("WARNING", self) self.update_warning()
def on_changed(self): text = self.text() # FIXME: Should go via gscontext and not settings get_settings(self).set("config_search", text)
def on_destroy(self): get_settings(self).remove_listener(self) super().on_destroy()
def __titlebar_font_changed(self): get_settings(self).set("launcher_titlebar_font", self.textfield.text().strip())
def __init__(self, parent): super().__init__(parent) self.set_min_size((500, 400)) self.layout.set_padding(20, 20, 20, 20) label = Label(self, "Titlebar font:") self.layout.add(label, fill=True) # FIXME: Text field is not updated when font changes (easy to check) # with reset to defaults function. # Same applies to Option UI stuff actually self.textfield = TextField( self, get_settings(self).get("launcher_titlebar_font"), # FIXME: Show real default text here! placeholder="Saira Condensed 16", ) self.textfield.changed.connect(self.__titlebar_font_changed) self.layout.add(self.textfield, fill=True, margin_top=10) label = Label(self, "Titlebar foreground color:") self.layout.add(label, fill=True, margin_top=10) self.layout.add(ColorSettingGroup(self, "launcher_titlebar_fgcolor"), margin_top=10) label = Label(self, "Titlebar foreground color (inactive):") self.layout.add(label, fill=True, margin_top=10) self.layout.add( ColorSettingGroup(self, "launcher_titlebar_fgcolor_inactive"), margin_top=10, ) label = Label(self, "Titlebar background color:") self.layout.add(label, fill=True, margin_top=10) self.layout.add(ColorSettingGroup(self, "launcher_titlebar_bgcolor"), margin_top=10) # self.layout.add( # ColorSettingIndicator(self, "launcher_titlebar_bgcolor") # ) # self.layout.add(ColorSettingButton(self, "launcher_titlebar_bgcolor")) label = Label(self, "Titlebar background (inactive):") self.layout.add(label, fill=True, margin_top=10) self.layout.add( ColorSettingGroup(self, "launcher_titlebar_bgcolor_inactive"), margin_top=10, ) from launcher.settings.option_ui import OptionUI self.add_option(Option.LAUNCHER_WINDOW_TITLE) self.add_option(Option.LAUNCHER_TITLEBAR_HEIGHT) self.add_option(Option.LAUNCHER_TITLEBAR_UPPERCASE) # self.layout.add( # OptionUI.create_group(self, Option.LAUNCHER_TITLEBAR_HEIGHT), # fill=True, # margin_top=10, # ) # from launcher.settings.option_ui import OptionUI # self.layout.add( # OptionUI.create_group(self, Option.LAUNCHER_TITLEBAR_UPPERCASE), # fill=True, # margin_top=10, # ) # self.add_option(Option.LAUNCHER_THEME) # self.add_option(Option.LAUNCHER_FONT_SIZE) # self.add_option(Option.LAUNCHER_CLOSE_BUTTONS) self.layout.add( DefaultPrefsButton( self, options=[ "launcher_titlebar_bgcolor", "launcher_titlebar_bgcolor_inactive", "launcher_titlebar_fgcolor", "launcher_titlebar_fgcolor_inactive", "launcher_titlebar_font", Option.LAUNCHER_TITLEBAR_HEIGHT, Option.LAUNCHER_TITLEBAR_UPPERCASE, "launcher_window_bgcolor", Option.LAUNCHER_WINDOW_TITLE, ], ), margin_top=20, )
def on_changed(self): value = self.text().strip() get_settings(self).set(self.option, value)
def __init__(self, parent, option): text = get_settings(self).get(option) super().__init__(parent, text) self.option = option self.set_min_width(100) get_settings(self).add_listener(self)
def __current_color_changed(self, color): get_settings(self).set(self.option, Color(color).to_hex())
def __init__(self, parent): super().__init__(parent) # label = fsui.MultiLineLabel( # self, # gettext( # "These options only apply when you use the automatic WHDLoad " # "support in FS-UAE Launcher & Arcade. (*)" # ), # self.WIDTH, # ) # self.layout.add(label, fill=True, margin_top=0, margin_bottom=20) self.add_option( Option.WHDLOAD_VERSION, margin_top=0, warnings=[(key_path_override_warning, [Option.WHDLOAD_PATH])], ) self.add_divider() # FIXME: Show units with grayed out text after the main label? # "Splash delay: [unit text in gray]" self.add_option( Option.WHDLOAD_SPLASH_DELAY, # gettext("Splash delay (1/50ths seconds)"), gettext("Splash delay"), # margin_top=20, ) self.add_divider() self.add_option( Option.WHDLOAD_PRELOAD, gettext("Preload game into RAM"), # margin_top=20, ) self.add_divider() self.add_option( Option.WHDLOAD_QUIT_KEY, gettext("Quit key"), # margin_top=20 ) self.add_divider() # FIXME: Label should have a flag to enable HTML-like markup. # markup=True. Should default to false and "escape" special chars. # label = fsui.Label( # self, # gettext("WHDLoad.key file (For WHDLoad < 18.3):").replace( # "<", "<" # ), # ) label = self.create_option_label( self, gettext("WHDLoad.key file"), ) self.layout.add(label, margin_top=10) horilayout = fsui.HorizontalLayout() self.layout.add(horilayout, fill=True, margin_top=6) self.whdload_key_path_picker = FilePickerField( self, path=get_settings(self).get(Option.WHDLOAD_KEY_PATH), placeholder=gettext("Registration key For WHDLoad < 18.3"), ) self.whdload_key_path_picker.changed.connect( self.__on_whdload_key_path_changed) horilayout.add(self.whdload_key_path_picker, expand=True) helpbutton = OptionHelpButton(self, Option.WHDLOAD_KEY_PATH) horilayout.add(helpbutton, fill=True, margin_left=10) self.add_divider() label = self.create_option_label( self, gettext("Custom WHDLoad executable"), ) self.layout.add(label, margin_top=10) horilayout = fsui.HorizontalLayout() self.layout.add(horilayout, fill=True, margin_top=6) self.whdload_path_picker = FilePickerField( self, path=get_settings(self).get(Option.WHDLOAD_PATH), placeholder=gettext("Overrides WHDLoad version"), ) self.whdload_path_picker.changed.connect( self.__on_whdload_path_changed) horilayout.add(self.whdload_path_picker, expand=True) helpbutton = OptionHelpButton(self, Option.WHDLOAD_PATH) horilayout.add(helpbutton, fill=True, margin_left=10) # self.add_divider() label = fsui.MultiLineLabel( self, gettext( "These options only apply when you use the automatic WHDLoad " "support in FS-UAE Launcher & Arcade, for example when " "running WHDLoad variants from the online game database."), self.WIDTH, ) self.layout.add(label, fill=True, margin_top=20) self.layout.add( DefaultPrefsButton( self, options=[ Option.WHDLOAD_KEY_PATH, Option.WHDLOAD_PATH, Option.WHDLOAD_PRELOAD, Option.WHDLOAD_QUIT_KEY, Option.WHDLOAD_SPLASH_DELAY, Option.WHDLOAD_VERSION, ], ), margin_top=20, )
def __on_whdload_key_path_changed(self): get_settings(self).set(Option.WHDLOAD_KEY_PATH, self.whdload_key_path_picker.path())
def __init__(self, parent): super().__init__(parent) self.layout = HorizontalLayout() self.title = get_workspace_window_title() self.dragging = False self.dragging_mouse_origin = (0, 0) self.dragging_window_origin = (0, 0) self.buttons = [] theme = get_theme(self) self.height = theme.titlebar_height() self.set_min_height(self.height) button_size = (self.height, self.height) # fgcolor = theme.titlebar_fgcolor() # fgcolor_inactive = theme.titlebar_fgcolor_inactive() fgcolor = Color(0x000000) fgcolor_inactive = Color(0x000000) self.set_background_color(Color(0xFFFFFF)) menu = True if menu: self.menubutton = TitleBarButton( self, icon_name="TitleBarMenu", size=button_size, fgcolor=fgcolor, fgcolor_inactive=fgcolor_inactive, ) self.menubutton.activated.connect(self.__on_menu_activated) self.layout.add(self.menubutton) self.buttons.append(self.menubutton) else: self.menubutton = None self.layout.add_spacer(0, expand=True) self.volumebutton = VolumeButton(self) self.layout.add(self.volumebutton) self.monitorbutton = MonitorButton(self) self.layout.add(self.monitorbutton) self.fullscreenbutton = FullscreenToggleButton(self) self.layout.add(self.fullscreenbutton) self._window_active = True # parent.activated.connect(self.__on_window_activated) # parent.deactivated.connect(self.__on_window_deactivated) # FIXME: Would be better to do this via theme instead and get a theme # updated notification. Works well enough for now. for option in [ "launcher_titlebar_font", "launcher_titlebar_height", "launcher_titlebar_uppercase", ]: self.on_setting( option, get_settings(self).get(option), ) get_settings(self).add_listener(self)
def __on_reset_to_defaults(self): settings = get_settings(self) for option in self.options: settings.set(option, "")