-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
117 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from qfluentwidgets import (TimePicker, SettingCard, FluentIconBase) | ||
from typing import Union | ||
from PyQt5.QtCore import Qt, QTime | ||
from PyQt5.QtGui import QIcon | ||
|
||
from module.config import cfg | ||
|
||
|
||
class TimePickerSettingCard1(SettingCard): | ||
""" Setting card with a TimePicker """ | ||
|
||
def __init__(self, configname: str, icon: Union[str, QIcon, FluentIconBase], title, content=None, texts=None, parent=None): | ||
super().__init__(icon, title, content, parent) | ||
self.configname = configname | ||
self.timePicker = TimePicker(self) | ||
self.hBoxLayout.addWidget(self.timePicker, 0, Qt.AlignRight) | ||
|
||
time_str = cfg.get_value(configname) | ||
time_parts = list(map(int, time_str.split(":"))) # 分割小时和分钟 | ||
qtime = QTime(*time_parts) # 创建 QTime 对象 | ||
self.timePicker.setTime(qtime) | ||
|
||
self.timePicker.timeChanged.connect(self._onTimeChanged) | ||
|
||
def _onTimeChanged(self, time: QTime): | ||
cfg.set_value(self.configname, time.toString(Qt.DefaultLocaleShortDate)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters