def __init__(self, parent, cursor: AnimatedCursor):
        super().__init__(parent)
        self._core_painter = QtGui.QPainter()
        self._pixmaps = [
            toqpixmap(sub_cur[self.CURSOR_SIZE].image)
            for sub_cur, delay in cursor
        ]
        self._hotspots = [
            sub_cur[self.CURSOR_SIZE].hotspot for sub_cur, delay in cursor
        ]
        self._delays = [delay for sub_cur, delay in cursor]

        self._animation_timer = QtCore.QTimer()
        self._animation_timer.setSingleShot(True)
        self._animation_timer.timeout.connect(self.moveStep)
        self._current_frame = -1

        self._main_layout = QtWidgets.QVBoxLayout()
        self._example_label = QtWidgets.QLabel(
            "Hover over me to see the cursor! Click to see the hotspot.")
        self._main_layout.addWidget(self._example_label)
        self.setLayout(self._main_layout)

        self._hotspot_preview_loc = None
        self._pressed = False

        self.moveStep()
    def __init__(self, parent=None, metadata: Dict[str, Any] = None):
        super().__init__(parent)
        super().setWindowFlags(QtCore.Qt.Window
                               | QtCore.Qt.WindowCloseButtonHint)
        self.setWindowTitle(self.TITLE)

        if metadata is None:
            self._metadata = {"author": None, "licence": None}
        else:
            self._metadata = copy.deepcopy(metadata)

        self._main_layout = QtWidgets.QFormLayout(self)
        self._author = QtWidgets.QLineEdit()
        self._author.setText("" if (self._metadata.get("author", None) is None
                                    ) else self._metadata["author"])

        self._licence_text = QtWidgets.QTextEdit()
        self._licence_text.setText("" if (
            self._metadata.get("licence", None) is None
        ) else self._metadata["licence"])

        self._licence_btn = QtWidgets.QPushButton("From File")

        self._submit_btns = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)

        self._main_layout.addRow("Author:", self._author)
        self._main_layout.addRow("Licence:", self._licence_btn)
        self._main_layout.addRow(self._licence_text)
        self._main_layout.addRow(self._submit_btns)

        self._licence_btn.clicked.connect(self._on_file_req)
        self._submit_btns.accepted.connect(self._on_accept)
        self._submit_btns.rejected.connect(self.reject)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
Exemplo n.º 3
0
    def __init__(self, parent=None):
        self._app = QtWidgets.QApplication.instance()
        if self._app is None:
            self._app = QtWidgets.QApplication([])

        self._web_engine = QtWebEngineWidgets.QWebEngineView(parent)
        self._page = self.DumpPage(self._web_engine)
        self._web_engine.setPage(self._page)
def launch_gui(def_project: Union[str, None]):
    app = QtWidgets.QApplication(sys.argv)
    window = CursorThemeMaker()
    window.show()

    if def_project is not None:
        window.load_from_path(def_project)

    app.exec_()
Exemplo n.º 5
0
    def __init__(self, parent=None, cursor: AnimatedCursor = None):
        super().__init__(parent)
        super().setWindowFlags(QtCore.Qt.Window
                               | QtCore.Qt.WindowCloseButtonHint)

        self._outer_layout = QtWidgets.QVBoxLayout(self)
        self._inner_layout = FlowLayout()
        self._in_scroll_wid = QtWidgets.QWidget()
        self._scroll_area = QtWidgets.QScrollArea()
        self._scroll_area.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self._scroll_area.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)

        self._info_text = "Modify cursor hotspots below: "
        self._info_label = QtWidgets.QLabel(self._info_text)

        if (cursor is None) or (len(cursor) == 0):
            self._hotspot_picker_lst = [CursorEditWidget()]
            self._cursor = self._hotspot_picker_lst[0].current_cursor
        else:
            self._hotspot_picker_lst = [
                CursorEditWidget(None, cursor, i) for i in range(len(cursor))
            ]
            self._cursor = cursor

        for i, cur_picker in enumerate(self._hotspot_picker_lst):
            self._inner_layout.addWidget(cur_picker)
        self._scroll_area.setWidgetResizable(True)
        self._in_scroll_wid.setLayout(self._inner_layout)
        self._scroll_area.setWidget(self._in_scroll_wid)

        self._share_hotspots = QtWidgets.QCheckBox(
            "Share Hotspots Between Frames")
        self._share_hotspots.setTristate(False)

        self._share_delays = QtWidgets.QCheckBox("Share Delays Between Frames")
        self._share_delays.setTristate(False)

        self._preview = QtWidgets.QPushButton("Preview")

        self._outer_layout.addWidget(self._info_label)
        self._outer_layout.addWidget(self._scroll_area)
        self._outer_layout.addWidget(self._share_hotspots)
        self._outer_layout.addWidget(self._share_delays)
        self._outer_layout.addWidget(self._preview)

        self.setLayout(self._outer_layout)
        self.resize(self.sizeHint())

        # Event connections...
        self._share_hotspots.stateChanged.connect(self._share_hotspot_chg)
        self._share_delays.stateChanged.connect(self._share_delays_chg)
        self._preview.clicked.connect(self._on_preview)
        for cur_picker in self._hotspot_picker_lst:
            cur_picker.userHotspotChange.connect(self._on_hotspot_changed)
            cur_picker.userDelayChange.connect(self._on_delay_changed)
        # Set to delete this dialog on close...
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
Exemplo n.º 6
0
    def __init__(self,
                 parent=None,
                 cursor: AnimatedCursor = None,
                 frame=0,
                 *args,
                 **kwargs):
        super().__init__(parent, *args, **kwargs)

        self._main_layout = QtWidgets.QVBoxLayout(self)
        self._hotspot_picker = CursorHotspotWidget(cursor=cursor, frame=frame)
        self._delay_adjuster = QtWidgets.QSpinBox()
        self._delay_adjuster.setRange(0, 0xFFFF)
        self._delay_adjuster.setSingleStep(1)

        self._frame = QtWidgets.QFrame()
        self._f_lay = QtWidgets.QVBoxLayout()
        self._f_lay.setContentsMargins(0, 0, 0, 0)
        self._f_lay.addWidget(self._hotspot_picker)
        self._frame.setLayout(self._f_lay)
        self._frame.setFrameStyle(QtWidgets.QFrame.Panel
                                  | QtWidgets.QFrame.Sunken)
        self._frame.setSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Fixed)

        self._main_layout.addWidget(self._frame)
        self._main_layout.setAlignment(self._frame, QtCore.Qt.AlignHCenter)
        self._main_layout.addWidget(self._delay_adjuster)

        self.setLayout(self._main_layout)
        self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised)

        # Copy properties from the hotspot picking widget...
        self._hotspot_picker.userHotspotChange.connect(
            lambda x, y: self.userHotspotChange.emit(x, y))

        # Update the delay value...
        self.delay = self.delay
        self._delay_adjuster.setValue(self.delay)

        # Connect spin box to delay value
        self._delay_adjuster.valueChanged.connect(self._change_delay)
    def __init__(self, parent=None, cursor: AnimatedCursor = None):
        super().__init__(parent)
        super().setWindowFlags(QtCore.Qt.Window
                               | QtCore.Qt.WindowCloseButtonHint)

        self._colors = ["white", "black"]

        self._main_layout = QtWidgets.QVBoxLayout()

        self._preview_panel = PreviewArea(None, cursor)
        self._frame = QtWidgets.QFrame()
        self._frame.setFrameStyle(QtWidgets.QFrame.Box
                                  | QtWidgets.QFrame.Plain)
        self._box = QtWidgets.QVBoxLayout()
        self._box.addWidget(self._preview_panel)
        self._frame.setLayout(self._box)
        self._box.setContentsMargins(0, 0, 0, 0)

        self._viewers = []

        for color in self._colors:
            widget = QtWidgets.QWidget()
            widget.setStyleSheet(f"background-color: {color};")
            hbox = QtWidgets.QHBoxLayout()

            for size in cursor_util.DEFAULT_SIZES:
                c_view = CursorDisplayWidget(cursor=cursor, size=size[0])
                self._viewers.append(c_view)
                hbox.addWidget(c_view)

            widget.setLayout(hbox)
            self._main_layout.addWidget(widget)

        self._main_layout.addWidget(self._frame)

        self.setLayout(self._main_layout)
        self.setMinimumSize(self.sizeHint())

        # Set to delete this dialog on close...
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
    def __init__(self,
                 parent=None,
                 label_text="Label",
                 def_cursor=None,
                 *args,
                 **kwargs):
        super().__init__(parent, *args, **kwargs)

        self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised)

        self._main_layout = QtWidgets.QVBoxLayout()
        self._label = QtWidgets.QLabel(label_text)
        self._label.setAlignment(QtCore.Qt.AlignCenter)
        self._viewer = CursorViewEditWidget(cursor=def_cursor)
        self._file_sel_btn = QtWidgets.QPushButton("Select File")
        self._current_file = None

        # Make a frame to wrap around the hotspot picker and add a border...
        self._frame = QtWidgets.QFrame()
        self._f_lay = QtWidgets.QVBoxLayout()
        # self._f_lay.setMargin(0)
        self._f_lay.setContentsMargins(0, 0, 0, 0)
        self._f_lay.addWidget(self._viewer)
        self._frame.setLayout(self._f_lay)
        self._frame.setFrameStyle(QtWidgets.QFrame.Panel
                                  | QtWidgets.QFrame.Sunken)
        self._frame.setSizePolicy(QtWidgets.QSizePolicy.Fixed,
                                  QtWidgets.QSizePolicy.Fixed)

        self._main_layout.addWidget(self._label)
        self._main_layout.addWidget(self._frame)
        self._main_layout.addWidget(self._file_sel_btn)

        self._main_layout.setAlignment(self._frame, QtCore.Qt.AlignHCenter)

        self.setLayout(self._main_layout)
        self.setAcceptDrops(True)

        # Events...
        self._file_sel_btn.clicked.connect(self.open_file)
    def __init__(self, parent=None, name=""):
        super().__init__(parent)
        super().setWindowFlags(QtCore.Qt.Window
                               | QtCore.Qt.WindowCloseButtonHint)
        self.setWindowTitle(name)
        self._result = None

        self._form_layout = QtWidgets.QFormLayout(self)
        self._hbox_layout = QtWidgets.QHBoxLayout()

        self._button = QtWidgets.QPushButton("Select")
        self._text = QtWidgets.QLineEdit("")
        self._text.setReadOnly(True)
        self._hbox_layout.addWidget(self._button)
        self._hbox_layout.addWidget(self._text)

        self._theme_text = QtWidgets.QLineEdit()

        self._form_layout.addRow("Theme Name:", self._theme_text)
        self._form_layout.addRow("Theme Directory:", self._hbox_layout)

        self._submit_btns = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Cancel | QtWidgets.QDialogButtonBox.Ok)
        self._submit_btns.button(
            QtWidgets.QDialogButtonBox.Ok).setEnabled(False)
        self._form_layout.addRow(self._submit_btns)

        self.setLayout(self._form_layout)

        self._button.clicked.connect(self.open_dir)

        self._submit_btns.rejected.connect(self.reject)
        self._submit_btns.accepted.connect(self.accept)
        self._theme_text.textChanged.connect(lambda a: self.validate())

        self.accepted.connect(self.on_submit_stuff)
        self.setAttribute(QtCore.Qt.WA_DeleteOnClose, True)
    def __init__(self, parent=None, *args, **kwargs):
        super().__init__(parent, *args, **kwargs)

        mem_icon = BytesIO(base64.b64decode(ICON))

        self.setWindowTitle("Cursor Theme Builder")
        self.setWindowIcon(QtGui.QIcon(toqpixmap(Image.open(mem_icon))))

        self._open_build_project = None

        self._metadata = {"author": None, "licence": None}

        self._main_layout = QtWidgets.QVBoxLayout(self)

        self._scroll_pane = QtWidgets.QScrollArea()
        self._scroll_pane.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)
        self._scroll_pane.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self._scroll_pane.setWidgetResizable(True)

        self._inner_pane_area = QtWidgets.QWidget()
        self._flow_layout = FlowLayout()

        self._cursor_selectors = {}

        for cursor_name in sorted(CursorThemeBuilder.DEFAULT_CURSORS):
            self._cursor_selectors[cursor_name] = CursorSelectWidget(
                label_text=cursor_name)
            self._flow_layout.addWidget(self._cursor_selectors[cursor_name])

        self._edit_metadata = QtWidgets.QPushButton("Edit Artist Info")
        self._main_layout.addWidget(self._edit_metadata)

        self._inner_pane_area.setLayout(self._flow_layout)
        self._scroll_pane.setWidget(self._inner_pane_area)

        self._button_layout = QtWidgets.QHBoxLayout()
        self._main_layout.addWidget(self._scroll_pane)

        self._build_button = QtWidgets.QPushButton("Build Project")
        self._create_proj_btn = QtWidgets.QPushButton("Save Project")
        self._load_proj_btn = QtWidgets.QPushButton("Load Project")
        self._update_proj_btn = QtWidgets.QPushButton("Update Project")
        self._build_in_place = QtWidgets.QPushButton("Build in Place")
        self._clear_btn = QtWidgets.QPushButton("New Project")
        self._update_proj_btn.setEnabled(False)
        self._build_in_place.setEnabled(False)
        self._button_layout.addWidget(self._build_button)
        self._button_layout.addWidget(self._create_proj_btn)
        self._button_layout.addWidget(self._load_proj_btn)
        self._button_layout.addWidget(self._update_proj_btn)
        self._button_layout.addWidget(self._build_in_place)
        self._button_layout.addWidget(self._clear_btn)

        self._main_layout.addLayout(self._button_layout)

        self.setLayout(self._main_layout)
        # self.setMinimumSize(self.sizeHint())

        self._build_button.clicked.connect(self.build_project)
        self._create_proj_btn.clicked.connect(self.create_project)
        self._load_proj_btn.clicked.connect(self.load_project)
        self._update_proj_btn.clicked.connect(self.update_project)
        self._build_in_place.clicked.connect(self.build_in_place)
        self._clear_btn.clicked.connect(self.clear_ui)
        self._edit_metadata.clicked.connect(self._chg_metadata)
    @current_cursor.setter
    def current_cursor(self, value):
        self._viewer.current_cursor = value

    @property
    def label_text(self):
        return self._label.text()

    @label_text.setter
    def label_text(self, value):
        self._label.setText(value)

    @property
    def current_file(self):
        return self._current_file

    @current_file.setter
    def current_file(self, value):
        if (not isinstance(value, str)) and (value is not None):
            raise ValueError("The file path must be a string!!!")

        self._current_file = value


if __name__ == "__main__":
    app = QtWidgets.QApplication([])
    window = CursorSelectWidget(label_text="wait")
    window.show()
    app.exec_()
    print(window.current_cursor, window.current_file)