提交 c9a9bb23 编写于 作者: 之一Yo's avatar 之一Yo

添加日历组件

上级 d557dfd2
# coding:utf-8
import sys
from time import time
from PyQt5.QtCore import Qt, QCalendar, QDate
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout
from qfluentwidgets import CalendarPicker, setTheme, Theme
class Demo(QWidget):
def __init__(self):
super().__init__()
# setTheme(Theme.DARK)
self.setStyleSheet('Demo{background: white}')
self.picker = CalendarPicker(self)
self.picker.dateChanged.connect(print)
# set date
# self.picker.setDate(QDate(2023, 5, 30))
# customize date format
# self.picker.setDateFormat(Qt.TextDate)
# self.picker.setDateFormat('yyyy-M-d')
self.hBoxLayout = QHBoxLayout(self)
self.hBoxLayout.addWidget(self.picker, 0, Qt.AlignCenter)
self.resize(500, 500)
if __name__ == '__main__':
# enable dpi scale
QApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)
QApplication.setAttribute(Qt.AA_UseHighDpiPixmaps)
app = QApplication(sys.argv)
t0 = time()
w = Demo()
t1 = time()
print('耗时:', t1-t0)
w.show()
app.exec_()
\ No newline at end of file
......@@ -217,30 +217,40 @@
<context>
<name>DateTimeInterface</name>
<message>
<location filename="../../view/date_time_interface.py" line="21"/>
<location filename="../../view/date_time_interface.py" line="36"/>
<source>A simple DatePicker</source>
<translation>日期选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="27"/>
<location filename="../../view/date_time_interface.py" line="42"/>
<source>A DatePicker in another format</source>
<translation>另一种格式的日期选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="34"/>
<location filename="../../view/date_time_interface.py" line="49"/>
<source>A simple TimePicker</source>
<translation>时间选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="41"/>
<location filename="../../view/date_time_interface.py" line="56"/>
<source>A TimePicker using a 24-hour clock</source>
<translation>24 小时制的时间选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="48"/>
<location filename="../../view/date_time_interface.py" line="63"/>
<source>A TimePicker with seconds column</source>
<translation>显示秒的时间选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="21"/>
<source>A simple CalendarPicker</source>
<translation>日历选择器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="29"/>
<source>A CalendarPicker in another format</source>
<translation>自定义格式的日历选择器</translation>
</message>
</context>
<context>
<name>DialogInterface</name>
......
......@@ -16,7 +16,7 @@
<message>
<location filename="../../view/basic_input_interface.py" line="56"/>
<source>A hyperlink button that navigates to a URI</source>
<translation>導航到一個超鏈接的按鈕</translation>
<translation>導航到一個超連結的按鈕</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="63"/>
......@@ -96,7 +96,7 @@
<message>
<location filename="../../view/basic_input_interface.py" line="149"/>
<source>Soft and Wet</source>
<translation>軟又</translation>
<translation>軟又</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="241"/>
......@@ -121,7 +121,7 @@
<message>
<location filename="../../view/basic_input_interface.py" line="107"/>
<source>Send</source>
<translation></translation>
<translation></translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="108"/>
......@@ -217,30 +217,40 @@
<context>
<name>DateTimeInterface</name>
<message>
<location filename="../../view/date_time_interface.py" line="21"/>
<location filename="../../view/date_time_interface.py" line="36"/>
<source>A simple DatePicker</source>
<translation>日期選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="27"/>
<location filename="../../view/date_time_interface.py" line="42"/>
<source>A DatePicker in another format</source>
<translation>另一種格式的日期選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="34"/>
<location filename="../../view/date_time_interface.py" line="49"/>
<source>A simple TimePicker</source>
<translation>時間選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="41"/>
<location filename="../../view/date_time_interface.py" line="56"/>
<source>A TimePicker using a 24-hour clock</source>
<translation>24 小時的時間選擇器</translation>
<translation>24 小時的時間選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="48"/>
<location filename="../../view/date_time_interface.py" line="63"/>
<source>A TimePicker with seconds column</source>
<translation>顯示秒的時間選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="21"/>
<source>A simple CalendarPicker</source>
<translation>日曆選擇器</translation>
</message>
<message>
<location filename="../../view/date_time_interface.py" line="29"/>
<source>A CalendarPicker in another format</source>
<translation>自定義格式的日曆選擇器</translation>
</message>
</context>
<context>
<name>DialogInterface</name>
......@@ -290,7 +300,7 @@
<message>
<location filename="../../view/gallery_interface.py" line="114"/>
<source>Source code</source>
<translation>源代</translation>
<translation>原始</translation>
</message>
</context>
<context>
......@@ -354,7 +364,7 @@
<message>
<location filename="../../view/layout_interface.py" line="38"/>
<source>Killer Queen</source>
<translation>殺手皇💀</translation>
<translation>殺手皇💀</translation>
</message>
<message>
<location filename="../../view/layout_interface.py" line="39"/>
......@@ -382,7 +392,7 @@
<message>
<location filename="../../view/icon_interface.py" line="21"/>
<source>Search icons</source>
<translation>索圖標</translation>
<translation>索圖標</translation>
</message>
</context>
<context>
......@@ -485,7 +495,7 @@
<message>
<location filename="../../view/view_interface.py" line="85"/>
<source>Scary Monster</source>
<translation>駭人</translation>
<translation>駭人</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="85"/>
......@@ -525,7 +535,7 @@
<message>
<location filename="../../view/view_interface.py" line="89"/>
<source>SOFT &amp; WET</source>
<translation>軟又</translation>
<translation>軟又</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="89"/>
......@@ -535,7 +545,7 @@
<message>
<location filename="../../view/view_interface.py" line="90"/>
<source>Wonder of U</source>
<translation>於你</translation>
<translation>於你</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="90"/>
......@@ -565,7 +575,7 @@
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Killer Queen</source>
<translation>殺手皇💀</translation>
<translation>殺手皇💀</translation>
</message>
</context>
<context>
......@@ -839,7 +849,7 @@
<message>
<location filename="../../view/setting_interface.py" line="85"/>
<source>Use system setting</source>
<translation>跟隨統設置</translation>
<translation>跟隨統設置</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="67"/>
......@@ -854,7 +864,7 @@
<message>
<location filename="../../view/setting_interface.py" line="74"/>
<source>Interface zoom</source>
<translation>縮放</translation>
<translation>縮放</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="74"/>
......@@ -869,7 +879,7 @@
<message>
<location filename="../../view/setting_interface.py" line="85"/>
<source>Set your preferred language for UI</source>
<translation>選擇界所使用的語言</translation>
<translation>選擇界所使用的語言</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="95"/>
......@@ -894,7 +904,7 @@
<message>
<location filename="../../view/setting_interface.py" line="108"/>
<source>Check for updates when the application starts</source>
<translation>在應用程啟動時檢查更新</translation>
<translation>在應用程啟動時檢查更新</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="108"/>
......@@ -909,7 +919,7 @@
<message>
<location filename="../../view/setting_interface.py" line="118"/>
<source>Open help page</source>
<translation>打開幫助頁</translation>
<translation>打開幫助頁</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="118"/>
......@@ -919,7 +929,7 @@
<message>
<location filename="../../view/setting_interface.py" line="118"/>
<source>Discover new features and learn useful tips about PyQt-Fluent-Widgets</source>
<translation>現新功能並了解有關 PyQt-Fluent-Widgets 的使用技巧</translation>
<translation>現新功能並了解有關 PyQt-Fluent-Widgets 的使用技巧</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="127"/>
......@@ -1002,7 +1012,7 @@
<message>
<location filename="../../view/status_info_interface.py" line="179"/>
<source>Please wait patiently</source>
<translation>心急吃不了熱請耐心等待哦~</translation>
<translation>心急吃不了熱請耐心等待哦~</translation>
</message>
<message>
<location filename="../../view/status_info_interface.py" line="181"/>
......@@ -1067,7 +1077,7 @@
<message>
<location filename="../../view/status_info_interface.py" line="75"/>
<source>My name is kira yoshikake, 33 years old. Living in the villa area northeast of duwangting, unmarried. I work in Guiyou chain store. Every day I have to work overtime until 8 p.m. to go home. I don&apos;t smoke. The wine is only for a taste. Sleep at 11 p.m. for 8 hours a day. Before I go to bed, I must drink a cup of warm milk, then do 20 minutes of soft exercise, get on the bed, and immediately fall asleep. Never leave fatigue and stress until the next day. Doctors say I&apos;m normal.</source>
<translation>我的名字是吉良吉影年齡33歲家住杜王町東北部別墅區未婚我在龜友百貨連鎖公司上班每天最晚也是八點前回家不吸菸酒也是淺嚐輒止晚上十一點上床保証八個小時的充足睡眠睡前喝一盃熱牛奶再做二十分鐘伸展運動暖身然後再睡覺基本可以熟睡到天亮像嬰兒一樣不留下疲勞與壓力迎來第二天的早晨健康檢查結果也顯示我很健康我的意思是我是一個隨時都想追求平靜生活的人不拘泥於勝負與煩惱不樹立令我夜不能寐的敵人這就是我對於這個社會的生活態度我也清楚這就是我的幸福</translation>
<translation>我的名字是吉良吉影年齡33歲家住杜王町東北部別墅區未婚我在龜友百貨連鎖公司上班每天最晚也是八點前回家不吸煙酒也是淺嘗輒止晚上十一點上床保證八個小時的充足睡眠睡前喝一杯熱牛奶再做二十分鐘伸展運動暖身然後再睡覺基本可以熟睡到天亮像嬰兒一樣不留下疲勞與壓力迎來第二天的早晨健康檢查結果也顯示我很健康我的意思是我是一個隨時都想追求平靜生活的人不拘泥於勝負與煩惱不樹立令我夜不能寐的敵人這就是我對於這個社會的生活態度我也清楚這就是我的幸福</translation>
</message>
<message>
<location filename="../../view/status_info_interface.py" line="186"/>
......@@ -1077,16 +1087,16 @@
<message>
<location filename="../../view/status_info_interface.py" line="186"/>
<source>Believe in the spin, just keep believing!</source>
<translation>相信回旋吧管相信就是了</translation>
<translation>相信迴旋吧管相信就是了</translation>
</message>
<message>
<location filename="../../view/status_info_interface.py" line="198"/>
<source>With respect, let&apos;s advance towards a new stage of the spin.</source>
<translation>表達敬意吧表達出敬意然後邁向旋的另一個全新階段</translation>
<translation>表達敬意吧表達出敬意然後邁向旋的另一個全新階段</translation>
</message>
<message>
<location filename="../../view/status_info_interface.py" line="209"/>
<source>路を行けば最短ルート</source>
<source>路を行けば最短ルート</source>
<translation>最短的捷徑就是繞遠路繞遠路才是我的最短捷徑</translation>
</message>
<message>
......@@ -1251,7 +1261,7 @@
<message>
<location filename="../../view/gallery_interface.py" line="43"/>
<source>Source</source>
<translation>源代</translation>
<translation>原始</translation>
</message>
<message>
<location filename="../../view/gallery_interface.py" line="80"/>
......@@ -1347,7 +1357,7 @@
<message>
<location filename="../../view/view_interface.py" line="108"/>
<source>Dio Brando</source>
<translation>迪奧·蘭度</translation>
<translation>迪奧·蘭度</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="108"/>
......
# coding:utf-8
from PyQt5.QtCore import Qt
from qfluentwidgets import DatePicker, TimePicker, AMTimePicker, ZhDatePicker
from qfluentwidgets import DatePicker, TimePicker, AMTimePicker, ZhDatePicker, CalendarPicker
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -17,6 +17,21 @@ class DateTimeInterface(GalleryInterface):
parent=parent
)
# calendar picker
self.addExampleCard(
title=self.tr('A simple CalendarPicker'),
widget=CalendarPicker(self),
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/calendar_picker/demo.py'
)
w = CalendarPicker(self)
w.setDateFormat(Qt.TextDate)
self.addExampleCard(
title=self.tr('A CalendarPicker in another format'),
widget=w,
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/calendar_picker/demo.py'
)
# date picker
self.addExampleCard(
title=self.tr('A simple DatePicker'),
......
......@@ -194,12 +194,19 @@ class HomeInterface(ScrollArea):
# date time samples
dateTimeView = SampleCardView(self.tr('Date & time samples'), self.view)
dateTimeView.addSampleCard(
icon=":/gallery/images/controls/CalendarDatePicker.png",
title="CalendarPicker",
content=self.tr("A control that lets a user pick a date value using a calendar."),
routeKey="dateTimeInterface",
index=0
)
dateTimeView.addSampleCard(
icon=":/gallery/images/controls/DatePicker.png",
title="DatePicker",
content=self.tr("A control that lets a user pick a date value."),
routeKey="dateTimeInterface",
index=0
index=2
)
dateTimeView.addSampleCard(
icon=":/gallery/images/controls/TimePicker.png",
......@@ -207,7 +214,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A configurable control that lets a user pick a time value."),
routeKey="dateTimeInterface",
index=2
index=4
)
self.vBoxLayout.addWidget(dateTimeView)
......
......@@ -28,7 +28,7 @@ class StatusInfoInterface(GalleryInterface):
self.addExampleCard(
self.tr('State tool tip'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/status_tool_tip/demo.py'
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/state_tool_tip/demo.py'
)
# tool tip
......
......@@ -5,7 +5,7 @@ from qfluentwidgets import (PrimaryPushButton, SplitPushButton, DropDownPushButt
ToolButton, SplitToolButton, DropDownToolButton, FluentIcon, ToggleButton,
SwitchButton, RadioButton, CheckBox, HyperlinkButton, Slider, ComboBox, IconWidget,
EditableComboBox, PixmapLabel, PushButton, PrimaryToolButton, PrimarySplitToolButton,
PrimarySplitPushButton, PrimaryDropDownPushButton, PrimaryDropDownToolButton)
PrimarySplitPushButton, PrimaryDropDownPushButton, PrimaryDropDownToolButton, TransparentToolButton)
from plugin_base import PluginBase
from task_menu_factory import EditTextTaskMenuFactory
......@@ -206,6 +206,19 @@ class PrimaryToolButtonPlugin(BasicInputPlugin, QPyDesignerCustomWidgetPlugin):
return "PrimaryToolButton"
class TransparentToolButtonPlugin(BasicInputPlugin, QPyDesignerCustomWidgetPlugin):
""" Primary color tool button plugin """
def createWidget(self, parent):
return TransparentToolButton(FluentIcon.BASKETBALL, parent)
def icon(self):
return super().icon('Button')
def name(self):
return "TransparentToolButton"
class DropDownToolButtonPlugin(BasicInputPlugin, QPyDesignerCustomWidgetPlugin):
""" Drop down tool button plugin """
......
......@@ -2,7 +2,7 @@
from PyQt5.QtCore import Qt
from PyQt5.QtDesigner import QPyDesignerCustomWidgetPlugin
from qfluentwidgets import DatePicker, TimePicker, ZhDatePicker, AMTimePicker
from qfluentwidgets import DatePicker, TimePicker, ZhDatePicker, AMTimePicker, CalendarPicker
from plugin_base import PluginBase
......@@ -13,6 +13,19 @@ class DateTimePlugin(PluginBase):
return super().group() + ' (Date Time)'
class CalendarPickerPlugin(DateTimePlugin, QPyDesignerCustomWidgetPlugin):
""" Calendar picker plugin """
def createWidget(self, parent):
return CalendarPicker(parent)
def icon(self):
return super().icon("CalendarDatePicker")
def name(self):
return "CalendarPicker"
class DatePickerPlugin(DateTimePlugin, QPyDesignerCustomWidgetPlugin):
""" Date picker plugin """
......
......@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: GPLv3, see LICENSE for more details.
"""
__version__ = "0.9.1"
__version__ = "0.9.2"
from .components import *
from .common import *
......
......@@ -2,6 +2,95 @@
<!DOCTYPE TS>
<TS version="2.1" language="zh_CN">
<!-- The translation of components in PyQt-Fluent-Widgets -->
<context>
<name>CalendarPicker</name>
<message>
<source>Pick a date</source>
<translation>选择日期</translation>
</message>
</context>
<context>
<name>MonthScrollView</name>
<message>
<source>Jan</source>
<translation>一月</translation>
</message>
<message>
<source>Feb</source>
<translation>二月</translation>
</message>
<message>
<source>Mar</source>
<translation>三月</translation>
</message>
<message>
<source>Apr</source>
<translation>四月</translation>
</message>
<message>
<source>May</source>
<translation>五月</translation>
</message>
<message>
<source>Jun</source>
<translation>六月</translation>
</message>
<message>
<source>Jul</source>
<translation>七月</translation>
</message>
<message>
<source>Aug</source>
<translation>八月</translation>
</message>
<message>
<source>Sep</source>
<translation>九月</translation>
</message>
<message>
<source>Oct</source>
<translation>十月</translation>
</message>
<message>
<source>Nov</source>
<translation>十一月</translation>
</message>
<message>
<source>Dec</source>
<translation>十二月</translation>
</message>
</context>
<context>
<name>DayScrollView</name>
<message>
<source>Mo</source>
<translation></translation>
</message>
<message>
<source>Tu</source>
<translation></translation>
</message>
<message>
<source>We</source>
<translation></translation>
</message>
<message>
<source>Th</source>
<translation></translation>
</message>
<message>
<source>Fr</source>
<translation></translation>
</message>
<message>
<source>Sa</source>
<translation></translation>
</message>
<message>
<source>Su</source>
<translation></translation>
</message>
</context>
<context>
<name>ColorDialog</name>
<message>
......
......@@ -2,6 +2,95 @@
<!DOCTYPE TS>
<TS version="2.1" language="zh_HK">
<!-- The translation of components in PyQt-Fluent-Widgets -->
<context>
<name>CalendarPicker</name>
<message>
<source>Pick a date</source>
<translation>選擇日期</translation>
</message>
</context>
<context>
<name>MonthScrollView</name>
<message>
<source>Jan</source>
<translation>一月</translation>
</message>
<message>
<source>Feb</source>
<translation>二月</translation>
</message>
<message>
<source>Mar</source>
<translation>三月</translation>
</message>
<message>
<source>Apr</source>
<translation>四月</translation>
</message>
<message>
<source>May</source>
<translation>五月</translation>
</message>
<message>
<source>Jun</source>
<translation>六月</translation>
</message>
<message>
<source>Jul</source>
<translation>七月</translation>
</message>
<message>
<source>Aug</source>
<translation>八月</translation>
</message>
<message>
<source>Sep</source>
<translation>九月</translation>
</message>
<message>
<source>Oct</source>
<translation>十月</translation>
</message>
<message>
<source>Nov</source>
<translation>十一月</translation>
</message>
<message>
<source>Dec</source>
<translation>十二月</translation>
</message>
</context>
<context>
<name>DayScrollView</name>
<message>
<source>Mo</source>
<translation></translation>
</message>
<message>
<source>Tu</source>
<translation></translation>
</message>
<message>
<source>We</source>
<translation></translation>
</message>
<message>
<source>Th</source>
<translation></translation>
</message>
<message>
<source>Fr</source>
<translation></translation>
</message>
<message>
<source>Sa</source>
<translation></translation>
</message>
<message>
<source>Su</source>
<translation></translation>
</message>
</context>
<context>
<name>ColorDialog</name>
<message>
......
......@@ -2,6 +2,95 @@
<!DOCTYPE TS>
<TS version="2.1" language="zh_TW">
<!-- The translation of components in PyQt-Fluent-Widgets -->
<context>
<name>CalendarPicker</name>
<message>
<source>Pick a date</source>
<translation>選擇日期</translation>
</message>
</context>
<context>
<name>MonthScrollView</name>
<message>
<source>Jan</source>
<translation>一月</translation>
</message>
<message>
<source>Feb</source>
<translation>二月</translation>
</message>
<message>
<source>Mar</source>
<translation>三月</translation>
</message>
<message>
<source>Apr</source>
<translation>四月</translation>
</message>
<message>
<source>May</source>
<translation>五月</translation>
</message>
<message>
<source>Jun</source>
<translation>六月</translation>
</message>
<message>
<source>Jul</source>
<translation>七月</translation>
</message>
<message>
<source>Aug</source>
<translation>八月</translation>
</message>
<message>
<source>Sep</source>
<translation>九月</translation>
</message>
<message>
<source>Oct</source>
<translation>十月</translation>
</message>
<message>
<source>Nov</source>
<translation>十一月</translation>
</message>
<message>
<source>Dec</source>
<translation>十二月</translation>
</message>
</context>
<context>
<name>DayScrollView</name>
<message>
<source>Mo</source>
<translation></translation>
</message>
<message>
<source>Tu</source>
<translation></translation>
</message>
<message>
<source>We</source>
<translation></translation>
</message>
<message>
<source>Th</source>
<translation></translation>
</message>
<message>
<source>Fr</source>
<translation></translation>
</message>
<message>
<source>Sa</source>
<translation></translation>
</message>
<message>
<source>Su</source>
<translation></translation>
</message>
</context>
<context>
<name>ColorDialog</name>
<message>
......
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="16" height="16" style="width:16px;height:16px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2048 2048" enable-background="new 0 0 2048 2048"
xml:space="preserve"><path fill="#000000" d="M1618.29 0 q85.71 0 163.99 34.85 q78.29 34.85 137.14 93.72 q58.86 58.86 93.72 137.15 q34.86 78.28 34.86 163.99 l0 1188.58 q0 85.71 -34.86 163.99 q-34.86 78.29 -93.72 137.14 q-58.86 58.86 -137.14 93.72 q-78.28 34.86 -163.99 34.86 l-1188.58 0 q-85.71 0 -163.99 -34.86 q-78.29 -34.86 -137.15 -93.72 q-58.86 -58.86 -93.72 -137.14 q-34.85 -78.28 -34.85 -163.99 l0 -1188.58 q0 -85.71 34.85 -163.99 q34.85 -78.29 93.72 -137.15 q58.86 -58.86 137.15 -93.72 q78.28 -34.85 163.99 -34.85 l1188.58 0 ZM433.14 146.29 q-58.28 0 -110.86 24 q-52.57 24 -91.43 64 q-38.85 40 -61.71 93.14 q-22.85 53.14 -22.85 111.43 l1755.42 0 l0 -5.72 q0 -57.14 -23.43 -109.14 q-23.42 -52 -62.86 -91.43 q-39.43 -39.43 -91.43 -62.86 q-52 -23.42 -109.14 -23.42 l-1181.72 0 ZM1614.86 1901.71 q57.14 0 109.14 -23.43 q52 -23.42 91.43 -62.86 q39.43 -39.43 62.86 -91.43 q23.43 -52 23.43 -109.14 l0 -1029.72 l-1755.42 0 l0 1029.72 q0 57.14 23.42 109.14 q23.43 52 62.86 91.43 q39.43 39.43 91.43 62.86 q52 23.43 109.14 23.43 l1181.72 0 ZM438.86 1024 q0 -30.86 11.42 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.72 -11.43 q30.85 0 57.13 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.43 26.29 11.43 57.15 q0 30.85 -11.43 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.28 31.43 q-26.29 11.43 -57.15 11.43 q-30.85 0 -57.71 -11.43 q-26.86 -11.43 -46.29 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.42 -26.86 -11.42 -57.71 ZM877.71 1024 q0 -30.86 11.43 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.71 -11.43 q30.86 0 57.14 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.43 26.29 11.43 57.15 q0 30.85 -11.43 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.29 31.43 q-26.29 11.43 -57.14 11.43 q-30.86 0 -57.72 -11.43 q-26.86 -11.43 -46.28 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.43 -26.86 -11.43 -57.71 ZM1609.14 1022.86 q0 30.85 -11.42 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.29 31.43 q-26.29 11.43 -57.14 11.43 q-30.86 0 -57.71 -11.43 q-26.86 -11.43 -46.28 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.43 -26.86 -11.43 -57.71 q0 -30.86 11.43 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.71 -11.43 q30.86 0 57.14 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.42 26.29 11.42 57.15 ZM731.43 1462.86 q0 30.85 -11.43 57.14 q-11.43 26.29 -31.43 46.29 q-20 20 -46.86 31.43 q-26.86 11.42 -57.72 11.42 q-30.86 0 -57.14 -11.42 q-26.29 -11.43 -45.72 -30.86 q-19.43 -19.43 -30.86 -45.72 q-11.42 -26.29 -11.42 -57.14 q0 -30.86 11.42 -57.71 q11.43 -26.86 31.43 -46.86 q20 -20 46.29 -31.43 q26.29 -11.43 57.14 -11.43 q30.86 0 57.72 11.43 q26.86 11.43 46.29 30.86 q19.43 19.43 30.86 46.28 q11.43 26.86 11.43 57.71 ZM1170.29 1462.86 q0 30.85 -11.43 57.14 q-11.43 26.29 -31.43 46.29 q-20 20 -46.86 31.43 q-26.86 11.42 -57.71 11.42 q-30.86 0 -57.15 -11.42 q-26.28 -11.43 -45.71 -30.86 q-19.43 -19.43 -30.86 -45.72 q-11.43 -26.29 -11.43 -57.14 q0 -30.86 11.43 -57.71 q11.43 -26.86 31.43 -46.86 q20 -20 46.28 -31.43 q26.28 -11.43 57.14 -11.43 q30.86 0 57.71 11.43 q26.86 11.43 46.29 30.86 q19.43 19.43 30.86 46.28 q11.43 26.86 11.43 57.71 Z"/></svg>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="16" height="16" style="width:16px;height:16px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2048 2048" enable-background="new 0 0 2048 2048"
xml:space="preserve"><path fill="#ffffff" d="M1618.29 0 q85.71 0 163.99 34.85 q78.29 34.85 137.14 93.72 q58.86 58.86 93.72 137.15 q34.86 78.28 34.86 163.99 l0 1188.58 q0 85.71 -34.86 163.99 q-34.86 78.29 -93.72 137.14 q-58.86 58.86 -137.14 93.72 q-78.28 34.86 -163.99 34.86 l-1188.58 0 q-85.71 0 -163.99 -34.86 q-78.29 -34.86 -137.15 -93.72 q-58.86 -58.86 -93.72 -137.14 q-34.85 -78.28 -34.85 -163.99 l0 -1188.58 q0 -85.71 34.85 -163.99 q34.85 -78.29 93.72 -137.15 q58.86 -58.86 137.15 -93.72 q78.28 -34.85 163.99 -34.85 l1188.58 0 ZM433.14 146.29 q-58.28 0 -110.86 24 q-52.57 24 -91.43 64 q-38.85 40 -61.71 93.14 q-22.85 53.14 -22.85 111.43 l1755.42 0 l0 -5.72 q0 -57.14 -23.43 -109.14 q-23.42 -52 -62.86 -91.43 q-39.43 -39.43 -91.43 -62.86 q-52 -23.42 -109.14 -23.42 l-1181.72 0 ZM1614.86 1901.71 q57.14 0 109.14 -23.43 q52 -23.42 91.43 -62.86 q39.43 -39.43 62.86 -91.43 q23.43 -52 23.43 -109.14 l0 -1029.72 l-1755.42 0 l0 1029.72 q0 57.14 23.42 109.14 q23.43 52 62.86 91.43 q39.43 39.43 91.43 62.86 q52 23.43 109.14 23.43 l1181.72 0 ZM438.86 1024 q0 -30.86 11.42 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.72 -11.43 q30.85 0 57.13 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.43 26.29 11.43 57.15 q0 30.85 -11.43 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.28 31.43 q-26.29 11.43 -57.15 11.43 q-30.85 0 -57.71 -11.43 q-26.86 -11.43 -46.29 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.42 -26.86 -11.42 -57.71 ZM877.71 1024 q0 -30.86 11.43 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.71 -11.43 q30.86 0 57.14 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.43 26.29 11.43 57.15 q0 30.85 -11.43 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.29 31.43 q-26.29 11.43 -57.14 11.43 q-30.86 0 -57.72 -11.43 q-26.86 -11.43 -46.28 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.43 -26.86 -11.43 -57.71 ZM1609.14 1022.86 q0 30.85 -11.42 57.71 q-11.43 26.86 -31.43 46.86 q-20 20 -46.29 31.43 q-26.29 11.43 -57.14 11.43 q-30.86 0 -57.71 -11.43 q-26.86 -11.43 -46.28 -30.86 q-19.43 -19.43 -30.86 -46.29 q-11.43 -26.86 -11.43 -57.71 q0 -30.86 11.43 -57.14 q11.43 -26.28 31.43 -46.28 q20 -20 46.86 -31.43 q26.86 -11.43 57.71 -11.43 q30.86 0 57.14 11.43 q26.29 11.43 45.72 30.86 q19.43 19.43 30.86 45.71 q11.42 26.29 11.42 57.15 ZM731.43 1462.86 q0 30.85 -11.43 57.14 q-11.43 26.29 -31.43 46.29 q-20 20 -46.86 31.43 q-26.86 11.42 -57.72 11.42 q-30.86 0 -57.14 -11.42 q-26.29 -11.43 -45.72 -30.86 q-19.43 -19.43 -30.86 -45.72 q-11.42 -26.29 -11.42 -57.14 q0 -30.86 11.42 -57.71 q11.43 -26.86 31.43 -46.86 q20 -20 46.29 -31.43 q26.29 -11.43 57.14 -11.43 q30.86 0 57.72 11.43 q26.86 11.43 46.29 30.86 q19.43 19.43 30.86 46.28 q11.43 26.86 11.43 57.71 ZM1170.29 1462.86 q0 30.85 -11.43 57.14 q-11.43 26.29 -31.43 46.29 q-20 20 -46.86 31.43 q-26.86 11.42 -57.71 11.42 q-30.86 0 -57.15 -11.42 q-26.28 -11.43 -45.71 -30.86 q-19.43 -19.43 -30.86 -45.72 q-11.43 -26.29 -11.43 -57.14 q0 -30.86 11.43 -57.71 q11.43 -26.86 31.43 -46.86 q20 -20 46.28 -31.43 q26.28 -11.43 57.14 -11.43 q30.86 0 57.71 11.43 q26.86 11.43 46.29 30.86 q19.43 19.43 30.86 46.28 q11.43 26.86 11.43 57.71 Z"/></svg>
\ No newline at end of file
......@@ -223,4 +223,9 @@ TransparentToolButton:hover {
TransparentToolButton:pressed {
background-color: rgba(255, 255, 255, 6);
border: none;
}
TransparentToolButton:disabled {
background-color: transparent;
border: none;
}
\ No newline at end of file
#titleButton {
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang Sc';
font-weight: 500;
color: white;
background-color: transparent;
border: none;
margin: 0;
padding-left: 8px;
text-align: left;
border-radius: 5px;
}
#titleButton:hover {
background-color: rgba(255, 255, 255, 9);
}
#titleButton:pressed {
background-color: rgba(255, 255, 255, 6);
}
#titleButton:disabled {
color: rgba(255, 255, 255, 0.4);
}
#weekDayLabel {
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang Sc';
font-weight: 500;
color: white;
background-color: transparent;
border: none;
text-align: center;
}
#weekDayGroup {
background-color: rgb(32, 32, 32);
}
CalendarViewBase {
background-color: rgb(37, 37, 37);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
}
ScrollViewBase {
border: none;
padding: 0px 1px 0px 1px;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
border-top: 1px solid rgb(52, 52, 52);
background-color: transparent;
}
CalendarPicker {
background: rgba(255, 255, 255, 0.0605);
border: 1px solid rgba(255, 255, 255, 0.053);
border-top: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 5px;
color: rgba(255, 255, 255, 0.6063);
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 32px 6px 12px;
outline: none;
}
CalendarPicker:hover {
background: rgba(255, 255, 255, 0.0837);
}
CalendarPicker:pressed {
background: rgba(255, 255, 255, 0.0326);
border-top: 1px solid rgba(255, 255, 255, 0.053);
}
CalendarPicker:disabled {
color: rgba(255, 255, 255, 0.3628);
background: rgba(255, 255, 255, 0.0419);
border: 1px solid rgba(255, 255, 255, 0.053);
border-top: 1px solid rgba(255, 255, 255, 0.053);
}
CalendarPicker[hasDate=true] {
color: white;
}
\ No newline at end of file
......@@ -223,4 +223,9 @@ TransparentToolButton:hover {
TransparentToolButton:pressed {
background-color: rgba(0, 0, 0, 6);
border: none;
}
\ No newline at end of file
}
TransparentToolButton:disabled {
background-color: transparent;
border: none;
}
#titleButton {
font: 14px 'Segoe UI', 'Microsoft YaHei', 'PingFang Sc';
font-weight: 500;
color: black;
background-color: transparent;
border: none;
margin: 0;
padding-left: 8px;
text-align: left;
border-radius: 5px;
}
#titleButton:hover {
background-color: rgba(0, 0, 0, 9);
}
#titleButton:pressed {
background-color: rgba(0, 0, 0, 6);
}
#titleButton:disabled {
color: rgba(0, 0, 0, 0.4);
}
#weekDayLabel {
font: 12px 'Segoe UI', 'Microsoft YaHei', 'PingFang Sc';
font-weight: 500;
color: black;
background-color: transparent;
border: none;
text-align: center;
}
#weekDayGroup {
background-color: transparent;
}
CalendarViewBase {
background-color: rgb(255, 255, 255);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
ScrollViewBase {
border: none;
padding: 0px 1px 0px 1px;
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
border-top: 1px solid rgb(240, 240, 240);
background-color: transparent;
}
CalendarPicker {
color: rgba(0, 0, 0, 0.6063);
background: rgba(255, 255, 255, 0.7);
border: 1px solid rgba(0, 0, 0, 0.073);
border-bottom: 1px solid rgba(0, 0, 0, 0.183);
border-radius: 5px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 32px 6px 12px;
outline: none;
}
CalendarPicker:hover {
background: rgba(249, 249, 249, 0.5);
}
CalendarPicker:pressed {
background: rgba(249, 249, 249, 0.3);
border-bottom: 1px solid rgba(0, 0, 0, 0.073);
}
CalendarPicker:disabled {
color: rgba(0, 0, 0, 0.36);
background: rgba(249, 249, 249, 0.3);
border: 1px solid rgba(0, 0, 0, 0.06);
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
CalendarPicker[hasDate=true] {
color: black;
}
\ No newline at end of file
此差异已折叠。
......@@ -176,6 +176,8 @@
<file>images/icons/CareRightSolid_white.svg</file>
<file>images/icons/EmojiTabSymbols_black.svg</file>
<file>images/icons/EmojiTabSymbols_white.svg</file>
<file>images/icons/Calendar_black.svg</file>
<file>images/icons/Calendar_white.svg</file>
<file>images/acrylic/noise.png</file>
<file>images/folder_list_dialog/Close_white.png</file>
......@@ -231,6 +233,7 @@
<file>qss/dark/table_view.qss</file>
<file>qss/dark/time_picker.qss</file>
<file>qss/dark/pivot.qss</file>
<file>qss/dark/calendar_picker.qss</file>
<file>qss/light/color_dialog.qss</file>
<file>qss/light/dialog.qss</file>
......@@ -256,6 +259,7 @@
<file>qss/light/tree_view.qss</file>
<file>qss/light/time_picker.qss</file>
<file>qss/light/pivot.qss</file>
<file>qss/light/calendar_picker.qss</file>
<file>i18n/qfluentwidgets.zh_CN.qm</file>
<file>i18n/qfluentwidgets.zh_HK.qm</file>
......
......@@ -260,6 +260,7 @@ class FluentIcon(FluentIconBase, Enum):
PALETTE = "Palette"
MESSAGE = "Message"
ZOOM_OUT = "ZoomOut"
CALENDAR = "Calendar"
FEEDBACK = "Feedback"
MINIMIZE = "Minimize"
CHECKBOX = "CheckBox"
......
......@@ -106,6 +106,7 @@ class FluentStyleSheet(StyleSheetBase, Enum):
SWITCH_BUTTON = "switch_button"
MESSAGE_DIALOG = "message_dialog"
STATE_TOOL_TIP = "state_tool_tip"
CALENDAR_PICKER = "calendar_picker"
FOLDER_LIST_DIALOG = "folder_list_dialog"
SETTING_CARD_GROUP = "setting_card_group"
EXPAND_SETTING_CARD = "expand_setting_card"
......
from .calendar_picker import CalendarPicker
from .date_picker import DatePickerBase, DatePicker, ZhDatePicker
from .picker_base import PickerBase, PickerPanel, PickerColumnFormatter
from .time_picker import TimePicker, AMTimePicker
\ No newline at end of file
# coding:utf-8
from typing import Union
from PyQt5.QtCore import Qt, pyqtSignal, QRectF, QDate, QPoint
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QWidget, QPushButton, QApplication
from ...common.style_sheet import FluentStyleSheet
from ...common.icon import FluentIcon as FIF
from .calendar_view import CalendarView
class CalendarPicker(QPushButton):
""" Calendar picker """
dateChanged = pyqtSignal(QDate)
def __init__(self, parent=None):
super().__init__(parent=parent)
self.date = QDate()
self.dateFormat = Qt.SystemLocaleDate
self.view = CalendarView(self.window())
self.view.hide()
self.setText(self.tr('Pick a date'))
FluentStyleSheet.CALENDAR_PICKER.apply(self)
self.clicked.connect(self._showCalendarView)
self.view.dateChanged.connect(self._onDateChanged)
def setDate(self, date: QDate):
""" set the selected date """
self._onDateChanged(date)
self.view.setDate(date)
def setDateFormat(self, format: Union[Qt.DateFormat, str]):
self.dateFormat = format
if self.date.isValid():
self.setText(self.date.toString(self.dateFormat))
def _showCalendarView(self):
x = int(self.width()/2 - self.view.sizeHint().width()/2)
y = self.height()
self.view.exec(self.mapToGlobal(QPoint(x, y)))
def _onDateChanged(self, date: QDate):
self.date = QDate(date)
self.setText(date.toString(self.dateFormat))
self.setProperty('hasDate', True)
self.setStyle(QApplication.style())
self.update()
self.dateChanged.emit(date)
def paintEvent(self, e):
super().paintEvent(e)
painter = QPainter(self)
painter.setRenderHints(QPainter.Antialiasing)
if not self.property('hasDate'):
painter.setOpacity(0.6)
w = 12
rect = QRectF(self.width() - 23, self.height()/2 - w/2, w, w)
FIF.CALENDAR.render(painter, rect)
此差异已折叠。
......@@ -150,6 +150,10 @@ class SearchLineEdit(LineEdit):
else:
self.clearSignal.emit()
def setClearButtonEnabled(self, enable: bool):
self._isClearButtonEnabled = enable
self.setTextMargins(0, 0, 28*enable+30, 0)
class TextEdit(QTextEdit):
""" Text edit """
......
......@@ -786,20 +786,34 @@ class EditMenu(RoundMenu):
if QApplication.clipboard().mimeData().hasText():
if self._parentText():
if self._parentSelectedText():
self.addActions(self.action_list)
if self.parent().isReadOnly():
self.addActions([self.copyAct, self.selectAllAct])
else:
self.addActions(self.action_list)
else:
self.addActions(self.action_list[2:])
else:
if self.parent().isReadOnly():
self.addAction(self.selectAllAct)
else:
self.addActions(self.action_list[2:])
elif not self.parent().isReadOnly():
self.addAction(self.pasteAct)
else:
return
else:
if self._parentText():
if self._parentSelectedText():
if not self._parentText():
return
if self._parentSelectedText():
if self.parent().isReadOnly():
self.addAction([self.copyAct, self.selectAllAct])
else:
self.addActions(
self.action_list[:2] + self.action_list[3:])
else:
if self.parent().isReadOnly():
self.addAction(self.selectAllAct)
else:
self.addActions(self.action_list[3:])
else:
return
super().exec(pos, ani, aniType)
......
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.9.1",
version="0.9.2",
keywords="pyqt fluent widgets",
author="zhiyiYo",
author_email="shokokawaii@outlook.com",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册