Skip to content

Commit

Permalink
Merge pull request #173 from ChinaIceF/refactor-btn-abst
Browse files Browse the repository at this point in the history
Refactor Buttons
  • Loading branch information
ChinaIceF authored Nov 17, 2024
2 parents 1710fab + 9eb9639 commit 82c6572
Show file tree
Hide file tree
Showing 8 changed files with 2,439 additions and 126 deletions.
63 changes: 55 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,7 +3,7 @@

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

from siui.components import (
SiCircularProgressBar,
Expand All @@ -14,7 +14,13 @@
SiTitledWidgetGroup,
SiWidget,
)
from siui.components.button import SiPushButtonRefactor
from siui.components.button import (
SiFlatButton,
SiLongPressButtonRefactor,
SiProgressPushButton,
SiPushButtonRefactor,
SiToggleButtonRefactor, SiSwitchRefactor,
)
from siui.components.combobox import SiComboBox
from siui.components.menu import SiMenu
from siui.components.page import SiPage
Expand Down Expand Up @@ -250,6 +256,52 @@ 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_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().addPlaceholder(12)
self.refactor_buttons.adjustSize()

# 按钮
self.push_buttons = OptionCardPlaneForWidgetDemos(self)
self.push_buttons.setSourceCodeURL("https://github.com/ChinaIceF/PyQt-SiliconUI/blob/main/siui/components"
Expand All @@ -259,11 +311,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 +324,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 +433,7 @@ def __init__(self, *args, **kwargs):
self.checkboxes.body().addPlaceholder(12)
self.checkboxes.adjustSize()

group.addWidget(self.refactor_buttons)
group.addWidget(self.push_buttons)
group.addWidget(self.flat_buttons)
group.addWidget(self.switches)
Expand Down
Loading

0 comments on commit 82c6572

Please sign in to comment.