From 899d0d91302140676d57e68f358aa0aade26fa0c Mon Sep 17 00:00:00 2001 From: Kacper Donat Date: Sat, 20 Jan 2024 00:06:03 +0100 Subject: [PATCH] Sketcher: Make Constraints UI style aware This adds reference to the actual widget to the painting of Constraints List control of Sketcher. Thanks to this this list can now be styled using standard mechanisms of Qt framework like QSS. --- src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp index b927ec8ac3..363aea9859 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstraints.cpp @@ -262,12 +262,12 @@ public: static QIcon snell_driven( Gui::BitmapFactory().iconFromTheme("Constraint_SnellsLaw_Driven")); - auto selicon = [](const Sketcher::Constraint* constr, + auto selicon = [this](const Sketcher::Constraint* constr, const QIcon& normal, const QIcon& driven) -> QIcon { if (!constr->isActive) { QIcon darkIcon; - int w = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); + int w = listWidget()->style()->pixelMetric(QStyle::PM_ListViewIconSize); darkIcon.addPixmap(normal.pixmap(w, w, QIcon::Disabled, QIcon::Off), QIcon::Normal, QIcon::Off); @@ -466,7 +466,7 @@ protected: QStyleOptionViewItem options = option; initStyleOption(&options, index); - options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter); + options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter, option.widget); ConstraintItem* item = dynamic_cast(view->item(index.row())); if (!item || item->sketch->Constraints.getSize() <= item->ConstraintNbr)