Changeset 102613 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- Dec 15, 2023 4:04:56 PM (16 months ago)
- svn:sync-xref-src-repo-rev:
- 160768
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/extensions/QILineEdit.cpp
r101560 r102613 33 33 #include <QLabel> 34 34 #include <QMenu> 35 #include <QPalette>36 35 #include <QStyleOptionFrame> 37 36 #include <QWindow> -
trunk/src/VBox/Frontends/VirtualBox/src/settings/UIAdvancedSettingsDialog.cpp
r102529 r102613 115 115 116 116 117 /** QILineEdit subclass used as filter line-edit. */ 118 class UIFilterLineEdit : public QILineEdit 119 { 120 Q_OBJECT; 121 122 public: 123 124 /** Constructs line-edit passing @a pParent to the base-class. */ 125 UIFilterLineEdit(QWidget *pParent) 126 : QILineEdit(pParent) 127 , m_iRadius(0) 128 { 129 prepare(); 130 } 131 132 protected: 133 134 /** Handles paint @a pEvent. */ 135 virtual void paintEvent(QPaintEvent *pEvent) RT_OVERRIDE 136 { 137 /* Prepare painter: */ 138 QPainter painter(this); 139 painter.setRenderHint(QPainter::Antialiasing); 140 painter.setRenderHint(QPainter::TextAntialiasing); 141 /* Avoid painting more than necessary: */ 142 painter.setClipRect(pEvent->rect()); 143 144 /* Prepare colors: */ 145 const bool fActive = window() && window()->isActiveWindow(); 146 const QPalette::ColorGroup enmColorGroup = fActive ? QPalette::Active : QPalette::Inactive; 147 QColor colorBase = qApp->palette().color(enmColorGroup, QPalette::Base); 148 QColor colorFrame; 149 if (uiCommon().isInDarkMode()) 150 colorFrame = qApp->palette().color(enmColorGroup, QPalette::Window).lighter(120); 151 else 152 colorFrame = qApp->palette().color(enmColorGroup, QPalette::Window).darker(120); 153 154 /* Prepare base/frame painter path: */ 155 const QRect widgetRect = rect(); 156 QPainterPath path; 157 QSizeF arcSize(2 * m_iRadius, 2 * m_iRadius); 158 path.moveTo(widgetRect.x() + m_iRadius, widgetRect.y()); 159 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-m_iRadius, 0), 90, 90); 160 path.lineTo(path.currentPosition().x(), widgetRect.height() - m_iRadius); 161 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(0, -m_iRadius), 180, 90); 162 path.lineTo(widgetRect.width() - m_iRadius, path.currentPosition().y()); 163 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-m_iRadius, -2 * m_iRadius), 270, 90); 164 path.lineTo(path.currentPosition().x(), widgetRect.y() + m_iRadius); 165 path.arcTo(QRectF(path.currentPosition(), arcSize).translated(-2 * m_iRadius, -m_iRadius), 0, 90); 166 path.closeSubpath(); 167 168 /* Draw base/frame: */ 169 painter.fillPath(path, colorBase); 170 painter.strokePath(path, colorFrame); 171 172 /* Call to base-class: */ 173 QILineEdit::paintEvent(pEvent); 174 } 175 176 private: 177 178 /** Prepares everything. */ 179 void prepare() 180 { 181 /* A bit of magic to be able to replace the frame. 182 * Disable border, adjust margins and make background transparent. */ 183 setStyleSheet("QLineEdit {\ 184 background-color: rgba(255, 255, 255, 0%);\ 185 border: 0px none black;\ 186 margin: 3px 10px 3px 10px;\ 187 }"); 188 189 /* Init the decoration radius: */ 190 m_iRadius = 10; 191 } 192 193 /** Holds the decoration radius. */ 194 int m_iRadius; 195 }; 196 197 117 198 /** QWidget reimplementation 118 * wrapping custom QILineEdit and199 * wrapping UIFilterLineEdit and 119 200 * representing filter editor for advanced settings dialog. */ 120 201 class UIFilterEditor : public QWidget … … 186 267 187 268 /** Holds the filter editor instance. */ 188 QILineEdit*m_pLineEdit;269 UIFilterLineEdit *m_pLineEdit; 189 270 /** Holds the filter reset button instance. */ 190 QToolButton *m_pToolButton;271 QToolButton *m_pToolButton; 191 272 192 273 /** Holds whether filter editor focused. */ … … 444 525 { 445 526 /* Prepare filter editor: */ 446 m_pLineEdit = new QILineEdit(this);527 m_pLineEdit = new UIFilterLineEdit(this); 447 528 if (m_pLineEdit) 448 529 { 449 530 m_pLineEdit->installEventFilter(this); 450 connect(m_pLineEdit, & QILineEdit::textChanged,531 connect(m_pLineEdit, &UIFilterLineEdit::textChanged, 451 532 this, &UIFilterEditor::sltHandleEditorTextChanged); 452 533 }
Note:
See TracChangeset
for help on using the changeset viewer.