def update_height(self, new_height):
     if self.height == new_height:
         return
     self.height = new_height
     self.set_min_height(new_height)
     for button in self.buttons:
         button.set_size((new_height, new_height))
     get_window(self).layout.update()
    def on_activate(self):
        if self.dialog is not None:
            self.dialog.raise_()
            self.dialog.activateWindow()
            return
        from fsui.qt import QColorDialog

        # FIXME: Use accessor funtion get_qwindow
        # print("Initial color", Color.from_hex(get_settings(self).get(self.option)))
        # dialog = QColorDialog(
        #     Color.from_hex(get_settings(self).get(self.option)),
        #     parent=get_window(self)._real_window,
        # )
        self.dialog = QColorDialog(parent=get_window(self)._qwidget)

        # dialog.setOption(QColorDialog.ShowAlphaChannel)
        self.dialog.setOption(QColorDialog.NoButtons)
        self.dialog.setOption(QColorDialog.DontUseNativeDialog)
        # Setting initial color only seems to work after setting options.
        # Calling this method earlier (or setting initial color in constructor)
        # seems to be ignored causing black color to be pre-selected.
        self.dialog.setCurrentColor(
            Color.from_hex(get_settings(self).get(self.option)))
        # dialog.colorSelected.connect(self.__color_selected)
        self.dialog.currentColorChanged.connect(self.__current_color_changed)
        self.dialog.destroyed.connect(self.__dialog_destroyed)

        # self.dialog.setAttribute(Qt.WA_DeleteOnClose)
        self.dialog.installEventFilter(self)
        self.dialog.show()
    def update_stylesheet(self):
        # FIXME: From theme
        row_bg = "#3B5275"
        if not get_window(self).window_focus():
            row_bg = "#505050"
        self._qwidget.setStyleSheet("""
        QListView {{
            background-color: {base};
            /*
            background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #999999, stop: 1 #909090);
            */
            /*
            background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #A0A0A0, stop: 1 #909090);
            */
            outline: none;
        }}
        QListView::item {{
            padding-left: 10px;
            border: 0;

        }}
        QListView::item:selected {{
            background-color: {row_bg};
            color: {row_fg};
        }}

        """.format(
            row_fg="#ffffff",
            row_bg=row_bg,
            base="#999999",
        ))
示例#4
0
 def on_paint(self):
     dc = self.create_dc()
     w, h = self.size()
     if get_window(self).window_focus():
         color = self._fgcolor
         cacheslot = 0
     else:
         color = self._fgcolor_inactive
         cacheslot = 1
     if self._image:
         x = (w - self._image.width()) // 2
         y = (h - self._image.width()) // 2
         dc.draw_image(self._image, x, y)
     else:
         self._svg.draw_to_dc(dc, 0, 0, w, h, color, cacheslot)
    def __on_browse_button(self):
        # FIXME: Show file picker dialog
        # dialog = FileDialog()
        # dialog.show()

        # FIXME: Choose initial directory based on directory of existing path,
        # if any

        dialog = LauncherFilePicker(
            get_window(self),
            # FIXME
            gettext("Select file"),
            # FIXME
            "floppy",
        )
        if not dialog.show_modal():
            print("dialog.show returned false")
            return
        print("dialog.show returned true")
        path = dialog.get_path()
        self.text_field.set_text(path)
    def __init__(self, parent):
        VerticalItemView.__init__(self, parent, border=False)
        self.items = []
        self.game_icon = Image("launcher:/data/16x16/controller.png")
        self.config_icon = Image("launcher:/data/fsuae_config_16.png")
        LauncherSettings.add_listener(self)
        self.update_search()

        self.manual_download_icon = Image(
            "launcher:/data/16x16/arrow_down_yellow.png")
        self.auto_download_icon = Image(
            "launcher:/data/16x16/arrow_down_green.png")
        self.blank_icon = Image("launcher:/data/16x16/blank.png")
        self.missing_color = Color(0xA8, 0xA8, 0xA8)
        self.unpublished_color = Color(0xCC, 0x00, 0x00)

        self.platform_icons = {}

        self.set_background_color(Color(0x999999))
        self.set_font(Font("Saira Condensed", 17, weight=500))

        self.set_row_height(32)
        get_window(self).activated.connect(self.__on_activated)
        get_window(self).deactivated.connect(self.__on_deactivated)

        self._qwidget.verticalScrollBar().setStyleSheet(f"""
            QScrollBar:vertical {{
                border: 0px;
                /*
                background: #32CC99;
                */
                /*
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #888888, stop: 1 #909090);
                */
                /*
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #848484, stop: 0.0625 #8A8A8A stop: 1 #909090);
                */
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #858585, stop: {1 / (16 - 1)} #8A8A8A stop: 1 #909090);
                width: 16px;
                margin: 0 0 0 0;
            }}
            QScrollBar::handle:vertical {{
                /*
                background: #9d9d9d;
                */
                background: #999999;
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #AAAAAA stop: 1 #999999);
                min-height: 60px;
            }}
            
            QScrollBar::handle:vertical:hover {{
                background: #AAAAAA;   
                background-color: qlineargradient(x1: 0, y1: 0 x2: 1, y2: 0, stop: 0 #B2B2B2 stop: 1 #A0A0A0);
            }}

            QScrollBar::handle:vertical:pressed {{
                background: #777777;
            }}

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

            QScrollBar::sub-line:vertical {{
                border: none;
                background: none;
                width: 0;
                height: 0;
            }}
            """)
示例#7
0
 def on_left_down(self):
     get_window(self).close()