def _update_color(self, name, value):
     # if name == "window_bgcolor"
     # print("_")
     color = None
     if value and value != "#00000000":
         try:
             color = Color.from_hex(value)
         except Exception:
             pass
     if color is None:
         color = Color.from_hex(getattr(self, f"_{name}_default_str"))
     print("Setting", name, "->", color)
     setattr(self, f"_{name}", color)
    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()
Beispiel #3
0
 def __init__(self, visible=True):
     parent = ParentStack.top()
     super().__init__(parent)
     parent.layout.add(self)
     self.set_background_color(Color.from_hex("#ff0000"))
     # FIXME
     self.set_min_height(30)
     self.set_min_width(30)
     if not visible:
         self.set_visible(False)
    def __init__(self, parent=None, *args, style=None, **kwargs):
        super().__init__(parent=parent, *args, **kwargs)

        self.style = Style({"flexDirection": "column"}, style)

        backgroundColor = self.style.get("backgroundColor")
        if backgroundColor is not None:
            self.set_background_color(Color.from_hex(backgroundColor))

        flex_layout = FlexLayout(self)
        for child in self.layout.children:
            flex_layout.add(child.element)
        self.layout = flex_layout
 def on_setting(self, option, value):
     if option == self.option:
         color = Color.from_hex(value)
         if color != self.color:
             self.color = color
             self.refresh()