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

调整补全菜单的选中样式

上级 a02ea848
......@@ -4,215 +4,250 @@
<context>
<name>BasicInputInterface</name>
<message>
<location filename="../../view/basic_input_interface.py" line="25"/>
<location filename="../../view/basic_input_interface.py" line="27"/>
<source>A simple button with text content</source>
<translation>带有文本的简单按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="35"/>
<location filename="../../view/basic_input_interface.py" line="37"/>
<source>A button with graphical content</source>
<translation>带有图标的按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="56"/>
<location filename="../../view/basic_input_interface.py" line="170"/>
<source>A hyperlink button that navigates to a URI</source>
<translation>导航到一个超链接的按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="63"/>
<location filename="../../view/basic_input_interface.py" line="72"/>
<source>A 2-state CheckBox</source>
<translation>双态复选框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="72"/>
<location filename="../../view/basic_input_interface.py" line="81"/>
<source>A 3-state CheckBox</source>
<translation>三态复选框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="83"/>
<location filename="../../view/basic_input_interface.py" line="92"/>
<source>A ComboBox with items</source>
<translation>下拉框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="158"/>
<location filename="../../view/basic_input_interface.py" line="192"/>
<source>A group of RadioButton controls in a button group</source>
<translation>单选按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="169"/>
<location filename="../../view/basic_input_interface.py" line="203"/>
<source>A simple horizontal slider</source>
<translation>水平滑动条</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="220"/>
<location filename="../../view/basic_input_interface.py" line="254"/>
<source>A simple switch button</source>
<translation>开关按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="237"/>
<location filename="../../view/basic_input_interface.py" line="293"/>
<source>Off</source>
<translation></translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="235"/>
<location filename="../../view/basic_input_interface.py" line="291"/>
<source>On</source>
<translation></translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="25"/>
<location filename="../../view/basic_input_interface.py" line="58"/>
<source>Standard push button</source>
<translation>标准按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="42"/>
<location filename="../../view/basic_input_interface.py" line="44"/>
<source>Accent style button</source>
<translation>主题色按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="63"/>
<location filename="../../view/basic_input_interface.py" line="72"/>
<source>Two-state CheckBox</source>
<translation>双态复选框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="70"/>
<location filename="../../view/basic_input_interface.py" line="79"/>
<source>Three-state CheckBox</source>
<translation>三态复选框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="56"/>
<location filename="../../view/basic_input_interface.py" line="170"/>
<source>GitHub home page</source>
<translation>GItHub 主页</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="241"/>
<location filename="../../view/basic_input_interface.py" line="297"/>
<source>Star Platinum</source>
<translation>白金之星</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="241"/>
<location filename="../../view/basic_input_interface.py" line="297"/>
<source>Crazy Diamond</source>
<translation>疯狂钻石</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="149"/>
<location filename="../../view/basic_input_interface.py" line="183"/>
<source>Soft and Wet</source>
<translation>软又湿</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="241"/>
<location filename="../../view/basic_input_interface.py" line="297"/>
<source>Gold Experience</source>
<translation>黄金体验</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="241"/>
<location filename="../../view/basic_input_interface.py" line="297"/>
<source>Sticky Fingers</source>
<translation>钢链手指</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="201"/>
<location filename="../../view/basic_input_interface.py" line="235"/>
<source>Choose your stand</source>
<translation>选择你的替身</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="99"/>
<location filename="../../view/basic_input_interface.py" line="108"/>
<source>An editable ComboBox</source>
<translation>可编辑的下拉框</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="107"/>
<location filename="../../view/basic_input_interface.py" line="116"/>
<source>Send</source>
<translation>发送</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="108"/>
<location filename="../../view/basic_input_interface.py" line="117"/>
<source>Save</source>
<translation>保存</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="126"/>
<location filename="../../view/basic_input_interface.py" line="152"/>
<source>Email</source>
<translation>邮件</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="111"/>
<location filename="../../view/basic_input_interface.py" line="120"/>
<source>A push button with drop down menu</source>
<translation>带下拉菜单的按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="119"/>
<location filename="../../view/basic_input_interface.py" line="128"/>
<source>A tool button with drop down menu</source>
<translation>带下拉菜单的工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="227"/>
<source>A simple ToggleButton with text content</source>
<translation>带文本的状态开关按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="227"/>
<location filename="../../view/basic_input_interface.py" line="275"/>
<source>Start practicing</source>
<translation>开始练习</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="178"/>
<location filename="../../view/basic_input_interface.py" line="212"/>
<source>A split push button with drop down menu</source>
<translation>带下拉菜单的拆分按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="185"/>
<location filename="../../view/basic_input_interface.py" line="219"/>
<source>Sing</source>
<translation></translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="185"/>
<location filename="../../view/basic_input_interface.py" line="219"/>
<source>Jump</source>
<translation></translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="185"/>
<location filename="../../view/basic_input_interface.py" line="219"/>
<source>Rap</source>
<translation>Rap</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="185"/>
<location filename="../../view/basic_input_interface.py" line="219"/>
<source>Music</source>
<translation>Music</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="194"/>
<location filename="../../view/basic_input_interface.py" line="228"/>
<source>A split tool button with drop down menu</source>
<translation>带下拉菜单的工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="42"/>
<location filename="../../view/basic_input_interface.py" line="44"/>
<source>Accent style applied to push button</source>
<translation>主题色按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="49"/>
<location filename="../../view/basic_input_interface.py" line="51"/>
<source>Accent style applied to tool button</source>
<translation>主题色工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="128"/>
<location filename="../../view/basic_input_interface.py" line="137"/>
<source>A primary color push button with drop down menu</source>
<translation>带下拉菜单的主题色按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="136"/>
<location filename="../../view/basic_input_interface.py" line="145"/>
<source>A primary color tool button with drop down menu</source>
<translation>带下拉菜单的主题色工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="203"/>
<location filename="../../view/basic_input_interface.py" line="237"/>
<source>A primary color split push button with drop down menu</source>
<translation>带下拉菜单的主题色拆分按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="211"/>
<location filename="../../view/basic_input_interface.py" line="245"/>
<source>A primary color split tool button with drop down menu</source>
<translation>带下拉菜单的主题色拆分工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="58"/>
<source>A transparent push button</source>
<translation>透明按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="65"/>
<source>A transparent tool button</source>
<translation>透明工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="154"/>
<source>A transparent push button with drop down menu</source>
<translation>带下拉菜单的透明按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="163"/>
<source>A transparent tool button with drop down menu</source>
<translation>带下拉菜单的透明工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="261"/>
<source>A simple toggle push button</source>
<translation>状态开关按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="268"/>
<source>A simple toggle tool button</source>
<translation>状态开关工具按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="275"/>
<source>A transparent toggle push button</source>
<translation>透明的状态开关按钮</translation>
</message>
<message>
<location filename="../../view/basic_input_interface.py" line="282"/>
<source>A transparent toggle tool button</source>
<translation>透明的状态开关工具按钮</translation>
</message>
</context>
<context>
<name>DateTimeInterface</name>
......
......@@ -4,7 +4,9 @@ from PyQt5.QtWidgets import QAction, QWidget, QVBoxLayout, QButtonGroup
from qfluentwidgets import (Action, DropDownPushButton, DropDownToolButton, PushButton, ToolButton, PrimaryPushButton,
HyperlinkButton, ComboBox, RadioButton, CheckBox, Slider, SwitchButton, EditableComboBox,
ToggleButton, RoundMenu, FluentIcon, SplitPushButton, SplitToolButton, PrimarySplitToolButton,
PrimarySplitPushButton, PrimaryDropDownPushButton, PrimaryToolButton, PrimaryDropDownToolButton)
PrimarySplitPushButton, PrimaryDropDownPushButton, PrimaryToolButton, PrimaryDropDownToolButton,
ToggleToolButton, TransparentDropDownPushButton, TransparentPushButton, TransparentToggleToolButton,
TransparentTogglePushButton, TransparentDropDownToolButton, TransparentToolButton)
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -52,10 +54,17 @@ class BasicInputInterface(GalleryInterface):
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# hyperlink button
# transparent push button
self.addExampleCard(
self.tr('A hyperlink button that navigates to a URI'),
HyperlinkButton('http://github.com', self.tr('GitHub home page')),
self.tr('A transparent push button'),
TransparentPushButton(self.tr('Standard push button'), self, FluentIcon.BOOK_SHELF),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent tool button
self.addExampleCard(
self.tr('A transparent tool button'),
TransparentToolButton(FluentIcon.BOOK_SHELF, self),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
......@@ -139,6 +148,31 @@ class BasicInputInterface(GalleryInterface):
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent drop down button
button = TransparentDropDownPushButton(self.tr('Email'), self, FluentIcon.MAIL)
button.setMenu(menu)
self.addExampleCard(
self.tr('A transparent push button with drop down menu'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent drop down tool button
button = TransparentDropDownToolButton(FluentIcon.MAIL, self)
button.setMenu(menu)
self.addExampleCard(
self.tr('A transparent tool button with drop down menu'),
button,
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# hyperlink button
self.addExampleCard(
self.tr('A hyperlink button that navigates to a URI'),
HyperlinkButton('http://github.com', self.tr('GitHub home page')),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# radio button
radioWidget = QWidget()
radioLayout = QVBoxLayout(radioWidget)
......@@ -225,11 +259,33 @@ class BasicInputInterface(GalleryInterface):
# toggle button
self.addExampleCard(
self.tr('A simple ToggleButton with text content'),
self.tr('A simple toggle push button'),
ToggleButton(self.tr('Start practicing'), self, FluentIcon.BASKETBALL),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# toggle tool button
self.addExampleCard(
self.tr('A simple toggle tool button'),
ToggleToolButton(FluentIcon.BASKETBALL, self),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent toggle button
self.addExampleCard(
self.tr('A transparent toggle push button'),
TransparentTogglePushButton(self.tr('Start practicing'), self, FluentIcon.BASKETBALL),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
# transparent toggle tool button
self.addExampleCard(
self.tr('A transparent toggle tool button'),
TransparentToggleToolButton(FluentIcon.BASKETBALL, self),
'https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/button/demo.py'
)
def onSwitchCheckedChanged(self, isChecked):
if isChecked:
self.switchButton.setText(self.tr('On'))
......
......@@ -132,7 +132,7 @@ class HomeInterface(ScrollArea):
title="CheckBox",
content=self.tr("A control that a user can select or clear."),
routeKey="basicInputInterface",
index=5
index=7
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/ComboBox.png",
......@@ -140,7 +140,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A drop-down list of items a user can select from."),
routeKey="basicInputInterface",
index=7
index=9
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/DropDownButton.png",
......@@ -148,7 +148,15 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A button that displays a flyout of choices when clicked."),
routeKey="basicInputInterface",
index=9
index=11
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/HyperlinkButton.png",
title="HyperlinkButton",
content=self.tr(
"A button that appears as hyperlink text, and can navigate to a URI or handle a Click event."),
routeKey="basicInputInterface",
index=16
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/RadioButton.png",
......@@ -156,7 +164,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A control that allows a user to select a single option from a group of options."),
routeKey="basicInputInterface",
index=13
index=17
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/Slider.png",
......@@ -164,7 +172,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A control that lets the user select from a range of values by moving a Thumb control along a track."),
routeKey="basicInputInterface",
index=14
index=18
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/SplitButton.png",
......@@ -172,7 +180,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A two-part button that displays a flyout when its secondary part is clicked."),
routeKey="basicInputInterface",
index=15
index=19
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/ToggleSwitch.png",
......@@ -180,7 +188,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A switch that can be toggled between 2 states."),
routeKey="basicInputInterface",
index=19
index=23
)
basicInputView.addSampleCard(
icon=":/gallery/images/controls/ToggleButton.png",
......@@ -188,7 +196,7 @@ class HomeInterface(ScrollArea):
content=self.tr(
"A button that can be switched between two states like a CheckBox."),
routeKey="basicInputInterface",
index=20
index=24
)
self.vBoxLayout.addWidget(basicInputView)
......
......@@ -39,7 +39,7 @@ class PivotInterface(QWidget):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.setFixedSize(300, 200)
self.setFixedSize(300, 140)
self.pivot = self.Nav(self)
self.stackedWidget = QStackedWidget(self)
......@@ -54,7 +54,7 @@ class PivotInterface(QWidget):
self.addSubInterface(self.albumInterface, 'albumInterface', self.tr('Album'))
self.addSubInterface(self.artistInterface, 'artistInterface', self.tr('Artist'))
self.vBoxLayout.addWidget(self.pivot, 0)
self.vBoxLayout.addWidget(self.pivot, 0, Qt.AlignLeft)
self.vBoxLayout.addWidget(self.stackedWidget)
self.vBoxLayout.setContentsMargins(0, 0, 0, 0)
StyleSheet.NAVIGATION_VIEW_INTERFACE.apply(self)
......
# coding:utf-8
from qfluentwidgets import LineEdit, SpinBox, DoubleSpinBox, TimeEdit, DateTimeEdit, DateEdit, TextEdit
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QCompleter
from qfluentwidgets import LineEdit, SpinBox, DoubleSpinBox, TimeEdit, DateTimeEdit, DateEdit, TextEdit, SearchLineEdit
from .gallery_interface import GalleryInterface
from ..common.translator import Translator
......@@ -16,7 +18,7 @@ class TextInterface(GalleryInterface):
parent=parent
)
# spin box
# line edit
lineEdit = LineEdit(self)
lineEdit.setText(self.tr('ko no dio da!'))
lineEdit.setClearButtonEnabled(True)
......@@ -26,6 +28,41 @@ class TextInterface(GalleryInterface):
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py'
)
# line edit with completer
lineEdit = SearchLineEdit(self)
lineEdit.setPlaceholderText('Type a stand name')
lineEdit.setClearButtonEnabled(True)
lineEdit.setFixedWidth(230)
stands = [
"Star Platinum", "Hierophant Green",
"Made in Haven", "King Crimson",
"Silver Chariot", "Crazy diamond",
"Metallica", "Another One Bites The Dust",
"Heaven's Door", "Killer Queen",
"The Grateful Dead", "Stone Free",
"The World", "Sticky Fingers",
"Ozone Baby", "Love Love Deluxe",
"Hermit Purple", "Gold Experience",
"King Nothing", "Paper Moon King",
"Scary Monster", "Mandom",
"20th Century Boy", "Tusk Act 4",
"Ball Breaker", "Sex Pistols",
"D4C • Love Train", "Born This Way",
"SOFT & WET", "Paisley Park",
"Wonder of U", "Walking Heart",
"Cream Starter", "November Rain",
"Smooth Operators", "The Matte Kudasai"
]
completer = QCompleter(stands, lineEdit)
completer.setCaseSensitivity(Qt.CaseInsensitive)
lineEdit.setCompleter(completer)
self.addExampleCard(
title=self.tr("A autosuggest line edit"),
widget=lineEdit,
sourcePath='https://github.com/zhiyiYo/PyQt-Fluent-Widgets/blob/master/examples/line_edit/demo.py'
)
# spin box
self.addExampleCard(
title=self.tr("A SpinBox with a spin button"),
......
......@@ -223,16 +223,21 @@ RadioButton::indicator:disabled:checked {
TransparentToolButton,
TransparentToggleToolButton,
TransparentDropDownToolButton,
TransparentPushButton,
TransparentDropDownPushButton,
TransparentTogglePushButton {
background-color: transparent;
border: none;
border-radius: 4px;
margin: 0;
}
TransparentToolButton:hover,
TransparentToggleToolButton:hover,
TransparentDropDownToolButton:hover,
TransparentPushButton:hover,
TransparentDropDownPushButton:hover,
TransparentTogglePushButton:hover {
background-color: rgba(255, 255, 255, 9);
border: none;
......@@ -240,7 +245,9 @@ TransparentTogglePushButton:hover {
TransparentToolButton:pressed,
TransparentToggleToolButton:pressed,
TransparentDropDownToolButton:pressed,
TransparentPushButton:pressed,
TransparentDropDownPushButton:pressed,
TransparentTogglePushButton:pressed {
background-color: rgba(255, 255, 255, 6);
border: none;
......@@ -248,7 +255,9 @@ TransparentTogglePushButton:pressed {
TransparentToolButton:disabled,
TransparentToggleToolButton:disabled,
TransparentDropDownToolButton:disabled,
TransprentPushButton:disabled,
TransparentDropDownPushButton:disabled,
TransprentTogglePushButton:disabled {
background-color: transparent;
border: none;
......
......@@ -25,43 +25,3 @@ ComboBox:disabled {
border: 1px solid rgba(255, 255, 255, 0.053);
border-top: 1px solid rgba(255, 255, 255, 0.053);
}
ComboBoxMenu>MenuActionListWidget {
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 9px;
background-color: rgb(43, 43, 43);
outline: none;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
ComboBoxMenu>MenuActionListWidget::item {
margin-top: 4px;
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
color: white;
}
ComboBoxMenu>MenuActionListWidget::disbled {
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
color: white;
}
ComboBoxMenu>MenuActionListWidget::item:hover {
background-color: rgba(255, 255, 255, 0.08);
}
ComboBoxMenu>MenuActionListWidget::item:selected {
background-color: rgba(255, 255, 255, 0.08);
color: white;
}
ComboBoxMenu>MenuActionListWidget::item:selected:active {
background-color: rgba(255, 255, 255, 0.06);
color: rgba(255, 255, 255, 0.7);
}
\ No newline at end of file
......@@ -50,8 +50,6 @@ MenuActionListWidget::item {
border-radius: 5px;
border: none;
color: white;
margin-left: 6px;
margin-right: 6px;
}
MenuActionListWidget::item:disabled {
......@@ -86,10 +84,7 @@ MenuActionListWidget::item:selected:active {
border-bottom-right-radius: 0px;
}
#completerListWidget::item {
#completerListWidget::item,
#comboListWidget::item {
margin-top: 4px;
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
}
\ No newline at end of file
......@@ -25,43 +25,3 @@ ComboBox:disabled {
border: 1px solid rgba(0, 0, 0, 0.06);
border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
ComboBoxMenu>MenuActionListWidget {
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 9px;
background-color: rgb(249, 249, 249);
outline: none;
font: 14px 'Segoe UI', 'Microsoft YaHei';
}
ComboBoxMenu>MenuActionListWidget::item {
margin-top: 4px;
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
color: black;
}
ComboBoxMenu>MenuActionListWidget::item:disabled {
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
color: black;
}
ComboBoxMenu>MenuActionListWidget::item:hover {
background-color: rgba(0, 0, 0, 9);
}
ComboBoxMenu>MenuActionListWidget::item:selected {
background-color: rgba(0, 0, 0, 7);
color: black;
}
ComboBoxMenu>MenuActionListWidget::item:selected:active {
background-color: rgba(0, 0, 0, 0.06);
color: rgba(0, 0, 0, 0.7);
}
\ No newline at end of file
......@@ -47,8 +47,6 @@ MenuActionListWidget::item {
padding-right: 10px;
border-radius: 5px;
border: none;
margin-left: 6px;
margin-right: 6px;
color: black;
}
......@@ -83,10 +81,7 @@ MenuActionListWidget::item:selected:active {
border-bottom-right-radius: 0px;
}
#completerListWidget::item {
#completerListWidget::item,
#comboListWidget::item {
margin-top: 4px;
padding-left: 10px;
padding-right: 10px;
border-radius: 5px;
border: none;
}
\ No newline at end of file
此差异已折叠。
......@@ -164,7 +164,7 @@ class Pivot(QWidget):
widget.itemClicked.connect(onClick)
self.items[routeKey] = widget
self.hBoxLayout.insertWidget(index, widget, 0, Qt.AlignLeft)
self.hBoxLayout.insertWidget(index, widget, 1)
def removeWidget(self, routeKey: str):
""" remove widget
......
......@@ -50,15 +50,3 @@ class SegmentedWidget(Pivot):
self.insertWidget(index, routeKey, item, onClick)
return item
def insertWidget(self, index: int, routeKey: str, widget: PivotItem, onClick=None):
if routeKey in self.items:
return
widget.setProperty('routeKey', routeKey)
widget.itemClicked.connect(self._onItemClicked)
if onClick:
widget.itemClicked.connect(onClick)
self.items[routeKey] = widget
self.hBoxLayout.insertWidget(index, widget, 1)
......@@ -11,7 +11,8 @@ from .icon_widget import IconWidget
from .label import (PixmapLabel, CaptionLabel, StrongBodyLabel, BodyLabel, SubtitleLabel, TitleLabel,
LargeTitleLabel, DisplayLabel, FluentLabelBase)
from .list_view import ListWidget, ListView, ListItemDelegate
from .menu import DWMMenu, LineEditMenu, RoundMenu, MenuAnimationManager, MenuAnimationType
from .menu import (DWMMenu, LineEditMenu, RoundMenu, MenuAnimationManager, MenuAnimationType, IndicatorMenuItemDelegate,
MenuItemDelegate)
from .info_bar import InfoBar, InfoBarIcon, InfoBarPosition
from .scroll_area import SingleDirectionScrollArea, SmoothMode, SmoothScrollArea, ScrollArea
from .slider import Slider, HollowHandleStyle
......
......@@ -5,12 +5,12 @@ from PyQt5.QtCore import Qt, pyqtSignal, QRectF, QPoint, QObject, QEvent
from PyQt5.QtGui import QPainter, QCursor, QIcon
from PyQt5.QtWidgets import QAction, QPushButton, QStyledItemDelegate, QStyle
from .menu import RoundMenu, MenuItemDelegate, MenuAnimationType
from .menu import RoundMenu, MenuAnimationType, IndicatorMenuItemDelegate
from .line_edit import LineEdit, LineEditButton
from ...common.animation import TranslateYAnimation
from ...common.icon import FluentIconBase, isDarkTheme
from ...common.icon import FluentIcon as FIF
from ...common.style_sheet import FluentStyleSheet, themeColor
from ...common.style_sheet import FluentStyleSheet
class ComboItem:
......@@ -412,24 +412,6 @@ class EditableComboBox(LineEdit, ComboBoxBase):
self.dropMenu = None
class ComboMenuItemDelegate(MenuItemDelegate):
""" Combo box drop menu item delegate """
def paint(self, painter: QPainter, option, index):
super().paint(painter, option, index)
if not option.state & QStyle.State_Selected:
return
painter.save()
painter.setRenderHints(
QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing)
painter.setPen(Qt.NoPen)
painter.setBrush(themeColor())
painter.drawRoundedRect(0, 11+option.rect.y(), 3, 15, 1.5, 1.5)
painter.restore()
class ComboBoxMenu(RoundMenu):
""" Combo box menu """
......@@ -439,9 +421,9 @@ class ComboBoxMenu(RoundMenu):
self.view.setViewportMargins(5, 2, 5, 6)
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.view.setItemDelegate(ComboMenuItemDelegate())
self.view.setItemDelegate(IndicatorMenuItemDelegate())
self.view.setObjectName('comboListWidget')
FluentStyleSheet.COMBO_BOX.apply(self)
self.setItemHeight(33)
def exec(self, pos, ani=True, aniType=MenuAnimationType.DROP_DOWN):
......
......@@ -3,14 +3,14 @@ from typing import List, Union
from PyQt5.QtCore import QSize, Qt, QRectF, pyqtSignal, QPoint, QTimer, QEvent, QAbstractItemModel
from PyQt5.QtGui import QPainter, QPainterPath, QIcon, QCursor
from PyQt5.QtWidgets import (QApplication, QAction, QHBoxLayout, QLineEdit, QToolButton, QTextEdit,
QPlainTextEdit, QCompleter)
QPlainTextEdit, QCompleter, QStyle)
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, RoundMenu, MenuAnimationType, MenuActionListWidget
from .menu import LineEditMenu, TextEditMenu, RoundMenu, MenuAnimationType, IndicatorMenuItemDelegate
from .scroll_bar import SmoothScrollDelegate
......@@ -164,17 +164,19 @@ class LineEdit(QLineEdit):
class CompleterMenu(RoundMenu):
""" Completer menu """
def __init__(self, lineEdit: LineEditMenu):
def __init__(self, lineEdit: LineEdit):
super().__init__()
self.items = []
self.lineEdit = lineEdit
self.installEventFilter(self)
self.view.setViewportMargins(0, 2, 0, 6)
self.setItemHeight(33)
self.view.setViewportMargins(6, 2, 6, 6)
self.view.setObjectName('completerListWidget')
self.view.setItemDelegate(IndicatorMenuItemDelegate())
self.view.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.installEventFilter(self)
self.setItemHeight(33)
def setCompletion(self, model: QAbstractItemModel):
""" set the completion model """
items = []
......@@ -195,10 +197,18 @@ class CompleterMenu(RoundMenu):
return True
def eventFilter(self, obj, e: QEvent):
if e.type() == QEvent.KeyPress:
self.lineEdit.event(e)
if e.key() == Qt.Key_Escape:
self.close()
if e.type() != QEvent.KeyPress:
return super().eventFilter(obj, e)
# redirect input to line edit
self.lineEdit.event(e)
self.view.event(e)
if e.key() == Qt.Key_Escape:
self.close()
if e.key() in [Qt.Key_Enter, Qt.Key_Return] and self.view.currentRow() >= 0:
self.lineEdit.setText(self.view.currentItem().text())
self.close()
return super().eventFilter(obj, e)
......
......@@ -12,7 +12,7 @@ from PyQt5.QtWidgets import (QAction, QApplication, QMenu, QProxyStyle, QStyle,
from ...common.icon import FluentIcon as FIF
from ...common.icon import MenuIconEngine, Action, FluentIconBase, Icon
from ...common.style_sheet import FluentStyleSheet
from ...common.style_sheet import FluentStyleSheet, themeColor
from ...common.config import isDarkTheme
from .scroll_bar import SmoothScrollDelegate
......@@ -126,7 +126,7 @@ class MenuActionListWidget(QListWidget):
def __init__(self, parent=None):
super().__init__(parent)
self.setViewportMargins(0, 6, 0, 6)
self.setViewportMargins(6, 6, 6, 6)
self.setTextElideMode(Qt.ElideNone)
self.setDragEnabled(False)
self.setMouseTracking(True)
......@@ -944,3 +944,22 @@ class TextEditMenu(EditMenu):
QTextCursor.Right, QTextCursor.KeepAnchor, self.selectionLength)
super()._onItemClicked(item)
class IndicatorMenuItemDelegate(MenuItemDelegate):
""" Menu item delegate with indicator """
def paint(self, painter: QPainter, option, index):
super().paint(painter, option, index)
if not option.state & QStyle.State_Selected:
return
painter.save()
painter.setRenderHints(
QPainter.Antialiasing | QPainter.SmoothPixmapTransform | QPainter.TextAntialiasing)
painter.setPen(Qt.NoPen)
painter.setBrush(themeColor())
painter.drawRoundedRect(0, 11+option.rect.y(), 3, 15, 1.5, 1.5)
painter.restore()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册