Fix preview image decoration offset
parent
24e675911e
commit
b05066cd96
|
@ -20,16 +20,17 @@ void ComponentPreviewImagesDecorator::decorate()
|
|||
|
||||
m_resultImages = std::make_unique<std::unordered_map<dust3d::Uuid, std::unique_ptr<QImage>>>();
|
||||
|
||||
QPointF iconOffset(Theme::previewIconMargin, 0);
|
||||
for (auto &it: *m_previewInputs) {
|
||||
if (it.isDirectory) {
|
||||
QPainter painter(it.image.get());
|
||||
painter.setRenderHints(QPainter::Antialiasing);
|
||||
QPolygonF polygon;
|
||||
polygon << QPointF(it.image->width() / 4, 0.0) << QPointF(it.image->width() / 2.5, 0.0);
|
||||
polygon << QPointF(0.0, it.image->height() / 2.5) << QPointF(0.0, it.image->height() / 4);
|
||||
polygon << iconOffset + QPointF(it.image->width() / 4, 0) << iconOffset + QPointF(it.image->width() / 2, 0);
|
||||
polygon << iconOffset + QPointF(0.0, it.image->height() / 2) << iconOffset + QPointF(0.0, it.image->height() / 4);
|
||||
QPainterPath painterPath;
|
||||
painterPath.addPolygon(polygon);
|
||||
painter.setBrush(Theme::white);
|
||||
painter.setBrush(Theme::green);
|
||||
painter.setPen(Qt::NoPen);
|
||||
painter.drawPath(painterPath);
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ PreviewGridView::PreviewGridView(QWidget *parent):
|
|||
viewPalette.setColor(QPalette::Base, Qt::transparent);
|
||||
setPalette(viewPalette);
|
||||
|
||||
auto borderSize = std::max(1, Theme::partPreviewImageSize / 20);
|
||||
auto margin = std::max(1, borderSize / 2);
|
||||
auto borderRadius = std::max(3, Theme::partPreviewImageSize / 10);
|
||||
auto borderSize = Theme::previewIconBorderSize;
|
||||
auto margin = Theme::previewIconMargin;
|
||||
auto borderRadius = Theme::previewIconBorderRadius;
|
||||
setStyleSheet(
|
||||
"QListView::item {border:" + QString::number(borderSize) + "px solid transparent; margin:" + QString::number(margin) + "px; background-color: " + Theme::gray.name() +"; border-radius: " + QString::number(borderRadius) + ";}" +
|
||||
"QListView::item:selected {border-color: " + Theme::red.name() + ";}"
|
||||
|
|
|
@ -22,6 +22,9 @@ int Theme::miniIconSize = 0;
|
|||
int Theme::partPreviewImageSize = 0;
|
||||
int Theme::materialPreviewImageSize = 0;
|
||||
int Theme::sidebarPreferredWidth = 0;
|
||||
int Theme::previewIconBorderSize = 0;
|
||||
int Theme::previewIconMargin = 0;
|
||||
int Theme::previewIconBorderRadius = 0;
|
||||
|
||||
void Theme::initialize()
|
||||
{
|
||||
|
@ -55,6 +58,9 @@ void Theme::initialize()
|
|||
Theme::partPreviewImageSize = (Theme::miniIconSize * 2);
|
||||
Theme::sidebarPreferredWidth = Theme::partPreviewImageSize * 4.5;
|
||||
Theme::materialPreviewImageSize = Theme::sidebarPreferredWidth * 0.4;
|
||||
Theme::previewIconBorderSize = std::max(1, Theme::partPreviewImageSize / 20);
|
||||
Theme::previewIconMargin = std::max(1, Theme::previewIconBorderSize / 2);
|
||||
Theme::previewIconBorderRadius = std::max(3, Theme::partPreviewImageSize / 10);
|
||||
}
|
||||
|
||||
QtAwesome *Theme::awesome()
|
||||
|
|
|
@ -28,6 +28,9 @@ public:
|
|||
static int partPreviewImageSize;
|
||||
static int materialPreviewImageSize;
|
||||
static int sidebarPreferredWidth;
|
||||
static int previewIconBorderSize;
|
||||
static int previewIconMargin;
|
||||
static int previewIconBorderRadius;
|
||||
|
||||
static void initialize();
|
||||
static QtAwesome *awesome();
|
||||
|
|
Loading…
Reference in New Issue