Esempio n. 1
0
    def __init__(self, api: Api, parent: QWidget) -> None:
        super().__init__(parent)
        self._z_mode = False
        self._api = api

        self.setMinimumHeight(get_text_edit_row_height(self, 2))
        self.vim_mode_enabled = self._api.cfg.opt["basic"]["vim_mode"]

        self.objectNameChanged.connect(self._on_object_name_change)
Esempio n. 2
0
    def __init__(
        self,
        api: Api,
        model: AssStylesModel,
        selection_model: QtCore.QItemSelectionModel,
        parent: QtWidgets.QWidget,
    ) -> None:
        super().__init__("Preview", parent)
        self._api = api
        self._selection_model = selection_model

        self._renderer = AssRenderer()

        self._editor = QtWidgets.QPlainTextEdit()
        self._editor.setPlainText(api.cfg.opt["styles"]["preview_test_text"])
        self._editor.setFixedWidth(400)
        self._editor.setTabChangesFocus(True)
        self._editor.setFixedHeight(get_text_edit_row_height(self._editor, 2))

        self._background_combobox = QtWidgets.QComboBox()
        for i, path in enumerate(get_assets("style_preview_bk")):
            self._background_combobox.addItem(path.name, path.resolve())
            if path.name == api.cfg.opt["styles"]["preview_background"]:
                self._background_combobox.setCurrentIndex(i)

        self._preview_box = QtWidgets.QLabel(self)
        self._preview_box.setLineWidth(1)
        self._preview_box.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self._preview_box.setFrameShadow(QtWidgets.QFrame.Sunken)
        self._preview_box.setSizePolicy(
            QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored
        )

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(self._editor)
        layout.addWidget(self._background_combobox)
        layout.addWidget(self._preview_box)

        self.update_preview()
        self._editor.textChanged.connect(self._on_text_change)
        self._background_combobox.currentIndexChanged.connect(
            self._on_background_change
        )

        model.dataChanged.connect(self.update_preview)
        model.rowsInserted.connect(self.update_preview)
        model.rowsRemoved.connect(self.update_preview)
        selection_model.selectionChanged.connect(self.update_preview)
Esempio n. 3
0
    def __init__(
        self, api: Api, parent: QtWidgets.QWidget, **kwargs: T.Any
    ) -> None:
        super().__init__(parent, **kwargs)
        self._api = api
        try:
            font_def = self._api.cfg.opt["gui"]["fonts"][self.objectName()]
        except KeyError:
            pass
        else:
            if font_def:
                font = QtGui.QFont()
                font.fromString(font_def)
                self.setFont(font)

        self.setMinimumHeight(get_text_edit_row_height(self, 2))
        self.vim_mode_enabled = self._api.cfg.opt["basic"]["vim_mode"]