mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-03-10 08:09:23 -04:00
Fix funny resizing bug and increase min-padding
This commit is contained in:
parent
74afd8e819
commit
ad2ccae5db
@ -49,16 +49,12 @@ QSize CategoryListWidget::sizeHint() const
|
||||
{
|
||||
QSize sizeHint = QWidget::sizeHint();
|
||||
|
||||
int width = m_ui->categoryList->sizeHintForColumn(0);
|
||||
if (m_ui->categoryList->verticalScrollBar()->isVisible()) {
|
||||
width += m_ui->categoryList->verticalScrollBar()->width();
|
||||
}
|
||||
int width = m_ui->categoryList->width();
|
||||
|
||||
QSize min = minimumSizeHint();
|
||||
if (width < min.width()) {
|
||||
width = min.width();
|
||||
int min = minimumSizeHint().width();
|
||||
if (width < min) {
|
||||
width = min;
|
||||
}
|
||||
width += m_ui->categoryList->frameWidth() * 2;
|
||||
sizeHint.setWidth(width);
|
||||
|
||||
return sizeHint;
|
||||
@ -66,7 +62,7 @@ QSize CategoryListWidget::sizeHint() const
|
||||
|
||||
QSize CategoryListWidget::minimumSizeHint() const
|
||||
{
|
||||
return QSize(m_ui->categoryList->sizeHintForColumn(0) + m_ui->categoryList->frameWidth() * 2,
|
||||
return QSize(m_itemDelegate->minWidth() + m_ui->categoryList->frameWidth() * 2,
|
||||
m_ui->categoryList->sizeHintForRow(0) * 2);
|
||||
}
|
||||
|
||||
@ -204,7 +200,10 @@ int CategoryListWidgetDelegate::minWidth() const
|
||||
}
|
||||
}
|
||||
|
||||
return maxWidth > m_size.height() ? maxWidth + 5 : m_size.height();
|
||||
// add some padding
|
||||
maxWidth += 10;
|
||||
|
||||
return maxWidth < m_size.height() ? m_size.height() : maxWidth;
|
||||
}
|
||||
|
||||
QSize CategoryListWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||
|
@ -73,13 +73,13 @@ class CategoryListWidgetDelegate : public QStyledItemDelegate
|
||||
|
||||
public:
|
||||
explicit CategoryListWidgetDelegate(QListWidget* parent = nullptr);
|
||||
int minWidth() const;
|
||||
|
||||
protected:
|
||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||
|
||||
private:
|
||||
int minWidth() const;
|
||||
|
||||
const int ICON_SIZE = 32;
|
||||
|
||||
|
@ -38,11 +38,11 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||
<item>
|
||||
<widget class="CategoryListWidget" name="categoryList" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
Loading…
x
Reference in New Issue
Block a user