Ejemplo n.º 1
0
    def __init__(self, parent):
        # fsui.VerticalItemView.__init__(self, parent, border=(not Skin.fws()))
        fsui.VerticalItemView.__init__(self, parent, border=False)
        self.items = []
        self.game_icon = fsui.Image("launcher:res/16x16/controller.png")
        self.config_icon = fsui.Image("launcher:res/fsuae_config_16.png")

        self.manual_download_icon = fsui.Image(
            "launcher:res/16x16/arrow_down_yellow.png")
        self.auto_download_icon = fsui.Image(
            "launcher:res/16x16/arrow_down_green.png")
        self.blank_icon = fsui.Image("launcher:res/16x16/blank.png")
        self.missing_color = fsui.Color(0xa8, 0xa8, 0xa8)
        self.platform_icons = {}

        from workspace.ui.theme import WorkspaceTheme
        theme = WorkspaceTheme.instance()
        self.set_row_height(28)
        # self.list_view.set_background_color(fsui.Color(0xeb, 0xeb, 0xeb))
        self.setStyleSheet("""
        QListView {{
            background-color: {0};
            outline: none;
        }}
        QListView::item {{
            padding-left: 6px;
            border: 0px;
        }}
        QListView::item:selected {{
            background-color: {1};
        }}
        """.format(theme.sidebar_background.to_hex(),
                   theme.selection_background.to_hex()))
Ejemplo n.º 2
0
    def draw_selected_tab(cls, widget, dc):
        line_color_1 = Skin.get_background_color()
        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme

            theme = WorkspaceTheme.instance()
            line_color_1 = theme.title_separator_color
            line_color_2 = line_color_1
        elif fsbc.system.macosx and False:
            line_color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
            line_color_2 = Skin.get_background_color().mix(
                fsui.Color(0xFF, 0xFF, 0xFF)
            )
        elif line_color_1 is not None:
            line_color_2 = Skin.get_background_color().mix(
                fsui.Color(0xFF, 0xFF, 0xFF)
            )
        else:
            line_color_1 = fsui.Color(0xFF, 0xFF, 0xFF, 0x00)
            line_color_2 = fsui.Color(0xFF, 0xFF, 0xFF, 0xA0)

        size = widget.size()
        dc.draw_vertical_gradient(0, 0, 2, size[1], line_color_1, line_color_2)
        dc.draw_vertical_gradient(
            size[0] - 2, 0, 2, size[1], line_color_1, line_color_2
        )
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
    def __init__(self):
        from fsui.qt import QPalette
        palette = QPalette()
        self.sidebar_list_background = fsui.Color(
            palette.color(QPalette.Base))
        self.sidebar_list_row_height = 28
        self.sidebar_list_row_text = fsui.Color(
            palette.color(QPalette.HighlightedText))
        self.sidebar_list_row_background = fsui.Color(
            palette.color(QPalette.Highlight))

        if Skin.fws():
            from workspace.ui.theme import WorkspaceTheme as WorkspaceTheme
            ws_theme = WorkspaceTheme.instance()
            self.sidebar_list_background = ws_theme.sidebar_background
            self.sidebar_list_row_text = fsui.Color(0xff, 0xff, 0xff)
            self.sidebar_list_row_background = ws_theme.selection_background
        elif Skin.windows_10():
            self.sidebar_list_background = fsui.Color(0xe2, 0xe2, 0xe2)
Ejemplo n.º 5
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
Ejemplo n.º 6
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
Ejemplo n.º 7
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()
Ejemplo n.º 8
0
    def draw_border(cls, widget, dc):
        size = widget.size()

        line_color_1 = Skin.get_background_color()
        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme
            theme = WorkspaceTheme.instance()
            line_color_1 = theme.title_separator_color
            line_color_2 = line_color_1
        elif line_color_1 is not None:
            line_color_1 = line_color_1.mix(fsui.Color(0xff, 0xff, 0xff))
            line_color_2 = line_color_1
        else:
            line_color_1 = fsui.Color(0xff, 0xff, 0xff, 0xa0)
            line_color_2 = line_color_1

        # line_color_1 = fsui.Color(0xff, 0x00, 0x00, 0xff)
        # line_color_2 = fsui.Color(0x00, 0xff, 0x00, 0xff)

        dc.draw_line(0, size[1] - 2, size[0], size[1] - 2, line_color_1)
        dc.draw_line(0, size[1] - 1, size[0], size[1] - 1, line_color_2)
Ejemplo n.º 9
0
    def __init__(self):
        from fsui.qt import QPalette

        palette = QPalette()
        self.sidebar_list_background = fsui.Color(palette.color(QPalette.Base))
        self.sidebar_list_row_height = 28
        self.sidebar_list_row_text = fsui.Color(
            palette.color(QPalette.HighlightedText)
        )
        self.sidebar_list_row_background = fsui.Color(
            palette.color(QPalette.Highlight)
        )

        if Skin.fws():
            from workspace.ui.theme import WorkspaceTheme as WorkspaceTheme

            ws_theme = WorkspaceTheme.instance()
            self.sidebar_list_background = ws_theme.sidebar_background
            self.sidebar_list_row_text = fsui.Color(0xFF, 0xFF, 0xFF)
            self.sidebar_list_row_background = ws_theme.selection_background
        elif Skin.windows_10():
            self.sidebar_list_background = fsui.Color(0xE2, 0xE2, 0xE2)
Ejemplo n.º 10
0
    def draw_border(cls, widget, dc):
        size = widget.size()

        line_color_1 = Skin.get_background_color()
        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme

            theme = WorkspaceTheme.instance()
            line_color_1 = theme.title_separator_color
            line_color_2 = line_color_1
        elif line_color_1 is not None:
            line_color_1 = line_color_1.mix(fsui.Color(0xFF, 0xFF, 0xFF))
            line_color_2 = line_color_1
        else:
            line_color_1 = fsui.Color(0xFF, 0xFF, 0xFF, 0xA0)
            line_color_2 = line_color_1

        # line_color_1 = fsui.Color(0xff, 0x00, 0x00, 0xff)
        # line_color_2 = fsui.Color(0x00, 0xff, 0x00, 0xff)

        dc.draw_line(0, size[1] - 2, size[0], size[1] - 2, line_color_1)
        dc.draw_line(0, size[1] - 1, size[0], size[1] - 1, line_color_2)
Ejemplo n.º 11
0
    def draw_selected_tab(cls, widget, dc):
        line_color_1 = Skin.get_background_color()
        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme
            theme = WorkspaceTheme.instance()
            line_color_1 = theme.title_separator_color
            line_color_2 = line_color_1
        elif fsbc.system.macosx and False:
            line_color_1 = fsui.Color(0xa7, 0xa7, 0xa7)
            line_color_2 = Skin.get_background_color().mix(
                fsui.Color(0xff, 0xff, 0xff))
        elif line_color_1 is not None:
            line_color_2 = Skin.get_background_color().mix(
                fsui.Color(0xff, 0xff, 0xff))
        else:
            line_color_1 = fsui.Color(0xff, 0xff, 0xff, 0x00)
            line_color_2 = fsui.Color(0xff, 0xff, 0xff, 0xa0)

        size = widget.size()
        dc.draw_vertical_gradient(0, 0, 2, size[1], line_color_1, line_color_2)
        dc.draw_vertical_gradient(size[0] - 2, 0, 2, size[1], line_color_1,
                                  line_color_2)
Ejemplo n.º 12
0
    def __init__(
        self,
        parent,
        title="",
        border=True,
        minimizable=True,
        maximizable=True,
        separator=True,
        menu=False,
        native=None,
        header=True,
        below=False,
        closable=True,
        color=None,
        **_
    ):
        init_qt()
        super().__init__()

        # if parent is None and len(default_window_parent) > 0:
        #     parent = default_window_parent[-1]
        #     print("using default parent", parent)

        # FIXME
        self._window = weakref.ref(self)

        if native is None:
            if fsboot.get("fws") == "1":
                native = False
            else:
                native = not _use_fws
        if native:
            self._real_window = RealWindow(
                QParent(parent, True),
                self,
                minimizable=minimizable,
                maximizable=maximizable,
                below=below,
                border=border,
            )
        else:
            self._real_window = FwsWindow(
                QParent(parent, True), self, below=below
            )

        self._real_widget = RealWidget(self._real_window, self)

        # Widget.__init__(self, parent)
        # self.init_widget(parent)

        # MixinBase.__init__(self)

        self.set_title(title)

        self.layout = None
        self._size_specified = False
        self.close_listeners = []
        # _windows.add(self)
        self.destroyed.connect(self.__destroyed)

        self._real_window.setAttribute(Qt.WA_DeleteOnClose, True)

        # if not border:
        #     self.setWindowFlags(Qt.FramelessWindowHint |
        #                         Qt.NoDropShadowWindowHint)
        #     # self.setWindowFlags(Qt.FramelessWindowHint)

        self.center_on_show = True
        self._centered_on_initial_show = False
        if hasattr(self, "accepted"):
            self.accepted.connect(self.__accepted)
        if hasattr(self, "rejected"):
            self.rejected.connect(self.__rejected)

        # Add a keep-alive reference
        print("Adding window reference", self)
        windows.add(self)
        self.closed.connect(self.__closed)

        self.title_panel = None
        self.title_panel_visible = False
        if not native:
            self.real_window()._window = weakref.ref(self)
            from workspace.ui.theme import WorkspaceTheme
            from workspace.ui.window import WindowHeader

            if header:
                self.title_panel = WindowHeader(
                    self.real_window(),
                    menu=menu,
                    minimizable=minimizable,
                    maximizable=maximizable,
                    separator=separator,
                    closable=closable,
                    background=color,
                )
            self.title_panel_visible = True
            self.set_background_color(
                WorkspaceTheme.instance().window_background
            )
Ejemplo n.º 13
0
    def draw_background(
        cls, widget, dc, selected=False, hover=False, button_style=True
    ):
        unused(button_style)
        if selected:
            cls.draw_selected_tab(widget, dc)
        else:
            cls.draw_border(widget, dc)

        size = widget.size()
        x = 0
        y = 0
        w = size[0]
        h = size[1] - 2

        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme

            theme = WorkspaceTheme.instance()
            white = fsui.Color(0xFF, 0xFF, 0xFF)
            if selected:
                bg_color = theme.window_background
                bd_color = theme.title_separator_color
            elif hover:
                bg_color = theme.window_background.copy().mix(
                    theme.title_background
                )
                bd_color = theme.title_separator_color.copy().mix(
                    theme.title_background
                )
            else:
                bg_color = theme.title_background
                bd_color = theme.title_background

            # dc.draw_rectangle(0, 0, w, h, bd_color)
            if selected or hover:
                dc.draw_vertical_gradient(0, 0, 2, size[1], white, bd_color)
                dc.draw_vertical_gradient(
                    size[0] - 2,
                    0,
                    2,
                    size[1],
                    theme.title_background,
                    bd_color,
                )
                # dc.draw_rectangle(2, 2, w - 4, h - 2, bg_color)
                dc.draw_vertical_gradient(
                    2,
                    0,
                    size[0] - 4,
                    size[1],
                    theme.title_background,
                    bg_color,
                )
                if hover and not selected:
                    dc.draw_rectangle(
                        0, size[1] - 2, size[0], 2, theme.title_separator_color
                    )
            else:
                dc.draw_rectangle(0, 0, w, h, bd_color)
            return

        if fsbc.system.macosx:
            # dc.draw_line(0, 0, w, 0, fsui.Color(198, 198, 198))
            # dc.draw_line(0, 0, w, 0, fsui.Color(188, 188, 188))
            dc.draw_line(0, 0, w, 0, fsui.Color(248, 248, 248))
            y += 1
            h -= 1

        if selected:
            x += 2
            w -= 4
            h += 2

        # if button_style and hover:
        #     x += 6
        #     y += 6
        #     w -= 12
        #     h -= 12

        color_1 = Skin.get_background_color()
        if fsbc.system.macosx and False:
            if selected:
                color_2 = color_1
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
            elif hover:
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
                color_2 = fsui.Color(0xEF, 0xEF, 0xEF)
            else:
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
                color_2 = fsui.Color(0xC0, 0xC0, 0xC0)
        elif color_1 is not None:
            if selected:
                color_2 = color_1
            elif hover:
                color_2 = color_1.copy().lighten()
            else:
                color_2 = color_1.copy().darken(0.08)
        else:
            if selected:
                return
                # color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00)
                # color_2 = color_1
            elif hover:
                color_1 = fsui.Color(0xFF, 0xFF, 0xFF, 0x00)
                color_2 = fsui.Color(0xFF, 0xFF, 0xFF, 0x40)
            else:
                color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00)
                color_2 = fsui.Color(0x00, 0x00, 0x00, 0x20)
        dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)

        if fsbc.system.macosx and False and not selected and not hover:
            dc.draw_line(
                x, y + h - 1, x + w, y + h - 1, fsui.Color(0xA8, 0xA8, 0xA8)
            )
Ejemplo n.º 14
0
    def __init__(self, parent=None):
        title = gettext("HDF Disk Image Creator")
        super().__init__(parent, title=title)
        self.theme = WorkspaceTheme.instance()
        buttons, layout = fsui.DialogButtons.create_with_layout(self)
        if self.window.theme.has_close_buttons:
            buttons.create_close_button()

        self.dialog = None
        self.path = ""

        self.set_icon(fsui.Icon("hd-volume", "pkg:workspace"))

        layout.min_width = 500

        self.icon_header = IconHeader(
            self, fsui.Icon("hd-volume", "pkg:workspace"),
            gettext("HDF Disk Image Creator"),
            gettext("Create a single-partition or partitionable hard "
                    "drive image"))
        layout.add(self.icon_header, fill=True, margin_bottom=20)

        label = fsui.Label(self, gettext("Create disk image of type:"))
        layout.add(label)
        layout.add_spacer(6)
        self.list_view = fsui.ListView(self)
        self.list_view.set_min_width(560)
        self.list_view.set_min_height(60)
        icon = fsui.Image("workspace:res/16x16/hd-volume.png")
        self.list_view.add_item(
            gettext("HDF - Single Partition Hard Disk File"), icon)
        self.list_view.add_item(
            gettext("HDF - Partitionable Hard Drive Image (RDB)"), icon)
        layout.add(self.list_view, expand=True, fill=True)
        self.list_view.item_selected.connect(self.on_item_selected)

        layout.add_spacer(20)
        label = fsui.Label(self, gettext("Filename for the new disk image:"))
        layout.add(label)
        layout.add_spacer(6)
        hori_layout = fsui.HorizontalLayout()
        layout.add(hori_layout, fill=True)
        self.name_field = fsui.TextField(
            self, "", read_only=False)
        hori_layout.add(self.name_field, expand=True)
        text = gettext("Size:")
        label = fsui.Label(self, text)
        hori_layout.add(label, margin_left=20)
        self.size_field = fsui.TextField(self, "")
        self.size_field.set_min_width(60)
        hori_layout.add(self.size_field, expand=False, margin_left=10)
        text = gettext("MB")
        label = fsui.Label(self, text)
        hori_layout.add(label, margin_left=10)

        layout.add_spacer(20)
        label = fsui.Label(self, gettext("Save to directory:"))
        layout.add(label)
        layout.add_spacer(6)
        hori_layout = fsui.HorizontalLayout()
        layout.add(hori_layout, fill=True)
        self.dir_field = fsui.TextField(self, "", read_only=True)
        hori_layout.add(self.dir_field, expand=True)
        self.browse_button = fsui.Button(self, gettext("Browse"))
        self.browse_button.clicked.connect(self.on_browse_clicked)
        hori_layout.add(self.browse_button, margin_left=10)

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

        # layout.add_spacer(20)
        # layout.add_spacer(20)
        # hori_layout = fsui.HorizontalLayout()
        # 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.create_button = fsui.Button(buttons, gettext("Create"))
        # self.create_button.activated.connect(self.on_create_clicked)
        self.create_button.clicked.connect(self.on_create_clicked)
        # hori_layout.add(self.create_button)
        buttons.add_button(self.create_button)

        self.list_view.select_item(0)
        self.update_name_suggestion()
Ejemplo n.º 15
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()
Ejemplo n.º 16
0
    def __init__(self,
                 parent,
                 title="",
                 border=True,
                 minimizable=True,
                 maximizable=True,
                 separator=True,
                 menu=False,
                 native=None,
                 header=True,
                 below=False,
                 closable=True,
                 color=None,
                 **_):
        init_qt()
        super().__init__()

        # if parent is None and len(default_window_parent) > 0:
        #     parent = default_window_parent[-1]
        #     print("using default parent", parent)

        # FIXME
        self._window = weakref.ref(self)

        if native is None:
            if fsboot.get("fws") == "1":
                native = False
            else:
                native = not _use_fws
        if native:
            self._real_window = RealWindow(QParent(parent, True),
                                           self,
                                           minimizable=minimizable,
                                           maximizable=maximizable,
                                           below=below,
                                           border=border)
        else:
            self._real_window = FwsWindow(QParent(parent, True),
                                          self,
                                          below=below)

        self._real_widget = RealWidget(self._real_window, self)

        # Widget.__init__(self, parent)
        # self.init_widget(parent)

        # MixinBase.__init__(self)

        self.set_title(title)

        self.layout = None
        self._size_specified = False
        self.close_listeners = []
        # _windows.add(self)
        self.destroyed.connect(self.__destroyed)

        self._real_window.setAttribute(Qt.WA_DeleteOnClose, True)

        # if not border:
        #     self.setWindowFlags(Qt.FramelessWindowHint |
        #                         Qt.NoDropShadowWindowHint)
        #     # self.setWindowFlags(Qt.FramelessWindowHint)

        self.center_on_show = True
        self._centered_on_initial_show = False
        if hasattr(self, "accepted"):
            self.accepted.connect(self.__accepted)
        if hasattr(self, "rejected"):
            self.rejected.connect(self.__rejected)

        # Add a keep-alive reference
        print("Adding window reference", self)
        windows.add(self)
        self.closed.connect(self.__closed)

        self.title_panel = None
        self.title_panel_visible = False
        if not native:
            self.real_window()._window = weakref.ref(self)
            from workspace.ui.theme import WorkspaceTheme
            from workspace.ui.window import WindowHeader
            if header:
                self.title_panel = WindowHeader(self.real_window(),
                                                menu=menu,
                                                minimizable=minimizable,
                                                maximizable=maximizable,
                                                separator=separator,
                                                closable=closable,
                                                background=color)
            self.title_panel_visible = True
            self.set_background_color(
                WorkspaceTheme.instance().window_background)
Ejemplo n.º 17
0
    def __init__(self, parent=None):
        title = gettext("ADF Disk Image Creator")
        super().__init__(parent, title=title, maximizable=False)
        self.theme = WorkspaceTheme.instance()
        buttons, layout = fsui.DialogButtons.create_with_layout(self)
        if self.window.theme.has_close_buttons:
            buttons.create_close_button()

        self.dialog = None
        self.path = ""

        self.set_icon(fsui.Icon("floppy", "pkg:workspace"))

        layout.min_width = 500

        self.icon_header = IconHeader(
            self,
            fsui.Icon("floppy", "pkg:workspace"),
            gettext("ADF Disk Image Creator"),
            gettext("Create a blank or formatted ADF floppy disk image"),
        )
        layout.add(self.icon_header, fill=True, margin_bottom=20)

        label = fsui.Label(self, gettext("Create disk image of type:"))
        layout.add(label)
        layout.add_spacer(6)
        self.list_view = fsui.ListView(self)
        self.list_view.set_min_width(560)
        self.list_view.set_min_height(60)
        icon = fsui.Image("workspace:res/16x16/floppy.png")
        self.list_view.add_item(
            gettext("ADF - Standard Floppy Disk Image"), icon
        )
        self.list_view.add_item(
            gettext("ADF - Extended Floppy Disk Image (MFM Encoded)"), icon
        )
        layout.add(self.list_view, expand=True, fill=True)
        # self.list_view.on_select_item = self.on_select_item
        self.list_view.item_selected.connect(self.on_item_selected)

        layout.add_spacer(20)
        label = fsui.Label(self, gettext("Filename for the new disk image:"))
        layout.add(label)
        layout.add_spacer(6)
        hori_layout = fsui.HorizontalLayout()
        layout.add(hori_layout, fill=True)
        self.name_field = fsui.TextField(self, "", read_only=False)
        hori_layout.add(self.name_field, expand=True)
        text = gettext("Size:")
        label = fsui.Label(self, text)
        hori_layout.add(label, margin_left=20)
        self.size_field = fsui.TextField(self, "")
        self.size_field.set_min_width(60)
        hori_layout.add(self.size_field, expand=False, margin_left=10)
        text = gettext("MB")
        label = fsui.Label(self, text)
        hori_layout.add(label, margin_left=10)

        layout.add_spacer(20)
        label = fsui.Label(self, gettext("Save to directory:"))
        layout.add(label)
        layout.add_spacer(6)
        hori_layout = fsui.HorizontalLayout()
        layout.add(hori_layout, fill=True)
        self.dir_field = fsui.TextField(self, "", read_only=True)
        hori_layout.add(self.dir_field, expand=True)
        self.browse_button = fsui.Button(self, gettext("Browse"))
        self.browse_button.clicked.connect(self.on_browse_clicked)
        hori_layout.add(self.browse_button, margin_left=10)

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

        # layout.add_spacer(20)
        # layout.add_spacer(20)
        # hori_layout = fsui.HorizontalLayout()
        # 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.create_button = fsui.Button(buttons, gettext("Create"))
        # self.create_button.activated.connect(self.on_create_clicked)
        self.create_button.activated.connect(self.on_create_clicked)
        # hori_layout.add(self.create_button)
        buttons.add_button(self.create_button)

        self.list_view.select_item(0)
        self.update_name_suggestion()
Ejemplo n.º 18
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()
Ejemplo n.º 19
0
    def draw_background(cls,
                        widget,
                        dc,
                        selected=False,
                        hover=False,
                        button_style=True):
        unused(button_style)
        if selected:
            cls.draw_selected_tab(widget, dc)
        else:
            cls.draw_border(widget, dc)

        size = widget.size()
        x = 0
        y = 0
        w = size[0]
        h = size[1] - 2

        if Skin.fws() or Skin.windows_10():
            from workspace.ui.theme import WorkspaceTheme

            theme = WorkspaceTheme.instance()
            white = fsui.Color(0xFF, 0xFF, 0xFF)
            if selected:
                bg_color = theme.window_background
                bd_color = theme.title_separator_color
            elif hover:
                bg_color = theme.window_background.copy().mix(
                    theme.title_background)
                bd_color = theme.title_separator_color.copy().mix(
                    theme.title_background)
            else:
                bg_color = theme.title_background
                bd_color = theme.title_background

            # dc.draw_rectangle(0, 0, w, h, bd_color)
            if selected or hover:
                dc.draw_vertical_gradient(0, 0, 2, size[1], white, bd_color)
                dc.draw_vertical_gradient(
                    size[0] - 2,
                    0,
                    2,
                    size[1],
                    theme.title_background,
                    bd_color,
                )
                # dc.draw_rectangle(2, 2, w - 4, h - 2, bg_color)
                dc.draw_vertical_gradient(
                    2,
                    0,
                    size[0] - 4,
                    size[1],
                    theme.title_background,
                    bg_color,
                )
                if hover and not selected:
                    dc.draw_rectangle(0, size[1] - 2, size[0], 2,
                                      theme.title_separator_color)
            else:
                dc.draw_rectangle(0, 0, w, h, bd_color)
            return

        if System.macos:
            # dc.draw_line(0, 0, w, 0, fsui.Color(198, 198, 198))
            # dc.draw_line(0, 0, w, 0, fsui.Color(188, 188, 188))
            dc.draw_line(0, 0, w, 0, fsui.Color(248, 248, 248))
            y += 1
            h -= 1

        if selected:
            x += 2
            w -= 4
            h += 2

        # if button_style and hover:
        #     x += 6
        #     y += 6
        #     w -= 12
        #     h -= 12

        color_1 = Skin.get_background_color()
        if System.macos and False:
            if selected:
                color_2 = color_1
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
            elif hover:
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
                color_2 = fsui.Color(0xEF, 0xEF, 0xEF)
            else:
                color_1 = fsui.Color(0xA7, 0xA7, 0xA7)
                color_2 = fsui.Color(0xC0, 0xC0, 0xC0)
        # elif Skin.adwaita():
        #     color_1 = fsui.Color(0xea, 0xe7, 0xe5)
        #     color_2 = fsui.Color(0xea, 0xe7, 0xe5)
        elif color_1 is not None:
            if selected:
                color_2 = color_1
            elif hover:
                color_2 = color_1.copy().lighten()
            else:
                color_2 = color_1.copy().darken(0.08)
        else:
            if selected:
                return
                # color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00)
                # color_2 = color_1
            elif hover:
                color_1 = fsui.Color(0xFF, 0xFF, 0xFF, 0x00)
                color_2 = fsui.Color(0xFF, 0xFF, 0xFF, 0x40)
            else:
                color_1 = fsui.Color(0x00, 0x00, 0x00, 0x00)
                color_2 = fsui.Color(0x00, 0x00, 0x00, 0x20)
        dc.draw_vertical_gradient(x, y, w, h, color_1, color_2)

        if System.macos and False and not selected and not hover:
            dc.draw_line(x, y + h - 1, x + w, y + h - 1,
                         fsui.Color(0xA8, 0xA8, 0xA8))
Ejemplo n.º 20
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()
Ejemplo n.º 21
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)

        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.type_field = fsui.Choice(panel, self.device_type_labels)
        self.type_field.changed.connect(self.on_change)
        panel.layout.add(self.type_field)

        panel.layout.add(
            fsui.PlainLabel(panel, gettext("Make:")), margin_left=20
        )
        self.make_field = fsui.TextField(panel)
        self.make_field.set_min_width(140)
        self.make_field.changed.connect(self.on_change)
        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)
        self.model_field.changed.connect(self.on_change)
        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.save_button.disable()
        self.set_size(self.layout.get_min_size())
        self.center_on_parent()

        self.stopped = False
        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()