start: fix file cards not respecting styling

This commit is contained in:
Alfredo Monclus
2025-03-22 15:59:11 -03:00
committed by GitHub
parent 11ff46f84a
commit 8fb23b9117
2 changed files with 6 additions and 12 deletions

View File

@@ -34,13 +34,13 @@
#include <QVBoxLayout>
#include <QApplication>
#include <QPushButton>
#include <QString>
#endif
#include "FileCardDelegate.h"
#include "../App/DisplayedFilesModel.h"
#include "App/Application.h"
#include <Base/Color.h>
#include <gsl/pointers>
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<QPushButton>();
_widget->setObjectName(QLatin1String("thumbnailWidget"));
auto layout = gsl::owner<QVBoxLayout*>(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 =

View File

@@ -26,7 +26,7 @@
#include <Base/Parameter.h>
#include <QImage>
#include <QPushButton>
#include <QStyledItemDelegate>
class FileCardDelegate: public QStyledItemDelegate
@@ -46,9 +46,9 @@ protected:
private:
Base::Reference<ParameterGrp> _parameterGroup;
std::unique_ptr<QWidget> _widget;
const int margin = 11;
const int textspacing = 2;
QPushButton styleButton;
};