Skip to content

Commit

Permalink
Added rounded corners
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugen Fischer authored and Eugen Fischer committed Feb 5, 2024
1 parent 6256b7a commit d54edb5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/gui/folderstatusview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#include "folderstatusview.h"
#include "QtCore/qtimer.h"
#include "QtGui/qevent.h"
#include "QtGui/qpainterpath.h"
#include "QtWidgets/qapplication.h"
#include "folderstatusdelegate.h"

#include "QPainter"
Expand All @@ -23,6 +25,8 @@ namespace OCC {

FolderStatusView::FolderStatusView(QWidget *parent) : QTreeView(parent)
{
//Removes the border
setStyleSheet("QTreeView { border: none; border-width: 0px; border-style: none; border-color: transparent; }");
}

QModelIndex FolderStatusView::indexAt(const QPoint &point) const
Expand Down Expand Up @@ -53,6 +57,27 @@ void FolderStatusView::drawBranches(QPainter *painter, const QRect &rect, const
//we will implement it in folderstatusdelegate.cpp paint funtion
}

void FolderStatusView::paintEvent(QPaintEvent *event)
{
//it paints rounded corner, Qtreeview does not support the stylesheet setting

QPainter painter(viewport());
painter.setRenderHint(QPainter::Antialiasing);

const int radius = 4;

QRect rect(0, 0, width(), height());
QPainterPath path;
path.addRoundedRect(rect, radius, radius);

QPalette palette = QApplication::palette();
painter.fillRect(rect, palette.window());

painter.fillPath(path, Qt::white);

QTreeView::paintEvent(event);
}



} // namespace OCC
1 change: 1 addition & 0 deletions src/gui/folderstatusview.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class FolderStatusView : public QTreeView

protected:
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
void paintEvent(QPaintEvent *event) override;
};

} // namespace OCC
Expand Down

0 comments on commit d54edb5

Please sign in to comment.