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