diff --git a/src/Mod/Start/Gui/FileCardDelegate.cpp b/src/Mod/Start/Gui/FileCardDelegate.cpp index a7cd323842..3fe602bf96 100644 --- a/src/Mod/Start/Gui/FileCardDelegate.cpp +++ b/src/Mod/Start/Gui/FileCardDelegate.cpp @@ -34,13 +34,13 @@ #include #include #include +#include #endif #include "FileCardDelegate.h" #include "../App/DisplayedFilesModel.h" #include "App/Application.h" #include -#include using namespace Start; @@ -49,11 +49,7 @@ FileCardDelegate::FileCardDelegate(QObject* parent) { _parameterGroup = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Start"); - _widget = std::make_unique(); - _widget->setObjectName(QLatin1String("thumbnailWidget")); - auto layout = gsl::owner(new QVBoxLayout()); - layout->setSpacing(0); - _widget->setLayout(layout); + setObjectName(QStringLiteral("thumbnailWidget")); } void FileCardDelegate::paint(QPainter* painter, @@ -61,10 +57,9 @@ void FileCardDelegate::paint(QPainter* painter, const QModelIndex& index) const { painter->save(); - // Step 1: Styling QStyleOptionButton buttonOption; - buttonOption.initFrom(_widget.get()); + buttonOption.initFrom(option.widget); buttonOption.rect = option.rect; buttonOption.state = QStyle::State_Enabled; @@ -77,8 +72,7 @@ void FileCardDelegate::paint(QPainter* painter, if ((option.state & QStyle::State_Sunken) != 0) { buttonOption.state |= QStyle::State_Sunken; } - - QApplication::style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter); + qApp->style()->drawControl(QStyle::CE_PushButton, &buttonOption, painter, &styleButton); // Step 2: Fetch required data auto thumbnailSize = diff --git a/src/Mod/Start/Gui/FileCardDelegate.h b/src/Mod/Start/Gui/FileCardDelegate.h index 78ba3f80b4..3da54f3c53 100644 --- a/src/Mod/Start/Gui/FileCardDelegate.h +++ b/src/Mod/Start/Gui/FileCardDelegate.h @@ -26,7 +26,7 @@ #include #include - +#include #include class FileCardDelegate: public QStyledItemDelegate @@ -46,9 +46,9 @@ protected: private: Base::Reference _parameterGroup; - std::unique_ptr _widget; const int margin = 11; const int textspacing = 2; + QPushButton styleButton; };