Skip to content

Commit

Permalink
refactor: replace external dependencies with built-in or better alter…
Browse files Browse the repository at this point in the history
…natives

- Replaced python-dateutil with datetime for standard date handling.
- Migrated from setuptools to pdm for improved dependency management.
- Replaced pyperclip with PySide6.QtGui.QClipboard for clipboard functionality.
- Removed unnecessary external dependencies and simplified the project setup.
  • Loading branch information
H1DDENADM1N committed Jan 3, 2025
1 parent a6167b6 commit a8b0d79
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 105 deletions.
8 changes: 5 additions & 3 deletions examples/Gallery for siui/components/page_icons/page_icons.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pyperclip
from PySide6.QtCore import Qt

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication
from PySide6.QtGui import QClipboard
from siui.components import (
SiDenseHContainer,
SiDenseVContainer,
Expand All @@ -20,7 +21,8 @@

def get_on_button_clicked_func(button):
def on_button_clicked():
pyperclip.copy(button.objectName())
clipboard = QApplication.clipboard()
clipboard.setText(button.objectName())
SiGlobal.siui.windows["TOOL_TIP"].setText(
f"{button.objectName()}<br>"
f'<span style="color: {button.getColor(SiColor.TEXT_D)}">复制成功</span>',
Expand Down
47 changes: 1 addition & 46 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ version = "1.0.1"
authors = [
{ name = "ChinaIceF", email = "[email protected]" },
{ name = "rainzee wang", email = "[email protected]" },
{name = "H1DDENADM1N", email = "[email protected]"},
{ name = "H1DDENADM1N", email = "[email protected]" },
]
description = "Default template for PDM package"
readme = "README.md"
license = { file = "LICENSE", text = "GPLv3"}
license = { file = "LICENSE", text = "GPLv3" }
requires-python = "==3.12.*"
dependencies = [
"PySide6==6.6.3.1",
"typing-extensions>=4.12.2",
"python-dateutil>=2.9.0",
"setuptools>=75.6.0",
"numpy==1.26.4",
"pyperclip>=1.9.0",
]

[project.urls]
Repository = "hhttps://github.com/H1DDENADM1N/PySide6-SiliconUI"
Repository = "https://github.com/H1DDENADM1N/PySide6-SiliconUI"

[tool.pdm]
distribution = false
Expand Down
47 changes: 0 additions & 47 deletions setup.py

This file was deleted.

30 changes: 27 additions & 3 deletions siui/components/widgets/timedate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import datetime
import time

from dateutil.relativedelta import relativedelta
from PySide6.QtCore import QPoint, Qt, Signal
from PySide6.QtGui import QFont

Expand Down Expand Up @@ -153,8 +152,33 @@ def __init__(self, *args, **kwargs):
self.updateYearMonthLabel()

def modifyDisplayedDate(self, month_delta):
self.displayed_date = self.displayed_date.replace(day=1) # 归一化,防止因日期引起的切换错误,日期不重要,月份重要
self.displayed_date = self.displayed_date + relativedelta(months=month_delta)
# 归一化,防止因日期引起的切换错误,日期不重要,月份重要
self.displayed_date = self.displayed_date.replace(day=1)

# 计算新的年份和月份
year = self.displayed_date.year
month = self.displayed_date.month + month_delta

# 处理跨年的情况
if month > 12:
year += (month - 1) // 12
month = month % 12 or 12
elif month < 1:
year += (month - 1) // 12
month = month % 12 or 12

# 处理目标月份的天数差异
try:
self.displayed_date = self.displayed_date.replace(year=year, month=month)
except ValueError:
# 如果目标月份没有当前日期的天数,则调整到目标月份的最后一天
if month == 12:
next_month = datetime(year + 1, 1, 1)
else:
next_month = datetime(year, month + 1, 1)
last_day_of_month = next_month - datetime.timedelta(days=1)
self.displayed_date = last_day_of_month

self.updateCalendar()
self.updateYearMonthLabel()

Expand Down

0 comments on commit a8b0d79

Please sign in to comment.