mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-11-14 20:40:54 -05:00
Fix funny resizing bug and increase min-padding
This commit is contained in:
parent
74afd8e819
commit
ad2ccae5db
3 changed files with 12 additions and 13 deletions
|
|
@ -49,16 +49,12 @@ QSize CategoryListWidget::sizeHint() const
|
||||||
{
|
{
|
||||||
QSize sizeHint = QWidget::sizeHint();
|
QSize sizeHint = QWidget::sizeHint();
|
||||||
|
|
||||||
int width = m_ui->categoryList->sizeHintForColumn(0);
|
int width = m_ui->categoryList->width();
|
||||||
if (m_ui->categoryList->verticalScrollBar()->isVisible()) {
|
|
||||||
width += m_ui->categoryList->verticalScrollBar()->width();
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize min = minimumSizeHint();
|
int min = minimumSizeHint().width();
|
||||||
if (width < min.width()) {
|
if (width < min) {
|
||||||
width = min.width();
|
width = min;
|
||||||
}
|
}
|
||||||
width += m_ui->categoryList->frameWidth() * 2;
|
|
||||||
sizeHint.setWidth(width);
|
sizeHint.setWidth(width);
|
||||||
|
|
||||||
return sizeHint;
|
return sizeHint;
|
||||||
|
|
@ -66,7 +62,7 @@ QSize CategoryListWidget::sizeHint() const
|
||||||
|
|
||||||
QSize CategoryListWidget::minimumSizeHint() 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);
|
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
|
QSize CategoryListWidgetDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
||||||
|
|
|
||||||
|
|
@ -73,13 +73,13 @@ class CategoryListWidgetDelegate : public QStyledItemDelegate
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CategoryListWidgetDelegate(QListWidget* parent = nullptr);
|
explicit CategoryListWidgetDelegate(QListWidget* parent = nullptr);
|
||||||
|
int minWidth() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override;
|
||||||
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int minWidth() const;
|
|
||||||
|
|
||||||
const int ICON_SIZE = 32;
|
const int ICON_SIZE = 32;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,11 +38,11 @@
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1">
|
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="CategoryListWidget" name="categoryList" native="true">
|
<widget class="CategoryListWidget" name="categoryList" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue