Skip to content

Commit

Permalink
Made the property label indentation shrink when there is very little …
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
bjorn committed Sep 16, 2024
1 parent e3b2ee1 commit 5dc9211
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/tiled/varianteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,15 +528,19 @@ void VariantEditor::addProperty(Property *property)
case Property::DisplayMode::Default:
case Property::DisplayMode::NoLabel: {
auto propertyLayout = new QHBoxLayout;
propertyLayout->setContentsMargins(spacing, 0, spacing, 0);
propertyLayout->setContentsMargins(0, 0, spacing, 0);
propertyLayout->setSpacing(spacing);

// Property label indentation, which shrinks when there is very little space
propertyLayout->addSpacerItem(new QSpacerItem(branchIndicatorWidth + spacing, 0,
QSizePolicy::Maximum));
propertyLayout->setStretch(0, 1);

if (property->displayMode() == Property::DisplayMode::Default) {
auto label = new LineEditLabel(property->name(), this);
label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
label->setToolTip(property->toolTip());
label->setEnabled(property->isEnabled());
label->setContentsMargins(branchIndicatorWidth, 0, 0, 0);
connect(property, &Property::toolTipChanged, label, &QWidget::setToolTip);
connect(property, &Property::enabledChanged, label, &QWidget::setEnabled);
propertyLayout->addWidget(label, LabelStretch, Qt::AlignTop);
Expand Down
4 changes: 2 additions & 2 deletions src/tiled/varianteditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ class VariantEditor : public QWidget
QWidget *createEditor(Property *property);

enum Column {
LabelStretch = 2,
WidgetStretch = 3,
LabelStretch = 4,
WidgetStretch = 6,
};

QVBoxLayout *m_layout;
Expand Down

0 comments on commit 5dc9211

Please sign in to comment.