| 13 | namespace PJ { |
| 14 | |
| 15 | void applyComboBoxStyling(QComboBox* combo) { |
| 16 | if (combo == nullptr) { |
| 17 | return; |
| 18 | } |
| 19 | combo->setItemDelegate(new ComboBoxGradientDelegate(combo)); |
| 20 | // QAbstractItemView inherits QFrame; without this, Qt's style paints |
| 21 | // its own 1-px frame around the view ON TOP of the QSS border, giving |
| 22 | // a double-line at the popup's edges. Killing the QFrame frame leaves |
| 23 | // only the QSS border + border-radius visible. |
| 24 | combo->view()->setFrameShape(QFrame::NoFrame); |
| 25 | |
| 26 | // Popup container (QComboBoxPrivateContainer): make it ARGB so QSS |
| 27 | // border-radius clips corners to alpha=0; kill its frame; zero |
| 28 | // margins so the inner view fills it exactly; suppress WM shadow. |
| 29 | if (auto* popup_window = combo->view()->window()) { |
| 30 | popup_window->setAttribute(Qt::WA_TranslucentBackground, true); |
| 31 | popup_window->setWindowFlag(Qt::NoDropShadowWindowHint, true); |
| 32 | if (auto* frame = qobject_cast<QFrame*>(popup_window)) { |
| 33 | frame->setFrameShape(QFrame::NoFrame); |
| 34 | } |
| 35 | popup_window->setContentsMargins(0, 0, 0, 0); |
| 36 | if (auto* lay = popup_window->layout()) { |
| 37 | lay->setContentsMargins(0, 0, 0, 0); |
| 38 | lay->setSpacing(0); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | ComboBox::ComboBox(QWidget* parent) : QComboBox(parent) { |
| 44 | applyComboBoxStyling(this); |
no test coverage detected