Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: buttons and sliders #197

Merged
merged 36 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e1b53c6
refactor: class method init supported
ChinaIceF Oct 29, 2024
1710fab
refactor: icon / text / icon and text are supported in push button
ChinaIceF Oct 29, 2024
594d5f6
refactor: icon / text / icon and text are supported in push button
ChinaIceF Oct 29, 2024
bac4215
refactor: `SiProgressPushButton`
ChinaIceF Oct 30, 2024
86154a1
feat: new `init` method for easier initialization for SiExpAnimation
ChinaIceF Oct 30, 2024
9775e9c
feat: color animation in SiProgressPushButton
ChinaIceF Oct 30, 2024
5367495
refactor: `SiLongPressButtonRefactor`
ChinaIceF Oct 30, 2024
f880dd0
refactor: `SiLongPressButtonRefactor`
ChinaIceF Oct 30, 2024
63dcb4a
refactor: `SiToggleButtonRefactor`
ChinaIceF Oct 31, 2024
e77248a
flatten new button.py for further discussion on proj structure
ChinaIceF Oct 31, 2024
cc78ba8
refactor: new SiExpAnimation Inherits QAbstractAnimation
ChinaIceF Nov 2, 2024
1ea040d
refactor: new SiExpAnimation Inherits QAbstractAnimation
ChinaIceF Nov 3, 2024
dff1e85
refactor: use new SiExpAnimationRefactor as a test
ChinaIceF Nov 3, 2024
d4676d6
fix: ghost window caused by tooltip
ChinaIceF Nov 3, 2024
e8b700d
feat: new `toPixmap` in parser.py
ChinaIceF Nov 3, 2024
1d8b6ab
refactor: adopt new `SiExpAnimationRefactor` in button.py
ChinaIceF Nov 3, 2024
9a05bbe
refactor: use Property class for better reference
ChinaIceF Nov 4, 2024
6148b5d
refactor: new `reloadStyleData` method for style reloading when style…
ChinaIceF Nov 5, 2024
8483db5
refactor: impl `GlobalStyleManager` to distribute style data
ChinaIceF Nov 6, 2024
94533bf
feat: impl button scaling ani
ChinaIceF Nov 16, 2024
d31aaa0
chore: opt coding style
ChinaIceF Nov 16, 2024
9eb9639
refactor: SiSwitch
ChinaIceF Nov 16, 2024
82c6572
Merge pull request #173 from ChinaIceF/refactor-btn-abst
ChinaIceF Nov 17, 2024
237223c
fix:
rainzee Nov 17, 2024
afc3377
refactor: SiRadioButton
ChinaIceF Nov 19, 2024
98bc852
refactor: SiRadioButtonWithDescription
ChinaIceF Nov 20, 2024
b9bbaaa
refactor: SiRadioButtonWithAvatar
ChinaIceF Nov 21, 2024
e25cc40
Merge pull request #194 from ChinaIceF/refactor-newbtns
ChinaIceF Nov 21, 2024
a7994b8
refactor: Examples in Gallery
ChinaIceF Nov 21, 2024
235e017
Merge pull request #195 from ChinaIceF/refactor-newbtns
ChinaIceF Nov 21, 2024
6394996
opt: ani and style of radio buttons
ChinaIceF Nov 25, 2024
797bf7c
refactor: impl SiSlider
ChinaIceF Nov 27, 2024
89a669d
feat: impl SiCoordinatePicker2D
ChinaIceF Nov 29, 2024
4cd913a
feat: impl SiCoordinatePicker3D
ChinaIceF Dec 1, 2024
64a8d1c
fix: invisible tooltip of coordinate pickers
ChinaIceF Dec 3, 2024
8911a3c
Merge branch 'main' into refactor
ChinaIceF Dec 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .page_refactor import RefactoredWidgets
375 changes: 375 additions & 0 deletions examples/Gallery for siui/components/page_refactor/page_refactor.py

Large diffs are not rendered by default.

210 changes: 202 additions & 8 deletions examples/Gallery for siui/components/page_widgets/page_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,36 @@

import numpy
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QCursor
from PyQt5.QtGui import QCursor, QIcon
from PyQt5.QtWidgets import QGraphicsBlurEffect

from siui.components import (
SiCircularProgressBar,
SiDenseVContainer,
SiLineEdit,
SiLineEditWithDeletionButton,
SiLineEditWithItemName,
SiOptionCardLinear,
SiTitledWidgetGroup,
SiWidget,
)
from siui.components.button import SiPushButtonRefactor
from siui.components.button import (
SiFlatButton,
SiLongPressButtonRefactor,
SiProgressPushButton,
SiPushButtonRefactor,
SiRadioButtonRefactor,
SiRadioButtonWithAvatar,
SiRadioButtonWithDescription,
SiSwitchRefactor,
SiToggleButtonRefactor,
)
from siui.components.combobox import SiComboBox
from siui.components.menu import SiMenu
from siui.components.page import SiPage
from siui.components.progress_bar import SiProgressBar
from siui.components.slider import SiSliderH
from siui.components.slider_ import SiCoordinatePicker2D, SiCoordinatePicker3D, SiSlider
from siui.components.spinbox.spinbox import SiDoubleSpinBox, SiIntSpinBox
from siui.components.widgets import (
SiCheckBox,
Expand Down Expand Up @@ -250,6 +263,189 @@ def __init__(self, *args, **kwargs):
with self.titled_widgets_group as group:
group.addTitle("按钮")

# 按钮
self.refactor_buttons = OptionCardPlaneForWidgetDemos(self)
self.refactor_buttons.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
"/widgets/button.py")
self.refactor_buttons.setTitle("重构的按钮")

self.refactor_pushbutton = SiPushButtonRefactor(self)
self.refactor_pushbutton.setText("Confirm")
self.refactor_pushbutton.setSvgIcon(SiGlobal.siui.iconpack.get("ic_fluent_mail_checkmark_filled"))
self.refactor_pushbutton.adjustSize()

self.refactor_progress_button = SiProgressPushButton(self)
self.refactor_progress_button.setText("Downloading")
self.refactor_progress_button.setSvgIcon(SiGlobal.siui.iconpack.get("ic_fluent_arrow_download_filled"))
self.refactor_progress_button.setToolTip("Click me to set a random progress value.")
self.refactor_progress_button.clicked.connect(lambda: self.refactor_progress_button.setProgress(random.random() * 1.3))
self.refactor_progress_button.adjustSize()

self.refactor_long_press_button = SiLongPressButtonRefactor(self)
self.refactor_long_press_button.setText("Delete Files")
self.refactor_long_press_button.setToolTip("Hold me to confirm.<br><strong>Your files will be lost forever!</strong>")
self.refactor_long_press_button.setSvgIcon(SiGlobal.siui.iconpack.get("ic_fluent_delete_filled"))
self.refactor_long_press_button.longPressed.connect(lambda: self.refactor_long_press_button.setToolTip("Deleted!"))
self.refactor_long_press_button.adjustSize()

self.refactor_flat_button = SiFlatButton(self)
self.refactor_flat_button.setText("Flat Button")
self.refactor_flat_button.setSvgIcon(SiGlobal.siui.iconpack.get("ic_fluent_wrench_settings_filled"))
self.refactor_flat_button.adjustSize()

self.refactor_toggle_button = SiToggleButtonRefactor(self)
self.refactor_toggle_button.setText("Auto Save")
self.refactor_toggle_button.setSvgIcon(SiGlobal.siui.iconpack.get("ic_fluent_save_filled"))
self.refactor_toggle_button.adjustSize()

self.refactor_slider = SiSlider(self)
self.refactor_slider.resize(512, 32)
self.refactor_slider.setValue(5)
self.refactor_slider.setMinimum(-50)
self.refactor_slider.setMaximum(50)
self.refactor_slider.setToolTipConvertionFunc(lambda x: f"{x} ms")

self.refactor_slider2 = SiSlider(self)
self.refactor_slider2.resize(32, 256)
self.refactor_slider2.setOrientation(Qt.Orientation.Vertical)
self.refactor_slider2.setValue(0)
self.refactor_slider2.setMinimum(-30)
self.refactor_slider2.setMaximum(12)
self.refactor_slider2.setToolTipConvertionFunc(lambda x: f"{x} dB")

self.coordinate_picker_2d = SiCoordinatePicker3D(self)
self.coordinate_picker_2d.resize(384, 256)
self.coordinate_picker_2d.slider_z.setMaximum(6)

self.refactor_switch = SiSwitchRefactor(self)

self.refactor_buttons.body().addWidget(self.refactor_pushbutton)
self.refactor_buttons.body().addWidget(self.refactor_progress_button)
self.refactor_buttons.body().addWidget(self.refactor_long_press_button)
self.refactor_buttons.body().addWidget(self.refactor_flat_button)
self.refactor_buttons.body().addWidget(self.refactor_toggle_button)
self.refactor_buttons.body().addWidget(self.refactor_switch)
self.refactor_buttons.body().addWidget(self.refactor_slider)
self.refactor_buttons.body().addWidget(self.refactor_slider2)
self.refactor_buttons.body().addWidget(self.coordinate_picker_2d)

self.refactor_buttons.body().addPlaceholder(12)
self.refactor_buttons.adjustSize()

self.refactor_radiobuttons = OptionCardPlaneForWidgetDemos(self)
self.refactor_radiobuttons.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
"/widgets/button.py")
self.refactor_radiobuttons.setTitle("单行单选框")

radio_button_container = SiDenseVContainer(self)
radio_button_container.setSpacing(6)

self.refactor_radio_button = SiRadioButtonRefactor(self)
self.refactor_radio_button.setText("I want to go sleep now")
self.refactor_radio_button.adjustSize()
self.refactor_radio_button.setChecked(True)

self.refactor_radio_button2 = SiRadioButtonRefactor(self)
self.refactor_radio_button2.setText("你干嘛嗨嗨呦")
self.refactor_radio_button2.adjustSize()

self.refactor_radio_button3 = SiRadioButtonRefactor(self)
self.refactor_radio_button3.setText("唱跳 Rap 篮球")
self.refactor_radio_button3.adjustSize()

self.refactor_radio_button4 = SiRadioButtonRefactor(self)
self.refactor_radio_button4.setText("不是哥们我真的要困死了让我睡觉吧")
self.refactor_radio_button4.adjustSize()

self.refactor_radio_button5 = SiRadioButtonRefactor(self)
self.refactor_radio_button5.setText("nihao")
self.refactor_radio_button5.adjustSize()

radio_button_container.addWidget(self.refactor_radio_button)
radio_button_container.addWidget(self.refactor_radio_button2)
radio_button_container.addWidget(self.refactor_radio_button3)
radio_button_container.addWidget(self.refactor_radio_button4)
radio_button_container.addWidget(self.refactor_radio_button5)
radio_button_container.adjustSize()

self.refactor_radiobuttons.body().addWidget(radio_button_container)
self.refactor_radiobuttons.body().addPlaceholder(12)
self.refactor_radiobuttons.adjustSize()

self.refactor_radiobuttons_desc = OptionCardPlaneForWidgetDemos(self)
self.refactor_radiobuttons_desc.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
"/widgets/button.py")
self.refactor_radiobuttons_desc.setTitle("带解释的单选框")

radio_button_container = SiDenseVContainer(self)
radio_button_container.setSpacing(6)

self.refactor_radio_button = SiRadioButtonWithDescription(self)
self.refactor_radio_button.setText("Hello World")
self.refactor_radio_button.setDescription("This is the description of Item1, which is very long.")
self.refactor_radio_button.setDescriptionWidth(180)
self.refactor_radio_button.adjustSize()
self.refactor_radio_button.setChecked(True)

self.refactor_radio_button2 = SiRadioButtonWithDescription(self)
self.refactor_radio_button2.setText("我吃你牛魔")
self.refactor_radio_button2.setDescription("这是第二个选项的解释,短一些")
self.refactor_radio_button2.setDescriptionWidth(180)
self.refactor_radio_button2.adjustSize()

self.refactor_radio_button3 = SiRadioButtonWithDescription(self)
self.refactor_radio_button3.setText("诗人我吃")
self.refactor_radio_button3.setDescription("你干嘛嗨嗨呦~")
self.refactor_radio_button3.setDescriptionWidth(180)
self.refactor_radio_button3.adjustSize()

radio_button_container.addWidget(self.refactor_radio_button)
radio_button_container.addWidget(self.refactor_radio_button2)
radio_button_container.addWidget(self.refactor_radio_button3)
radio_button_container.adjustSize()

self.refactor_radiobuttons_desc.body().addWidget(radio_button_container)
self.refactor_radiobuttons_desc.body().addPlaceholder(12)
self.refactor_radiobuttons_desc.adjustSize()


self.refactor_radiobuttons_avatar = OptionCardPlaneForWidgetDemos(self)
self.refactor_radiobuttons_avatar.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
"/widgets/button.py")
self.refactor_radiobuttons_avatar.setTitle("带头像的单选框")

radio_button_container = SiDenseVContainer(self)
radio_button_container.setSpacing(16)

self.refactor_radio_button = SiRadioButtonWithAvatar(self)
self.refactor_radio_button.setText("霏泠Ice")
self.refactor_radio_button.setDescription("[email protected]")
self.refactor_radio_button.setIcon(QIcon("./img/avatar1.png"))
self.refactor_radio_button.adjustSize()
self.refactor_radio_button.setChecked(True)

self.refactor_radio_button2 = SiRadioButtonWithAvatar(self)
self.refactor_radio_button2.setText("我家鸽鸽")
self.refactor_radio_button2.setDescription("[email protected]")
self.refactor_radio_button2.setIcon(QIcon("./img/avatar2.png"))
self.refactor_radio_button2.adjustSize()

self.refactor_radio_button3 = SiRadioButtonWithAvatar(self)
self.refactor_radio_button3.setText("你干嘛嗨嗨呦")
self.refactor_radio_button3.setDescription("[email protected]")
self.refactor_radio_button3.setIcon(QIcon("./img/avatar1.png"))
self.refactor_radio_button3.adjustSize()

radio_button_container.addWidget(self.refactor_radio_button)
radio_button_container.addWidget(self.refactor_radio_button2)
radio_button_container.addWidget(self.refactor_radio_button3)
radio_button_container.adjustSize()

self.refactor_radiobuttons_avatar.body().addWidget(radio_button_container)
self.refactor_radiobuttons_avatar.body().addPlaceholder(12)
self.refactor_radiobuttons_avatar.adjustSize()


# 按钮
self.push_buttons = OptionCardPlaneForWidgetDemos(self)
self.push_buttons.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
Expand All @@ -259,11 +455,6 @@ def __init__(self, *args, **kwargs):
container_push_buttons = SiDenseHContainer(self)
container_push_buttons.setFixedHeight(32)

self.debug_new_button = SiPushButtonRefactor(self)
self.debug_new_button.resize(128, 32)
self.debug_new_button.setText("新按钮")
self.debug_new_button.setToolTip("我是工具提示")

self.demo_push_button_normal = SiPushButton(self)
self.demo_push_button_normal.resize(128, 32)
self.demo_push_button_normal.attachment().setText("普通按钮")
Expand All @@ -277,7 +468,6 @@ def __init__(self, *args, **kwargs):
self.demo_push_button_long_press.resize(128, 32)
self.demo_push_button_long_press.attachment().setText("长按按钮")

container_push_buttons.addWidget(self.debug_new_button)
container_push_buttons.addWidget(self.demo_push_button_normal)
container_push_buttons.addWidget(self.demo_push_button_transition)
container_push_buttons.addWidget(self.demo_push_button_long_press)
Expand Down Expand Up @@ -387,6 +577,10 @@ def __init__(self, *args, **kwargs):
self.checkboxes.body().addPlaceholder(12)
self.checkboxes.adjustSize()

group.addWidget(self.refactor_buttons)
group.addWidget(self.refactor_radiobuttons)
group.addWidget(self.refactor_radiobuttons_desc)
group.addWidget(self.refactor_radiobuttons_avatar)
group.addWidget(self.push_buttons)
group.addWidget(self.flat_buttons)
group.addWidget(self.switches)
Expand Down
Binary file added examples/Gallery for siui/img/avatar2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion examples/Gallery for siui/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import siui
from siui.core import SiGlobal

#siui.gui.set_scale_factor(1)
# siui.gui.set_scale_factor(1)


def show_version_message(window):
Expand Down
4 changes: 4 additions & 0 deletions examples/Gallery for siui/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from components.page_icons import ExampleIcons
from components.page_option_cards import ExampleOptionCards
from components.page_page_control import ExamplePageControl
from components.page_refactor import RefactoredWidgets
from components.page_widgets import ExampleWidgets
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QDesktopWidget
Expand Down Expand Up @@ -39,6 +40,9 @@ def __init__(self, *args, **kwargs):
self.layerMain().addPage(ExampleIcons(self),
icon=SiGlobal.siui.iconpack.get("ic_fluent_diversity_filled"),
hint="图标包", side="top")
self.layerMain().addPage(RefactoredWidgets(self),
icon=SiGlobal.siui.iconpack.get("ic_fluent_box_arrow_up_filled"),
hint="重构控件", side="top")
self.layerMain().addPage(ExampleWidgets(self),
icon=SiGlobal.siui.iconpack.get("ic_fluent_box_multiple_filled"),
hint="控件", side="top")
Expand Down
2 changes: 1 addition & 1 deletion siui/components/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from siui.components.option_card import *
from siui.components.progress_bar import *
from siui.components.slider import *
# from siui.components.slider import *
from siui.components.titled_widget_group import *
from siui.components.widgets import *
Loading
Loading