Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
k54kdk
PyQt Fluent Widgets
提交
35d14c98
P
PyQt Fluent Widgets
项目概览
k54kdk
/
PyQt Fluent Widgets
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PyQt Fluent Widgets
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
35d14c98
编写于
4月 02, 2023
作者:
之一Yo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
调整单行编辑框底部边框样式,添加富文本框
上级
9b8d43aa
变更
20
展开全部
隐藏空白更改
内联
并排
Showing
20 changed file
with
46575 addition
and
46376 deletion
+46575
-46376
examples/gallery/app/resource/i18n/gallery_hk.qm
examples/gallery/app/resource/i18n/gallery_hk.qm
+0
-0
examples/gallery/app/resource/i18n/gallery_hk.ts
examples/gallery/app/resource/i18n/gallery_hk.ts
+25
-20
examples/gallery/app/resource/i18n/gallery_zh.qm
examples/gallery/app/resource/i18n/gallery_zh.qm
+0
-0
examples/gallery/app/resource/i18n/gallery_zh.ts
examples/gallery/app/resource/i18n/gallery_zh.ts
+5
-0
examples/gallery/app/view/home_interface.py
examples/gallery/app/view/home_interface.py
+9
-1
examples/gallery/app/view/text_interface.py
examples/gallery/app/view/text_interface.py
+13
-1
examples/line_edit/demo.py
examples/line_edit/demo.py
+7
-3
qfluentwidgets/__init__.py
qfluentwidgets/__init__.py
+1
-1
qfluentwidgets/_rc/qss/dark/button.qss
qfluentwidgets/_rc/qss/dark/button.qss
+1
-0
qfluentwidgets/_rc/qss/dark/color_dialog.qss
qfluentwidgets/_rc/qss/dark/color_dialog.qss
+1
-0
qfluentwidgets/_rc/qss/dark/line_edit.qss
qfluentwidgets/_rc/qss/dark/line_edit.qss
+55
-5
qfluentwidgets/_rc/qss/light/button.qss
qfluentwidgets/_rc/qss/light/button.qss
+1
-0
qfluentwidgets/_rc/qss/light/color_dialog.qss
qfluentwidgets/_rc/qss/light/color_dialog.qss
+1
-0
qfluentwidgets/_rc/qss/light/line_edit.qss
qfluentwidgets/_rc/qss/light/line_edit.qss
+55
-5
qfluentwidgets/_rc/resource.py
qfluentwidgets/_rc/resource.py
+46242
-46302
qfluentwidgets/components/widgets/__init__.py
qfluentwidgets/components/widgets/__init__.py
+1
-1
qfluentwidgets/components/widgets/line_edit.py
qfluentwidgets/components/widgets/line_edit.py
+48
-6
qfluentwidgets/components/widgets/menu.py
qfluentwidgets/components/widgets/menu.py
+68
-27
qfluentwidgets/components/widgets/spin_box.py
qfluentwidgets/components/widgets/spin_box.py
+41
-3
setup.py
setup.py
+1
-1
未找到文件。
examples/gallery/app/resource/i18n/gallery_hk.qm
浏览文件 @
35d14c98
无法预览此类型文件
examples/gallery/app/resource/i18n/gallery_hk.ts
浏览文件 @
35d14c98
...
...
@@ -273,7 +273,7 @@
<
message
>
<
location
filename
=
"
../../view/main_window.py
"
line
=
"
189
"
/>
<
source
>
Text
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
文本
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
@@ -688,52 +688,52 @@
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
113
"
/>
<
source
>
Top
right
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
右上角
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
114
"
/>
<
source
>
Top
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
頂部居中
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
115
"
/>
<
source
>
Top
left
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
左上角
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
116
"
/>
<
source
>
Bottom
right
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
右下角
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
117
"
/>
<
source
>
Bottom
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
底部居中
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
118
"
/>
<
source
>
Bottom
left
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
左下角
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
201
"
/>
<
source
>
Lesson
1
<
/source
>
<
translation
type
=
"
unfinished
"
>
Lesson
1
<
/translation
>
<
translation
>
Lesson
1
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
201
"
/>
<
source
>
Don
&
apos
;
t
have
any
strange
expectations
of
me
.
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
別對我抱有什麼奇怪的期待
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
212
"
/>
<
source
>
Lesson
2
<
/source
>
<
translation
type
=
"
unfinished
"
>
Lesson
2
<
/translation
>
<
translation
>
Lesson
2
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/status_info_interface.py
"
line
=
"
212
"
/>
<
source
>
Don
&
apos
;
t
let
your
muscles
notice
.
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
不要讓肌肉察覺
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
@@ -741,37 +741,42 @@
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
23
"
/>
<
source
>
ko
no
dio
da
!
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
><
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
25
"
/>
<
source
>
A
LineEdit
with
a
clear
button
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
帶清空按鈕的
LineEdit
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
39
"
/>
<
source
>
A
DoubleSpinBox
with
a
spin
button
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
帶調節按鈕的
DoubleSpinBox
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
46
"
/>
<
source
>
A
DateEdit
with
a
spin
button
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
帶調節按鈕的
DateEdit
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
53
"
/>
<
source
>
A
TimeEdit
with
a
spin
button
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
帶調節按鈕的
TimeEdit
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
60
"
/>
<
source
>
A
DateTimeEdit
with
a
spin
button
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
帶調節按鈕的
DateTimeEdit
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
32
"
/>
<
source
>
A
SpinBox
with
a
spin
button
<
/source
>
<
translation
type
=
"
unfinished
"
><
/translation
>
<
translation
>
帶調節按鈕的
SpinBox
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
71
"
/>
<
source
>
A
simple
TextEdit
<
/source
>
<
translation
>
富文本框
<
/translation
>
<
/message
>
<
/context
>
<
context
>
...
...
@@ -837,7 +842,7 @@
<
message
>
<
location
filename
=
"
../../common/translator.py
"
line
=
"
16
"
/>
<
source
>
Text
<
/source
>
<
translation
type
=
"
unfinished
"
>
<
/translation
>
<
translation
>
文本
<
/translation
>
<
/message
>
<
/context
>
<
/TS
>
<
/TS>
\ No newline at end of file
examples/gallery/app/resource/i18n/gallery_zh.qm
浏览文件 @
35d14c98
无法预览此类型文件
examples/gallery/app/resource/i18n/gallery_zh.ts
浏览文件 @
35d14c98
...
...
@@ -773,6 +773,11 @@
<
source
>
A
SpinBox
with
a
spin
button
<
/source
>
<
translation
>
带调节按钮的
SpinBox
<
/translation
>
<
/message
>
<
message
>
<
location
filename
=
"
../../view/text_interface.py
"
line
=
"
71
"
/>
<
source
>
A
simple
TextEdit
<
/source
>
<
translation
>
富文本框
<
/translation
>
<
/message
>
<
/context
>
<
context
>
<
name
>
ToolBar
<
/name
>
...
...
examples/gallery/app/view/home_interface.py
浏览文件 @
35d14c98
...
...
@@ -277,10 +277,18 @@ class HomeInterface(ScrollArea):
)
textView
.
addSampleCard
(
icon
=
"app/resource/images/controls/NumberBox.png"
,
title
=
"
Number
Box"
,
title
=
"
Spin
Box"
,
content
=
self
.
tr
(
"A text control used for numeric input and evaluation of algebraic equations."
),
routeKey
=
"textInterface"
,
index
=
1
)
textView
.
addSampleCard
(
icon
=
"app/resource/images/controls/RichEditBox.png"
,
title
=
"TextEdit"
,
content
=
self
.
tr
(
"A rich text editing control that supports formatted text, hyperlinks, and other rich content."
),
routeKey
=
"textInterface"
,
index
=
6
)
self
.
vBoxLayout
.
addWidget
(
textView
)
examples/gallery/app/view/text_interface.py
浏览文件 @
35d14c98
...
...
@@ -2,7 +2,7 @@
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtGui
import
QPixmap
,
QColor
from
PyQt5.QtWidgets
import
QWidget
,
QHBoxLayout
from
qfluentwidgets
import
LineEdit
,
SpinBox
,
DoubleSpinBox
,
TimeEdit
,
DateTimeEdit
,
DateEdit
from
qfluentwidgets
import
LineEdit
,
SpinBox
,
DoubleSpinBox
,
TimeEdit
,
DateTimeEdit
,
DateEdit
,
TextEdit
from
.gallery_interface
import
GalleryInterface
from
..common.translator
import
Translator
...
...
@@ -62,3 +62,15 @@ class TextInterface(GalleryInterface):
widget
=
DateTimeEdit
(
self
),
sourcePath
=
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/spin_box/demo.py'
)
# text edit
textEdit
=
TextEdit
(
self
)
textEdit
.
setMarkdown
(
"## Steel Ball Run
\n
* Johnny Joestar 🦄
\n
* Gyro Zeppeli 🐴 "
)
textEdit
.
setFixedHeight
(
150
)
self
.
addExampleCard
(
title
=
self
.
tr
(
"A simple TextEdit"
),
widget
=
textEdit
,
sourcePath
=
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py'
,
stretch
=
1
)
examples/line_edit/demo.py
浏览文件 @
35d14c98
...
...
@@ -3,7 +3,7 @@ import sys
from
PyQt5.QtCore
import
Qt
from
PyQt5.QtWidgets
import
QApplication
,
QWidget
from
qfluentwidgets
import
LineEdit
,
PushButton
from
qfluentwidgets
import
LineEdit
,
PushButton
,
TextEdit
class
Demo
(
QWidget
):
...
...
@@ -12,9 +12,13 @@ class Demo(QWidget):
super
().
__init__
()
self
.
lineEdit
=
LineEdit
(
''
,
self
)
self
.
button
=
PushButton
(
'按钮'
,
self
)
self
.
textEdit
=
TextEdit
(
self
)
self
.
resize
(
500
,
500
)
self
.
lineEdit
.
move
(
110
,
220
)
self
.
button
.
move
(
320
,
220
)
self
.
textEdit
.
move
(
110
,
200
)
self
.
lineEdit
.
move
(
110
,
50
)
self
.
button
.
move
(
320
,
52
)
self
.
lineEdit
.
resize
(
200
,
33
)
self
.
lineEdit
.
setClearButtonEnabled
(
True
)
...
...
qfluentwidgets/__init__.py
浏览文件 @
35d14c98
...
...
@@ -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.5.
2
"
__version__
=
"0.5.
3
"
from
.components
import
*
from
.common
import
*
...
...
qfluentwidgets/_rc/qss/dark/button.qss
浏览文件 @
35d14c98
...
...
@@ -6,6 +6,7 @@ PushButton, ToolButton {
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 12px 6px 12px;
outline: none;
}
ToolButton {
...
...
qfluentwidgets/_rc/qss/dark/color_dialog.qss
浏览文件 @
35d14c98
...
...
@@ -125,6 +125,7 @@ QScrollBar::sub-page:vertical {
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 9px 6px 9px;
outline: none;
}
#cancelButton:hover {
...
...
qfluentwidgets/_rc/qss/dark/line_edit.qss
浏览文件 @
35d14c98
QLine
Edit {
LineEdit, Text
Edit {
background-color: rgb(55, 55, 55);
border: 1px solid rgb(58, 58, 58);
border-bottom: 1px solid rgb(159, 159, 159);
...
...
@@ -10,21 +10,25 @@ QLineEdit {
selection-color: black;
}
QLineEdit:hover {
TextEdit {
padding: 0px 0px 0px 10px;
}
LineEdit:hover, TextEdit:hover {
background-color: rgb(60, 60, 60);
}
QLine
Edit:!focus {
LineEdit:!focus, Text
Edit:!focus {
background-color: rgb(55, 55, 55);
border-bottom: 1px solid rgb(159, 159, 159);
}
QLine
Edit:focus {
LineEdit:focus, Text
Edit:focus {
border-bottom: 1px solid --ThemeColorPrimary;
background-color: rgb(34, 34, 34);
}
QLine
Edit:disabled {
LineEdit:disabled, Text
Edit:disabled {
color: rgba(255, 255, 255, 150);
background-color: rgb(59, 59, 59);
border: 1px solid rgb(73, 73, 73);
...
...
@@ -42,4 +46,50 @@ QLineEdit:disabled {
#clearButton:pressed {
background-color: rgba(255, 255, 255, 6);
}
QScrollBar {
background: transparent;
width: 4px;
margin-top: 12px;
margin-bottom: 0;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
margin-left: 12px;
margin-right: 12px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/qss/light/button.qss
浏览文件 @
35d14c98
...
...
@@ -6,6 +6,7 @@ PushButton, ToolButton {
border-radius: 5px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 12px 6px 12px;
outline: none;
}
ToolButton {
...
...
qfluentwidgets/_rc/qss/light/color_dialog.qss
浏览文件 @
35d14c98
...
...
@@ -122,6 +122,7 @@ QScrollBar::sub-page:vertical {
border-radius: 5px;
font: 14px 'Segoe UI', 'Microsoft YaHei';
padding: 5px 9px 6px 9px;
outline: none;
}
#cancelButton:hover {
...
...
qfluentwidgets/_rc/qss/light/line_edit.qss
浏览文件 @
35d14c98
QLine
Edit {
LineEdit, Text
Edit {
color: black;
background-color: white;
border: 1px solid rgba(0, 0, 0, 13);
...
...
@@ -9,23 +9,27 @@ QLineEdit {
selection-background-color: --ThemeColorLight1;
}
QLineEdit:hover {
TextEdit {
padding: 0px 0px 0px 10px;
}
LineEdit:hover, TextEdit:hover {
background-color: rgb(252, 252, 252);
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
}
QLine
Edit:!focus {
LineEdit:!focus, Text
Edit:!focus {
background-color: white;
border-bottom: 1px solid rgba(0, 0, 0, 100);
}
QLine
Edit:focus {
LineEdit:focus, Text
Edit:focus {
border-bottom: 1px solid --ThemeColorPrimary;
background-color: white;
}
QLine
Edit:disabled {
LineEdit:disabled, Text
Edit:disabled {
color: rgba(0, 0, 0, 150);
background-color: rgb(252, 252, 252);
border: 1px solid rgb(237, 237, 237);
...
...
@@ -43,4 +47,50 @@ QLineEdit:disabled {
#clearButton:pressed {
background-color: rgba(0, 0, 0, 6);
}
QScrollBar:vertical {
background: transparent;
width: 4px;
margin-top: 12px;
margin-bottom: 12px;
padding-right: 2px;
}
QScrollBar:horizontal {
background: transparent;
height: 4px;
margin-left: 12px;
margin-right: 12px;
padding-bottom: 2px;
}
QScrollBar::sub-line {
background: transparent;
}
QScrollBar::add-line {
background: transparent;
}
QScrollBar::handle {
background: rgb(122, 122, 122);
border: 2px solid rgb(128, 128, 128);
border-radius: 1px;
}
QScrollBar::handle:vertical {
min-height: 32px;
}
QScrollBar::handle:horizontal {
min-width: 32px;
}
QScrollBar::add-page:vertical,
QScrollBar::sub-page:vertical,
QScrollBar::add-page:horizontal,
QScrollBar::sub-page:horizontal {
background: none;
}
\ No newline at end of file
qfluentwidgets/_rc/resource.py
浏览文件 @
35d14c98
此差异已折叠。
点击以展开。
qfluentwidgets/components/widgets/__init__.py
浏览文件 @
35d14c98
from
.button
import
PrimaryPushButton
,
PushButton
,
RadioButton
,
HyperlinkButton
,
ToolButton
from
.check_box
import
CheckBox
from
.combo_box
import
ComboBox
from
.line_edit
import
LineEdit
from
.line_edit
import
LineEdit
,
TextEdit
from
.icon_widget
import
IconWidget
from
.label
import
PixmapLabel
from
.menu
import
DWMMenu
,
LineEditMenu
,
RoundMenu
...
...
qfluentwidgets/components/widgets/line_edit.py
浏览文件 @
35d14c98
# coding: utf-8
from
PyQt5.QtCore
import
QSize
,
Qt
,
QRectF
from
PyQt5.QtGui
import
QPainter
from
PyQt5.QtWidgets
import
QLineEdit
,
QToolButton
from
PyQt5.QtCore
import
QSize
,
Qt
,
QRectF
,
QEvent
from
PyQt5.QtGui
import
QPainter
,
QPainterPath
from
PyQt5.QtWidgets
import
QLineEdit
,
QToolButton
,
QTextEdit
from
...common.style_sheet
import
setStyleSheet
from
...common.style_sheet
import
setStyleSheet
,
themeColor
from
...common.icon
import
writeSvg
,
isDarkTheme
,
drawSvgIcon
from
...common.icon
import
FluentIcon
as
FIF
from
.menu
import
LineEditMenu
from
...common.smooth_scroll
import
SmoothMode
,
SmoothScroll
from
.menu
import
LineEditMenu
,
TextEditMenu
class
ClearButton
(
QToolButton
):
...
...
@@ -23,7 +24,8 @@ class ClearButton(QToolButton):
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
|
QPainter
.
SmoothPixmapTransform
)
if
isDarkTheme
():
FIF
.
CLOSE
.
render
(
painter
,
QRectF
(
9.5
,
7
,
10
,
10
))
else
:
...
...
@@ -76,3 +78,43 @@ class LineEdit(QLineEdit):
def
resizeEvent
(
self
,
e
):
self
.
clearButton
.
move
(
self
.
width
()
-
33
,
4
)
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
if
not
self
.
hasFocus
():
return
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
path
=
QPainterPath
()
w
,
h
=
self
.
width
()
-
2
,
self
.
height
()
path
.
addRoundedRect
(
QRectF
(
1
,
h
-
12
,
w
,
12
),
6
,
6
)
rectPath
=
QPainterPath
()
rectPath
.
addRect
(
1
,
h
-
12
,
w
,
9.5
)
path
=
path
.
subtracted
(
rectPath
)
painter
.
fillPath
(
path
,
themeColor
())
class
TextEdit
(
QTextEdit
):
""" Text edit """
def
__init__
(
self
,
parent
=
None
):
super
().
__init__
(
parent
=
parent
)
self
.
verticalSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Vertical
)
self
.
horizonSmoothScroll
=
SmoothScroll
(
self
,
Qt
.
Horizontal
)
setStyleSheet
(
self
,
'line_edit'
)
def
contextMenuEvent
(
self
,
e
):
menu
=
TextEditMenu
(
self
)
menu
.
exec_
(
e
.
globalPos
())
def
wheelEvent
(
self
,
e
):
if
e
.
modifiers
()
==
Qt
.
NoModifier
:
self
.
verticalSmoothScroll
.
wheelEvent
(
e
)
else
:
self
.
horizonSmoothScroll
.
wheelEvent
(
e
)
qfluentwidgets/components/widgets/menu.py
浏览文件 @
35d14c98
...
...
@@ -2,10 +2,10 @@
from
qframelesswindow
import
WindowEffect
from
PyQt5.QtCore
import
(
QEasingCurve
,
QEvent
,
QPropertyAnimation
,
QRect
,
Qt
,
QSize
,
QRectF
,
pyqtSignal
,
QPoint
,
QTimer
)
from
PyQt5.QtGui
import
QIcon
,
QColor
,
QPainter
,
QPen
,
QPixmap
,
QRegion
,
QCursor
from
PyQt5.QtGui
import
QIcon
,
QColor
,
QPainter
,
QPen
,
QPixmap
,
QRegion
,
QCursor
,
QTextCursor
from
PyQt5.QtWidgets
import
(
QAction
,
QApplication
,
QMenu
,
QProxyStyle
,
QStyle
,
QGraphicsDropShadowEffect
,
QListWidget
,
QWidget
,
QHBoxLayout
,
QListWidgetItem
)
QListWidgetItem
,
QLineEdit
,
QTextEdit
)
from
...common.smooth_scroll
import
SmoothScroll
from
...common.icon
import
FluentIcon
as
FIF
...
...
@@ -52,7 +52,6 @@ class DWMMenu(QMenu):
return
QMenu
.
event
(
self
,
e
)
class
MenuSeparator
(
QWidget
):
""" Menu separator """
...
...
@@ -514,8 +513,9 @@ class RoundMenu(QWidget):
# get the rect of menu item
margin
=
view
.
viewportMargins
()
rect
=
view
.
visualItemRect
(
self
.
menuItem
).
translated
(
view
.
mapToGlobal
(
QPoint
()))
rect
=
rect
.
translated
(
margin
.
left
(),
margin
.
top
()
+
2
)
rect
=
view
.
visualItemRect
(
self
.
menuItem
).
translated
(
view
.
mapToGlobal
(
QPoint
()))
rect
=
rect
.
translated
(
margin
.
left
(),
margin
.
top
()
+
2
)
if
self
.
parentMenu
.
geometry
().
contains
(
pos
)
and
not
rect
.
contains
(
pos
)
and
\
not
self
.
geometry
().
contains
(
pos
):
view
.
clearSelection
()
...
...
@@ -569,7 +569,8 @@ class RoundMenu(QWidget):
rect
=
QApplication
.
screenAt
(
QCursor
.
pos
()).
availableGeometry
()
w
,
h
=
self
.
width
()
+
5
,
self
.
height
()
+
5
pos
.
setX
(
min
(
pos
.
x
()
-
self
.
layout
().
contentsMargins
().
left
(),
rect
.
right
()
-
w
))
pos
.
setX
(
min
(
pos
.
x
()
-
self
.
layout
().
contentsMargins
().
left
(),
rect
.
right
()
-
w
))
pos
.
setY
(
min
(
pos
.
y
()
-
4
,
rect
.
bottom
()
-
h
))
if
ani
:
...
...
@@ -610,17 +611,8 @@ class RoundMenu(QWidget):
self
.
exec
(
pos
,
ani
)
class
LineEditMenu
(
RoundMenu
):
""" Line edit menu """
def
__init__
(
self
,
parent
):
super
().
__init__
(
""
,
parent
)
self
.
animation
=
QPropertyAnimation
(
self
,
b
"geometry"
)
self
.
animation
.
setDuration
(
300
)
self
.
animation
.
setEasingCurve
(
QEasingCurve
.
OutQuad
)
self
.
setProperty
(
"selectAll"
,
bool
(
self
.
parent
().
text
()))
self
.
selectionStart
=
parent
.
selectionStart
()
self
.
selectionLength
=
parent
.
selectionLength
()
class
EditMenu
(
RoundMenu
):
""" Edit menu """
def
createActions
(
self
):
self
.
cutAct
=
QAction
(
...
...
@@ -657,30 +649,32 @@ class LineEditMenu(RoundMenu):
shortcut
=
"Ctrl+A"
,
triggered
=
self
.
parent
().
selectAll
)
self
.
action_list
=
[
self
.
cutAct
,
self
.
copyAct
,
self
.
pasteAct
,
self
.
cancelAct
,
self
.
selectAllAct
]
self
.
action_list
=
[
self
.
cutAct
,
self
.
copyAct
,
self
.
pasteAct
,
self
.
cancelAct
,
self
.
selectAllAct
]
def
_onItemClicked
(
self
,
item
):
if
self
.
selectionLength
:
self
.
parent
().
setSelection
(
self
.
selectionStart
,
self
.
selectionLength
)
def
_parentText
(
self
):
raise
NotImplementedError
super
().
_onItemClicked
(
item
)
def
_parentSelectedText
(
self
):
raise
NotImplementedError
def
exec
(
self
,
pos
,
ani
=
True
):
self
.
clear
()
self
.
createActions
()
if
QApplication
.
clipboard
().
mimeData
().
hasText
():
if
self
.
parent
().
t
ext
():
if
self
.
parent
().
s
electedText
():
if
self
.
_parentT
ext
():
if
self
.
_parentS
electedText
():
self
.
addActions
(
self
.
action_list
)
else
:
self
.
addActions
(
self
.
action_list
[
2
:])
else
:
self
.
addAction
(
self
.
pasteAct
)
else
:
if
self
.
parent
().
t
ext
():
if
self
.
parent
().
s
electedText
():
if
self
.
_parentT
ext
():
if
self
.
_parentS
electedText
():
self
.
addActions
(
self
.
action_list
[:
2
]
+
self
.
action_list
[
3
:])
else
:
...
...
@@ -689,3 +683,50 @@ class LineEditMenu(RoundMenu):
return
super
().
exec
(
pos
,
ani
)
class
LineEditMenu
(
EditMenu
):
""" Line edit menu """
def
__init__
(
self
,
parent
:
QLineEdit
):
super
().
__init__
(
""
,
parent
)
self
.
selectionStart
=
parent
.
selectionStart
()
self
.
selectionLength
=
parent
.
selectionLength
()
def
_onItemClicked
(
self
,
item
):
if
self
.
selectionStart
>=
0
:
self
.
parent
().
setSelection
(
self
.
selectionStart
,
self
.
selectionLength
)
super
().
_onItemClicked
(
item
)
def
_parentText
(
self
):
return
self
.
parent
().
text
()
def
_parentSelectedText
(
self
):
return
self
.
parent
().
selectedText
()
class
TextEditMenu
(
EditMenu
):
""" Text edit menu """
def
__init__
(
self
,
parent
:
QTextEdit
):
super
().
__init__
(
""
,
parent
)
cursor
=
parent
.
textCursor
()
self
.
selectionStart
=
cursor
.
selectionStart
()
self
.
selectionLength
=
cursor
.
selectionEnd
()
-
self
.
selectionStart
+
1
def
_parentText
(
self
):
return
self
.
parent
().
toPlainText
()
def
_parentSelectedText
(
self
):
return
self
.
parent
().
textCursor
().
selectedText
()
def
_onItemClicked
(
self
,
item
):
if
self
.
selectionStart
>=
0
:
cursor
=
self
.
parent
().
textCursor
()
cursor
.
setPosition
(
self
.
selectionStart
)
cursor
.
movePosition
(
QTextCursor
.
Right
,
QTextCursor
.
KeepAnchor
,
self
.
selectionLength
)
super
().
_onItemClicked
(
item
)
qfluentwidgets/components/widgets/spin_box.py
浏览文件 @
35d14c98
...
...
@@ -2,11 +2,11 @@
from
enum
import
Enum
from
PyQt5.QtCore
import
Qt
,
QSize
,
QRectF
from
PyQt5.QtGui
import
QPainter
,
Q
TextCursor
from
PyQt5.QtGui
import
QPainter
,
Q
PainterPath
from
PyQt5.QtWidgets
import
(
QSpinBox
,
QDoubleSpinBox
,
QToolButton
,
QHBoxLayout
,
QDateEdit
,
QDateTimeEdit
,
QTimeEdit
)
QDateEdit
,
QDateTimeEdit
,
QTimeEdit
,
QLineEdit
,
QAbstractSpinBox
)
from
...common.style_sheet
import
setStyleSheet
from
...common.style_sheet
import
setStyleSheet
,
themeColor
from
...common.icon
import
FluentIconBase
,
Theme
,
getIconColor
from
...components.widgets
import
LineEditMenu
...
...
@@ -77,6 +77,24 @@ class Ui_SpinBox:
menu
=
LineEditMenu
(
self
.
lineEdit
())
menu
.
exec_
(
self
.
mapToGlobal
(
pos
))
def
_drawBorderBottom
(
self
):
if
not
self
.
hasFocus
():
return
painter
=
QPainter
(
self
)
painter
.
setRenderHints
(
QPainter
.
Antialiasing
)
painter
.
setPen
(
Qt
.
NoPen
)
path
=
QPainterPath
()
w
,
h
=
self
.
width
()
-
2
,
self
.
height
()
path
.
addRoundedRect
(
QRectF
(
1
,
h
-
12
,
w
,
12
),
6
,
6
)
rectPath
=
QPainterPath
()
rectPath
.
addRect
(
1
,
h
-
12
,
w
,
9.5
)
path
=
path
.
subtracted
(
rectPath
)
painter
.
fillPath
(
path
,
themeColor
())
class
SpinBox
(
QSpinBox
,
Ui_SpinBox
):
""" Spin box """
...
...
@@ -85,6 +103,10 @@ class SpinBox(QSpinBox, Ui_SpinBox):
super
().
__init__
(
parent
=
parent
)
self
.
_setUpUi
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
self
.
_drawBorderBottom
()
class
DoubleSpinBox
(
QDoubleSpinBox
,
Ui_SpinBox
):
""" Double spin box """
...
...
@@ -93,6 +115,10 @@ class DoubleSpinBox(QDoubleSpinBox, Ui_SpinBox):
super
().
__init__
(
parent
)
self
.
_setUpUi
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
self
.
_drawBorderBottom
()
class
TimeEdit
(
QTimeEdit
,
Ui_SpinBox
):
""" Time edit """
...
...
@@ -101,6 +127,10 @@ class TimeEdit(QTimeEdit, Ui_SpinBox):
super
().
__init__
(
parent
)
self
.
_setUpUi
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
self
.
_drawBorderBottom
()
class
DateTimeEdit
(
QDateTimeEdit
,
Ui_SpinBox
):
""" Date time edit """
...
...
@@ -109,6 +139,10 @@ class DateTimeEdit(QDateTimeEdit, Ui_SpinBox):
super
().
__init__
(
parent
)
self
.
_setUpUi
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
self
.
_drawBorderBottom
()
class
DateEdit
(
QDateEdit
,
Ui_SpinBox
):
""" Date edit """
...
...
@@ -117,3 +151,7 @@ class DateEdit(QDateEdit, Ui_SpinBox):
super
().
__init__
(
parent
)
self
.
_setUpUi
()
def
paintEvent
(
self
,
e
):
super
().
paintEvent
(
e
)
self
.
_drawBorderBottom
()
setup.py
浏览文件 @
35d14c98
...
...
@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools
.
setup
(
name
=
"PyQt-Fluent-Widgets"
,
version
=
"0.5.
2
"
,
version
=
"0.5.
3
"
,
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录