mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-07-19 01:15:14 -05:00
Resize list to minimum necessary height
This commit is contained in:
parent
5dfed8ac2a
commit
4d32e921f9
|
|
@ -55,6 +55,8 @@ protected:
|
|||
std::shared_ptr<MacroActionRandom> _entryData;
|
||||
|
||||
private:
|
||||
void SetMacroListSize();
|
||||
|
||||
MacroSelection *_macroSelection;
|
||||
QListWidget *_macroList;
|
||||
QPushButton *_add;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ protected:
|
|||
std::shared_ptr<MacroActionRun> _entryData;
|
||||
|
||||
private:
|
||||
void SetArgListSize();
|
||||
|
||||
FileSelection *_filePath;
|
||||
QListWidget *_argList;
|
||||
QPushButton *_addArg;
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ void listAddClicked(QListWidget *list, QWidget *newWidget,
|
|||
QMetaObject::Connection *addHighlight = nullptr);
|
||||
bool listMoveUp(QListWidget *list);
|
||||
bool listMoveDown(QListWidget *list);
|
||||
void setHeightToContentHeight(QListWidget *list);
|
||||
bool DisplayMessage(const QString &msg, bool question = false);
|
||||
void DisplayTrayMessage(const QString &title, const QString &msg);
|
||||
void addSelectionEntry(QComboBox *sel, const char *description,
|
||||
|
|
|
|||
|
|
@ -155,6 +155,7 @@ void MacroActionRandomEdit::UpdateEntryData()
|
|||
QListWidgetItem *item = new QListWidgetItem(name, _macroList);
|
||||
item->setData(Qt::UserRole, name);
|
||||
}
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::MacroRemove(const QString &name)
|
||||
|
|
@ -209,6 +210,7 @@ void MacroActionRandomEdit::AddMacro()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_macros.push_back(macro);
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::RemoveMacro()
|
||||
|
|
@ -232,6 +234,7 @@ void MacroActionRandomEdit::RemoveMacro()
|
|||
}
|
||||
}
|
||||
delete item;
|
||||
SetMacroListSize();
|
||||
}
|
||||
|
||||
int MacroActionRandomEdit::FindEntry(const std::string ¯o)
|
||||
|
|
@ -261,3 +264,9 @@ void MacroActionRandomEdit::MacroSelectionChanged(int idx)
|
|||
QString name = item->text();
|
||||
_macroSelection->SetCurrentMacro(GetMacroByName(name.toUtf8().data()));
|
||||
}
|
||||
|
||||
void MacroActionRandomEdit::SetMacroListSize()
|
||||
{
|
||||
setHeightToContentHeight(_macroList);
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ void MacroActionRunEdit::UpdateEntryData()
|
|||
QListWidgetItem *item = new QListWidgetItem(arg, _argList);
|
||||
item->setData(Qt::UserRole, arg);
|
||||
}
|
||||
SetArgListSize();
|
||||
}
|
||||
|
||||
void MacroActionRunEdit::PathChanged(const QString &text)
|
||||
|
|
@ -175,6 +176,7 @@ void MacroActionRunEdit::AddArg()
|
|||
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
_entryData->_args << arg;
|
||||
SetArgListSize();
|
||||
}
|
||||
|
||||
void MacroActionRunEdit::RemoveArg()
|
||||
|
|
@ -195,6 +197,7 @@ void MacroActionRunEdit::RemoveArg()
|
|||
return;
|
||||
}
|
||||
delete item;
|
||||
SetArgListSize();
|
||||
}
|
||||
|
||||
void MacroActionRunEdit::ArgUp()
|
||||
|
|
@ -224,3 +227,9 @@ void MacroActionRunEdit::ArgDown()
|
|||
_entryData->_args.move(idx, idx + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void MacroActionRunEdit::SetArgListSize()
|
||||
{
|
||||
setHeightToContentHeight(_argList);
|
||||
adjustSize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -962,3 +962,14 @@ bool listMoveDown(QListWidget *list)
|
|||
list->setCurrentRow(index + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
void setHeightToContentHeight(QListWidget *list)
|
||||
{
|
||||
auto nrItems = list->count();
|
||||
if (nrItems == 0) {
|
||||
list->setMaximumHeight(0);
|
||||
} else {
|
||||
list->setMaximumHeight(list->sizeHintForRow(0) * nrItems +
|
||||
2 * list->frameWidth());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user