mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-06 17:25:39 -05:00
Enable setting min and max list size
This commit is contained in:
parent
d15a324137
commit
aadedbb610
|
|
@ -44,6 +44,16 @@ void ListEditor::SetPlaceholderText(const QString &text)
|
|||
UpdatePlaceholder();
|
||||
}
|
||||
|
||||
void ListEditor::SetMinListHeight(int value)
|
||||
{
|
||||
_minHeight = value;
|
||||
}
|
||||
|
||||
void ListEditor::SetMaxListHeight(int value)
|
||||
{
|
||||
_maxHeight = value;
|
||||
}
|
||||
|
||||
void ListEditor::UpdatePlaceholder()
|
||||
{
|
||||
bool visible = !_placeholder->text().isEmpty() && _list->count() == 0;
|
||||
|
|
@ -104,11 +114,24 @@ int ListEditor::GetIndexOfSignal() const
|
|||
void ListEditor::UpdateListSize()
|
||||
{
|
||||
SetHeightToContentHeight(_list);
|
||||
|
||||
if (_list->count() == 0 && !_placeholder->text().isEmpty()) {
|
||||
auto height = _list->fontMetrics().height() * 3;
|
||||
_list->setMinimumHeight(height);
|
||||
_list->setMaximumHeight(height);
|
||||
}
|
||||
|
||||
if (_minHeight >= 0 && _list->minimumHeight() != _minHeight) {
|
||||
_list->setMinimumHeight(_minHeight);
|
||||
}
|
||||
|
||||
if (_maxHeight >= 0 && _list->maximumHeight() != _maxHeight) {
|
||||
if (_list->minimumHeight() > _maxHeight) {
|
||||
_list->setMinimumHeight(_maxHeight);
|
||||
}
|
||||
_list->setMaximumHeight(_maxHeight);
|
||||
}
|
||||
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ public:
|
|||
ListEditor(QWidget *parent = nullptr, bool reorder = true);
|
||||
int count() const { return _list->count(); };
|
||||
void SetPlaceholderText(const QString &text);
|
||||
void SetMinListHeight(int);
|
||||
void SetMaxListHeight(int);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
|
|
@ -38,6 +40,8 @@ protected:
|
|||
|
||||
private:
|
||||
QLabel *_placeholder;
|
||||
int _minHeight = -1;
|
||||
int _maxHeight = -1;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user