diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2020-12-31 17:53:45 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:18 +0100 |
| commit | cc4dcf617fbad6783b74b4df0963911a149ffaf1 (patch) | |
| tree | 9f79796ac1657c9e3f6d9708c7ddd7bad7e43b16 | |
| parent | ac6373edf677aba5a2add70f41e373e678c567ba (diff) | |
Move modlistview proxy style to moapplication.
| -rw-r--r-- | src/moapplication.cpp | 19 | ||||
| -rw-r--r-- | src/modlistview.cpp | 29 |
2 files changed, 13 insertions, 35 deletions
diff --git a/src/moapplication.cpp b/src/moapplication.cpp index fb6a7121..9b261a45 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -65,6 +65,13 @@ public: void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
if(element == QStyle::PE_IndicatorItemViewItemDrop) {
+
+ QRect rect(option->rect);
+ if (auto* view = qobject_cast<const QTreeView*>(widget)) {
+ rect.setLeft(view->indentation());
+ rect.setRight(widget->width());
+ }
+
painter->setRenderHint(QPainter::Antialiasing, true);
QColor col(option->palette.windowText().color());
@@ -75,16 +82,16 @@ public: painter->setPen(pen);
painter->setBrush(brush);
- if(option->rect.height() == 0) {
+ if(rect.height() == 0) {
QPoint tri[3] = {
- option->rect.topLeft(),
- option->rect.topLeft() + QPoint(-5, 5),
- option->rect.topLeft() + QPoint(-5, -5)
+ rect.topLeft(),
+ rect.topLeft() + QPoint(-5, 5),
+ rect.topLeft() + QPoint(-5, -5)
};
painter->drawPolygon(tri, 3);
- painter->drawLine(QPoint(option->rect.topLeft().x(), option->rect.topLeft().y()), option->rect.topRight());
+ painter->drawLine(QPoint(rect.topLeft().x(), rect.topLeft().y()), rect.topRight());
} else {
- painter->drawRoundedRect(option->rect, 5, 5);
+ painter->drawRoundedRect(rect, 5, 5);
}
} else {
QProxyStyle::drawPrimitive(element, option, painter, widget);
diff --git a/src/modlistview.cpp b/src/modlistview.cpp index 18486eeb..37dcb2ca 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -27,30 +27,6 @@ using namespace MOBase;
-class ModListProxyStyle : public QProxyStyle {
-public:
-
- using QProxyStyle::QProxyStyle;
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const override
- {
- if (element == QStyle::PE_IndicatorItemViewItemDrop)
- {
- QStyleOption opt(*option);
- opt.rect.setLeft(0);
- if (auto* view = qobject_cast<const QTreeView*>(widget)) {
- opt.rect.setLeft(view->indentation());
- opt.rect.setRight(widget->width());
- }
- QProxyStyle::drawPrimitive(element, &opt, painter, widget);
- }
- else {
- QProxyStyle::drawPrimitive(element, option, painter, widget);
- }
- }
-
-};
-
class ModListStyledItemDelegated : public QStyledItemDelegate
{
ModListView* m_view;
@@ -87,7 +63,6 @@ ModListView::ModListView(QWidget* parent) MOBase::setCustomizableColumns(this);
setAutoExpandDelay(1000);
- setStyle(new ModListProxyStyle(style()));
setItemDelegate(new ModListStyledItemDelegated(this));
connect(this, &ModListView::doubleClicked, this, &ModListView::onDoubleClicked);
@@ -97,10 +72,6 @@ ModListView::ModListView(QWidget* parent) void ModListView::refresh()
{
updateGroupByProxy(-1);
-
- // since we use a proxy, modifying the stylesheet breaks it
- // so we need to reset it
- setStyle(new ModListProxyStyle(QApplication::style()));
}
void ModListView::setProfile(Profile* profile)
|
