Loading ui/custom_widget/__init__.py +3 −2 Original line number Diff line number Diff line from .scrollbar import ScrollBar from .combobox import ComboBox, ConfigComboBox, ParamComboBox from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox from .widget import Widget, SeparatorWidget from .view_panel import PanelGroupBox, PanelArea, PanelAreaContent, ViewWidget, ExpandLabel from .message import MessageBox, TaskProgressBar, FrameLessMessageBox, ProgressMessageBox, ImgtransProgressMessageBox Loading @@ -8,3 +8,4 @@ from .label import FadeLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, from .slider import PaintQSlider from .helper import isDarkTheme, themeColor from .push_button import NoBorderPushBtn from .checkbox import QFontChecker, AlignmentChecker No newline at end of file ui/custom_widget/checkbox.py 0 → 100644 +21 −0 Original line number Diff line number Diff line import sys from qtpy.QtWidgets import QCheckBox from qtpy.QtGui import QMouseEvent class QFontChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 45px") class AlignmentChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 15px") def mousePressEvent(self, event: QMouseEvent) -> None: if self.isChecked(): return event.accept() return super().mousePressEvent(event) ui/custom_widget/combobox.py +42 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from typing import List from qtpy.QtWidgets import QComboBox, QWidget from qtpy.QtCore import Signal, Qt from qtpy.QtGui import QDoubleValidator from utils.shared import CONFIG_COMBOBOX_LONG, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT, CONFIG_COMBOBOX_HEIGHT Loading Loading @@ -67,3 +68,44 @@ class ParamComboBox(ComboBox): def on_select_changed(self): self.paramwidget_edited.emit(self.param_key, self.currentText()) class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) self.activated.connect(self.on_current_index_changed) self.setEditable(True) self.min_val = val_range[0] self.max_val = val_range[1] validator = QDoubleValidator() if val_range is not None: validator.setTop(val_range[1]) validator.setBottom(val_range[0]) validator.setNotation(QDoubleValidator.Notation.StandardNotation) self.setValidator(validator) self._value = 0 def on_text_changed(self): if self.hasFocus(): self.param_changed.emit(self.param_name, self.value()) def on_current_index_changed(self): if self.hasFocus() or self.view().isVisible(): self.param_changed.emit(self.param_name, self.value()) def value(self) -> float: txt = self.currentText() try: val = float(txt) self._value = val return val except: return self._value def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2))) ui/text_advanced_format.py +6 −1 Original line number Diff line number Diff line Loading @@ -3,10 +3,12 @@ from typing import Any, Callable from qtpy.QtWidgets import QVBoxLayout, QPushButton, QComboBox, QLabel, QHBoxLayout from qtpy.QtCore import Signal, Qt, QRectF from .custom_widget import PanelGroupBox, PanelArea, ComboBox from .custom_widget import PanelGroupBox, PanelArea, ComboBox, QFontChecker from utils.fontformat import FontFormat class TextAdvancedFormatPanel(PanelArea): param_changed = Signal(str, object) Loading @@ -32,6 +34,8 @@ class TextAdvancedFormatPanel(PanelArea): linespacing_type_layout.addWidget(self.linespacing_type_combobox) # linespacing_type_layout.addStretch() # self.tate_chu_yoko_checker = QFontChecker() vlayout = QVBoxLayout() vlayout.addLayout(linespacing_type_layout) self.setContentLayout(vlayout) Loading @@ -39,6 +43,7 @@ class TextAdvancedFormatPanel(PanelArea): def set_active_format(self, font_format: FontFormat): self.active_format = font_format self.linespacing_type_combobox.setCurrentIndex(font_format.line_spacing_type) # self.tate_chu_yoko_checker.setChecked(font_format.font) def on_format_changed(self, format_name: str, get_format: Callable): self.param_changed.emit(format_name, get_format()) No newline at end of file ui/text_panel.py +3 −63 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ import copy import sys from typing import List from qtpy.QtWidgets import QComboBox, QLineEdit, QSizePolicy, QHBoxLayout, QVBoxLayout, QFrame, QFontComboBox, QApplication, QPushButton, QCheckBox, QLabel from qtpy.QtWidgets import QLineEdit, QSizePolicy, QHBoxLayout, QVBoxLayout, QFrame, QFontComboBox, QApplication, QPushButton, QLabel from qtpy.QtCore import Signal, Qt from qtpy.QtGui import QDoubleValidator, QFocusEvent, QMouseEvent, QTextCursor, QKeyEvent from qtpy.QtGui import QFocusEvent, QMouseEvent, QTextCursor, QKeyEvent from utils import shared from utils import config as C from utils.fontformat import FontFormat, px2pt, LineSpacingType from .custom_widget import Widget, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel from .custom_widget import Widget, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, AlignmentChecker, QFontChecker, SizeComboBox from .textitem import TextBlkItem from .text_graphical_effect import TextEffectPanelDeprecated from .text_effect import TextEffectPanel Loading Loading @@ -48,72 +48,12 @@ class LineEdit(QLineEdit): self.return_pressed_wochange.emit() class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) self.activated.connect(self.on_current_index_changed) self.setEditable(True) self.min_val = val_range[0] self.max_val = val_range[1] validator = QDoubleValidator() if val_range is not None: validator.setTop(val_range[1]) validator.setBottom(val_range[0]) validator.setNotation(QDoubleValidator.Notation.StandardNotation) self.setValidator(validator) self._value = 0 def on_text_changed(self): if self.hasFocus(): self.param_changed.emit(self.param_name, self.value()) def on_current_index_changed(self): if self.hasFocus() or self.view().isVisible(): self.param_changed.emit(self.param_name, self.value()) def value(self) -> float: txt = self.currentText() try: val = float(txt) self._value = val return val except: return self._value def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2))) class IncrementalBtn(QPushButton): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setFixedSize(13, 13) class QFontChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 45px") class AlignmentChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 15px") def mousePressEvent(self, event: QMouseEvent) -> None: if self.isChecked(): return event.accept() return super().mousePressEvent(event) class AlignmentBtnGroup(QFrame): param_changed = Signal(str, int) def __init__(self, *args, **kwargs): Loading Loading
ui/custom_widget/__init__.py +3 −2 Original line number Diff line number Diff line from .scrollbar import ScrollBar from .combobox import ComboBox, ConfigComboBox, ParamComboBox from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox from .widget import Widget, SeparatorWidget from .view_panel import PanelGroupBox, PanelArea, PanelAreaContent, ViewWidget, ExpandLabel from .message import MessageBox, TaskProgressBar, FrameLessMessageBox, ProgressMessageBox, ImgtransProgressMessageBox Loading @@ -8,3 +8,4 @@ from .label import FadeLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, from .slider import PaintQSlider from .helper import isDarkTheme, themeColor from .push_button import NoBorderPushBtn from .checkbox import QFontChecker, AlignmentChecker No newline at end of file
ui/custom_widget/checkbox.py 0 → 100644 +21 −0 Original line number Diff line number Diff line import sys from qtpy.QtWidgets import QCheckBox from qtpy.QtGui import QMouseEvent class QFontChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 45px") class AlignmentChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 15px") def mousePressEvent(self, event: QMouseEvent) -> None: if self.isChecked(): return event.accept() return super().mousePressEvent(event)
ui/custom_widget/combobox.py +42 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ from typing import List from qtpy.QtWidgets import QComboBox, QWidget from qtpy.QtCore import Signal, Qt from qtpy.QtGui import QDoubleValidator from utils.shared import CONFIG_COMBOBOX_LONG, CONFIG_COMBOBOX_MIDEAN, CONFIG_COMBOBOX_SHORT, CONFIG_COMBOBOX_HEIGHT Loading Loading @@ -67,3 +68,44 @@ class ParamComboBox(ComboBox): def on_select_changed(self): self.paramwidget_edited.emit(self.param_key, self.currentText()) class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) self.activated.connect(self.on_current_index_changed) self.setEditable(True) self.min_val = val_range[0] self.max_val = val_range[1] validator = QDoubleValidator() if val_range is not None: validator.setTop(val_range[1]) validator.setBottom(val_range[0]) validator.setNotation(QDoubleValidator.Notation.StandardNotation) self.setValidator(validator) self._value = 0 def on_text_changed(self): if self.hasFocus(): self.param_changed.emit(self.param_name, self.value()) def on_current_index_changed(self): if self.hasFocus() or self.view().isVisible(): self.param_changed.emit(self.param_name, self.value()) def value(self) -> float: txt = self.currentText() try: val = float(txt) self._value = val return val except: return self._value def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2)))
ui/text_advanced_format.py +6 −1 Original line number Diff line number Diff line Loading @@ -3,10 +3,12 @@ from typing import Any, Callable from qtpy.QtWidgets import QVBoxLayout, QPushButton, QComboBox, QLabel, QHBoxLayout from qtpy.QtCore import Signal, Qt, QRectF from .custom_widget import PanelGroupBox, PanelArea, ComboBox from .custom_widget import PanelGroupBox, PanelArea, ComboBox, QFontChecker from utils.fontformat import FontFormat class TextAdvancedFormatPanel(PanelArea): param_changed = Signal(str, object) Loading @@ -32,6 +34,8 @@ class TextAdvancedFormatPanel(PanelArea): linespacing_type_layout.addWidget(self.linespacing_type_combobox) # linespacing_type_layout.addStretch() # self.tate_chu_yoko_checker = QFontChecker() vlayout = QVBoxLayout() vlayout.addLayout(linespacing_type_layout) self.setContentLayout(vlayout) Loading @@ -39,6 +43,7 @@ class TextAdvancedFormatPanel(PanelArea): def set_active_format(self, font_format: FontFormat): self.active_format = font_format self.linespacing_type_combobox.setCurrentIndex(font_format.line_spacing_type) # self.tate_chu_yoko_checker.setChecked(font_format.font) def on_format_changed(self, format_name: str, get_format: Callable): self.param_changed.emit(format_name, get_format()) No newline at end of file
ui/text_panel.py +3 −63 Original line number Diff line number Diff line Loading @@ -2,14 +2,14 @@ import copy import sys from typing import List from qtpy.QtWidgets import QComboBox, QLineEdit, QSizePolicy, QHBoxLayout, QVBoxLayout, QFrame, QFontComboBox, QApplication, QPushButton, QCheckBox, QLabel from qtpy.QtWidgets import QLineEdit, QSizePolicy, QHBoxLayout, QVBoxLayout, QFrame, QFontComboBox, QApplication, QPushButton, QLabel from qtpy.QtCore import Signal, Qt from qtpy.QtGui import QDoubleValidator, QFocusEvent, QMouseEvent, QTextCursor, QKeyEvent from qtpy.QtGui import QFocusEvent, QMouseEvent, QTextCursor, QKeyEvent from utils import shared from utils import config as C from utils.fontformat import FontFormat, px2pt, LineSpacingType from .custom_widget import Widget, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel from .custom_widget import Widget, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, AlignmentChecker, QFontChecker, SizeComboBox from .textitem import TextBlkItem from .text_graphical_effect import TextEffectPanelDeprecated from .text_effect import TextEffectPanel Loading Loading @@ -48,72 +48,12 @@ class LineEdit(QLineEdit): self.return_pressed_wochange.emit() class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) self.activated.connect(self.on_current_index_changed) self.setEditable(True) self.min_val = val_range[0] self.max_val = val_range[1] validator = QDoubleValidator() if val_range is not None: validator.setTop(val_range[1]) validator.setBottom(val_range[0]) validator.setNotation(QDoubleValidator.Notation.StandardNotation) self.setValidator(validator) self._value = 0 def on_text_changed(self): if self.hasFocus(): self.param_changed.emit(self.param_name, self.value()) def on_current_index_changed(self): if self.hasFocus() or self.view().isVisible(): self.param_changed.emit(self.param_name, self.value()) def value(self) -> float: txt = self.currentText() try: val = float(txt) self._value = val return val except: return self._value def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2))) class IncrementalBtn(QPushButton): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.setFixedSize(13, 13) class QFontChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 45px") class AlignmentChecker(QCheckBox): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) if sys.platform == 'darwin': self.setStyleSheet("min-width: 15px") def mousePressEvent(self, event: QMouseEvent) -> None: if self.isChecked(): return event.accept() return super().mousePressEvent(event) class AlignmentBtnGroup(QFrame): param_changed = Signal(str, int) def __init__(self, *args, **kwargs): Loading