Skip to content

Commit

Permalink
fix: change size in qss to theme variable
Browse files Browse the repository at this point in the history
  • Loading branch information
muyr authored and loonghao committed Jun 21, 2024
1 parent 08fb749 commit 597e359
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 60 deletions.
1 change: 1 addition & 0 deletions dayu_widgets/item_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def __init__(self, size=None, show_row_count=False, parent=None):
size = size or dayu_theme.default_size
ver_header_view = MHeaderView(QtCore.Qt.Vertical, parent=self)
ver_header_view.setDefaultSectionSize(size)
ver_header_view.setSortIndicatorShown(False)
self.setVerticalHeader(ver_header_view)
self.header_list = []
self.header_view = MHeaderView(QtCore.Qt.Horizontal, parent=self)
Expand Down
94 changes: 37 additions & 57 deletions dayu_widgets/static/main.qss
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ QToolButton#qt_calendar_yearbutton {
QToolButton#qt_calendar_monthbutton::menu-indicator {
subcontrol-origin: padding;
subcontrol-position: center right;
right: 0;
width: @drop_down_small@unit;
right: @indicator_padding@unit;
}

QCalendarWidget QWidget {
Expand Down Expand Up @@ -360,7 +359,7 @@ MTaobaoButton:checked{

MBlockButton{
border-radius: 0;
padding: 2px 10px;
padding: 1% 10%;
border:none;
}
MBlockButton:hover{
Expand All @@ -374,7 +373,7 @@ MBlockButton:checked{

MUnderlineButton{
border-radius: 0;
padding: 6px 10px;
padding: 1% 10%;
border-color: transparent;
}
MUnderlineButton:hover{
Expand Down Expand Up @@ -418,10 +417,8 @@ MToolButton[dayu_size="@tiny"], MPushButton[dayu_size="@tiny"]{
MToolButton::menu-indicator {
subcontrol-origin: border;
subcontrol-position: bottom right;
right: 5px;
bottom: 5px;
height: 10px;
width: 10px;
right: @indicator_padding@unit;
bottom: @indicator_padding@unit;
image: url(@icon_down);
}

Expand Down Expand Up @@ -636,10 +633,8 @@ MPushButton:disabled{
MPushButton::menu-indicator {
subcontrol-origin: border;
subcontrol-position: bottom right;
right: 5px;
bottom: 5px;
height: 10px;
width: 10px;
right: @indicator_padding@unit;
bottom: @indicator_padding@unit;
image: url(@icon_down);
}

Expand Down Expand Up @@ -681,9 +676,6 @@ MRadioButton::indicator:checked:disabled{


/*MSwitch*/
MSwitch{
spacing: -20px;
}
MSwitch::indicator{
subcontrol-origin: border;
subcontrol-position: center left;
Expand Down Expand Up @@ -867,8 +859,8 @@ MTabWidget::tab-bar {
MTabBar::tab {
border: 1px solid @border_color;
border-bottom: none;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
border-top-left-radius: 5%;
border-top-right-radius: 5%;
background-color: @background_in_color;
}

Expand All @@ -888,7 +880,7 @@ MTabBar::tab:hover {
MTabBar::close-button {
subcontrol-origin: content;
subcontrol-position: right center;
margin-right: 5px;
right: @indicator_padding@unit;
image: url(@icon_close);
}
MTabBar::close-button:hover {
Expand Down Expand Up @@ -920,7 +912,7 @@ MHeaderView {
MHeaderView::section{
background-color: @background_out_color;
border: 0 solid @border_color;
padding: 1px 6px;
padding: 1px @indicator_padding@unit;
}


Expand All @@ -944,20 +936,16 @@ MHeaderView::section:hover {
}

MHeaderView::up-arrow {
width: 8px;
height: 8px;
position: relative;
top: -10px;
right: 50%;
subcontrol-origin: padding;
subcontrol-position: center right;
right: @indicator_padding@unit;
image: url(@icon_up);
}

MHeaderView::down-arrow {
width: 8px;
height: 8px;
position: relative;
top: -10px;
right: 50%;
subcontrol-origin: padding;
subcontrol-position: center right;
right: @indicator_padding@unit;
image: url(@icon_down);
}
MListView[dayu_size="@huge"]::item{
Expand Down Expand Up @@ -1012,47 +1000,44 @@ MTableView QTableCornerButton::section {
border: 0px solid @border_color;
border-right: 1px solid @border_color;
border-bottom: 1px solid @border_color;
padding: 1px 6px;
}

QScrollBar:horizontal {
border: 0 solid @border_color;
height: 9px;
margin: 0 32px 0 0;
height: @indicator_size@unit;
margin: 0 @scroll_bar_margin@unit 0 0;
background-color: @border_color;
}

QScrollBar::handle:horizontal {
background-color: @background_selected_color;
min-width: 10px;
border-radius: @scroll_bar_radius@unit;
}

QScrollBar::add-line:horizontal {
subcontrol-origin: margin;
subcontrol-position: right center;
background: @border_color;
width: 15px;
width: @scroll_bar_size@unit;
}

QScrollBar::sub-line:horizontal {
subcontrol-origin: margin;
subcontrol-position: right center;
background: @border_color;
width: 15px;
right: 16px;
width: @scroll_bar_size@unit;
right: @scroll_bar_size@unit;
}

QScrollBar::left-arrow:horizontal {
width: 9px;
height: 9px;
position: relative;
subcontrol-origin: margin;
subcontrol-position: center center;
image: url(@icon_left);
}

QScrollBar::right-arrow:horizontal {
width: 9px;
height: 9px;
position: relative;
subcontrol-origin: margin;
subcontrol-position: center center;
image: url(@icon_right);
}

Expand All @@ -1062,41 +1047,36 @@ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {

QScrollBar:vertical {
border: 0 solid @border_color;
width: 9px;
margin: 0 0 32px 0 ;
width: @indicator_size@unit;
margin: 0 0 @scroll_bar_margin@unit 0 ;
background-color: @border_color;
}

QScrollBar::handle:vertical {
background-color: @background_selected_color;
min-height: 10px;
}

QScrollBar::add-line:vertical {
subcontrol-origin: margin;
subcontrol-position: center bottom;
background: @border_color;
height: 15px;
height: @scroll_bar_size@unit;
}

QScrollBar::sub-line:vertical {
subcontrol-origin: margin;
subcontrol-position: center bottom;
background: @border_color;
height: 15px;
bottom: 16px;
height: @scroll_bar_size@unit;
bottom: @scroll_bar_size@unit;
}

QScrollBar::up-arrow:vertical {
width: 9px;
height: 9px;
position: relative;
image: url(@icon_up)
}

QScrollBar::down-arrow:vertical {
width: 9px;
height: 9px;
position: relative;
image: url(@icon_down)
}
Expand Down Expand Up @@ -1184,19 +1164,19 @@ MDockWidget {
MDockWidget::title {
background: @background_selected_color;
text-align: left;
padding-left: 10px;
padding-left: @indicator_padding@unit;
}

MDockWidget::close-button {
subcontrol-origin: margin;
subcontrol-position: right center;
right: 8px;
right: @indicator_padding@unit;
}

MDockWidget::float-button {
subcontrol-origin: margin;
subcontrol-position: right center;
right: 30px;
right: @scroll_bar_margin@unit;
}
MDockWidget::close-button:hover, MDockWidget::float-button:hover {
border: 1px solid @primary_color;
Expand Down Expand Up @@ -1241,7 +1221,7 @@ MMenu::item {
padding: 2px 2px;
}
MMenu::item {
padding: 8px auto;
padding: @indicator_padding@unit auto;
}
MMenu::item:checked {
color: @primary_color;
Expand All @@ -1252,7 +1232,7 @@ MMenu::item:selected {
}

MMenu::indicator {
left: 6px;
left: @indicator_padding@unit;
}

QToolTip {
Expand Down
11 changes: 8 additions & 3 deletions dayu_widgets/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,25 @@ def get_theme_size():
"check_box_size": int(13 * scale_factor_x),
"check_box_spacing": int(4 * scale_factor_x),
"radio_size": int(14 * scale_factor_x),
"radio_radius": int(14 * scale_factor_x) / 2.0,
"radio_radius": int(14 * scale_factor_x / 2.0),
"radio_spacing": int(4 * scale_factor_x),
"slider_height": int(4 * scale_factor_x),
"slider_radius": int(3 * scale_factor_x),
"slider_handle_size": int(8 * scale_factor_x),
"slider_handle_radius": int(8 * scale_factor_x) / 1.5,
"slider_handle_radius": int(8 * scale_factor_x / 1.5),
"progress_circle_default_radius": int(120 * scale_factor_x),
"progress_bar_size": int(12 * scale_factor_x),
"progress_bar_radius": int(12 * scale_factor_x) / 2.0,
"progress_bar_radius": int(12 * scale_factor_x / 2.0),
"toast_size": int(120 * scale_factor_x),
"toast_icon_size": int(60 * scale_factor_x),
"big_view_default_size": int(120 * scale_factor_x),
"big_view_max_size": int(400 * scale_factor_x),
"big_view_min_size": int(24 * scale_factor_x),
"indicator_padding": int(4 * scale_factor_x),
"indicator_size": int(8 * scale_factor_x),
"scroll_bar_size": int(12 * scale_factor_x),
"scroll_bar_margin": int(12 * scale_factor_x * 2) + 1,
"scroll_bar_radius": int(12 * scale_factor_x / 2.0),
}


Expand Down

0 comments on commit 597e359

Please sign in to comment.