Beispiel #1
0
    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)
Beispiel #2
0
    def __init__(self, parent):
        if fsgs.product == "OpenRetro":
            app_name = "OpenRetro Launcher"
        else:
            app_name = "FS-UAE Launcher"
        title = "{} - {}".format(gettext("About"), app_name)
        super().__init__(parent, title, minimizable=False, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.set_padding(20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("fs-uae-launcher", "pkg:launcher"),
            "{name} {version}".format(name=app_name, version=app.version),
            "Copyright © 2012-2017 Frode Solheim",
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        self.text_area = fsui.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)
Beispiel #3
0
    def __init__(self, parent):
        if fsgs.product == "OpenRetro":
            app_name = "OpenRetro Launcher"
        else:
            app_name = "FS-UAE Launcher"
        title = "{} - {}".format(gettext("About"), app_name)
        super().__init__(parent, title, minimizable=False, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.set_padding(20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("fs-uae-launcher", "pkg:launcher"),
            "{name} {version}".format(name=app_name, version=app.version),
            "Copyright © 2012-2017 Frode Solheim",
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        self.text_area = fsui.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):
     fsui.Panel.__init__(self, parent)
     self.layout = fsui.VerticalLayout()
     self.import_rom_group = ImportGroup(self)
     self.layout.add(self.import_rom_group, fill=True)
     self.layout.add_spacer(20)
     self.import_af_group = ImportGroup(self, ImportGroup.AMIGA_FOREVER)
     self.layout.add(self.import_af_group, fill=True)
     self.layout.add_spacer(20)
     self.scan_kickstart_group = ScanKickstartGroup(self)
     self.layout.add(self.scan_kickstart_group, fill=True)
     CloseButton.add_to_layout(self, self.layout, margin_top=20)
Beispiel #5
0
    def __init__(self, parent, path, import_type):
        if import_type == self.AMIGA_FOREVER:
            title = gettext("Import From Amiga Forever CD/DVD")
        else:
            title = gettext("Import Kickstarts and ROMs")
        super().__init__(parent, title, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.padding_left = 20
        self.layout.padding_top = 20
        self.layout.padding_right = 20
        self.layout.padding_bottom = 20

        self.text_area = fsui.TextArea(self, read_only=True)
        self.text_area.set_min_width(600)
        self.text_area.set_min_height(300)
        self.layout.add(self.text_area)

        self.close_button = CloseButton.add_to_layout(
            self, self.layout, margin_top=20
        )
        if self.close_button:
            self.close_button.disable()

        self.line_count = 0
        self.task = ImportTask(path, import_type)
        self.task.start()

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        fsui.call_later(TIMER_INTERVAL, self.on_timer)
    def __init__(self, parent, path, import_type):
        if import_type == self.AMIGA_FOREVER:
            title = gettext("Import From Amiga Forever CD/DVD")
        else:
            title = gettext("Import Kickstarts and ROMs")
        super().__init__(parent, title, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()
        self.layout.padding_left = 20
        self.layout.padding_top = 20
        self.layout.padding_right = 20
        self.layout.padding_bottom = 20

        self.text_area = fsui.TextArea(self, read_only=True)
        self.text_area.set_min_width(600)
        self.text_area.set_min_height(300)
        self.layout.add(self.text_area)

        self.close_button = CloseButton.add_to_layout(self,
                                                      self.layout,
                                                      margin_top=20)
        if self.close_button:
            self.close_button.set_enabled(False)

        self.line_count = 0
        self.task = ImportTask(path, import_type)
        self.task.start()

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        fsui.call_later(TIMER_INTERVAL, self.on_timer)
Beispiel #7
0
    def __init__(self, parent=None):
        title = gettext("OpenRetro Locker Uploader")
        super().__init__(parent, title)
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()
        self.set_icon(fsui.Icon("refresh", "pkg:workspace"))

        self.layout.min_width = 600
        self.layout.set_padding(20, 20, 20, 20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("refresh", "pkg:workspace"),
            gettext("OpenRetro Locker Uploader"),
            gettext("Upload recognized Amiga files to your OpenRetro locker"),
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)

        self.upload_button = fsui.Button(self, gettext("Upload"))
        self.upload_button.activated.connect(self.on_upload_activated)
        hori_layout.add(self.upload_button, margin_left=10)

        self.stop_button = fsui.Button(self, gettext("Stop"))
        self.stop_button.activated.connect(self.on_stop_activated)
        self.stop_button.disable()
        hori_layout.add(self.stop_button, margin_left=10)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, margin_left=10)
        else:
            self.close_button = None

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        self.task = None
Beispiel #8
0
    def __init__(self, parent=None):
        title = gettext("Log Out from Your OpenRetro Account")
        super().__init__(parent, title, minimizable=False, maximizable=False)
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()
        self.set_icon(fsui.Icon("password", "pkg:workspace"))

        self.layout.set_padding(20, 20, 20, 20)

        heading_layout = fsui.HorizontalLayout()
        self.layout.add(heading_layout)
        heading_layout.add(
            fsui.ImageView(self,
                           fsui.Image("workspace:/data/48/password.png")))
        heading_layout.add_spacer(20)
        heading_layout_2 = fsui.VerticalLayout()
        heading_layout.add(heading_layout_2,
                           expand=True,
                           fill=False,
                           valign=0.5)
        heading_layout_2.add(
            fsui.HeadingLabel(self,
                              gettext("Log Out from Your OpenRetro Account")))
        heading_layout_2.add_spacer(2)
        heading_layout_2.add(
            fsui.Label(
                self,
                gettext("While logged out you will not get "
                        "database updates"),
            ))

        self.layout.add_spacer(20)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)
        hori_layout.add_spacer(20)

        self.logout_button = fsui.Button(self, gettext("Log Out"))
        # self.logout_button.set_enabled(False)
        self.logout_button.activated.connect(self.__logout_activated)
        hori_layout.add(self.logout_button)

        if self.window().theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, fill=True, margin_left=10)
Beispiel #9
0
    def __init__(self, parent):
        super().__init__(parent, gettext("Setup Wizard"),
                         minimizable=False, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()

        page = SetupWelcomePage(self)
        self.layout.add(page, expand=True, fill=True)

        button_layout = fsui.HorizontalLayout()
        self.layout.add(button_layout, fill=True, margin=20)
        button_layout.add_spacer(0, expand=True)
        self.prev_button = PrevButton(self)
        button_layout.add(self.prev_button, fill=True, margin_left=10)
        self.next_button = NextButton(self)
        button_layout.add(self.next_button, fill=True, margin_left=10)
        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            button_layout.add(self.close_button, fill=True, margin_left=10)
Beispiel #10
0
    def __init__(self, parent=None):
        print("RefreshWindow parent =", parent)
        title = gettext("Updating Database")
        super().__init__(parent, title, maximizable=False)
        self.set_icon(fsui.Icon("refresh", "pkg:workspace"))
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()

        self.layout.min_width = 500
        self.layout.set_padding(20, 20, 20, 20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("refresh", "pkg:workspace"),
            gettext("Updating Database"),
            "",
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)
        hori_layout.add_spacer(20)
        self.stop_button = fsui.Button(self, gettext("Stop"))
        self.stop_button.activated.connect(self.on_abort_activated)
        hori_layout.add(self.stop_button)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, fill=True, margin_left=10)

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.task = DatabaseRefreshTask()
        self.task.progressed.connect(self.on_progress)
        self.task.failed.connect(self.on_failure)
        self.task.succeeded.connect(self.close)
        self.task.stopped.connect(self.close)
        self.task.start()
Beispiel #11
0
    def __init__(self, parent=None):
        title = gettext("OAGD.net Locker Uploader")
        super().__init__(parent, title)
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()
        self.set_icon(fsui.Icon("refresh", "pkg:workspace"))

        self.layout.min_width = 600
        self.layout.set_padding(20, 20, 20, 20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("refresh", "pkg:workspace"),
            gettext("OAGD.net Locker Uploader"),
            gettext("Upload recognized Amiga files to your OAGD.net locker"),
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)

        self.upload_button = fsui.Button(self, gettext("Upload"))
        self.upload_button.activated.connect(self.on_upload_activated)
        hori_layout.add(self.upload_button, margin_left=10)

        self.stop_button = fsui.Button(self, gettext("Stop"))
        self.stop_button.activated.connect(self.on_stop_activated)
        self.stop_button.disable()
        hori_layout.add(self.stop_button, margin_left=10)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, margin_left=10)
        else:
            self.close_button = None

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        self.task = None
Beispiel #12
0
    def __init__(self, parent=None):
        print("LoginWindow, parent =", parent)
        super().__init__(parent, gettext("Log In to Your OAGD.net Account"))
        self.set_icon(fsui.Icon("password", "pkg:workspace"))
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()

        self.layout.set_padding(20, 20, 20, 20)

        heading_layout = fsui.HorizontalLayout()
        self.layout.add(heading_layout)
        heading_layout.add(
            fsui.ImageView(self, fsui.Image("workspace:res/48/password.png")))
        heading_layout.add_spacer(20)
        heading_layout_2 = fsui.VerticalLayout()
        heading_layout.add(heading_layout_2,
                           expand=True,
                           fill=False,
                           valign=0.5)
        heading_layout_2.add(
            fsui.HeadingLabel(self,
                              gettext("Log In to Your OAGD.net Account")))
        heading_layout_2.add_spacer(2)
        heading_layout_2.add(
            fsui.Label(
                self,
                gettext("Logging in will enable the online game database "
                        "and more")))

        self.username_field = fsui.TextField(
            self, app.settings["database_email"].strip())
        self.password_field = fsui.PasswordField(self)
        if self.username_field.get_text():
            self.password_field.focus()

        self.layout.add_spacer(20)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        label = fsui.Label(self, gettext("E-mail:"))
        label.set_min_width(100)
        hori_layout.add(label)
        hori_layout.add_spacer(20)
        # self.username_field.select_all()
        self.username_field.changed.connect(self.on_text_field_changed)
        self.username_field.activated.connect(self.on_username_activated)
        hori_layout.add(self.username_field, expand=True)

        self.layout.add_spacer(10)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        label = fsui.Label(self, gettext("Password:"******"Don't have an account already?"))
        hori_layout.add(label)
        hori_layout.add_spacer(20)
        label = fsui.URLLabel(
            self, gettext("Create an account now"),
            "https://oagd.net/user/register?referrer=fs-uae-launcher")
        hori_layout.add(label, expand=True)

        self.layout.add_spacer(6)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        label = fsui.Label(self, gettext("Forgot your password?"))
        hori_layout.add(label)
        hori_layout.add_spacer(20)
        self.reset_label = fsui.URLLabel(
            self, gettext("Reset password via e-mail"),
            "https://oagd.net/user/reset?referrer=fs-uae-launcher")
        hori_layout.add(self.reset_label, expand=True)

        self.layout.add_spacer(20)
        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)
        hori_layout.add_spacer(20)

        self.login_button = fsui.Button(self, gettext("Log In"))
        self.login_button.disable()
        self.login_button.activated.connect(self.on_login_activated)
        hori_layout.add(self.login_button)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, fill=True, margin_left=10)

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        if len(self.username_field.text()) == 0:
            self.username_field.focus()
        else:
            self.password_field.focus()
Beispiel #13
0
    def __init__(self, parent, device_name):
        title = gettext("Configure {device_name}").format(
            device_name=device_name
        )
        super().__init__(
            parent,
            title=title,
            minimizable=False,
            maximizable=False,
            separator=False,
        )
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()

        self.image = fsui.Image("workspace:res/gamepad-config.png")
        self.joystick_panel = fsui.ImageView(self, self.image)
        self.layout.add(self.joystick_panel)

        if Skin.fws():
            from workspace.ui import TitleSeparator

            separator = TitleSeparator(self)
            self.layout.add(separator, fill=True)

        self.mapping_field = fsui.TextArea(
            self, read_only=True, line_wrap=False
        )
        self.layout.add(
            self.mapping_field,
            fill=True,
            margin_left=20,
            margin_top=20,
            margin_right=20,
        )

        panel = fsui.Panel(self)
        self.layout.add(panel, fill=True)

        panel.layout = fsui.HorizontalLayout()
        panel.layout.padding = 20

        self.device_type_ids = [
            "",
            "gamepad",
            "joystick",
            # "flightstick",
            "other",
        ]
        self.device_type_labels = [
            gettext("Choose Type"),
            gettext("Gamepad"),
            gettext("Digital Joystick"),
            # gettext("Flight Stick"),
            gettext("Other Device"),
        ]

        self.reset_button = fsui.Button(panel, gettext("Reset"))
        self.reset_button.activated.connect(self.on_reset_button)
        panel.layout.add(self.reset_button)

        self.priority_type_ids = [
            "axis,hat,button",
            "hat,button,axis",
        ]
        self.priority_type_labels = [
            gettext("Axes, hats, buttons"),
            gettext("Hats, buttons, axes"),
        ]
        self.priority_choice = fsui.Choice(panel, self.priority_type_labels)
        panel.layout.add(self.priority_choice, margin_left=20)

        self.type_field = fsui.Choice(panel, self.device_type_labels)
        panel.layout.add(self.type_field, margin_left=20)

        # panel.layout.add(
        #     fsui.PlainLabel(panel, gettext("Make:")), margin_left=20
        # )
        # self.make_field = fsui.TextField(panel)
        # self.make_field.set_min_width(140)
        # panel.layout.add(self.make_field, margin_left=10)

        panel.layout.add(
            fsui.PlainLabel(panel, gettext("Model:")), margin_left=20
        )
        self.model_field = fsui.TextField(panel)
        panel.layout.add(self.model_field, expand=True, margin_left=10)

        self.save_button = fsui.Button(panel, gettext("Save"))
        self.save_button.activated.connect(self.on_save_button)
        panel.layout.add(self.save_button, margin_left=20)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(panel)
            panel.layout.add(self.close_button, margin_left=10)

        self.device_name = device_name
        existing_config = self.read_existing_config()

        self.button_panels = []
        for x, y, direction, name in BUTTONS:
            b = MappingButton(self.joystick_panel, (x, y + 4), direction, name)
            self.button_panels.append(b)
            if name in existing_config:
                b.event_name = existing_config[name]

        self.type_field.changed.connect(self.on_change)
        # self.make_field.changed.connect(self.on_change)
        self.model_field.changed.connect(self.on_change)

        self.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        self.previous_timer_state = {}
        self.current_state = {}
        self.initial_state = {}
        self.map_key_name = None

        fsui.call_later(100, self.on_timer_callback)
        thread = threading.Thread(
            target=event_thread,
            name="JoystickConfigEventThread",
            args=(self.device_name, weakref.ref(self)),
        )
        thread.start()
Beispiel #14
0
class LockerUploaderWindow(fsui.DialogWindow):
    @classmethod
    def open(cls, parent=None):
        return fsui.open_window_instance(cls, parent)

    def __init__(self, parent=None):
        title = gettext("OAGD.net Locker Uploader")
        super().__init__(parent, title)
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()
        self.set_icon(fsui.Icon("refresh", "pkg:workspace"))

        self.layout.min_width = 600
        self.layout.set_padding(20, 20, 20, 20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("refresh", "pkg:workspace"),
            gettext("OAGD.net Locker Uploader"),
            gettext("Upload recognized Amiga files to your OAGD.net locker"),
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)

        self.upload_button = fsui.Button(self, gettext("Upload"))
        self.upload_button.activated.connect(self.on_upload_activated)
        hori_layout.add(self.upload_button, margin_left=10)

        self.stop_button = fsui.Button(self, gettext("Stop"))
        self.stop_button.activated.connect(self.on_stop_activated)
        self.stop_button.disable()
        hori_layout.add(self.stop_button, margin_left=10)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, margin_left=10)
        else:
            self.close_button = None

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        self.task = None

    def __del__(self):
        print("LockerUploaderWindow.__del__")

    def on_close(self):
        if self.task is not None:
            self.task.stop()

    # def on_close_activated(self):
    #     self.close()

    def on_upload_activated(self):
        if self.close_button:
            self.close_button.disable()
        self.upload_button.disable()
        self.stop_button.enable()
        self.task = LockerUploaderTask()
        self.task.progressed.connect(self.on_progress)
        self.task.failed.connect(self.on_failure)
        self.task.succeeded.connect(self.on_success)
        self.task.stopped.connect(self.on_stopped)
        self.task.start()

    def on_stop_activated(self):
        self.task.stop()
        if self.close_button:
            self.stop_button.disable()

    def on_stopped(self):
        self.icon_header.subtitle_label.set_text(gettext("Stopped by user"))
        self.after_task_has_stopped()

    def on_success(self):
        self.after_task_has_stopped()

    def on_failure(self, message):
        fsui.show_error(message, parent=self.get_window())
        self.after_task_has_stopped()

    def after_task_has_stopped(self):
        if self.close_button:
            self.close_button.enable()
        self.upload_button.enable()
        self.stop_button.disable()

    def on_progress(self, message):
        if not isinstance(message, str):
            message = message[0]
        self.icon_header.subtitle_label.set_text(message)
Beispiel #15
0
    def __init__(self, parent, title):
        super().__init__(parent, title, minimizable=False, maximizable=False)
        self.theme = LauncherTheme.get()
        self.layout = fsui.VerticalLayout()

        # self.layout.set_padding(20)
        layout = self.layout

        h_layout = fsui.HorizontalLayout()
        layout.add(h_layout, fill=True, expand=True)

        layout_2 = fsui.VerticalLayout()
        # layout_2.padding_top = 20
        # layout_2.padding_bottom = 20
        # layout_2.padding_left = 20

        self.list_view = fsui.ListView(self, border=False)
        self.list_view.set_min_width(240)
        self.list_view.item_selected.connect(self.on_select_item)

        self.list_view.set_row_height(
            self.window.theme.sidebar_list_row_height)
        self.list_view.setStyleSheet("""
        QListView {{
            padding-top: 20px;
            background-color: {base};
            outline: none;
        }}
        QListView::item {{
            padding-left: 20px;
            border: 0px;
        }}
        QListView::item:selected {{
            background-color: {row_bg};
            color: {row_fg};
        }}
        """.format(
            row_fg=self.window.theme.sidebar_list_row_text.to_hex(),
            row_bg=self.window.theme.sidebar_list_row_background.to_hex(),
            base=self.window.theme.sidebar_list_background.to_hex()))
        layout_2.add(self.list_view, fill=True, expand=True)
        h_layout.add(layout_2, fill=True)

        # h_layout.add_spacer(20)

        v_layout = fsui.VerticalLayout()
        h_layout.add(v_layout, fill=True, expand=True)

        use_scrolling = False
        if use_scrolling:
            # FIXME: Problems with page height
            scroll_area = fsui.VerticalScrollArea(self)
            self.page_container = fsui.Panel(scroll_area)
            self.page_container.layout = fsui.VerticalLayout()
            scroll_area.set_widget(self.page_container)
            v_layout.add(scroll_area, fill=True, expand=True)
        else:
            self.page_container = fsui.Panel(self)
            self.page_container.layout = fsui.VerticalLayout()
            v_layout.add(self.page_container, fill=True, expand=True)

        # self.layout.add_spacer(20)

        # h_layout = fsui.HorizontalLayout()
        # layout.add(h_layout, fill=True)

        self.page_titles = []
        self.pages = []

        # self.add_page(_("Hardware"), HardwarePage)
        # self.add_page(_("Hard Drives"), HardDrivesPage)
        # elf.add_page(_("Custom Options"), CustomOptionsPage)

        self.button_layout = fsui.HorizontalLayout()
        v_layout.add(self.button_layout, fill=True, margin=20, margin_top=0)
        if self.window.theme.has_close_buttons:
            self.button_layout.add_spacer(expand=True)
            self.close_button = CloseButton(self)
            self.button_layout.add(
                self.close_button, fill=True, margin_left=10)

        self.current_page = None

        # self.page_container.set_min_width(600)
        # self.page_container.set_min_height(640)
        # self.set_size_from_layout()
        self.set_size((840, 640))
        self.center_on_parent()
Beispiel #16
0
class LockerUploaderWindow(fsui.DialogWindow):
    @classmethod
    def open(cls, parent=None):
        return fsui.open_window_instance(cls, parent)

    def __init__(self, parent=None):
        title = gettext("OpenRetro Locker Uploader")
        super().__init__(parent, title)
        self.theme = WorkspaceTheme.instance()
        self.layout = fsui.VerticalLayout()
        self.set_icon(fsui.Icon("refresh", "pkg:workspace"))

        self.layout.min_width = 600
        self.layout.set_padding(20, 20, 20, 20)

        self.icon_header = IconHeader(
            self,
            fsui.Icon("refresh", "pkg:workspace"),
            gettext("OpenRetro Locker Uploader"),
            gettext("Upload recognized Amiga files to your OpenRetro locker"),
        )
        self.layout.add(self.icon_header, fill=True, margin_bottom=20)

        hori_layout = fsui.HorizontalLayout()
        self.layout.add(hori_layout, fill=True)
        self.created_label = fsui.Label(self, "")
        hori_layout.add(self.created_label, expand=True)

        self.upload_button = fsui.Button(self, gettext("Upload"))
        self.upload_button.activated.connect(self.on_upload_activated)
        hori_layout.add(self.upload_button, margin_left=10)

        self.stop_button = fsui.Button(self, gettext("Stop"))
        self.stop_button.activated.connect(self.on_stop_activated)
        self.stop_button.disable()
        hori_layout.add(self.stop_button, margin_left=10)

        if self.window.theme.has_close_buttons:
            self.close_button = CloseButton(self)
            hori_layout.add(self.close_button, margin_left=10)
        else:
            self.close_button = None

        self.set_size(self.layout.get_min_size())
        self.center_on_parent()
        self.task = None

    def __del__(self):
        print("LockerUploaderWindow.__del__")

    def on_close(self):
        if self.task is not None:
            self.task.stop()

    # def on_close_activated(self):
    #     self.close()

    def on_upload_activated(self):
        if self.close_button:
            self.close_button.disable()
        self.upload_button.disable()
        self.stop_button.enable()
        self.task = LockerUploaderTask()
        self.task.progressed.connect(self.on_progress)
        self.task.failed.connect(self.on_failure)
        self.task.succeeded.connect(self.on_success)
        self.task.stopped.connect(self.on_stopped)
        self.task.start()

    def on_stop_activated(self):
        self.task.stop()
        if self.close_button:
            self.stop_button.disable()

    def on_stopped(self):
        self.icon_header.subtitle_label.set_text(gettext("Stopped by user"))
        self.after_task_has_stopped()

    def on_success(self):
        self.after_task_has_stopped()

    def on_failure(self, message):
        fsui.show_error(message, parent=self.get_window())
        self.after_task_has_stopped()

    def after_task_has_stopped(self):
        if self.close_button:
            self.close_button.enable()
        self.upload_button.enable()
        self.stop_button.disable()

    def on_progress(self, message):
        if not isinstance(message, str):
            message = message[0]
        self.icon_header.subtitle_label.set_text(message)