예제 #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/16/controller.png")
        self.config_icon = fsui.Image("launcher:res/fsuae_config_16.png")

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

        from workspace.ui.theme import Theme
        theme = Theme.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()))
예제 #2
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/16/controller.png")
        self.config_icon = fsui.Image(
            "launcher:res/fsuae_config_16.png")

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

        from workspace.ui.theme import Theme
        theme = Theme.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()))
예제 #3
0
    def draw_border(cls, widget, dc):
        size = widget.size()

        line_color_1 = Skin.get_background_color()
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.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)
예제 #4
0
    def draw_border(cls, widget, dc):
        size = widget.size()

        line_color_1 = Skin.get_background_color()
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.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)
예제 #5
0
    def draw_selected_tab(cls, widget, dc):
        line_color_1 = Skin.get_background_color()
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.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)
예제 #6
0
    def draw_selected_tab(cls, widget, dc):
        line_color_1 = Skin.get_background_color()
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.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)
예제 #7
0
    def __init__(self, parent, title):
        super().__init__(parent, title, minimizable=False, maximizable=False)
        # buttons, layout = fsui.DialogButtons.create_with_layout(self)
        # buttons.create_close_button()
        self.layout = fsui.VerticalLayout()
        # self.layout.set_padding(20)
        layout = self.layout

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_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=(not Skin.fws()))
        self.list_view.set_min_width(240)
        self.list_view.item_selected.connect(self.on_select_item)
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.instance()
            self.list_view.set_row_height(28)
            # self.list_view.set_background_color(fsui.Color(0xeb, 0xeb, 0xeb))
            self.list_view.setStyleSheet("""
            QListView {{
                padding-top: 20px;
                background-color: {0};
                outline: none;
            }}
            QListView::item {{
                padding-left: 20px;
                border: 0px;
            }}
            QListView::item:selected {{
                background-color: {1};
            }}
            """.format(theme.sidebar_background.to_hex(),
                       theme.selection_background.to_hex()))
            layout_2.add(self.list_view, fill=True, expand=True)
        else:
            layout_2.add(self.list_view,
                         fill=True,
                         expand=True,
                         margin=20,
                         margin_right=0)
        hor_layout.add(layout_2, fill=True)

        hor_layout.add_spacer(20)

        self.page_container = fsui.Panel(self)
        self.page_container.layout = fsui.VerticalLayout()
        hor_layout.add(self.page_container,
                       fill=True,
                       expand=True,
                       margin_top=20,
                       margin_right=20,
                       margin_bottom=20)

        # self.layout.add_spacer(20)

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_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.current_page = None
        self.set_size((840, 640))
        self.center_on_parent()
예제 #8
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 Theme
            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(Theme.instance().window_background)
예제 #9
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():
            from workspace.ui.theme import Theme
            theme = Theme.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))
예제 #10
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():
            from workspace.ui.theme import Theme
            theme = Theme.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))
예제 #11
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 Theme
            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(Theme.instance().window_background)
예제 #12
0
    def __init__(self, parent, title):
        super().__init__(parent, title, minimizable=False, maximizable=False)
        # buttons, layout = fsui.DialogButtons.create_with_layout(self)
        # buttons.create_close_button()
        self.layout = fsui.VerticalLayout()
        # self.layout.set_padding(20)
        layout = self.layout

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_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=(not Skin.fws()))
        self.list_view.set_min_width(240)
        self.list_view.item_selected.connect(self.on_select_item)
        if Skin.fws():
            from workspace.ui.theme import Theme
            theme = Theme.instance()
            self.list_view.set_row_height(28)
            # self.list_view.set_background_color(fsui.Color(0xeb, 0xeb, 0xeb))
            self.list_view.setStyleSheet("""
            QListView {{
                padding-top: 20px;
                background-color: {0};
                outline: none;
            }}
            QListView::item {{
                padding-left: 20px;
                border: 0px;
            }}
            QListView::item:selected {{
                background-color: {1};
            }}
            """.format(theme.sidebar_background.to_hex(),
                       theme.selection_background.to_hex()))
            layout_2.add(self.list_view, fill=True, expand=True)
        else:
            layout_2.add(self.list_view, fill=True, expand=True,
                         margin=20, margin_right=0)
        hor_layout.add(layout_2, fill=True)

        hor_layout.add_spacer(20)

        self.page_container = fsui.Panel(self)
        self.page_container.layout = fsui.VerticalLayout()
        hor_layout.add(self.page_container, fill=True, expand=True,
                       margin_top=20, margin_right=20, margin_bottom=20)

        # self.layout.add_spacer(20)

        hor_layout = fsui.HorizontalLayout()
        layout.add(hor_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.current_page = None
        self.set_size((840, 640))
        self.center_on_parent()