diff --git a/dstyleplugin/brushschemes/ddark.css b/dstyleplugin/brushschemes/ddark.css index 24b6040b..4dac9326 100644 --- a/dstyleplugin/brushschemes/ddark.css +++ b/dstyleplugin/brushschemes/ddark.css @@ -106,6 +106,7 @@ PushButton:flat:hover { LineEdit { BackgroundBrush: rgba(255,255,255,0.15); BorderBrush: transparent; + AlertBorderBrush: "#FF8F00"; } LineEdit:disabled { diff --git a/dstyleplugin/brushschemes/dlight.css b/dstyleplugin/brushschemes/dlight.css index 6331098d..982b5381 100644 --- a/dstyleplugin/brushschemes/dlight.css +++ b/dstyleplugin/brushschemes/dlight.css @@ -111,6 +111,7 @@ PushButton:flat:pressed { LineEdit { BackgroundBrush: rgb(255,255,255); BorderBrush: rgba(0,0,0,0.1); + AlertBorderBrush: "#FF8F00"; } LineEdit:disabled { diff --git a/dstyleplugin/brushschemes/dsemidark.css b/dstyleplugin/brushschemes/dsemidark.css index f914ec39..c98432da 100644 --- a/dstyleplugin/brushschemes/dsemidark.css +++ b/dstyleplugin/brushschemes/dsemidark.css @@ -106,6 +106,7 @@ PushButton:flat:hover { LineEdit { BackgroundBrush: rgba(255,255,255,0.15); BorderBrush: transparent; + AlertBorderBrush: "#FF8F00"; } LineEdit:disabled { diff --git a/dstyleplugin/brushschemes/dsemilight.css b/dstyleplugin/brushschemes/dsemilight.css index a623cc1c..4a08301b 100644 --- a/dstyleplugin/brushschemes/dsemilight.css +++ b/dstyleplugin/brushschemes/dsemilight.css @@ -111,6 +111,7 @@ PushButton:flat:pressed { LineEdit { BackgroundBrush: rgb(255,255,255); BorderBrush: rgba(0,0,0,0.1); + AlertBorderBrush: "#FF8F00"; } LineEdit:disabled { diff --git a/dstyleplugin/commonhelper.cpp b/dstyleplugin/commonhelper.cpp index 032f7693..9b265f0f 100644 --- a/dstyleplugin/commonhelper.cpp +++ b/dstyleplugin/commonhelper.cpp @@ -45,7 +45,7 @@ void CommonHelper::renderFrame(QPainter *painter, const QRect &rect, const QBrus painter->setBrush( brush ); // render - painter->drawRoundedRect( frameRect, radius, radius ); + painter->drawRoundedRect( frameRect.adjusted(0.5, 0.5, -0.5, -0.5), radius, radius ); } Style *CommonHelper::widgetStyle(const QWidget *widget) diff --git a/dstyleplugin/lineedithelper.cpp b/dstyleplugin/lineedithelper.cpp index 053a8493..3a00bc96 100644 --- a/dstyleplugin/lineedithelper.cpp +++ b/dstyleplugin/lineedithelper.cpp @@ -20,6 +20,15 @@ #include "style.h" #include "paletteextended.h" +#include +#ifdef DTKWIDGET_CLASS_DStyleOptionLineEdit +#include +#include + +DWIDGET_USE_NAMESPACE +#endif + + namespace dstyle { bool Style::drawFrameLineEditPrimitive(const QStyleOption *option, QPainter *painter, const QWidget *widget) const @@ -30,8 +39,29 @@ bool Style::drawFrameLineEditPrimitive(const QStyleOption *option, QPainter *pai // render const QBrush background(m_palette->brush(PaletteExtended::LineEdit_BackgroundBrush, option) ); - const QBrush outline(m_palette->brush(PaletteExtended::LineEdit_BorderBrush, option) ); - CommonHelper::renderFrame( painter, rect, background, outline ); + QBrush outline(m_palette->brush(PaletteExtended::LineEdit_BorderBrush, option) ); + +#ifdef DTKWIDGET_CLASS_DLineEdit + if (const DLineEdit *edit = qobject_cast(widget)) { + DStyleOptionLineEdit edit_option; + edit_option.init(const_cast(edit)); + + if (edit_option.features.testFlag(DStyleOptionLineEdit::Alert)) + outline = m_palette->brush(PaletteExtended::LineEdit_AlertBorderBrush, option, PaletteExtended::PseudoClass_Unknown, outline); + + CommonHelper::renderFrame( painter, rect, background, outline ); + + if (edit_option.features.testFlag(DStyleOptionLineEdit::IconButton)) { + painter->save(); + painter->setPen(QPen(outline, Metrics::Painter_PenWidth)); + painter->drawLine(QPointF(edit_option.iconButtonRect.topLeft()) - QPointF(0.5, 0), QPointF(edit_option.iconButtonRect.bottomLeft()) + QPoint(-0.5, 1)); + painter->restore(); + } + } else +#endif + { + CommonHelper::renderFrame( painter, rect, background, outline ); + } return true; } diff --git a/dstyleplugin/paletteextended.h b/dstyleplugin/paletteextended.h index 425b6677..87720d45 100644 --- a/dstyleplugin/paletteextended.h +++ b/dstyleplugin/paletteextended.h @@ -77,6 +77,7 @@ class PaletteExtended : public QObject PushButton_SuggestTextColor, LineEdit_BorderBrush, + LineEdit_AlertBorderBrush, LineEdit_BackgroundBrush, Menu_SeparatorColor,