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

添加输入框和复选框

上级 47da1c47
......@@ -9,7 +9,7 @@
project = 'PyQt-Fluent-Widgets'
copyright = '2023, zhiyiYo'
author = 'zhiyiYo'
release = 'v0.2.8'
release = 'v0.4.0'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
......
......@@ -3,6 +3,9 @@
### Acrylic Label
<img width="60%" src="./_static/gallery/acrylic_label.png"/>
### Check Box
![](./_static/gallery/check_box.gif)
### Combo Box
![](./_static/gallery/combo_box.gif)
......@@ -27,6 +30,9 @@
### Folder List Dialog
![](./_static/gallery/folder_list_dialog.gif)
### Slider
![](./_static/gallery/slider.gif)
### Hollow Handle Slider
![](./_static/gallery/hollow_handle_slider.gif)
......
......@@ -48,6 +48,7 @@ This document will show you all the features of PyQt-Fluent-Widgets and the best
quick-start
settings
theme
navigation
icon
gallery
......
......@@ -61,6 +61,7 @@ PyQt-Fluent-Widgets provides many kinds of setting card:
| :----------------------: | ------------------------------------------------------------ |
| `HyperlinkCard` | Setting card with a hyper link |
| `ColorSettingCard` | Setting card with a color picker |
| `CustomColorSettingCard` | Setting card with a button to choose color |
| `ComboBoxSettingCard` | Setting card with a combo box |
| `RangeSettingCard` | Setting card with a slider |
| `PushSettingCard` | Setting card with a naive push button |
......
## Theme
### Theme mode
You can use the `setTheme()` method to switch the light/dark theme of PyQt-Fluent-Widgets. The parameter of `setTheme()` accepts the following three values:
* `Theme.LIGHT`: Light theme
* `Theme.DARK`: Dark theme
* `Theme.AUTO`: Follow system theme. If the system theme cannot be detected, the light theme will be used.
When the theme changes, `qconfig` will emit the `themeChanged` signal.
### Theme color
You can use `setThemeColor()` method to change the theme color of PyQt-Fluent-Widgets. This method accepts the following three types of parameters:
* `QColor`
* `Qt.GlobalColor`
* `str`: Hex color strings or color names, such as `#0065d5` or `red`.
\ No newline at end of file
# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget
from qfluentwidgets import CheckBox
class Demo(QWidget):
def __init__(self):
super().__init__()
self.checkBox = CheckBox('This is a check box', self)
self.checkBox.setTristate(True)
self.checkBox.move(120, 180)
self.setStyleSheet('Demo{background:white}')
self.resize(400, 400)
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)
w = Demo()
w.show()
app.exec_()
\ No newline at end of file
# coding:utf-8
import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton
from qfluentwidgets import LineEdit
class Demo(QWidget):
def __init__(self):
super().__init__()
self.lineEdit = LineEdit('', self)
self.button=QPushButton('按钮', self)
self.resize(500, 500)
self.lineEdit.move(150, 220)
self.lineEdit.resize(200, 33)
self.lineEdit.setClearButtonEnabled(True)
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)
w = Demo()
w.show()
app.exec_()
\ No newline at end of file
......@@ -4,15 +4,15 @@ from PyQt5.QtCore import Qt
from PyQt5.QtGui import QColor
from PyQt5.QtWidgets import QApplication, QWidget, QSlider
from qfluentwidgets import HollowHandleStyle
from qfluentwidgets import HollowHandleStyle, Slider
class Demo(QWidget):
class Demo1(QWidget):
def __init__(self):
super().__init__()
self.resize(300, 150)
self.setStyleSheet("Demo{background: rgb(184, 106, 106)}")
self.setStyleSheet("Demo1{background: rgb(184, 106, 106)}")
# customize style
style = {
......@@ -26,14 +26,29 @@ class Demo(QWidget):
self.slider.move(50, 61)
class Demo2(QWidget):
def __init__(self):
super().__init__()
self.resize(300, 150)
self.slider = Slider(Qt.Horizontal, self)
self.slider.setFixedWidth(200)
self.slider.move(50, 61)
self.setStyleSheet('Demo2{background: white}')
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)
w = Demo()
w.show()
w1 = Demo1()
w1.show()
w2 = Demo2()
w2.show()
sys.exit(app.exec_())
......@@ -12,7 +12,7 @@ Examples are available at https://github.com/zhiyiYo/PyQt-Fluent-Widgets/tree/ma
:license: MIT, see LICENSE for more details.
"""
__version__ = "0.3.5"
__version__ = "0.4.0"
from .components import *
from .common import *
......
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="13" height="13" style="width:13px;height:13px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3500 3500" enable-background="new 0 0 2048 2048"
xml:space="preserve">
<path fill="#000000" transform="translate(700, 1000)" d="M0 768 q0 -34.67 25.34 -60 q25.34 -25.33 59.99 -25.33 q34.67 0 60 25.33 l537.34 536 l1220 -1218.67 q25.33 -25.33 60 -25.33 q34.66 0 59.99 25.34 q25.34 25.34 25.34 59.99 q0 34.67 -25.33 60 l-1280 1280 q-25.34 25.34 -60 25.34 q-34.67 0 -60 -25.34 l-597.34 -597.33 q-25.33 -25.33 -25.33 -60 Z"/>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="13" height="13" style="width:13px;height:13px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3500 3500" enable-background="new 0 0 2048 2048"
xml:space="preserve">
<path fill="#ffffff" transform="translate(700, 1000)" d="M0 768 q0 -34.67 25.34 -60 q25.34 -25.33 59.99 -25.33 q34.67 0 60 25.33 l537.34 536 l1220 -1218.67 q25.33 -25.33 60 -25.33 q34.66 0 59.99 25.34 q25.34 25.34 25.34 59.99 q0 34.67 -25.33 60 l-1280 1280 q-25.34 25.34 -60 25.34 q-34.67 0 -60 -25.34 l-597.34 -597.33 q-25.33 -25.33 -25.33 -60 Z"/>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="13" height="13" style="width:13px;height:13px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3500 3500" enable-background="new 0 0 2048 2048"
xml:space="preserve">
<path fill="#000000" transform="translate(670, 1650)" d="M78.77 157.54 q-32 0 -55.38 -23.38 q-23.39 -23.39 -23.39 -55.39 q0 -32 23.39 -55.38 q23.39 -23.39 55.38 -23.39 l1890.46 0 q32 0 55.38 23.39 q23.38 23.39 23.38 55.38 q0 32 -23.38 55.39 q-23.38 23.38 -55.38 23.38 l-1890.46 0 Z"/>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<svg id="" width="13" height="13" style="width:13px;height:13px;" version="1.1"
xmlns="http://www.w3.org/2000/svg" viewBox="0 0 3500 3500" enable-background="new 0 0 2048 2048"
xml:space="preserve">
<path fill="#ffffff" transform="translate(670, 1650)" d="M78.77 157.54 q-32 0 -55.38 -23.38 q-23.39 -23.39 -23.39 -55.39 q0 -32 23.39 -55.38 q23.39 -23.39 55.38 -23.39 l1890.46 0 q32 0 55.38 23.39 q23.38 23.39 23.38 55.38 q0 32 -23.38 55.39 q-23.38 23.38 -55.38 23.38 l-1890.46 0 Z"/>
</svg>
\ No newline at end of file
CheckBox {
color: white;
font: 14px 'Segoe UI', 'Microsoft YaHei';
spacing: 8px;
min-width: 28px;
min-height: 20px;
}
CheckBox::indicator {
width: 18px;
height: 18px;
border-radius: 5px;
border: 1px solid rgb(159, 159, 159);
background-color: rgb(42, 42, 42);
}
CheckBox::indicator:hover {
border: 1px solid rgb(161, 161, 161);
background-color: rgb(56, 56, 56);
}
CheckBox::indicator:pressed {
border: 1px solid rgb(86, 86, 86);
background-color: rgb(62, 62, 62);
}
CheckBox::indicator:checked,
CheckBox::indicator:indeterminate {
background-color: --ThemeColorPrimary;
border: 1px solid --ThemeColorPrimary;
}
CheckBox::indicator:checked {
image: url(:/qfluentwidgets/images/check_box/Accept_black.svg);
}
CheckBox::indicator:indeterminate {
image: url(:/qfluentwidgets/images/check_box/PartialAccept_black.svg);
}
CheckBox::indicator:checked:hover,
CheckBox::indicator:indeterminate:hover {
border: 1px solid --ThemeColorDark1;
background-color: --ThemeColorDark1;
}
CheckBox::indicator:checked:pressed,
CheckBox::indicator:indeterminate:pressed {
border: 1px solid --ThemeColorDark2;
background-color: --ThemeColorDark2;
}
CheckBox:disabled {
color: rgba(255, 255, 255, 110);
}
CheckBox::indicator:disabled {
border: 1px solid rgb(82, 82, 82);
background-color: rgb(45, 45, 45);
}
CheckBox::indicator:checked:disabled,
CheckBox::indicator:indeterminate:disabled {
border: 1px solid rgb(82, 82, 82);
background-color: rgb(82, 82, 82);
}
\ No newline at end of file
......@@ -86,41 +86,6 @@ QSlider::handle:horizontal:disabled {
}
/* Line Edit */
QLineEdit {
background-color: rgb(55, 55, 55);
border: 1px solid rgb(58, 58, 58);
border-bottom: 1px solid rgb(159, 159, 159);
border-radius: 6px;
font: 14px "Segoe UI";
padding: 0px 13px;
color: white;
selection-background-color: rgb(0, 183, 195);
}
QLineEdit:hover {
background-color: rgb(60, 60, 60);
}
QLineEdit:focus {
border-bottom: 1px solid rgb(41, 247, 255);
background-color: rgb(34, 34, 34);
}
#clearButton {
background-color: transparent;
border-radius: 4px;
margin: 0;
}
#clearButton:hover {
background-color: rgba(255, 255, 255, 9);
}
#clearButton:pressed {
background-color: rgba(255, 255, 255, 6);
}
/* 滚动条 */
QScrollBar {
......
QLineEdit {
background-color: rgb(55, 55, 55);
border: 1px solid rgb(58, 58, 58);
border-bottom: 1px solid rgb(159, 159, 159);
border-radius: 6px;
font: 14px "Segoe UI";
padding: 0px 13px;
color: white;
selection-background-color: --ThemeColorPrimary;
selection-color: black;
}
QLineEdit:hover {
background-color: rgb(60, 60, 60);
}
QLineEdit:!focus {
background-color: rgb(55, 55, 55);
border-bottom: 1px solid rgb(159, 159, 159);
}
QLineEdit:focus {
border-bottom: 1px solid --ThemeColorPrimary;
background-color: rgb(34, 34, 34);
}
QLineEdit:disabled {
color: rgba(255, 255, 255, 150);
background-color: rgb(59, 59, 59);
border: 1px solid rgb(73, 73, 73);
}
#clearButton {
background-color: transparent;
border-radius: 4px;
margin: 0;
}
#clearButton:hover {
background-color: rgba(255, 255, 255, 9);
}
#clearButton:pressed {
background-color: rgba(255, 255, 255, 6);
}
\ No newline at end of file
......@@ -18,53 +18,6 @@ QLabel#contentLabel {
padding: 0;
}
/* 滑动条 */
QSlider:horizontal {
min-width: 268px;
min-height: 22px;
}
QSlider::groove:horizontal {
height: 4px;
background-color: rgb(158, 159, 159);
border-radius: 2px;
}
QSlider::sub-page:horizontal {
background: --ThemeColorPrimary;
height: 4px;
border-radius: 2px;
}
QSlider::handle:horizontal {
border: 1px solid rgb(58, 58, 58);
width: 21px;
min-height: 22px;
margin: -9px 0;
border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
RangeSettingCard > QLabel#valueLabel{
color: rgb(159, 159, 159);
}
......
QSlider:horizontal {
min-width: 268px;
min-height: 22px;
}
QSlider::groove:horizontal {
height: 4px;
background-color: rgb(158, 159, 159);
border-radius: 2px;
}
QSlider::sub-page:horizontal {
background: --ThemeColorPrimary;
height: 4px;
border-radius: 2px;
}
QSlider::handle:horizontal {
border: 1px solid rgb(58, 58, 58);
width: 21px;
min-height: 22px;
margin: -9px 0;
border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(69, 69, 69),
stop:1 rgb(69, 69, 69));
}
CheckBox {
color: black;
font: 14px 'Segoe UI', 'Microsoft YaHei';
spacing: 8px;
min-width: 28px;
min-height: 20px;
}
CheckBox::indicator {
width: 18px;
height: 18px;
border-radius: 5px;
border: 1px solid rgb(135, 135, 135);
background-color: rgb(241, 241, 241);
}
CheckBox::indicator:hover {
border: 1px solid rgb(132, 132, 132);
background-color: rgb(232, 232, 232);
}
CheckBox::indicator:pressed {
border: 1px solid rgb(184, 184, 184);
background-color: rgb(224, 224, 224);
}
CheckBox::indicator:checked,
CheckBox::indicator:indeterminate {
border: 1px solid --ThemeColorPrimary;
background-color: --ThemeColorPrimary;
}
CheckBox::indicator:checked {
image: url(:/qfluentwidgets/images/check_box/Accept_white.svg);
}
CheckBox::indicator:indeterminate {
image: url(:/qfluentwidgets/images/check_box/PartialAccept_white.svg);
}
CheckBox::indicator:checked:hover,
CheckBox::indicator:indeterminate:hover {
border: 1px solid --ThemeColorLight1;
background-color: --ThemeColorLight1;
}
CheckBox::indicator:checked:pressed,
CheckBox::indicator:indeterminate:pressed {
border: 1px solid --ThemeColorLight3;
background-color: --ThemeColorLight3;
}
CheckBox:disabled {
color: rgba(0, 0, 0, 110);
}
CheckBox::indicator:disabled {
border: 1px solid #bbbbbb;
background-color: rgb(224, 224, 224);
}
CheckBox::indicator:checked:disabled,
CheckBox::indicator:indeterminate:disabled {
border: 1px solid rgb(199, 199, 199);
background-color: rgb(199, 199, 199);
}
\ No newline at end of file
......@@ -84,53 +84,6 @@ QSlider::handle:horizontal:disabled {
}
/* Line Edit */
QLineEdit {
color: black;
background-color: white;
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
border-radius: 6px;
font: 14px "Segoe UI";
padding: 0px 13px;
selection-background-color: rgb(0, 183, 195);
}
QLineEdit:hover {
background-color: rgb(252, 252, 252);
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
}
QLineEdit:focus {
border-bottom: 1px solid rgb(0, 159, 170);
background-color: white;
border-top: 1px solid rgba(0, 0, 0, 13);
border-left: 1px solid rgba(0, 0, 0, 13);
border-right: 1px solid rgba(0, 0, 0, 13);
}
QLineEdit:disabled {
color: rgba(0, 0, 0, 150);
background-color: rgba(0, 0, 0, 13);
border: 1px solid rgba(0, 0, 0, 5);
}
#clearButton {
background-color: transparent;
border-radius: 4px;
margin: 0;
}
#clearButton:hover {
background-color: rgba(0, 0, 0, 9);
}
#clearButton:pressed {
background-color: rgba(0, 0, 0, 6);
}
/* 滚动条 */
QScrollBar {
background: transparent;
......
QLineEdit {
color: black;
background-color: white;
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
border-radius: 6px;
font: 14px "Segoe UI";
padding: 0px 13px;
selection-background-color: --ThemeColorLight1;
}
QLineEdit:hover {
background-color: rgb(252, 252, 252);
border: 1px solid rgba(0, 0, 0, 13);
border-bottom: 1px solid rgba(0, 0, 0, 100);
}
QLineEdit:focus {
background-color: white;
border-bottom: 1px solid rgba(0, 0, 0, 100);
}
QLineEdit:focus {
border-bottom: 1px solid --ThemeColorPrimary;
background-color: white;
}
QLineEdit:disabled {
color: rgba(0, 0, 0, 150);
background-color: rgb(252, 252, 252);
border: 1px solid rgb(237, 237, 237);
}
#clearButton {
background-color: transparent;
border-radius: 4px;
margin: 0;
}
#clearButton:hover {
background-color: rgba(0, 0, 0, 9);
}
#clearButton:pressed {
background-color: rgba(0, 0, 0, 6);
}
\ No newline at end of file
......@@ -18,62 +18,6 @@ QLabel#contentLabel {
padding: 0;
}
/* 滑动条 */
QSlider:horizontal {
min-width: 268px;
min-height: 24px;
}
QSlider::groove:horizontal {
height: 4px;
background-color: rgba(0, 0, 0, 100);
border-radius: 2px;
}
QSlider::sub-page:horizontal {
background: --ThemeColorPrimary;
height: 4px;
border-radius: 2px;
}
QSlider::handle:horizontal {
border: 1px solid rgb(222, 222, 222);
width: 21px;
min-height: 24px;
margin: -9px 0;
border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::groove:horizontal:disabled {
background-color: rgba(0, 0, 0, 75);
}
QSlider::handle:horizontal:disabled {
background-color: #808080;
border: 5px solid #cccccc;
}
RangeSettingCard > QLabel#valueLabel{
color: rgb(96, 96, 96);
}
......
QSlider:horizontal {
min-height: 24px;
}
QSlider::groove:horizontal {
height: 4px;
background-color: rgba(0, 0, 0, 100);
border-radius: 2px;
}
QSlider::sub-page:horizontal {
background: --ThemeColorPrimary;
height: 4px;
border-radius: 2px;
}
QSlider::handle:horizontal {
border: 1px solid rgb(222, 222, 222);
width: 21px;
min-height: 24px;
margin: -9px 0;
border-radius: 11px;
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.5 --ThemeColorPrimary,
stop:0.6 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::handle:horizontal:hover {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.6 --ThemeColorPrimary,
stop:0.7 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::handle:horizontal:pressed {
background-color: qradialgradient(spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5,
stop:0 --ThemeColorPrimary,
stop:0.4 --ThemeColorPrimary,
stop:0.5 rgb(255, 255, 255),
stop:1 rgb(255, 255, 255));
}
QSlider::groove:horizontal:disabled {
background-color: rgba(0, 0, 0, 75);
}
QSlider::handle:horizontal:disabled {
background-color: #808080;
border: 5px solid #cccccc;
}
此差异已折叠。
......@@ -90,6 +90,10 @@
<file>images/folder_list_dialog/Close_black.png</file>
<file>images/folder_list_dialog/Add_black.png</file>
<file>images/folder_list_dialog/Add_white.png</file>
<file>images/check_box/Accept_black.svg</file>
<file>images/check_box/Accept_white.svg</file>
<file>images/check_box/PartialAccept_black.svg</file>
<file>images/check_box/PartialAccept_white.svg</file>
<file>qss/dark/color_dialog.qss</file>
<file>qss/dark/dialog.qss</file>
......@@ -105,6 +109,9 @@
<file>qss/dark/combo_box.qss</file>
<file>qss/dark/navigation_interface.qss</file>
<file>qss/dark/button.qss</file>
<file>qss/dark/slider.qss</file>
<file>qss/dark/line_edit.qss</file>
<file>qss/dark/check_box.qss</file>
<file>qss/light/color_dialog.qss</file>
<file>qss/light/dialog.qss</file>
......@@ -120,5 +127,8 @@
<file>qss/light/combo_box.qss</file>
<file>qss/light/navigation_interface.qss</file>
<file>qss/light/button.qss</file>
<file>qss/light/slider.qss</file>
<file>qss/light/line_edit.qss</file>
<file>qss/light/check_box.qss</file>
</qresource>
</RCC>
\ No newline at end of file
......@@ -2,12 +2,12 @@
from PyQt5.QtCore import Qt, pyqtSignal, QPoint, QRegExp, QSize
from PyQt5.QtGui import (QBrush, QColor, QPixmap,
QPainter, QPen, QIntValidator, QRegExpValidator, QIcon)
from PyQt5.QtWidgets import (QApplication, QLabel, QLineEdit, QWidget,
QToolButton, QFrame, QVBoxLayout)
from PyQt5.QtWidgets import QApplication, QLabel, QWidget, QToolButton, QFrame, QVBoxLayout
from ...common.icon import getIconColor
from ...common.style_sheet import setStyleSheet, getStyleSheet
from ..widgets import LineEditMenu, Slider, ScrollArea, PushButton, PrimaryPushButton
from ..widgets.line_edit import LineEdit
from .mask_dialog_base import MaskDialogBase
......@@ -129,7 +129,7 @@ class ColorCard(QWidget):
painter.drawRoundedRect(self.rect(), 4, 4)
class ColorLineEdit(QLineEdit):
class ColorLineEdit(LineEdit):
""" Color line edit """
valueChanged = pyqtSignal(str)
......@@ -137,30 +137,10 @@ class ColorLineEdit(QLineEdit):
def __init__(self, value, parent=None):
super().__init__(str(value), parent)
self.setFixedSize(136, 33)
self.clearButton = QToolButton(self)
self.clearButton.move(self.width() - 33, 4)
self.clearButton.setFixedSize(29, 25)
self.clearButton.setObjectName('clearButton')
self.clearButton.setIcon(
QIcon(f":/qfluentwidgets/images/color_dialog/Clear_{getIconColor()}.svg"))
self.clearButton.setIconSize(QSize(10, 10))
self.clearButton.setCursor(Qt.PointingHandCursor)
self.clearButton.hide()
self.setClearButtonEnabled(True)
self.setValidator(QIntValidator(0, 255, self))
self.setTextMargins(0, 0, 33, 0)
self.clearButton.clicked.connect(self.clear)
self.textEdited.connect(self._onTextEdited)
self.textChanged.connect(self._onTextChanged)
def focusOutEvent(self, e):
super().focusOutEvent(e)
self.clearButton.hide()
def focusInEvent(self, e):
super().focusInEvent(e)
self.clearButton.setVisible(bool(self.text()))
self.textEdited.connect(self._onTextEdited)
def _onTextEdited(self, text):
""" text edited slot """
......@@ -168,14 +148,6 @@ class ColorLineEdit(QLineEdit):
if state == QIntValidator.Acceptable:
self.valueChanged.emit(text)
def _onTextChanged(self, text):
""" text changed slot """
self.clearButton.setVisible(bool(text) and self.hasFocus())
def contextMenuEvent(self, e):
menu = LineEditMenu(self)
menu.exec_(e.globalPos())
class HexColorLineEdit(ColorLineEdit):
""" Hex color line edit """
......
......@@ -6,4 +6,6 @@ from .switch_button import SwitchButton, IndicatorPosition
from .state_tool_tip import StateToolTip, ToastToolTip
from .scroll_area import ScrollArea, SmoothMode, SmoothScrollArea, SmoothScrollBar
from .tool_tip import ToolTip, ToolTipFilter
from .button import PrimaryPushButton, PushButton
\ No newline at end of file
from .button import PrimaryPushButton, PushButton
from .line_edit import LineEdit
from .check_box import CheckBox
\ No newline at end of file
# coding: utf-8
from PyQt5.QtWidgets import QCheckBox
from ...common.style_sheet import setStyleSheet
class CheckBox(QCheckBox):
""" Check box """
def __init__(self, text: str, parent=None):
super().__init__(text, parent)
setStyleSheet(self, 'check_box')
# coding: utf-8
from PyQt5.QtCore import QSize, Qt
from PyQt5.QtWidgets import QLineEdit, QToolButton
from ...common.style_sheet import setStyleSheet
from ...common.icon import FluentIcon as FIF
from .menu import LineEditMenu
class LineEdit(QLineEdit):
""" Line edit """
def __init__(self, contents='', parent=None):
super().__init__(contents, parent)
self._isClearButtonEnabled = False
setStyleSheet(self, 'line_edit')
self.setFixedHeight(33)
self.clearButton = QToolButton(self)
self.setTextMargins(0, 0, 33, 0)
self.clearButton.setObjectName('clearButton')
self.clearButton.move(self.width() - 33, 4)
self.clearButton.setFixedSize(29, 25)
self.clearButton.hide()
self.clearButton.setIcon(FIF.CLOSE.icon())
self.clearButton.setIconSize(QSize(10, 10))
self.clearButton.setCursor(Qt.PointingHandCursor)
self.clearButton.clicked.connect(self.clear)
self.textChanged.connect(self.__onTextChanged)
def setClearButtonEnabled(self, enable: bool):
self._isClearButtonEnabled = enable
def isClearButtonEnabled(self) -> bool:
return self._isClearButtonEnabled
def focusOutEvent(self, e):
super().focusOutEvent(e)
self.clearButton.hide()
def focusInEvent(self, e):
super().focusInEvent(e)
if self.isClearButtonEnabled():
self.clearButton.setVisible(bool(self.text()))
def __onTextChanged(self, text):
""" text changed slot """
if self.isClearButtonEnabled():
self.clearButton.setVisible(bool(text) and self.hasFocus())
def contextMenuEvent(self, e):
menu = LineEditMenu(self)
menu.exec_(e.globalPos())
def resizeEvent(self, e):
self.clearButton.move(self.width() - 33, 4)
......@@ -613,31 +613,33 @@ class LineEditMenu(RoundMenu):
self.animation.setDuration(300)
self.animation.setEasingCurve(QEasingCurve.OutQuad)
self.setProperty("selectAll", bool(self.parent().text()))
self.selectionStart = parent.selectionStart()
self.selectionLength = parent.selectionLength()
def createActions(self):
self.cutAct = QAction(
FIF.icon(FIF.CUT),
FIF.CUT.icon(),
self.tr("Cut"),
self,
shortcut="Ctrl+X",
triggered=self.parent().cut,
)
self.copyAct = QAction(
FIF.icon(FIF.COPY),
FIF.COPY.icon(),
self.tr("Copy"),
self,
shortcut="Ctrl+C",
triggered=self.parent().copy,
)
self.pasteAct = QAction(
FIF.icon(FIF.PASTE),
FIF.PASTE.icon(),
self.tr("Paste"),
self,
shortcut="Ctrl+V",
triggered=self.parent().paste,
)
self.cancelAct = QAction(
FIF.icon(FIF.CANCEL),
FIF.CANCEL.icon(),
self.tr("Cancel"),
self,
shortcut="Ctrl+Z",
......@@ -652,6 +654,12 @@ class LineEditMenu(RoundMenu):
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)
super()._onItemClicked(item)
def exec(self, pos, ani=True):
self.clear()
self.createActions()
......
......@@ -4,6 +4,8 @@ from PyQt5.QtGui import QColor, QMouseEvent, QPainter, QPainterPath
from PyQt5.QtWidgets import (QProxyStyle, QSlider, QStyle, QStyleOptionSlider,
QWidget)
from ...common.style_sheet import setStyleSheet
class Slider(QSlider):
""" A slider can be clicked """
......@@ -12,6 +14,7 @@ class Slider(QSlider):
def __init__(self, orientation, parent=None):
super().__init__(orientation, parent=parent)
setStyleSheet(self, 'slider')
def mousePressEvent(self, e: QMouseEvent):
super().mousePressEvent(e)
......
......@@ -6,7 +6,7 @@ with open('README.md', encoding='utf-8') as f:
setuptools.setup(
name="PyQt-Fluent-Widgets",
version="0.3.5",
version="0.4.0",
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.
先完成此消息的编辑!
想要评论请 注册