mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-24 02:05:24 -05:00
Add option to set Twitch stream tags
This commit is contained in:
@@ -12,6 +12,7 @@ class ADVSS_EXPORT ListEditor : public QWidget {
|
||||
|
||||
public:
|
||||
ListEditor(QWidget *parent = nullptr, bool reorder = true);
|
||||
int count() const { return _list->count(); };
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *);
|
||||
|
||||
@@ -46,14 +46,17 @@ void StringList::ResolveVariables()
|
||||
}
|
||||
}
|
||||
|
||||
StringListEdit::StringListEdit(QWidget *parent, const QString &addString,
|
||||
const QString &addStringDescription,
|
||||
int maxStringSize, bool allowEmtpy)
|
||||
StringListEdit::StringListEdit(
|
||||
QWidget *parent, const QString &addString,
|
||||
const QString &addStringDescription, int maxStringSize,
|
||||
const std::function<bool(const std::string &)> &filter,
|
||||
const std::function<void(std::string &input)> &preprocess)
|
||||
: ListEditor(parent),
|
||||
_addString(addString),
|
||||
_addStringDescription(addStringDescription),
|
||||
_maxStringSize(maxStringSize),
|
||||
_allowEmpty(allowEmtpy)
|
||||
_filterCallback(filter),
|
||||
_preprocessCallback(preprocess)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -77,15 +80,19 @@ void StringListEdit::SetMaxStringSize(int size)
|
||||
|
||||
void StringListEdit::Add()
|
||||
{
|
||||
std::string name;
|
||||
std::string entry;
|
||||
bool accepted = NameDialog::AskForName(this, _addString,
|
||||
_addStringDescription, name, "",
|
||||
_addStringDescription, entry, "",
|
||||
_maxStringSize, false);
|
||||
|
||||
if (!accepted || (!_allowEmpty && name.empty())) {
|
||||
if (!accepted) {
|
||||
return;
|
||||
}
|
||||
StringVariable string = name;
|
||||
|
||||
_preprocessCallback(entry);
|
||||
if (_filterCallback(entry)) {
|
||||
return;
|
||||
}
|
||||
StringVariable string = entry;
|
||||
QVariant v = QVariant::fromValue(string);
|
||||
QListWidgetItem *item = new QListWidgetItem(
|
||||
QString::fromStdString(string.UnresolvedValue()), _list);
|
||||
@@ -145,17 +152,21 @@ void StringListEdit::Down()
|
||||
|
||||
void StringListEdit::Clicked(QListWidgetItem *item)
|
||||
{
|
||||
std::string name;
|
||||
std::string entry;
|
||||
bool accepted = NameDialog::AskForName(this, _addString,
|
||||
_addStringDescription, name,
|
||||
_addStringDescription, entry,
|
||||
item->text(), _maxStringSize,
|
||||
false);
|
||||
|
||||
if (!accepted || (!_allowEmpty && name.empty())) {
|
||||
if (!accepted) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringVariable string = name;
|
||||
_preprocessCallback(entry);
|
||||
if (_filterCallback(entry)) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringVariable string = entry;
|
||||
QVariant v = QVariant::fromValue(string);
|
||||
item->setText(QString::fromStdString(string.UnresolvedValue()));
|
||||
item->setData(Qt::UserRole, string);
|
||||
|
||||
@@ -19,14 +19,20 @@ public:
|
||||
friend class StringListEdit;
|
||||
};
|
||||
|
||||
class ADVSS_EXPORT StringListEdit final : public ListEditor {
|
||||
class ADVSS_EXPORT StringListEdit : public ListEditor {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
StringListEdit(QWidget *parent, const QString &addString = "",
|
||||
const QString &addStringDescription = "",
|
||||
int maxStringSize = 170, bool allowEmtpy = false);
|
||||
StringListEdit(
|
||||
QWidget *parent, const QString &addString = "",
|
||||
const QString &addStringDescription = "",
|
||||
int maxStringSize = 170,
|
||||
const std::function<bool(const std::string &)> &filter =
|
||||
[](const std::string &) { return false; },
|
||||
const std::function<void(std::string &input)> &preprocess =
|
||||
[](std::string &) {});
|
||||
void SetStringList(const StringList &);
|
||||
StringList GetStringList() const { return _stringList; }
|
||||
void SetMaxStringSize(int);
|
||||
|
||||
private slots:
|
||||
@@ -44,7 +50,8 @@ private:
|
||||
QString _addString;
|
||||
QString _addStringDescription;
|
||||
int _maxStringSize = 170;
|
||||
bool _allowEmpty = false;
|
||||
std::function<bool(const std::string &)> _filterCallback;
|
||||
std::function<void(std::string &)> _preprocessCallback;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
||||
Reference in New Issue
Block a user