def __init__(self, parent): app_name = "{} Launcher".format(Product.base_name) title = "{} - {}".format(gettext("About"), app_name) super().__init__(parent, title, minimizable=False, maximizable=False) self.theme = LauncherTheme.get() self.layout = VerticalLayout() self.layout.set_padding(20) self.icon_header = IconHeader( self, Icon("fs-uae-launcher", "pkg:launcher"), "{name} {version}".format(name=app_name, version=app.version), "Copyright © 2012-2020 Frode Solheim", ) self.layout.add(self.icon_header, fill=True, margin_bottom=20) # FIXME: Python version # FIXME: Qt version # FIXME: PyQt5 version # (FIXME: Linux distribution?) self.text_area = TextArea(self, about_message, read_only=True, font_family="monospace") self.text_area.scroll_to_start() self.text_area.set_min_width(760) self.text_area.set_min_height(340) self.layout.add(self.text_area, fill=True, expand=True) CloseButton.add_to_layout(self, self.layout, margin_top=20)
def __init__(self, parent): super().__init__(parent) self.layout = VerticalLayout() self.page_titles = [] self.pages = [] self.current_page = None
class ConfigPanel(Panel): def __init__(self, parent): super().__init__(parent) Skin.set_background_color(self) self.layout = VerticalLayout() self.config_widget_factory = ConfigWidgetFactory() def add_option(self, name, fill=True): self.layout.add( self.config_widget_factory.create(self, name), fill=fill, margin=10, margin_bottom=0, ) def add_amiga_option(self, name, fill=True, parent=None): if parent is None: parent = self parent.layout.add( self.config_widget_factory.create(parent, name, platforms=AMIGA_PLATFORMS), fill=fill, margin=10, margin_bottom=0, )
def __init__(self, parent): Panel.__init__(self, parent, paintable=True) self.set_min_height(29) # self.set_background_color(Color(0xd8, 0xd8, 0xd8)) self.layout = VerticalLayout() self.hori_layout = HorizontalLayout() if Skin.fws(): self.top_border_size = 2 else: self.top_border_size = 1 self.layout.add(self.hori_layout, fill=True, expand=True, margin_top=self.top_border_size) element = ProtectionElement(self) self.hori_layout.add(element, fill=True) element = WarningsElement(self) self.hori_layout.add(element, fill=True, expand=True) self.hori_layout.add_spacer(16) for language, icon_name in reversed([ ("en", "flag-gb"), ("de", "flag-de"), ("fr", "flag-fr"), ("es", "flag-es"), ("it", "flag-it"), ("ja", "flag-jp"), # ("", "flag-unknown"), ]): icon = Image("workspace:res/16/" + icon_name + ".png") element = LanguageElement(self, language, icon) self.hori_layout.add(element, fill=True) self.hori_layout.add_spacer(16) element = PlayersElement(self) self.hori_layout.add(element, fill=True) # for config_key, icon_name in [ # ("database_url", "database_url_16"), # ("hol_url", "hol_url_16"), # ("lemonamiga_url", "lemon_url_16"), # ("mobygames_url", "mobygames_url_16"), # ("wikipedia_url", "wikipedia_url_16"), # ]: # icon = Image("launcher:res/" + icon_name + ".png") # element = LinkButtonElement(self, config_key, icon) # self.hori_layout.add(element) element = WebLinkElement(self) self.hori_layout.add(element, fill=True) # this listener is added after all status bar children have # added their listeners, this is important for re-layout... LauncherConfig.add_listener(self)
class ConfigPanel(Panel): def __init__(self, parent): super().__init__(parent) Skin.set_background_color(self) self.layout = VerticalLayout() self.config_widget_factory = ConfigWidgetFactory() def add_option(self, name, fill=True): self.layout.add(self.config_widget_factory.create( self, name), fill=fill, margin=10, margin_bottom=0)
def __init__(self, parent): super().__init__( parent, title=get_workspace_window_title(), border=False, below=True, ) self.theme = get_launcher_theme(self) self.layout = VerticalLayout() self.background_widget = BackgroundWidget(self) self.layout.add(WorkspaceTitleBar(self), fill=True) # self.layout.padding_top = 300 # self.layout.padding_right = 300 # self.layout.padding_bottom = 300 # self.layout.padding_left = 300 self.set_background_color(self.theme.window_bgcolor()) print("\n\nFIXME: Hardcoded to use rightmost screen\n\n") rect = screen_rects()[-1] self.set_position_and_size((rect["x"], rect["y"]), (rect["w"], rect["h"])) # self.set_position((1920, 0)) # self.layout.add_spacer(0, expand=True) # horilayout = HorizontalLayout() # self.layout.add(horilayout, fill=True) # button = Button(self, "Close") # button.activated.connect(self.close) # horilayout.add(button) # button = Button(self, "Prefs") # button.activated.connect(self.__prefs) # horilayout.add(button) self.iconview = WorkspaceIconView(self) self.layout.add(self.iconview, expand=True, fill=True) # self.layout.add( # BottomDebugPanel(self, close=False, quit=True), fill=True # ) # self.layout.add(button) # self.layout.update() # FIXME: self.show_maximized() ? # FIXME: If we set maximized before show, then the button does not # appear ? self.show() self.set_maximized(True)
def __init__(self, parent): super().__init__( parent, title=gettext("Execute a file"), maximizable=False, minimizable=False, escape=True, ) vertlayout = VerticalLayout(20) self.layout.add(vertlayout, fill=True, expand=True) vertlayout.add(Label(self, gettext("Enter command and its arguments:"))) horilayout = HorizontalLayout() vertlayout.add(horilayout, fill=True, margin_top=10) horilayout.add(Label(self, gettext("Command:")), fill=True) self.textfield = TextField(self) self.textfield.set_min_width(300) self.textfield.activated.connect(self.__on_execute) horilayout.add(self.textfield, expand=True, fill=True, margin_left=10) # Creating execute button first, so it will become default for when # the user presses return in the text field. This only applies when # this dialog is implemented as an actual Dialog though. self.executebutton = Button(self, gettext("Execute")) self.executebutton.activated.connect(self.__on_execute) self.cancelbutton = Button(self, gettext("Cancel")) self.cancelbutton.activated.connect(self.__on_cancel) horilayout = HorizontalLayout() vertlayout.add(horilayout, fill=True, margin_top=20) horilayout.add_spacer(0, expand=True) horilayout.add(self.cancelbutton, margin_left=10) horilayout.add(self.executebutton, margin_left=10) self._command = ""
def __init__(self, parent): super().__init__(parent) # self.set_background_color(fsui.Color(0x999900)) # This min width is not important # self.set_min_width(400) horilayout = HorizontalLayout() self.layout.add(horilayout, fill=True, expand=True) vertlayout = VerticalLayout() horilayout.add(vertlayout, fill=True, expand=True) self.top_panel = Launcher2TopPanel(self) vertlayout.add(self.top_panel, fill=True) # self.running_panel = Launcher2RunningPanel(self) # vertlayout.add(self.running_panel, fill=True) # self.running_panel.set_visible(False) self.configpanel = ConfigPanel(self) # FIXME: Refer to theme? dialog_bg_color? self.configpanel.set_background_color( Color(Launcher2Colors.CONFIG_PANEL_COLOR) ) # self.configpanel.set_background_color(Color(0xBBBBBB)) vertlayout.add(self.configpanel, fill=True, expand=True) self.bottom_panel = Launcher2BottomPanel(self) self.layout.add(self.bottom_panel, fill=True) design_test = True if design_test: self.side = Launcher2SidePanel(self) horilayout.add(self.side, fill=True) # The Launcher should fit into a 1280x720 display, with # common/reasonable GUI elements such as a task bar. # Or maybe use 1366x768 # Or maybe 1280x768 to support 1280x1024 and 1366x768. # Windows 10 taskbar width/side: 62 pixels # Windows 10 taskbar height/bottom: 40 pixels # screen_size = (1280, 720) screen_size = (1366, 768) min_width = screen_size[0] - 62 # Subtracting an additional 40 For Launcher title bar min_height = screen_size[1] - 40 - 40 self.parent().set_min_size((min_width, min_height)) self.parent().left.set_min_width(380) self.parent().set_min_size((1280, 720 - 40)) # For now, make the minimum _client size_ 1280x720 which will cause # the window with decorations to be 1280x740. This should not be # the min. required size going forward though. Too big for # 768-height screens with bottom Windows 10 taskbar... # self.parent().set_min_size((1280, 720)) ConfigDispatch(self, {"__running": self.__on_running_config})
class Book(Panel): def __init__(self, parent): super().__init__(parent) self.layout = VerticalLayout() self.page_titles = [] self.pages = [] self.current_page = None def add_page(self, function, title=""): self.page_titles.append(title) self.pages.append(function) def set_page(self, page): print("Book.set_page", page) try: index = page + 0 except TypeError: for i, p in enumerate(self.pages): if page == p: index = i break else: raise Exception("page not found") if self.current_page: self.current_page.hide() self.layout.remove(self.current_page) if callable(self.pages[index]): page = self.pages[index](self) self.pages[index] = page else: page = self.pages[index] self.layout.add(page, fill=True, expand=True) self.current_page = page page.show() if hasattr(page, "on_show"): page.on_show() print("Book, about to call self.layout.update, size =", self.size()) # self.layout.set_size((1000, 100)) # self.layout.update() # self.layout.set_size(self.size()) self.layout.update()
def __init__( self, parent, icon, button_type=TYPE_TAB, left_padding=0, right_padding=0, ): Panel.__init__(self, parent, paintable=True) Skin.set_background_color(self) self.layout = VerticalLayout() # self.set_background_color((0xdd, 0xdd, 0xdd)) # self.set_min_width(Constants.TAB_WIDTH + left_padding + right_padding) # self.set_min_height(Constants.TAB_HEIGHT) self.set_min_size((64, 48)) self.group_id = 0 self.icon = icon self.type = button_type self.state = self.STATE_NORMAL self.hover = False self.left_padding = left_padding self.right_padding = right_padding self.bgcolor = get_theme(self).window_bgcolor()
def __init__(self, parent): super().__init__(parent) Skin.set_background_color(self) self.layout = VerticalLayout() self.config_widget_factory = ConfigWidgetFactory()
class StatusBar(Panel): def __init__(self, parent): Panel.__init__(self, parent, paintable=True) self.set_min_height(29) # self.set_background_color(Color(0xd8, 0xd8, 0xd8)) self.layout = VerticalLayout() self.hori_layout = HorizontalLayout() if Skin.fws(): self.top_border_size = 2 else: self.top_border_size = 1 self.layout.add(self.hori_layout, fill=True, expand=True, margin_top=self.top_border_size) element = ProtectionElement(self) self.hori_layout.add(element, fill=True) element = WarningsElement(self) self.hori_layout.add(element, fill=True, expand=True) self.hori_layout.add_spacer(16) for language, icon_name in reversed([ ("en", "flag-gb"), ("de", "flag-de"), ("fr", "flag-fr"), ("es", "flag-es"), ("it", "flag-it"), ("ja", "flag-jp"), # ("", "flag-unknown"), ]): icon = Image("workspace:res/16/" + icon_name + ".png") element = LanguageElement(self, language, icon) self.hori_layout.add(element, fill=True) self.hori_layout.add_spacer(16) element = PlayersElement(self) self.hori_layout.add(element, fill=True) # for config_key, icon_name in [ # ("database_url", "database_url_16"), # ("hol_url", "hol_url_16"), # ("lemonamiga_url", "lemon_url_16"), # ("mobygames_url", "mobygames_url_16"), # ("wikipedia_url", "wikipedia_url_16"), # ]: # icon = Image("launcher:res/" + icon_name + ".png") # element = LinkButtonElement(self, config_key, icon) # self.hori_layout.add(element) element = WebLinkElement(self) self.hori_layout.add(element, fill=True) # this listener is added after all status bar children have # added their listeners, this is important for re-layout... LauncherConfig.add_listener(self) def on_destroy(self): LauncherConfig.remove_listener(self) def on_config(self, key, value): unused(value) layout = False if key in ["languages", "protection"]: layout = True if layout: self.layout.update() def on_paint(self): dc = self.create_dc() size = self.size() if Skin.fws(): dc.draw_rectangle( 0, 0, size[0], 2, Color(0xe5, 0xe5, 0xe5, 0xff)) return color_1 = Skin.get_background_color() if color_1 is not None: color_1 = color_1.copy().darken(0.12) else: color_1 = Color(0x00, 0x00, 0x00, 0x30) dc.draw_line(0, 0, size[0], 0, color_1) self.draw_background(self, dc, offset=1, height=size[1] - 1) @classmethod def draw_element_background(cls, widget, dc): cls.draw_background(widget, dc) @classmethod def draw_background(cls, widget, dc, offset=None, height=None): size = widget.size() if Skin.fws(): return x = 0 y = 0 w = size[0] h = size[1] if offset is not None: y += offset if height is not None: h = height color_1 = Skin.get_background_color() color_2 = color_1 # if fsui.System.macosx: # color_1 = Color(0xa7, 0xa7, 0xa7) # color_2 = Color(0xc0, 0xc0, 0xc0) if color_1 is not None: color_1 = color_1.copy().darken(0.08) else: color_1 = Color(0x00, 0x00, 0x00, 0x20) color_2 = Color(0x00, 0x00, 0x00, 0x00) dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)
class StatusBar(Panel): def __init__(self, parent): Panel.__init__(self, parent, paintable=True) self.set_min_height(29) # self.set_background_color(Color(0xd8, 0xd8, 0xd8)) self.layout = VerticalLayout() self.hori_layout = HorizontalLayout() if Skin.fws(): self.top_border_size = 2 else: self.top_border_size = 1 self.layout.add(self.hori_layout, fill=True, expand=True, margin_top=self.top_border_size) element = ProtectionElement(self) self.hori_layout.add(element, fill=True) element = WarningsElement(self) self.hori_layout.add(element, fill=True, expand=True) self.hori_layout.add_spacer(16) for language, icon_name in reversed([ ("en", "flag-gb"), ("de", "flag-de"), ("fr", "flag-fr"), ("es", "flag-es"), ("it", "flag-it"), ("ja", "flag-jp"), # ("", "flag-unknown"), ]): icon = Image("workspace:res/16/" + icon_name + ".png") element = LanguageElement(self, language, icon) self.hori_layout.add(element, fill=True) self.hori_layout.add_spacer(16) element = PlayersElement(self) self.hori_layout.add(element, fill=True) # for config_key, icon_name in [ # ("database_url", "database_url_16"), # ("hol_url", "hol_url_16"), # ("lemonamiga_url", "lemon_url_16"), # ("mobygames_url", "mobygames_url_16"), # ("wikipedia_url", "wikipedia_url_16"), # ]: # icon = Image("launcher:res/" + icon_name + ".png") # element = LinkButtonElement(self, config_key, icon) # self.hori_layout.add(element) element = WebLinkElement(self) self.hori_layout.add(element, fill=True) # this listener is added after all status bar children have # added their listeners, this is important for re-layout... LauncherConfig.add_listener(self) def on_destroy(self): LauncherConfig.remove_listener(self) def on_config(self, key, value): unused(value) layout = False if key in ["languages", "protection"]: layout = True if layout: self.layout.update() def on_paint(self): dc = self.create_dc() size = self.size() if Skin.fws(): dc.draw_rectangle(0, 0, size[0], 2, Color(0xe5, 0xe5, 0xe5, 0xff)) return color_1 = Skin.get_background_color() if color_1 is not None: color_1 = color_1.copy().darken(0.12) else: color_1 = Color(0x00, 0x00, 0x00, 0x30) dc.draw_line(0, 0, size[0], 0, color_1) self.draw_background(self, dc, offset=1, height=size[1] - 1) @classmethod def draw_element_background(cls, widget, dc): cls.draw_background(widget, dc) @classmethod def draw_background(cls, widget, dc, offset=None, height=None): size = widget.size() if Skin.fws(): return x = 0 y = 0 w = size[0] h = size[1] if offset is not None: y += offset if height is not None: h = height color_1 = Skin.get_background_color() color_2 = color_1 # if fsui.System.macosx: # color_1 = Color(0xa7, 0xa7, 0xa7) # color_2 = Color(0xc0, 0xc0, 0xc0) if color_1 is not None: color_1 = color_1.copy().darken(0.08) else: color_1 = Color(0x00, 0x00, 0x00, 0x20) color_2 = Color(0x00, 0x00, 0x00, 0x00) dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)
def __init__(self, parent, *, exception, backtrace, recoverable=False): self.theme = get_launcher_theme(self) window_parent = None if recoverable: title = "Recoverable Alert" else: title = "Software Failure" minimizable = False maximizable = False super().__init__(window_parent, title, border=False) self.layout = VerticalLayout() if recoverable: text_color = Color(0xFFAA22) # background_color = Color(0x111111) title_foreground_color = Color(0x000000) title_background_color = Color(0xFFAA22) else: text_color = Color(0xFF2222) title_foreground_color = Color(0x000000) title_background_color = Color(0xFF2222) background_color = Color(0x181818) self.set_background_color(background_color) if not self.theme.titlebar_system(): self.__titlebar = TitleBar( self, title=title, minimizable=minimizable, maximizable=maximizable, # foreground_color=Color(0xFFFFFF), # background_color=Color(0x282828), foreground_color=title_foreground_color, background_color=title_background_color, foreground_inactive_color=Color(0xCCCCCC), background_inactive_color=Color(0x333333), ) self.layout.add(self.__titlebar, fill=True) self.errorpanel = ExceptionPanel(self, title, exception, background_color, text_color) self.layout.add(self.errorpanel, fill=True, expand=True) # FIXME: For frozen version, we might want to clean up the file # references, so absolute paths from the development host is removed. text = f"{exception}\n\n{backtrace}" self.textarea = TextArea( self, text=text, read_only=True, border=False, text_color=Color(0xFFFFFF), background_color=background_color, padding=20, ) self.textarea.set_min_size((640, 320)) # FIXME: Include a suitable fixed-with font with the launcher and use # that? This font might not be available. self.textarea.set_font(Font("Courier New", 14)) self.textarea.scroll_to_start() self.layout.add(self.textarea, fill=True, expand=True)