def __init__(self, parent, icon=None):
     if icon is not None:
         self.icon = icon
     else:
         self.icon = Image("launcher:res/16/world.png")
     Panel.__init__(self, parent, paintable=True)
     # self.set_tooltip(tooltip)
     LauncherConfig.add_listener(self)
     self.on_config("variant_rating", "")
Exemple #2
0
 def __init__(self, parent, icon=None):
     if icon is not None:
         self.icon = icon
     else:
         self.icon = Image("launcher:res/16/world.png")
     Panel.__init__(self, parent, paintable=True)
     # self.set_tooltip(tooltip)
     LauncherConfig.add_listener(self)
     self.on_config("variant_rating", "")
Exemple #3
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)
 def __init__(self, parent, icon=None):
     if icon is not None:
         self.icon = icon
     else:
         self.icon = Image("launcher:/data/16x16/world.png")
     Panel.__init__(self, parent, paintable=True)
     # self.set_tooltip(tooltip)
     config = get_config(self)
     config.add_listener(self)
     self.on_config("variant_uuid", "")
    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 __init__(self, parent):
        """

        :type parent: fsui.Widget
        """
        Panel.__init__(self, parent, paintable=True)
        # self.set_background_color(Color(0xd0, 0xd0, 0xd0))
        self.set_background_color(parent.get_background_color())
        self.icon = None
        self.right_icon = None
        self.right_icon_disabled = None
        self.text = ""
        self.active = True
    def __init__(self, parent):
        """

        :type parent: fsui.Widget
        """
        Panel.__init__(self, parent, paintable=True)
        # self.set_background_color(Color(0xd0, 0xd0, 0xd0))
        self.set_background_color(parent.get_background_color())
        self.icon = None
        self.right_icon = None
        self.right_icon_disabled = None
        self.text = ""
        self.active = True
Exemple #8
0
    def __init__(self, parent, spacing=10):
        unused(spacing)
        Panel.__init__(self, parent, paintable=True)
        Skin.set_background_color(self)
        self.layout = HorizontalLayout()
        self.layout.add_spacer(20)
        # self.layout.add_spacer(spacing)
        # self.layout.padding_left = 10
        # self.layout.padding_right = 10

        # self.set_background_color(Color(0xAEAEAE))
        # self.set_min_height(Constants.TAB_HEIGHT)

        self.bgcolor = get_theme(self).window_bgcolor()
        self.set_background_color(self.bgcolor)
    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, *, vertical_layout=False, textcolor=None):
        super().__init__(parent)
        # self.set_background_color(fsui.Color(0x006699))
        self.vertical_layout = vertical_layout

        # self.set_background_color(fsui.Color(0x808080))
        self.panel = Panel(self)
        # self.panel.set_background_color(fsui.Color(0x009900))
        # self.panel.set_background_color(None)

        # FIXME: Why is it necessary to set a transparent color here? Shouldn't
        # it be sufficient to let the panel have its autoFillBackground set
        # to False (default)?
        self.panel.set_background_color(Color(0, 0, 0, 0))
        # self.panel._widget.setAutoFillBackground(False)

        self.icons = []
        if textcolor:
            self.textcolor = textcolor
        else:
            self.textcolor = Color(0x000000)

        # FIXME: Fix fsui.ScrollArea / Panel constructor so this isn't
        # necessary? (Child calls method on parent when parenting)
        self.set_child(self.panel)
        # self.panel.set_size((1400, 200))

        # self._qwidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self._qwidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        # # Base: 9999

        # g1 = "#858585"
        # g2 = "#8A8A8A"
        # g3 = "#909090"

        # # Handle gradient
        # hg1 = "#AAAAAA"
        # hg2 = "#999999"

        # # Handle hover gradient
        # hhg1 = "#B2B2B2"
        # hhg2 = "#A0A0A0"

        # # Handle pressed color
        # hpc = "#777777"

        # Base: AEAEAE

        g1 = "#959595"
        g2 = "#9A9A9A"
        g3 = "#A0A0A0"

        # Handle gradient
        hg1 = "#BBBBBB"
        hg2 = "#AEAEAE"

        # Handle hover gradient
        hhg1 = "#BEBEBE"
        hhg2 = "#B4B4B4"

        # Handle pressed color
        hpc = "#8C8C8C"

        scrollbar_stylesheet = f"""
            QScrollBar:vertical {{
                border: 0px;
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {g1}, stop: {1 / (16 - 1)} {g2} stop: 1 {g3});
                width: 16px;
                margin: 0 0 0 0;
            }}

            QScrollBar:horizontal {{
                border: 0px;
                background-color: qlineargradient(x1: 0, y1: 0 x2: 0, y2: 1, stop: 0 {g1}, stop: {1 / (16 - 1)} {g2} stop: 1 {g3});
                height: 16px;
                margin: 0 0 0 0;
            }}

            QScrollBar::handle:vertical {{
                /* background: #999999; */
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hg1} stop: 1 {hg2});
                min-height: 60px;
            }}

            QScrollBar::handle:horizontal {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 0, y2: 1, stop: 0 {hg1} stop: 1 {hg2});
                min-height: 60px;
            }}

            QScrollBar::handle:vertical:hover {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hhg1} stop: 1 {hhg2});
            }}

            QScrollBar::handle:horizontal:hover {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hhg1} stop: 1 {hhg2});
            }}

            QScrollBar::handle:vertical:pressed {{
                background: {hpc};
            }}

            QScrollBar::handle:horizontal:pressed {{
                background: {hpc};
            }}

            QScrollBar::add-line:vertical {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::add-line:horizontal {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::sub-line:vertical {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::sub-line:horizontal {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}
            """
        self._qwidget.horizontalScrollBar().setStyleSheet(scrollbar_stylesheet)
        self._qwidget.verticalScrollBar().setStyleSheet(scrollbar_stylesheet)
class WSIconView(ScrollArea):
    def __init__(self, parent, *, vertical_layout=False, textcolor=None):
        super().__init__(parent)
        # self.set_background_color(fsui.Color(0x006699))
        self.vertical_layout = vertical_layout

        # self.set_background_color(fsui.Color(0x808080))
        self.panel = Panel(self)
        # self.panel.set_background_color(fsui.Color(0x009900))
        # self.panel.set_background_color(None)

        # FIXME: Why is it necessary to set a transparent color here? Shouldn't
        # it be sufficient to let the panel have its autoFillBackground set
        # to False (default)?
        self.panel.set_background_color(Color(0, 0, 0, 0))
        # self.panel._widget.setAutoFillBackground(False)

        self.icons = []
        if textcolor:
            self.textcolor = textcolor
        else:
            self.textcolor = Color(0x000000)

        # FIXME: Fix fsui.ScrollArea / Panel constructor so this isn't
        # necessary? (Child calls method on parent when parenting)
        self.set_child(self.panel)
        # self.panel.set_size((1400, 200))

        # self._qwidget.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self._qwidget.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)

        # # Base: 9999

        # g1 = "#858585"
        # g2 = "#8A8A8A"
        # g3 = "#909090"

        # # Handle gradient
        # hg1 = "#AAAAAA"
        # hg2 = "#999999"

        # # Handle hover gradient
        # hhg1 = "#B2B2B2"
        # hhg2 = "#A0A0A0"

        # # Handle pressed color
        # hpc = "#777777"

        # Base: AEAEAE

        g1 = "#959595"
        g2 = "#9A9A9A"
        g3 = "#A0A0A0"

        # Handle gradient
        hg1 = "#BBBBBB"
        hg2 = "#AEAEAE"

        # Handle hover gradient
        hhg1 = "#BEBEBE"
        hhg2 = "#B4B4B4"

        # Handle pressed color
        hpc = "#8C8C8C"

        scrollbar_stylesheet = f"""
            QScrollBar:vertical {{
                border: 0px;
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {g1}, stop: {1 / (16 - 1)} {g2} stop: 1 {g3});
                width: 16px;
                margin: 0 0 0 0;
            }}

            QScrollBar:horizontal {{
                border: 0px;
                background-color: qlineargradient(x1: 0, y1: 0 x2: 0, y2: 1, stop: 0 {g1}, stop: {1 / (16 - 1)} {g2} stop: 1 {g3});
                height: 16px;
                margin: 0 0 0 0;
            }}

            QScrollBar::handle:vertical {{
                /* background: #999999; */
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hg1} stop: 1 {hg2});
                min-height: 60px;
            }}

            QScrollBar::handle:horizontal {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 0, y2: 1, stop: 0 {hg1} stop: 1 {hg2});
                min-height: 60px;
            }}

            QScrollBar::handle:vertical:hover {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hhg1} stop: 1 {hhg2});
            }}

            QScrollBar::handle:horizontal:hover {{
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 {hhg1} stop: 1 {hhg2});
            }}

            QScrollBar::handle:vertical:pressed {{
                background: {hpc};
            }}

            QScrollBar::handle:horizontal:pressed {{
                background: {hpc};
            }}

            QScrollBar::add-line:vertical {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::add-line:horizontal {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::sub-line:vertical {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}

            QScrollBar::sub-line:horizontal {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}
            """
        self._qwidget.horizontalScrollBar().setStyleSheet(scrollbar_stylesheet)
        self._qwidget.verticalScrollBar().setStyleSheet(scrollbar_stylesheet)

    def clear_selection(self, exception=None):
        for icon in self.icons:
            if icon.widget == exception:
                pass
            else:
                icon.widget.set_selected(False)

    def _add_icon(self, path, normal_image, selected_image, *, label=None):
        if label is None:
            label = self._label_for_path(path)
        # label = shell_basename(path)
        # if label.endswith(":"):
        #     # Hack for volumes
        #     label = label[:-1]
        wsopen = path

        widget = WSIconWidget(
            self.panel,
            label=label,
            icon=normal_image,
            selected_icon=selected_image,
            textcolor=self.textcolor,
        )
        widget.set_position((0, 0))
        widget.wsopen = wsopen
        self.icons.append(IconViewIconHolder(widget))
        self.layout_icons()

    def add_shell_icon(self, path):
        print("add_shell_icon", path)

        # normal_image = Image.create_blank(1, 1)
        # selected_image = Image.create_blank(1, 1)

        info_path = path
        # path = info_path[:-5]
        name = shell_basename(path)
        if name.lower().endswith(".info"):
            label = name[:-5]
        else:
            label = name

        icon = shell_icon(info_path)
        normal_image = icon.normal_image()
        selected_image = icon.selected_image()

        self._add_icon(path, normal_image, selected_image, label=label)

    def _label_for_path(self, path):
        label = shell_basename(path)
        if label.endswith(":"):
            # Hack for volumes
            label = label[:-1]
        return label

    def add_launcher_icon(self, path):
        print("add_launcher_icon", path)

        label = self._label_for_path(path)
        # label = shell_basename(path)
        # if label.endswith(":"):
        #     # Hack for volumes
        #     label = label[:-1]
        # wsopen = path

        # FIXME: Get proper data file path
        # icon_dir = os.path.join(
        #     Application.executable_dir(),
        #     "data",
        #     "Icons",
        #     shell_dirname(path).replace(":", "/"),
        # )
        # print(icon_dir, label)

        icon_dir = os.path.join(
            "Icons",
            shell_dirname(path).replace(":", "/"),
        )
        normal_image = Image(
            ApplicationData.path_or_stream(
                os.path.join(icon_dir, label + ".png")))
        selected_image = Image(
            ApplicationData.path_or_stream(
                os.path.join(icon_dir, label + "_Selected.png")))

        # # FIXME
        # icon = Image(
        #     os.path.join("data", "Icons")
        #     os.path.expanduser(
        #         "~/openretro/icons/Prefs/" + label + "_Normal.png"
        #     )
        # )
        # try:
        #     # icon = Image(
        #     #     os.path.expanduser("~/openretro/icons/Prefs/" + label + "/" + label + "_Normal.png")
        #     # )
        #     icon = Image(
        #         os.path.expanduser(
        #             "~/openretro/icons/Prefs/" + label + "_Normal.png"
        #         )
        #     )
        # except Exception:
        #     icon = Image(
        #         os.path.expanduser("~/openretro/icons/Prefs/Help_Normal.png")
        #     )

        # try:
        #     # selected_icon = Image(
        #     #     os.path.expanduser("~/openretro/icons/Prefs/" + label + "/" + label + "_Selected.png")
        #     # )
        #     selected_icon = Image(
        #         os.path.expanduser(
        #             "~/openretro/icons/Prefs/" + label + "_Selected.png"
        #         )
        #     )
        # except Exception:
        #     selected_icon = Image(
        #         os.path.expanduser("~/openretro/icons/Prefs/Help_Selected.png")
        #     )

        # try:
        #     selected_icon = Image(
        #         os.path.expanduser("~/openretro/icons/Prefs/" + label + "/" + label + "_Selected.png")
        #     )
        # except Exception:
        #     try:
        #         selected_icon = Image(
        #             os.path.expanduser(
        #                 "~/openretro/icons/Prefs/" + label + "_Selected.png"
        #             )
        #         )
        #     except Exception:
        #         selected_icon = None
        #         selected_icon = icon.copy()
        #         selected_icon.invert()
        self._add_icon(path, normal_image, selected_image, label=label)

    def layout_icons(self):
        if self.vertical_layout:
            w, h = self.layout_icons_vertically()
        else:
            w, h = self.layout_icons_horizontally()
        self.panel.set_size((w, h))
        # self.panel.set_size((1000, 500))

    def layout_icons_horizontally(self):
        print(" --- layout_icons", self.width())
        x = 10
        y = 10
        w = 0
        h = 0
        for icon in self.icons:
            icon.widget.set_position((x, y))
            x += WSIconWidget.ICON_WIDGET_WIDTH
            if x > w:
                w = x
            if y + WSIconWidget.ICON_WIDGET_HEIGHT > y:
                h = y + WSIconWidget.ICON_WIDGET_HEIGHT
            if x + WSIconWidget.ICON_WIDGET_WIDTH > self.width():
                x = 10
                y += WSIconWidget.ICON_WIDGET_HEIGHT
        return w, h

    def layout_icons_vertically(self):
        padding_y = 30
        x = 10
        y = padding_y
        w = 0
        h = 0
        for icon in self.icons:
            icon.widget.set_position((x, y))
            y += WSIconWidget.ICON_WIDGET_WIDTH
            if y > h:
                h = y
            if x + WSIconWidget.ICON_WIDGET_WIDTH > x:
                w = x + WSIconWidget.ICON_WIDGET_WIDTH
            if y + WSIconWidget.ICON_WIDGET_HEIGHT > self.height():
                y = padding_y
                x += WSIconWidget.ICON_WIDGET_WIDTH
        return w, h

    def on_resize(self):
        # print("resize?")
        super().on_resize()
        self.layout_icons()
Exemple #12
0
    def __init__(self, parent, *, close=False, quit=False):
        super().__init__(parent)

        panel = Panel(self)
        panel.set_min_height(1)
        panel.set_background_color(Color(0x888888))
        self.layout.add(panel, fill=True)

        horilayout = HorizontalLayout()
        self.layout.add(
            horilayout,
            fill=True,
            expand=True,
            margin_top=10,
            margin_right=10,
            margin_bottom=10,
        )

        if close:
            button = Button(self, label="Close")
            button.activated.connect(self.__on_close)
            horilayout.add(button, margin_left=10)
        if quit:
            button = Button(self, label="Quit")
            button.activated.connect(self.__on_quit)
            horilayout.add(button, margin_left=10)

        button = Button(self, label="Settings")
        button.activated.connect(self.__on_settings)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Launcher")
        button.activated.connect(self.__on_launcher)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Prefs")
        button.activated.connect(self.__on_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Advanced")
        button.activated.connect(self.__on_advanced_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="Appearance")
        button.activated.connect(self.__on_appearance_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="WHDLoad")
        button.activated.connect(self.__on_whdload_prefs)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="LoadWB")
        button.activated.connect(self.__on_loadwb)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH")
        button.activated.connect(self.__on_unhandled_exception)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH2")
        button.activated.connect(self.__on_unhandled_exception_2)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="UH3")
        button.activated.connect(self.__on_unhandled_exception_3)
        horilayout.add(button, margin_left=10)

        button = Button(self, label="GC")
        button.activated.connect(self.__on_garbage_collector)
        horilayout.add(button, margin_left=10)