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

调整富文本框底部边框样式 (#252)

上级 d28ab871
......@@ -11,7 +11,7 @@ LineEdit, TextEdit, PlainTextEdit {
}
TextEdit, PlainTextEdit {
padding: 0px 0px 0px 10px;
padding: 2px 3px 2px 8px;
}
LineEdit:hover, TextEdit:hover, PlainTextEdit:hover {
......
......@@ -11,7 +11,7 @@ LineEdit, TextEdit, PlainTextEdit {
TextEdit,
PlainTextEdit {
padding: 0px 0px 0px 10px;
padding: 2px 3px 2px 8px;
}
LineEdit:hover, TextEdit:hover, PlainTextEdit:hover {
......
此差异已折叠。
......@@ -3,7 +3,7 @@ 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, QStyle)
QPlainTextEdit, QCompleter, QStyle, QWidget)
from ...common.style_sheet import FluentStyleSheet, themeColor
......@@ -287,11 +287,46 @@ class SearchLineEdit(LineEdit):
self.setTextMargins(0, 0, 28*enable+30, 0)
class EditLayer(QWidget):
""" Edit layer """
def __init__(self, parent):
super().__init__(parent=parent)
self.setAttribute(Qt.WA_TransparentForMouseEvents)
parent.installEventFilter(self)
def eventFilter(self, obj, e):
if obj is self.parent() and e.type() == QEvent.Resize:
self.resize(e.size())
return super().eventFilter(obj, e)
def paintEvent(self, e):
if not self.parent().hasFocus():
return
painter = QPainter(self)
painter.setRenderHints(QPainter.Antialiasing)
painter.setPen(Qt.NoPen)
m = self.contentsMargins()
path = QPainterPath()
w, h = self.width()-m.left()-m.right(), self.height()
path.addRoundedRect(QRectF(m.left(), h-10, w, 10), 5, 5)
rectPath = QPainterPath()
rectPath.addRect(m.left(), h-10, w, 7.5)
path = path.subtracted(rectPath)
painter.fillPath(path, themeColor())
class TextEdit(QTextEdit):
""" Text edit """
def __init__(self, parent=None):
super().__init__(parent=parent)
self.layer = EditLayer(self)
self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self)
setFont(self)
......@@ -306,6 +341,7 @@ class PlainTextEdit(QPlainTextEdit):
def __init__(self, parent=None):
super().__init__(parent=parent)
self.layer = EditLayer(self)
self.scrollDelegate = SmoothScrollDelegate(self)
FluentStyleSheet.LINE_EDIT.apply(self)
setFont(self)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册