Loading config/stylesheet.css +38 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,15 @@ SizeComboBox::drop-down { width: 12px; } SizeControlLabel { font-size: 14px; } SmallSizeControlLabel { font-size: 12px; } QLabel#lineSpacingLabel { image: url(icons/fontfmt_linespacing.svg); max-width: 25px; Loading @@ -153,6 +162,19 @@ QLabel#lineSpacingLabel { min-height: 25px; } QGroupBox { font-size: 14px; border: 1px solid @borderColor; margin-top: 9px; border-radius: 6px; } QGroupBox::title { subcontrol-origin: margin; left: 7px; padding: 0px 5px 0px 5px; } QLabel#letterSpacingLabel { image: url(icons/fontfmt_letterspacing.svg); max-width: 28px; Loading @@ -173,6 +195,14 @@ ColorPickerLabel::hover { border: 2px solid rgb(30, 147, 229); } SmallColorPickerLabel { max-height: 17px; min-height: 17px; min-width: 17px; max-width: 17px; border: 1px solid @borderColor; } AlignmentChecker { margin: 0px; } Loading Loading @@ -1019,6 +1049,14 @@ SmallComboBox { background-color: @transtexteditBackgroundColor; } SmallSizeComboBox { height: 20px; font-size: 12px; /* padding-left: 8px; */ border: 1px solid @borderColor; background-color: @transtexteditBackgroundColor; } ArrowLeftButton { image: url(icons/arrow-left.svg); border: none; Loading ui/custom_widget/__init__.py +2 −2 Original line number Diff line number Diff line from .scrollbar import ScrollBar from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox, SmallComboBox from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox, SmallComboBox, SmallSizeComboBox from .widget import Widget, SeparatorWidget from .view_panel import PanelGroupBox, PanelArea, PanelAreaContent, ViewWidget, ExpandLabel from .message import MessageBox, TaskProgressBar, FrameLessMessageBox, ProgressMessageBox, ImgtransProgressMessageBox from .flow_layout import FlowLayout from .label import FadeLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, ParamNameLabel, SmallParamLabel from .label import FadeLabel, SmallColorPickerLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, ParamNameLabel, SmallParamLabel, SizeControlLabel, SmallSizeControlLabel from .slider import PaintQSlider from .helper import isDarkTheme, themeColor from .push_button import NoBorderPushBtn Loading ui/custom_widget/combobox.py +13 −2 Original line number Diff line number Diff line from typing import List from typing import List, Callable from qtpy.QtWidgets import QComboBox, QWidget from qtpy.QtCore import Signal, Qt Loading Loading @@ -76,7 +76,7 @@ class ParamComboBox(ComboBox): class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: def __init__(self, val_range: List = None, param_name: str = '', parent=None, init_value=None, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) Loading @@ -92,6 +92,8 @@ class SizeComboBox(QComboBox): self.setValidator(validator) self._value = 0 if init_value is not None: self.setValue(init_value) def on_text_changed(self): if self.hasFocus(): Loading @@ -113,3 +115,12 @@ class SizeComboBox(QComboBox): def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2))) def changeByDelta(self, delta: float, multiplier = 0.01): if isinstance(multiplier, Callable): multiplier = multiplier() self.setValue(self.value() + delta * multiplier) class SmallSizeComboBox(SizeComboBox): pass No newline at end of file ui/custom_widget/label.py +68 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ from qtpy.QtGui import QMouseEvent, QWheelEvent, QColor from utils.shared import CONFIG_FONTSIZE_CONTENT from utils import shared class FadeLabel(QLabel): def __init__(self, *args, **kwargs): Loading Loading @@ -42,9 +44,10 @@ class FadeLabel(QLabel): class ColorPickerLabel(QLabel): colorChanged = Signal(bool) changingColor = Signal() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def __init__(self, parent=None, param_name='', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.color: QColor = None self.param_name = param_name def mousePressEvent(self, event): self.changingColor.emit() Loading Loading @@ -73,6 +76,11 @@ class ColorPickerLabel(QLabel): return (color.red(), color.green(), color.blue(), color.alpha()) class SmallColorPickerLabel(ColorPickerLabel): pass class ClickableLabel(QLabel): clicked = Signal() Loading Loading @@ -167,8 +175,62 @@ class SmallParamLabel(QLabel): else: self.setAlignment(alignment) # font = self.font() # font.setPointSizeF(CONFIG_FONTSIZE_CONTENT-2) # self.setFont(font) self.setText(param_name) self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) class SizeControlLabel(QLabel): btn_released = Signal() size_ctrl_changed = Signal(int) def __init__(self, parent=None, direction=0, text='', alignment=None, transparent_bg=True): super().__init__(parent) if text: self.setText(text) if direction == 0: self.setCursor(Qt.CursorShape.SizeHorCursor) else: self.setCursor(Qt.CursorShape.SizeVerCursor) self.cur_pos = 0 self.direction = direction self.mouse_pressed = False if transparent_bg: self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) if alignment is not None: self.setAlignment(alignment) def mousePressEvent(self, e: QMouseEvent) -> None: if e.button() == Qt.MouseButton.LeftButton: self.mouse_pressed = True if shared.FLAG_QT6: g_pos = e.globalPosition().toPoint() else: g_pos = e.globalPos() self.cur_pos = g_pos.x() if self.direction == 0 else g_pos.y() return super().mousePressEvent(e) def mouseReleaseEvent(self, e: QMouseEvent) -> None: if e.button() == Qt.MouseButton.LeftButton: self.mouse_pressed = False self.btn_released.emit() return super().mouseReleaseEvent(e) def mouseMoveEvent(self, e: QMouseEvent) -> None: if self.mouse_pressed: if shared.FLAG_QT6: g_pos = e.globalPosition().toPoint() else: g_pos = e.globalPos() if self.direction == 0: new_pos = g_pos.x() self.size_ctrl_changed.emit(new_pos - self.cur_pos) else: new_pos = g_pos.y() self.size_ctrl_changed.emit(self.cur_pos - new_pos) self.cur_pos = new_pos return super().mouseMoveEvent(e) class SmallSizeControlLabel(SizeControlLabel): pass No newline at end of file ui/custom_widget/view_panel.py +39 −11 Original line number Diff line number Diff line Loading @@ -8,12 +8,22 @@ from utils import shared from utils.config import pcfg CHEVRON_SIZE = 20 CHEVRON_SIZE_SMALL = 14 def chevron_down(): return QIcon(r'icons/chevron-down.svg').pixmap(CHEVRON_SIZE, CHEVRON_SIZE, mode=QIcon.Mode.Normal) def chevron_right(): return QIcon(r'icons/chevron-right.svg').pixmap(CHEVRON_SIZE, CHEVRON_SIZE, mode=QIcon.Mode.Normal) def chevron_down_small(): return QIcon(r'icons/chevron-down.svg').pixmap(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL, mode=QIcon.Mode.Normal) def chevron_right_small(): return QIcon(r'icons/chevron-right.svg').pixmap(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL, mode=QIcon.Mode.Normal) class HidePanelButton(QPushButton): pass Loading @@ -23,19 +33,32 @@ class ExpandLabel(Widget): clicked = Signal() def __init__(self, text=None, parent=None, *args, **kwargs): def __init__(self, text=None, parent=None, size_type='normal', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.size_type = size_type self.textlabel = QLabel(self) self.textlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) self.arrowlabel = QLabel(self) self.arrowlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) font = self.textlabel.font() if size_type == 'normal': if shared.ON_MACOS: font.setPointSize(13) else: font.setPointSizeF(10) self.textlabel.setFont(font) self.arrowlabel = QLabel(self) self.setFixedHeight(26) self.arrowlabel.setFixedSize(CHEVRON_SIZE, CHEVRON_SIZE) self.arrowlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) elif size_type == 'small': if shared.ON_MACOS: font.setPointSize(10) else: font.setPointSizeF(8) self.setFixedHeight(20) self.arrowlabel.setFixedSize(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL) else: raise self.textlabel.setFont(font) self.hidelabel = HidePanelButton(self) self.hidelabel.setVisible(False) Loading @@ -51,7 +74,6 @@ class ExpandLabel(Widget): self.expanded = True self.setExpand(True) self.setFixedHeight(26) def enterEvent(self, event) -> None: self.hidelabel.setVisible(True) Loading Loading @@ -81,6 +103,7 @@ class PanelArea(QScrollArea): def __init__(self, panel_name: str, config_name: str, config_expand_name: str, action_name: str = None): super().__init__() self.scrollContent = PanelAreaContent() self.scrollContent.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum) self.setWidget(self.scrollContent) self.setWidgetResizable(True) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum) Loading Loading @@ -114,7 +137,12 @@ class PanelGroupBox(QGroupBox): class PanelAreaContent(Widget): pass after_resized = Signal() def resizeEvent(self, event) -> None: super().resizeEvent(event) self.after_resized.emit() class ViewWidget(Widget): Loading @@ -125,10 +153,10 @@ class ViewWidget(Widget): view_hide_btn_clicked = Signal(str) expend_changed = Signal() def __init__(self, content_widget: Widget, panel_name: str = None, parent=None, *args, **kwargs): def __init__(self, content_widget: Widget, panel_name: str = None, parent=None, title_size_type='normal', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.title_label = ExpandLabel(panel_name, self) self.title_label = ExpandLabel(panel_name, self, size_type=title_size_type) self.title_label.hidelabel.clicked.connect(self.on_view_hide_btn_clicked) self.content_widget = content_widget Loading Loading
config/stylesheet.css +38 −0 Original line number Diff line number Diff line Loading @@ -145,6 +145,15 @@ SizeComboBox::drop-down { width: 12px; } SizeControlLabel { font-size: 14px; } SmallSizeControlLabel { font-size: 12px; } QLabel#lineSpacingLabel { image: url(icons/fontfmt_linespacing.svg); max-width: 25px; Loading @@ -153,6 +162,19 @@ QLabel#lineSpacingLabel { min-height: 25px; } QGroupBox { font-size: 14px; border: 1px solid @borderColor; margin-top: 9px; border-radius: 6px; } QGroupBox::title { subcontrol-origin: margin; left: 7px; padding: 0px 5px 0px 5px; } QLabel#letterSpacingLabel { image: url(icons/fontfmt_letterspacing.svg); max-width: 28px; Loading @@ -173,6 +195,14 @@ ColorPickerLabel::hover { border: 2px solid rgb(30, 147, 229); } SmallColorPickerLabel { max-height: 17px; min-height: 17px; min-width: 17px; max-width: 17px; border: 1px solid @borderColor; } AlignmentChecker { margin: 0px; } Loading Loading @@ -1019,6 +1049,14 @@ SmallComboBox { background-color: @transtexteditBackgroundColor; } SmallSizeComboBox { height: 20px; font-size: 12px; /* padding-left: 8px; */ border: 1px solid @borderColor; background-color: @transtexteditBackgroundColor; } ArrowLeftButton { image: url(icons/arrow-left.svg); border: none; Loading
ui/custom_widget/__init__.py +2 −2 Original line number Diff line number Diff line from .scrollbar import ScrollBar from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox, SmallComboBox from .combobox import ComboBox, ConfigComboBox, ParamComboBox, SizeComboBox, SmallComboBox, SmallSizeComboBox from .widget import Widget, SeparatorWidget from .view_panel import PanelGroupBox, PanelArea, PanelAreaContent, ViewWidget, ExpandLabel from .message import MessageBox, TaskProgressBar, FrameLessMessageBox, ProgressMessageBox, ImgtransProgressMessageBox from .flow_layout import FlowLayout from .label import FadeLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, ParamNameLabel, SmallParamLabel from .label import FadeLabel, SmallColorPickerLabel, ColorPickerLabel, ClickableLabel, CheckableLabel, TextCheckerLabel, ParamNameLabel, SmallParamLabel, SizeControlLabel, SmallSizeControlLabel from .slider import PaintQSlider from .helper import isDarkTheme, themeColor from .push_button import NoBorderPushBtn Loading
ui/custom_widget/combobox.py +13 −2 Original line number Diff line number Diff line from typing import List from typing import List, Callable from qtpy.QtWidgets import QComboBox, QWidget from qtpy.QtCore import Signal, Qt Loading Loading @@ -76,7 +76,7 @@ class ParamComboBox(ComboBox): class SizeComboBox(QComboBox): param_changed = Signal(str, float) def __init__(self, val_range: List = None, param_name: str = '', *args, **kwargs) -> None: def __init__(self, val_range: List = None, param_name: str = '', parent=None, init_value=None, *args, **kwargs) -> None: super().__init__(*args, **kwargs) self.param_name = param_name self.editTextChanged.connect(self.on_text_changed) Loading @@ -92,6 +92,8 @@ class SizeComboBox(QComboBox): self.setValidator(validator) self._value = 0 if init_value is not None: self.setValue(init_value) def on_text_changed(self): if self.hasFocus(): Loading @@ -113,3 +115,12 @@ class SizeComboBox(QComboBox): def setValue(self, value: float): value = min(self.max_val, max(self.min_val, value)) self.setCurrentText(str(round(value, 2))) def changeByDelta(self, delta: float, multiplier = 0.01): if isinstance(multiplier, Callable): multiplier = multiplier() self.setValue(self.value() + delta * multiplier) class SmallSizeComboBox(SizeComboBox): pass No newline at end of file
ui/custom_widget/label.py +68 −6 Original line number Diff line number Diff line Loading @@ -7,6 +7,8 @@ from qtpy.QtGui import QMouseEvent, QWheelEvent, QColor from utils.shared import CONFIG_FONTSIZE_CONTENT from utils import shared class FadeLabel(QLabel): def __init__(self, *args, **kwargs): Loading Loading @@ -42,9 +44,10 @@ class FadeLabel(QLabel): class ColorPickerLabel(QLabel): colorChanged = Signal(bool) changingColor = Signal() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) def __init__(self, parent=None, param_name='', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.color: QColor = None self.param_name = param_name def mousePressEvent(self, event): self.changingColor.emit() Loading Loading @@ -73,6 +76,11 @@ class ColorPickerLabel(QLabel): return (color.red(), color.green(), color.blue(), color.alpha()) class SmallColorPickerLabel(ColorPickerLabel): pass class ClickableLabel(QLabel): clicked = Signal() Loading Loading @@ -167,8 +175,62 @@ class SmallParamLabel(QLabel): else: self.setAlignment(alignment) # font = self.font() # font.setPointSizeF(CONFIG_FONTSIZE_CONTENT-2) # self.setFont(font) self.setText(param_name) self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) class SizeControlLabel(QLabel): btn_released = Signal() size_ctrl_changed = Signal(int) def __init__(self, parent=None, direction=0, text='', alignment=None, transparent_bg=True): super().__init__(parent) if text: self.setText(text) if direction == 0: self.setCursor(Qt.CursorShape.SizeHorCursor) else: self.setCursor(Qt.CursorShape.SizeVerCursor) self.cur_pos = 0 self.direction = direction self.mouse_pressed = False if transparent_bg: self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) if alignment is not None: self.setAlignment(alignment) def mousePressEvent(self, e: QMouseEvent) -> None: if e.button() == Qt.MouseButton.LeftButton: self.mouse_pressed = True if shared.FLAG_QT6: g_pos = e.globalPosition().toPoint() else: g_pos = e.globalPos() self.cur_pos = g_pos.x() if self.direction == 0 else g_pos.y() return super().mousePressEvent(e) def mouseReleaseEvent(self, e: QMouseEvent) -> None: if e.button() == Qt.MouseButton.LeftButton: self.mouse_pressed = False self.btn_released.emit() return super().mouseReleaseEvent(e) def mouseMoveEvent(self, e: QMouseEvent) -> None: if self.mouse_pressed: if shared.FLAG_QT6: g_pos = e.globalPosition().toPoint() else: g_pos = e.globalPos() if self.direction == 0: new_pos = g_pos.x() self.size_ctrl_changed.emit(new_pos - self.cur_pos) else: new_pos = g_pos.y() self.size_ctrl_changed.emit(self.cur_pos - new_pos) self.cur_pos = new_pos return super().mouseMoveEvent(e) class SmallSizeControlLabel(SizeControlLabel): pass No newline at end of file
ui/custom_widget/view_panel.py +39 −11 Original line number Diff line number Diff line Loading @@ -8,12 +8,22 @@ from utils import shared from utils.config import pcfg CHEVRON_SIZE = 20 CHEVRON_SIZE_SMALL = 14 def chevron_down(): return QIcon(r'icons/chevron-down.svg').pixmap(CHEVRON_SIZE, CHEVRON_SIZE, mode=QIcon.Mode.Normal) def chevron_right(): return QIcon(r'icons/chevron-right.svg').pixmap(CHEVRON_SIZE, CHEVRON_SIZE, mode=QIcon.Mode.Normal) def chevron_down_small(): return QIcon(r'icons/chevron-down.svg').pixmap(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL, mode=QIcon.Mode.Normal) def chevron_right_small(): return QIcon(r'icons/chevron-right.svg').pixmap(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL, mode=QIcon.Mode.Normal) class HidePanelButton(QPushButton): pass Loading @@ -23,19 +33,32 @@ class ExpandLabel(Widget): clicked = Signal() def __init__(self, text=None, parent=None, *args, **kwargs): def __init__(self, text=None, parent=None, size_type='normal', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.size_type = size_type self.textlabel = QLabel(self) self.textlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) self.arrowlabel = QLabel(self) self.arrowlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) font = self.textlabel.font() if size_type == 'normal': if shared.ON_MACOS: font.setPointSize(13) else: font.setPointSizeF(10) self.textlabel.setFont(font) self.arrowlabel = QLabel(self) self.setFixedHeight(26) self.arrowlabel.setFixedSize(CHEVRON_SIZE, CHEVRON_SIZE) self.arrowlabel.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground, True) elif size_type == 'small': if shared.ON_MACOS: font.setPointSize(10) else: font.setPointSizeF(8) self.setFixedHeight(20) self.arrowlabel.setFixedSize(CHEVRON_SIZE_SMALL, CHEVRON_SIZE_SMALL) else: raise self.textlabel.setFont(font) self.hidelabel = HidePanelButton(self) self.hidelabel.setVisible(False) Loading @@ -51,7 +74,6 @@ class ExpandLabel(Widget): self.expanded = True self.setExpand(True) self.setFixedHeight(26) def enterEvent(self, event) -> None: self.hidelabel.setVisible(True) Loading Loading @@ -81,6 +103,7 @@ class PanelArea(QScrollArea): def __init__(self, panel_name: str, config_name: str, config_expand_name: str, action_name: str = None): super().__init__() self.scrollContent = PanelAreaContent() self.scrollContent.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum) self.setWidget(self.scrollContent) self.setWidgetResizable(True) self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Maximum) Loading Loading @@ -114,7 +137,12 @@ class PanelGroupBox(QGroupBox): class PanelAreaContent(Widget): pass after_resized = Signal() def resizeEvent(self, event) -> None: super().resizeEvent(event) self.after_resized.emit() class ViewWidget(Widget): Loading @@ -125,10 +153,10 @@ class ViewWidget(Widget): view_hide_btn_clicked = Signal(str) expend_changed = Signal() def __init__(self, content_widget: Widget, panel_name: str = None, parent=None, *args, **kwargs): def __init__(self, content_widget: Widget, panel_name: str = None, parent=None, title_size_type='normal', *args, **kwargs): super().__init__(parent=parent, *args, **kwargs) self.title_label = ExpandLabel(panel_name, self) self.title_label = ExpandLabel(panel_name, self, size_type=title_size_type) self.title_label.hidelabel.clicked.connect(self.on_view_hide_btn_clicked) self.content_widget = content_widget Loading