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

fixes #203, #221

上级 948dbde4
......@@ -9,7 +9,7 @@ assignees: ''
<!-- 作者还是一名学生党,有更加重要的事情等着自己完成。一个复杂的组件往往要花一到两天来完成,不仅费时费力且无任何经济收入,所以只会抽出一些周末时间来维护这个项目,响应 issue 的速度可能很慢。新组件将按照爱发电上的目标达成情况进行添加,请不要提关于新组件需求的 issue。考虑到代码风格和日后维护,不接受新组件的 PR。如果真的很想要这个组件,可以在爱发电上支持作者的开发。
提 Issue 前请先搜索历史 Issue,可能有相似的,如果没有,需要补充完整模板要求的环境信息和最小复现代码,这很重要,不符合规范的 Issue 会被直接关闭哦。同时请注意礼貌用词,语句之间夹杂的阴阳怪气的省略号或者流汗黄豆绝对达咩 -->
提 Issue 前请先搜索历史 Issue,可能有相似的,如果没有,需要补充完整模板要求的环境信息和最小复现代码,并确保自己安装的包是最新版本的,这很重要,不符合规范的 Issue 会被直接关闭哦。同时请注意礼貌用词,语句之间夹杂的阴阳怪气的省略号或者流汗黄豆绝对达咩 -->
**Describe the bug**
A clear and concise description of what the bug is.
......
......@@ -717,20 +717,28 @@
<translation>添加到</translation>
</message>
</context>
<context>
<name>NavigationViewInterface</name>
<message>
<location filename="../../view/navigation_view_interface.py" line="22"/>
<source>A basic pivot</source>
<translation>顶部导航栏</translation>
</message>
</context>
<context>
<name>PivotInterface</name>
<message>
<location filename="../../view/navigation_view_interface.py" line="44"/>
<location filename="../../view/navigation_view_interface.py" line="45"/>
<source>Song</source>
<translation>歌曲</translation>
</message>
<message>
<location filename="../../view/navigation_view_interface.py" line="45"/>
<location filename="../../view/navigation_view_interface.py" line="46"/>
<source>Album</source>
<translation>专辑</translation>
</message>
<message>
<location filename="../../view/navigation_view_interface.py" line="46"/>
<location filename="../../view/navigation_view_interface.py" line="47"/>
<source>Artist</source>
<translation>歌手</translation>
</message>
......
......@@ -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"/>
......@@ -234,7 +234,7 @@
<message>
<location filename="../../view/date_time_interface.py" line="41"/>
<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"/>
......@@ -354,7 +354,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 +382,7 @@
<message>
<location filename="../../view/icon_interface.py" line="21"/>
<source>Search icons</source>
<translation>索圖標</translation>
<translation>索圖標</translation>
</message>
</context>
<context>
......@@ -485,7 +485,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 +525,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 +535,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 +565,7 @@
<message>
<location filename="../../view/view_interface.py" line="79"/>
<source>Killer Queen</source>
<translation>殺手皇💀</translation>
<translation>殺手皇💀</translation>
</message>
</context>
<context>
......@@ -717,20 +717,28 @@
<translation>添加到</translation>
</message>
</context>
<context>
<name>NavigationViewInterface</name>
<message>
<location filename="../../view/navigation_view_interface.py" line="22"/>
<source>A basic pivot</source>
<translation>頂部導航欄</translation>
</message>
</context>
<context>
<name>PivotInterface</name>
<message>
<location filename="../../view/navigation_view_interface.py" line="44"/>
<location filename="../../view/navigation_view_interface.py" line="45"/>
<source>Song</source>
<translation>歌曲</translation>
</message>
<message>
<location filename="../../view/navigation_view_interface.py" line="45"/>
<location filename="../../view/navigation_view_interface.py" line="46"/>
<source>Album</source>
<translation>專輯</translation>
</message>
<message>
<location filename="../../view/navigation_view_interface.py" line="46"/>
<location filename="../../view/navigation_view_interface.py" line="47"/>
<source>Artist</source>
<translation>歌手</translation>
</message>
......@@ -763,7 +771,7 @@
<message>
<location filename="../../view/scroll_interface.py" line="56"/>
<source>Chitanda Eru is so hot 🥵🥵</source>
<translation>春寒賜浴華清池泉水滑洗凝脂 🥵🥵</translation>
<translation>春寒賜浴華清池泉水滑洗凝脂 🥵🥵</translation>
</message>
<message>
<location filename="../../view/scroll_interface.py" line="67"/>
......@@ -831,7 +839,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"/>
......@@ -846,7 +854,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"/>
......@@ -861,7 +869,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"/>
......@@ -886,12 +894,12 @@
<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"/>
<source>The new version will be more stable and have more features</source>
<translation>新版本將更加穩定並擁有更多功能建議用此選項</translation>
<translation>新版本將更加穩定並擁有更多功能建議用此選項</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="134"/>
......@@ -901,7 +909,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"/>
......@@ -911,7 +919,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"/>
......@@ -941,7 +949,7 @@
<message>
<location filename="../../view/setting_interface.py" line="192"/>
<source>Configuration takes effect after restart</source>
<translation>配置在重軟件後生效</translation>
<translation>配置在重軟件後生效</translation>
</message>
<message>
<location filename="../../view/setting_interface.py" line="192"/>
......@@ -994,7 +1002,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"/>
......@@ -1059,7 +1067,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"/>
......@@ -1069,16 +1077,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>
......@@ -1339,7 +1347,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"/>
......@@ -1367,7 +1375,7 @@
<message>
<location filename="../../view/view_interface.py" line="46"/>
<source>A TreeView with Multi-selection enabled</source>
<translation>用複選框的樹狀組件</translation>
<translation>用複選框的樹狀組件</translation>
</message>
<message>
<location filename="../../view/view_interface.py" line="31"/>
......
......@@ -15,12 +15,12 @@ class NavigationViewInterface(GalleryInterface):
t = Translator()
super().__init__(
title=t.navigation,
subtitle="qfluentwidgets.components.widgets",
subtitle="qfluentwidgets.components.navigation",
parent=parent
)
self.addExampleCard(
title='A basic pivot',
title=self.tr('A basic pivot'),
widget=PivotInterface(self),
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/pivot/demo.py'
)
......
......@@ -108,10 +108,10 @@ class Window(FramelessWindow):
self.navigationInterface.addSeparator()
self.addTreeSubInterface(self.albumInterface, FIF.ALBUM, 'Albums')
self.addTreeSubInterface(self.albumInterface1, FIF.ALBUM, 'Album 1', self.albumInterface)
self.addTreeSubInterface(self.albumInterface1_1, FIF.ALBUM, 'Album 1.1', self.albumInterface1)
self.addTreeSubInterface(self.albumInterface2, FIF.ALBUM, 'Album 2', self.albumInterface)
self.addSubInterface(self.albumInterface, FIF.ALBUM, 'Albums', NavigationItemPosition.SCROLL)
self.addSubInterface(self.albumInterface1, FIF.ALBUM, 'Album 1', parent=self.albumInterface)
self.addSubInterface(self.albumInterface1_1, FIF.ALBUM, 'Album 1.1', parent=self.albumInterface1)
self.addSubInterface(self.albumInterface2, FIF.ALBUM, 'Album 2', parent=self.albumInterface)
# add navigation items to scroll area
self.addSubInterface(self.folderInterface, FIF.FOLDER, 'Folder library', NavigationItemPosition.SCROLL)
......@@ -129,7 +129,7 @@ class Window(FramelessWindow):
routeKey='avatar',
widget=AvatarWidget(),
onClick=self.showMessageBox,
position=NavigationItemPosition.BOTTOM
position=NavigationItemPosition.BOTTOM,
)
self.addSubInterface(self.settingInterface, FIF.SETTING, 'Settings', NavigationItemPosition.BOTTOM)
......@@ -155,7 +155,7 @@ class Window(FramelessWindow):
self.setQss()
def addSubInterface(self, interface, icon, text: str, position=NavigationItemPosition.TOP):
def addSubInterface(self, interface, icon, text: str, position=NavigationItemPosition.TOP, parent=None):
""" add sub interface """
self.stackWidget.addWidget(interface)
self.navigationInterface.addItem(
......@@ -164,20 +164,8 @@ class Window(FramelessWindow):
text=text,
onClick=lambda: self.switchTo(interface),
position=position,
tooltip=text
)
def addTreeSubInterface(self, interface, icon, text: str, parent=None):
""" add tree sub interface """
self.stackWidget.addWidget(interface)
self.navigationInterface.addTreeItem(
routeKey=interface.objectName(),
icon=icon,
text=text,
onClick=lambda: self.switchTo(interface),
position=NavigationItemPosition.SCROLL,
tooltip=text,
parentRouteKey=(parent.objectName() if parent else None)
parentRouteKey=parent.objectName() if parent else None
)
def setQss(self):
......@@ -191,7 +179,7 @@ class Window(FramelessWindow):
def onCurrentInterfaceChanged(self, index):
widget = self.stackWidget.widget(index)
self.navigationInterface.setCurrentItem(widget.objectName())
#!IMPORTANT: This line of code needs to be uncommented if the return button is enabled
# qrouter.push(self.stackWidget, widget.objectName())
......
......@@ -67,7 +67,7 @@ class NavigationBar(QWidget):
def setCurrentItem(self, routeKey: str):
self.navigationPanel.setCurrentItem(routeKey)
self.setTitle(self.navigationPanel.items[routeKey]._text)
self.setTitle(self.navigationPanel.widget(routeKey).text())
def eventFilter(self, obj, e: QEvent):
if obj is self.window():
......@@ -122,48 +122,31 @@ class Window(FramelessWindow):
self.vBoxLayout.setStretchFactor(self.stackWidget, 1)
def initNavigation(self):
self.navigationInterface.addItem(
routeKey=self.searchInterface.objectName(),
icon=FIF.SEARCH,
text='Search',
onClick=lambda: self.switchTo(self.searchInterface)
)
self.navigationInterface.addItem(
routeKey=self.musicInterface.objectName(),
icon=FIF.MUSIC,
text='Music library',
onClick=lambda: self.switchTo(self.musicInterface)
)
self.navigationInterface.addItem(
routeKey=self.videoInterface.objectName(),
icon=FIF.VIDEO,
text='Video library',
onClick=lambda: self.switchTo(self.videoInterface)
)
self.addSubInterface(self.searchInterface, FIF.SEARCH, 'Search')
self.addSubInterface(self.musicInterface, FIF.MUSIC, 'Music library')
self.addSubInterface(self.videoInterface, FIF.VIDEO, 'Video library')
self.navigationInterface.addSeparator()
# add navigation items to scroll area
self.navigationInterface.addItem(
routeKey=self.folderInterface.objectName(),
icon=FIF.FOLDER,
text='Folder library',
onClick=lambda: self.switchTo(self.folderInterface),
position=NavigationItemPosition.SCROLL
)
self.addSubInterface(self.folderInterface, FIF.FOLDER, 'Folder library', NavigationItemPosition.SCROLL)
# add custom widget to bottom
self.navigationInterface.addItem(
routeKey=self.settingInterface.objectName(),
icon=FIF.SETTING,
text='Settings',
onClick=lambda: self.switchTo(self.settingInterface),
position=NavigationItemPosition.BOTTOM
)
# add item to bottom
self.addSubInterface(self.settingInterface, FIF.SETTING, 'Settings', NavigationItemPosition.BOTTOM)
self.stackWidget.currentChanged.connect(self.onCurrentInterfaceChanged)
self.stackWidget.setCurrentIndex(1)
def addSubInterface(self, w: QWidget, icon, text, position=NavigationItemPosition.TOP):
self.stackWidget.addWidget(w)
self.navigationInterface.addItem(
routeKey=w.objectName(),
icon=icon,
text=text,
onClick=lambda: self.switchTo(w),
position=position
)
def initWindow(self):
self.resize(500, 600)
self.setWindowIcon(QIcon('resource/logo.png'))
......
......@@ -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.0"
__version__ = "0.9.1"
from .components import *
from .common import *
......
......@@ -4,7 +4,7 @@ PushButton, ToolButton, ToggleButton {
border-top: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 5px;
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
/* font: 14px 'Segoe UI', 'Microsoft YaHei'; */
padding: 5px 12px 6px 12px;
outline: none;
}
......@@ -120,7 +120,7 @@ PrimarySplitDropButton {
}
HyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
/* font: 14px 'Segoe UI', 'Microsoft YaHei'; */
padding: 5px 12px 6px 12px;
color: --ThemeColorPrimary;
border: none;
......
......@@ -3,7 +3,7 @@ LineEdit, TextEdit, PlainTextEdit {
border: 1px solid rgba(255, 255, 255, 0.08);
border-bottom: 1px solid rgba(255, 255, 255, 0.5442);
border-radius: 5px;
font: 14px "Segoe UI", "Microsoft YaHei";
/* font: 14px "Segoe UI", "Microsoft YaHei"; */
padding: 0px 10px;
color: white;
selection-background-color: --ThemeColorPrimary;
......
......@@ -3,7 +3,7 @@ ListWidget {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
alternate-background-color: transparent;
padding-left: 4px;
......
......@@ -7,7 +7,7 @@ TimeEdit {
border: 1px solid rgba(255, 255, 255, 0.08);
border-bottom: 1px solid rgba(255, 255, 255, 0.5442);
border-radius: 5px;
font: 14px "Segoe UI", "Microsoft YaHei";
/* font: 14px "Segoe UI", "Microsoft YaHei"; */
padding: 0px 80px 0 10px;
color: white;
selection-background-color: --ThemeColorPrimary;
......
......@@ -2,7 +2,7 @@ QTableView {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
alternate-background-color: transparent;
}
......
......@@ -4,7 +4,7 @@ QTreeView {
border-radius: 5px;
outline: 0;
padding-right: 5px;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
}
......
......@@ -4,7 +4,7 @@ PushButton, ToolButton, ToggleButton {
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';
/* font: 14px 'Segoe UI', 'Microsoft YaHei'; */
padding: 5px 12px 6px 12px;
outline: none;
}
......@@ -120,7 +120,7 @@ PrimarySplitDropButton:pressed {
}
HyperlinkButton {
font: 14px 'Segoe UI', 'Microsoft YaHei';
/* font: 14px 'Segoe UI', 'Microsoft YaHei'; */
padding: 6px 12px 6px 12px;
color: --ThemeColorPrimary;
border: none;
......
......@@ -4,7 +4,7 @@ LineEdit, TextEdit, PlainTextEdit {
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
border-radius: 5px;
font: 14px "Segoe UI", "Microsoft YaHei";
/* font: 14px "Segoe UI", "Microsoft YaHei"; */
padding: 0px 10px;
selection-background-color: --ThemeColorLight1;
}
......
......@@ -3,7 +3,7 @@ ListWidget {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
alternate-background-color: transparent;
padding-left: 4px;
......
......@@ -4,7 +4,7 @@ SpinBox, DoubleSpinBox, DateEdit, DateTimeEdit, TimeEdit {
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
border-radius: 5px;
font: 14px "Segoe UI", "Microsoft YaHei";
/* font: 14px "Segoe UI", "Microsoft YaHei"; */
padding: 0px 80px 0 10px;
selection-background-color: --ThemeColorLight1;
}
......
......@@ -2,7 +2,7 @@ QTableView {
background: transparent;
outline: none;
border: none;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
alternate-background-color: transparent;
}
......
......@@ -4,7 +4,7 @@ QTreeView {
border-radius: 5px;
outline: 0;
padding-right: 5px;
font: 13px 'Segoe UI', 'Microsoft YaHei';
/* font: 13px 'Segoe UI', 'Microsoft YaHei'; */
selection-background-color: transparent;
}
......
此差异已折叠。
from .config import *
from .font import setFont, getFont
from .auto_wrap import TextWrap
from .icon import Action, Icon, getIconColor, drawSvgIcon, FluentIcon, drawIcon, FluentIconBase, writeSvg
from .style_sheet import (setStyleSheet, getStyleSheet, setTheme, ThemeColor, themeColor,
......
# coding: utf-8
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QWidget
def setFont(widget: QWidget, fontSize=14):
""" set the font of widget
Parameters
----------
widget: QWidget
the widget to set font
fontSize: int
font pixel size
"""
widget.setFont(getFont(fontSize))
def getFont(fontSize=14):
""" create font
Parameters
----------
fontSize: int
font pixel size
"""
font = QFont()
font.setFamilies(['Segoe UI', 'Microsoft YaHei'])
font.setPixelSize(fontSize)
return font
\ No newline at end of file
from .navigation_widget import NavigationWidget, NavigationPushButton, NavigationSeparator, NavigationToolButton
from .navigation_widget import (NavigationWidget, NavigationPushButton, NavigationSeparator, NavigationToolButton,
NavigationTreeWidget, NavigationTreeWidgetBase)
from .navigation_panel import NavigationPanel, NavigationItemPosition, NavigationDisplayMode
from .navigation_interface import NavigationInterface
from .pivot import Pivot, PivotItem
\ No newline at end of file
......@@ -6,7 +6,7 @@ from PyQt5.QtGui import QResizeEvent, QIcon
from PyQt5.QtWidgets import QWidget
from .navigation_panel import NavigationPanel, NavigationItemPosition, NavigationWidget, NavigationDisplayMode
from .navigation_widget import NavigationPushButton
from .navigation_widget import NavigationTreeWidget
from ...common.style_sheet import FluentStyleSheet
from ...common.icon import FluentIconBase
......@@ -41,8 +41,9 @@ class NavigationInterface(QWidget):
self.setAttribute(Qt.WA_StyledBackground)
FluentStyleSheet.NAVIGATION_INTERFACE.apply(self)
def addItem(self, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None, selectable=True,
position=NavigationItemPosition.TOP, tooltip: str = None) -> NavigationPushButton:
def addItem(self, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.TOP, tooltip: str = None,
parentRouteKey: str = None) -> NavigationTreeWidget:
""" add navigation item
Parameters
......@@ -65,45 +66,16 @@ class NavigationInterface(QWidget):
position: NavigationItemPosition
where the button is added
tooltip: str
the tooltip of item
"""
return self.insertItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip)
def addTreeItem(self, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.SCROLL, tooltip: str = None, parentRouteKey=None):
""" add navigation tree item
Parameters
----------
routeKey: str
the unique name of item
icon: str | QIcon | FluentIconBase
the icon of navigation item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
selectable: bool
whether the item is selectable
tooltip: str
the tooltip of item
parentRouteKey: str
the route key of parent item
the route key of parent item, the parent item should be `NavigationTreeWidgetBase`
"""
return self.insertTreeItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
return self.insertItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
def addWidget(self, routeKey: str, widget: NavigationWidget, onClick=None, position=NavigationItemPosition.TOP,
tooltip: str = None):
tooltip: str = None, parentRouteKey: str = None):
""" add custom widget
Parameters
......@@ -118,15 +90,19 @@ class NavigationInterface(QWidget):
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
where the widget is added
tooltip: str
the tooltip of widget
parentRouteKey: str
the route key of parent item, the parent item should be `NavigationTreeWidgetBase`
"""
self.insertWidget(-1, routeKey, widget, onClick, position, tooltip)
self.insertWidget(-1, routeKey, widget, onClick, position, tooltip, parentRouteKey)
def insertItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.TOP, tooltip: str = None) -> NavigationPushButton:
def insertItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str,
onClick=None, selectable=True, position=NavigationItemPosition.TOP, tooltip: str = None,
parentRouteKey: str = None) -> NavigationTreeWidget:
""" insert navigation item
Parameters
......@@ -150,55 +126,20 @@ class NavigationInterface(QWidget):
whether the item is selectable
position: NavigationItemPosition
where the button is added
tooltip: str
the tooltip of item
"""
button = self.panel.insertItem(index, routeKey, icon, text, onClick, selectable, position, tooltip)
self.setMinimumHeight(self.panel.layoutMinHeight())
return button
def insertTreeItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.SCROLL, tooltip: str = None, parentRouteKey=None):
""" insert navigation tree item
Parameters
----------
index: int
the insert position of parent widget
routeKey: str
the unique name of item
icon: str | QIcon | FluentIconBase
the icon of navigation item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
selectable: bool
whether the item is selectable
where the item is added
tooltip: str
the tooltip of item
parentRouteKey: str
the route key of parent item
the route key of parent item, the parent item should be `NavigationTreeWidgetBase`
"""
button = self.panel.insertTreeItem(
index, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
w = self.panel.insertItem(index, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
self.setMinimumHeight(self.panel.layoutMinHeight())
return button
return w
def insertWidget(self, index: int, routeKey: str, widget: NavigationWidget, onClick=None,
position=NavigationItemPosition.TOP, tooltip: str = None):
position=NavigationItemPosition.TOP, tooltip: str = None, parentRouteKey: str = None):
""" insert custom widget
Parameters
......@@ -216,12 +157,15 @@ class NavigationInterface(QWidget):
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
where the widget is added
tooltip: str
the tooltip of widget
parentRouteKey: str
the route key of parent item, the parent item should be `NavigationTreeWidgetBase`
"""
self.panel.insertWidget(index, routeKey, widget, onClick, position, tooltip)
self.panel.insertWidget(index, routeKey, widget, onClick, position, tooltip, parentRouteKey)
self.setMinimumHeight(self.panel.layoutMinHeight())
def addSeparator(self, position=NavigationItemPosition.TOP):
......@@ -276,6 +220,9 @@ class NavigationInterface(QWidget):
""" set the maximum width """
self.panel.setExpandWidth(width)
def widget(self, routeKey: str):
return self.panel.widget(routeKey)
def eventFilter(self, obj, e: QEvent):
if obj is not self.panel or e.type() != QEvent.Resize:
return super().eventFilter(obj, e)
......
......@@ -6,7 +6,7 @@ from PyQt5.QtCore import Qt, QPropertyAnimation, QRect, QSize, QEvent, QEasingCu
from PyQt5.QtGui import QResizeEvent, QIcon
from PyQt5.QtWidgets import QWidget, QVBoxLayout, QFrame, QApplication
from .navigation_widget import (NavigationPushButton, NavigationToolButton, NavigationWidget, NavigationSeparator,
from .navigation_widget import (NavigationTreeWidgetBase, NavigationToolButton, NavigationWidget, NavigationSeparator,
NavigationTreeWidget)
from ..widgets.scroll_area import SingleDirectionScrollArea
from ..widgets.tool_tip import ToolTipFilter
......@@ -45,6 +45,14 @@ class RouteKeyError(Exception):
""" Route key error """
class NavigationItem:
""" Navigation item """
def __init__(self, routeKey: str, parentRouteKey: str, widget: NavigationWidget):
self.routeKey = routeKey
self.parentRouteKey = parentRouteKey
self.widget = widget
class NavigationPanel(QFrame):
""" Navigation panel """
......@@ -68,7 +76,7 @@ class NavigationPanel(QFrame):
self.bottomLayout = NavigationItemLayout()
self.scrollLayout = NavigationItemLayout(self.scrollWidget)
self.items = {} # type: Dict[str, NavigationWidget]
self.items = {} # type: Dict[str, NavigationItem]
self.history = qrouter
self.expandAni = QPropertyAnimation(self, b'geometry', self)
......@@ -141,10 +149,10 @@ class NavigationPanel(QFrame):
if routeKey not in self.items:
raise RouteKeyError(f"`{routeKey}` is illegal.")
return self.items[routeKey]
return self.items[routeKey].widget
def addItem(self, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None, selectable=True,
position=NavigationItemPosition.TOP, tooltip: str = None):
position=NavigationItemPosition.TOP, tooltip: str = None, parentRouteKey: str = None):
""" add navigation item
Parameters
......@@ -169,11 +177,14 @@ class NavigationPanel(QFrame):
tooltip: str
the tooltip of item
parentRouteKey: str
the route key of parent item, the parent widget should be `NavigationTreeWidget`
"""
return self.insertItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip)
return self.insertItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
def addWidget(self, routeKey: str, widget: NavigationWidget, onClick=None, position=NavigationItemPosition.TOP,
tooltip: str = None):
tooltip: str = None, parentRouteKey: str = None):
""" add custom widget
Parameters
......@@ -192,81 +203,14 @@ class NavigationPanel(QFrame):
tooltip: str
the tooltip of widget
"""
self.insertWidget(-1, routeKey, widget, onClick, position, tooltip)
def insertItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.TOP, tooltip: str = None):
""" insert navigation item
Parameters
----------
index: int
insert position
routeKey: str
the unique name of item
icon: str | QIcon | FluentIconBase
the icon of navigation item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
selectable: bool
whether the item is selectable
tooltip: str
the tooltip of item
"""
if routeKey in self.items:
return
button = NavigationPushButton(icon, text, selectable, self)
self.insertWidget(index, routeKey, button, onClick, position, tooltip)
return button
def addTreeItem(self, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.SCROLL, tooltip: str = None, parentRouteKey=None):
""" add navigation tree item
Parameters
----------
routeKey: str
the unique name of item
icon: str | QIcon | FluentIconBase
the icon of navigation item
text: str
the text of navigation item
onClick: callable
the slot connected to item clicked signal
position: NavigationItemPosition
where the button is added
selectable: bool
whether the item is selectable
tooltip: str
the tooltip of item
parentRouteKey: str
the route key of parent item
the route key of parent item, the parent item should be `NavigationTreeWidget`
"""
return self.insertTreeItem(-1, routeKey, icon, text, onClick, selectable, position, tooltip, parentRouteKey)
self.insertWidget(-1, routeKey, widget, onClick, position, tooltip, parentRouteKey)
def insertTreeItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.SCROLL, tooltip: str = None, parentRouteKey=None):
def insertItem(self, index: int, routeKey: str, icon: Union[str, QIcon, FluentIconBase], text: str, onClick=None,
selectable=True, position=NavigationItemPosition.TOP, tooltip: str = None, parentRouteKey=None):
""" insert navigation tree item
Parameters
......@@ -296,22 +240,17 @@ class NavigationPanel(QFrame):
the tooltip of item
parentRouteKey: str
the route key of parent item
the route key of parent item, the parent item should be `NavigationTreeWidget`
"""
if routeKey in self.items:
return
w = NavigationTreeWidget(icon, text, selectable, self)
if parentRouteKey:
self._registerWidget(routeKey, w, onClick, tooltip)
self.widget(parentRouteKey).insertChild(index, w)
else:
self.insertWidget(index, routeKey, w, onClick, position, tooltip)
self.insertWidget(index, routeKey, w, onClick, position, tooltip, parentRouteKey)
return w
def insertWidget(self, index: int, routeKey: str, widget: NavigationWidget, onClick=None,
position=NavigationItemPosition.TOP, tooltip: str = None):
position=NavigationItemPosition.TOP, tooltip: str = None, parentRouteKey: str = None):
""" insert custom widget
Parameters
......@@ -333,12 +272,18 @@ class NavigationPanel(QFrame):
tooltip: str
the tooltip of widget
parentRouteKey: str
the route key of parent item, the parent item should be `NavigationTreeWidget`
"""
if routeKey in self.items:
return
self._registerWidget(routeKey, widget, onClick, tooltip)
self._insertWidgetToLayout(index, widget, position)
self._registerWidget(routeKey, parentRouteKey, widget, onClick, tooltip)
if parentRouteKey:
self.widget(parentRouteKey).insertChild(index, widget)
else:
self._insertWidgetToLayout(index, widget, position)
def addSeparator(self, position=NavigationItemPosition.TOP):
""" add separator
......@@ -364,7 +309,7 @@ class NavigationPanel(QFrame):
separator = NavigationSeparator(self)
self._insertWidgetToLayout(index, separator, position)
def _registerWidget(self, routeKey: str, widget: NavigationWidget, onClick, tooltip: str):
def _registerWidget(self, routeKey: str, parentRouteKey: str, widget: NavigationWidget, onClick, tooltip: str):
""" register widget """
widget.clicked.connect(self._onWidgetClicked)
......@@ -372,7 +317,8 @@ class NavigationPanel(QFrame):
widget.clicked.connect(onClick)
widget.setProperty('routeKey', routeKey)
self.items[routeKey] = widget
widget.setProperty('parentRouteKey', parentRouteKey)
self.items[routeKey] = NavigationItem(routeKey, parentRouteKey, widget)
if self.displayMode in [NavigationDisplayMode.EXPAND, NavigationDisplayMode.MENU]:
widget.setCompacted(False)
......@@ -406,8 +352,12 @@ class NavigationPanel(QFrame):
if routeKey not in self.items:
return
w = self.items.pop(routeKey)
w.deleteLater()
item = self.items.pop(routeKey)
if item.parentRouteKey is not None:
self.widget(item.parentRouteKey).removeChild(item.widget)
item.widget.deleteLater()
self.history.remove(routeKey)
def setMenuButtonVisible(self, isVisible: bool):
......@@ -462,9 +412,10 @@ class NavigationPanel(QFrame):
if self.expandAni.state() == QPropertyAnimation.Running:
return
for w in self.items.values():
if isinstance(w, NavigationTreeWidget) and w.isRoot():
w.setExpanded(False, ani=False)
for item in self.items.values():
w = item.widget
if isinstance(w, NavigationTreeWidgetBase) and w.isRoot():
w.setExpanded(False)
self.expandAni.setStartValue(
QRect(self.pos(), QSize(self.width(), self.height())))
......@@ -494,7 +445,7 @@ class NavigationPanel(QFrame):
return
for k, item in self.items.items():
item.setSelected(k == routeKey)
item.widget.setSelected(k == routeKey)
def _onWidgetClicked(self):
widget = self.sender() # type: NavigationWidget
......@@ -503,7 +454,7 @@ class NavigationPanel(QFrame):
self.setCurrentItem(widget.property('routeKey'))
if widget is not self.menuButton and self.displayMode == NavigationDisplayMode.MENU \
and not isinstance(widget, NavigationTreeWidget):
and not (isinstance(widget, NavigationTreeWidgetBase) and not widget.isLeaf()):
self.collapse()
def resizeEvent(self, e: QResizeEvent):
......@@ -550,7 +501,7 @@ class NavigationPanel(QFrame):
self.setStyle(QApplication.style())
for item in self.items.values():
item.setCompacted(True)
item.widget.setCompacted(True)
if not self._parent.isWindow():
self.setParent(self._parent)
......
# coding:utf-8
from typing import Union, List
from PyQt5.QtCore import Qt, pyqtSignal, QRect, QRectF, QPropertyAnimation, pyqtProperty, QMargins, QEasingCurve, QPoint
from PyQt5.QtCore import (Qt, pyqtSignal, QRect, QRectF, QPropertyAnimation, pyqtProperty, QMargins,
QEasingCurve, QPoint, QEvent)
from PyQt5.QtGui import QColor, QPainter, QPen, QIcon, QCursor
from PyQt5.QtWidgets import QWidget, QVBoxLayout
......@@ -24,6 +25,8 @@ class NavigationWidget(QWidget):
self.isPressed = False
self.isEnter = False
self.isSelectable = isSelectable
self.treeParent = None
self.nodeDepth = 0
self.setFixedSize(40, 36)
def enterEvent(self, e):
......@@ -65,7 +68,7 @@ class NavigationWidget(QWidget):
isSelected: bool
whether the button is selected
"""
if not self.isSelectable or self.isSelected == isSelected:
if not self.isSelectable:
return
self.isSelected = isSelected
......@@ -241,15 +244,65 @@ class NavigationTreeItem(NavigationPushButton):
arrowAngle = pyqtProperty(float, getArrowAngle, setArrowAngle)
class NavigationTreeWidget(NavigationWidget):
class NavigationTreeWidgetBase(NavigationWidget):
""" Navigation tree widget base class """
def addChild(self, child):
""" add child
Parameters
----------
child: NavigationTreeWidgetBase
child item
"""
raise NotImplementedError
def insertChild(self, index: int, child: NavigationWidget):
""" insert child
Parameters
----------
child: NavigationTreeWidgetBase
child item
"""
raise NotImplementedError
def removeChild(self, child: NavigationWidget):
""" remove child
Parameters
----------
child: NavigationTreeWidgetBase
child item
"""
raise NotImplementedError
def isRoot(self):
""" is root node """
return True
def isLeaf(self):
""" is leaf node """
return True
def setExpanded(self, isExpanded: bool):
""" set the expanded status
Parameters
----------
isExpanded: bool
whether to expand node
"""
raise NotImplementedError
class NavigationTreeWidget(NavigationTreeWidgetBase):
""" Navigation tree widget """
def __init__(self, icon: Union[str, QIcon, FIF], text: str, isSelectable: bool, parent=None):
super().__init__(isSelectable, parent)
self.treeChildren = [] # type: List[NavigationTreeWidget]
self.treeParent = None # type: NavigationTreeWidget
self.nodeDepth = 0
self.isExpanded = False
self.itemWidget = NavigationTreeItem(icon, text, isSelectable, self)
......@@ -267,27 +320,13 @@ class NavigationTreeWidget(NavigationWidget):
self.setAttribute(Qt.WA_TranslucentBackground)
self.expandAni.valueChanged.connect(lambda g: self.setFixedSize(g.size()))
def addChild(self, child: 'NavigationTreeWidget'):
""" add child
Parameters
----------
child: NavigationTreeWidget
child item
"""
def addChild(self, child):
self.insertChild(-1, child)
def text(self):
return self.itemWidget.text()
def insertChild(self, index: int, child: 'NavigationTreeWidget'):
""" insert child
Parameters
----------
child: NavigationTreeWidget
child item
"""
def insertChild(self, index, child):
if child in self.treeChildren:
return
......@@ -303,7 +342,11 @@ class NavigationTreeWidget(NavigationWidget):
self.treeChildren.insert(index, child)
self.vBoxLayout.insertWidget(index, child, 0, Qt.AlignTop)
def setExpanded(self, isExpanded: bool, ani=True):
def removeChild(self, child):
self.treeChildren.remove(child)
self.vBoxLayout.removeWidget(child)
def setExpanded(self, isExpanded: bool, ani=False):
""" set the expanded status """
if isExpanded == self.isExpanded:
return
......@@ -345,9 +388,9 @@ class NavigationTreeWidget(NavigationWidget):
def _onClicked(self, triggerByUser, clickArrow):
if not self.isCompacted:
if self.isSelectable and not self.isSelected and not clickArrow:
self.setExpanded(True)
self.setExpanded(True, ani=True)
else:
self.setExpanded(not self.isExpanded)
self.setExpanded(not self.isExpanded, ani=True)
if not clickArrow or self.isCompacted:
self.clicked.emit(triggerByUser)
......@@ -2,12 +2,13 @@
from typing import Union
from PyQt5.QtCore import pyqtSignal, QUrl, Qt, QRectF, QSize, QPoint, pyqtProperty
from PyQt5.QtGui import QDesktopServices, QIcon, QPainter
from PyQt5.QtGui import QDesktopServices, QIcon, QPainter, QFont
from PyQt5.QtWidgets import QHBoxLayout, QPushButton, QRadioButton, QToolButton, QApplication, QWidget, QSizePolicy
from ...common.animation import TranslateYAnimation
from ...common.icon import FluentIconBase, drawIcon, isDarkTheme, Theme, toQIcon
from ...common.icon import FluentIcon as FIF
from ...common.font import setFont
from ...common.style_sheet import FluentStyleSheet
from ...common.overload import singledispatchmethod
from .menu import RoundMenu
......@@ -24,6 +25,7 @@ class PushButton(QPushButton):
self.isHover = False
self.setIconSize(QSize(16, 16))
self.setIcon(None)
setFont(self)
self._postInit()
@__init__.register
......@@ -132,6 +134,7 @@ class HyperlinkButton(QPushButton):
self._url = QUrl()
FluentStyleSheet.BUTTON.apply(self)
self.setCursor(Qt.PointingHandCursor)
setFont(self)
self.clicked.connect(lambda i: QDesktopServices.openUrl(self.getUrl()))
@__init__.register
......@@ -174,6 +177,7 @@ class ToolButton(QToolButton):
self.isHover = False
self.setIconSize(QSize(16, 16))
self.setIcon(QIcon())
setFont(self)
self._postInit()
@__init__.register
......
......@@ -7,6 +7,7 @@ from PyQt5.QtWidgets import QHBoxLayout, QLineEdit, QToolButton, QTextEdit, QPla
from ...common.style_sheet import FluentStyleSheet, themeColor
from ...common.icon import isDarkTheme, FluentIconBase, drawIcon
from ...common.icon import FluentIcon as FIF
from ...common.font import setFont
from .menu import LineEditMenu, TextEditMenu
from .scroll_bar import SmoothScrollDelegate
......@@ -62,6 +63,7 @@ class LineEdit(QLineEdit):
FluentStyleSheet.LINE_EDIT.apply(self)
self.setFixedHeight(33)
self.setAttribute(Qt.WA_MacShowFocusRect, False)
setFont(self)
self.hBoxLayout = QHBoxLayout(self)
self.clearButton = LineEditButton(FIF.CLOSE, self)
......@@ -156,6 +158,7 @@ class TextEdit(QTextEdit):
super().__init__(parent=parent)
self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self)
setFont(self)
def contextMenuEvent(self, e):
menu = TextEditMenu(self)
......@@ -169,6 +172,7 @@ class PlainTextEdit(QPlainTextEdit):
super().__init__(parent=parent)
self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self)
setFont(self)
def contextMenuEvent(self, e):
menu = TextEditMenu(self)
......
......@@ -8,6 +8,7 @@ from PyQt5.QtWidgets import (QSpinBox, QDoubleSpinBox, QToolButton, QHBoxLayout,
from ...common.style_sheet import FluentStyleSheet, themeColor
from ...common.icon import FluentIconBase, Theme, getIconColor
from ...common.font import setFont
from ...components.widgets import LineEditMenu
......@@ -62,6 +63,7 @@ class Ui_SpinBox:
FluentStyleSheet.SPIN_BOX.apply(self)
self.setButtonSymbols(QSpinBox.NoButtons)
self.setFixedHeight(33)
setFont(self)
self.hBoxLayout = QHBoxLayout(self)
self.upButton = SpinButton(SpinIcon.UP, self)
......
......@@ -6,6 +6,7 @@ from PyQt5.QtGui import QPainter, QColor, QKeyEvent, QPalette
from PyQt5.QtWidgets import (QStyledItemDelegate, QApplication, QStyleOptionViewItem,
QTableView, QTableWidget, QWidget, QTableWidgetItem)
from ...common.font import getFont
from ...common.style_sheet import isDarkTheme, FluentStyleSheet, themeColor
from .line_edit import LineEdit
from .scroll_bar import SmoothScrollDelegate
......@@ -78,6 +79,7 @@ class TableItemDelegate(QStyledItemDelegate):
def initStyleOption(self, option: QStyleOptionViewItem, index: QModelIndex):
super().initStyleOption(option, index)
option.font = getFont(13)
if isDarkTheme():
option.palette.setColor(QPalette.Text, Qt.white)
option.palette.setColor(QPalette.HighlightedText, Qt.white)
......
# coding:utf-8
import typing
from PyQt5.QtCore import Qt, QSize
from PyQt5.QtGui import QPainter, QColor
from PyQt5.QtWidgets import QWidget, QTreeWidget, QStyledItemDelegate, QStyle, QTreeView
from PyQt5.QtGui import QPainter, QColor, QPalette
from PyQt5.QtWidgets import QTreeWidget, QStyledItemDelegate, QStyle, QTreeView
from ...common.style_sheet import FluentStyleSheet, themeColor, isDarkTheme
from ...common.font import getFont
from .scroll_area import SmoothScrollDelegate
......@@ -39,6 +39,16 @@ class TreeItemDelegate(QStyledItemDelegate):
painter.restore()
def initStyleOption(self, option, index):
super().initStyleOption(option, index)
option.font = getFont(13)
if isDarkTheme():
option.palette.setColor(QPalette.Text, Qt.white)
option.palette.setColor(QPalette.HighlightedText, Qt.white)
else:
option.palette.setColor(QPalette.Text, Qt.black)
option.palette.setColor(QPalette.HighlightedText, Qt.black)
class TreeViewBase:
""" Tree view base class """
......
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.9.0",
version="0.9.1",
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.
先完成此消息的编辑!
想要评论请 注册