Commit f1df97df authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port margins()

parent 00e4a73c
......@@ -339,16 +339,16 @@ QSize FileMetaDataWidget::sizeHint() const
}
// Based on the available width calculate the required height
int height = d->m_gridLayout->margin() * 2 + d->m_gridLayout->spacing() * (d->m_rows.count() - 1);
int height = getMargin() * 2 + d->m_gridLayout->spacing() * (d->m_rows.count() - 1);
for (const FileMetaDataWidgetPrivate::Row &row : std::as_const(d->m_rows)) {
const QWidget *valueWidget = row.value;
const int rowHeight = qMax(row.label->heightForWidth(leftWidthMax), valueWidget->heightForWidth(rightWidthMax));
height += rowHeight;
}
const int width = d->m_gridLayout->margin() * 2 + leftWidthMax + d->m_gridLayout->spacing() + rightWidthMax;
const int width = getMargin() * 2 + leftWidthMax + d->m_gridLayout->spacing() + rightWidthMax;
return {width, height};
return QSize{width, height};
}
void FileMetaDataWidget::setConfigurationMode(ConfigurationMode mode)
......@@ -365,4 +365,15 @@ void FileMetaDataWidget::setConfigurationMode(ConfigurationMode mode)
d->slotLoadingFinished();
}
int FileMetaDataWidget::getMargin() const
{
int left, top, right, bottom;
d->m_gridLayout->getContentsMargins(&left, &top, &right, &bottom);
if (left == top && top == right && right == bottom) {
return left;
} else {
return -1;
}
}
#include "moc_filemetadatawidget.cpp"
......@@ -99,6 +99,7 @@ Q_SIGNALS:
void metaDataRequestFinished(const KFileItemList &items);
private:
int getMargin() const;
friend class FileMetaDataWidgetPrivate;
std::unique_ptr<FileMetaDataWidgetPrivate> const d;
......
......@@ -150,6 +150,17 @@ void KBlockLayout::setGeometry(const QRect &rect)
doLayout(rect, false);
}
int KBlockLayout::getMargin() const
{
int left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
if (left == top && top == right && right == bottom) {
return left;
} else {
return -1;
}
}
QSize KBlockLayout::sizeHint() const
{
// TODO: try to get the items into a square
......@@ -163,7 +174,7 @@ QSize KBlockLayout::sizeHint() const
}
size.rwidth() += horizontalSpacing() * d->itemList.count();
size += QSize(2 * margin(), 2 * margin());
size += QSize(2 * getMargin(), 2 * getMargin());
return size;
}
......@@ -174,7 +185,7 @@ QSize KBlockLayout::minimumSize() const
size = size.expandedTo(item->minimumSize());
}
size += QSize(2 * margin(), 2 * margin());
size += QSize(2 * getMargin(), 2 * getMargin());
return size;
}
......
......@@ -52,6 +52,7 @@ public:
private:
int doLayout(const QRect &rect, bool testOnly) const;
int getMargin() const;
class Private;
Private *const d;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment