mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-23 10:39:46 -05:00
Combine manual category search button and combobox into a single widget
To avoid code duplication for Twitch condition and action
This commit is contained in:
parent
3b4cb6934d
commit
ecb6247959
|
|
@ -792,7 +792,7 @@ AdvSceneSwitcher.action.twitch.type.emoteOnlyEnable="Enable chat's emote-only mo
|
|||
AdvSceneSwitcher.action.twitch.type.emoteOnlyDisable="Disable chat's emote-only mode"
|
||||
AdvSceneSwitcher.action.twitch.type.raid="Raid channel"
|
||||
AdvSceneSwitcher.action.twitch.categorySelectionDisabled="Cannot select category without selecting a Twitch account first!"
|
||||
AdvSceneSwitcher.action.twitch.entry.line1="On{{account}}{{actions}}{{streamTitle}}{{category}}{{manualCategorySearch}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.entry.line1="On{{account}}{{actions}}{{streamTitle}}{{category}}{{markerDescription}}{{clipHasDelay}}{{duration}}{{announcementColor}}{{channel}}"
|
||||
AdvSceneSwitcher.action.twitch.tokenPermissionsInsufficient="Permissions of selected token are insufficient to perform selected action!"
|
||||
AdvSceneSwitcher.action.twitch.title.title="Enter title"
|
||||
AdvSceneSwitcher.action.twitch.marker.description="Describe marker"
|
||||
|
|
|
|||
|
|
@ -277,7 +277,8 @@ void ProgressDialog::CategoryCountUpdated(int value)
|
|||
.arg(value));
|
||||
}
|
||||
|
||||
TwitchCategorySearchButton::TwitchCategorySearchButton()
|
||||
TwitchCategorySearchButton::TwitchCategorySearchButton(QWidget *parent)
|
||||
: QPushButton(parent)
|
||||
{
|
||||
setMaximumWidth(22);
|
||||
const std::string pathPrefix =
|
||||
|
|
@ -355,6 +356,33 @@ void TwitchCategorySearchButton::StartManualCategorySearch()
|
|||
}
|
||||
}
|
||||
|
||||
TwitchCategoryWidget::TwitchCategoryWidget(QWidget *parent)
|
||||
: QWidget(parent),
|
||||
_selection(new TwitchCategorySelection(this)),
|
||||
_manualSearch(new TwitchCategorySearchButton(this))
|
||||
{
|
||||
QWidget::connect(_selection,
|
||||
SIGNAL(CategoreyChanged(const TwitchCategory &)), this,
|
||||
SIGNAL(CategoreyChanged(const TwitchCategory &)));
|
||||
|
||||
auto layout = new QHBoxLayout();
|
||||
layout->setContentsMargins(0, 0, 0, 0);
|
||||
layout->addWidget(_selection);
|
||||
layout->addWidget(_manualSearch);
|
||||
setLayout(layout);
|
||||
}
|
||||
|
||||
void TwitchCategoryWidget::SetCategory(const TwitchCategory &category)
|
||||
{
|
||||
_selection->SetCategory(category);
|
||||
}
|
||||
|
||||
void TwitchCategoryWidget::SetToken(const std::weak_ptr<TwitchToken> &token)
|
||||
{
|
||||
_selection->SetToken(token);
|
||||
_manualSearch->SetToken(token);
|
||||
}
|
||||
|
||||
TwitchCategorySignalManager *TwitchCategorySignalManager::Instance()
|
||||
{
|
||||
static TwitchCategorySignalManager manager;
|
||||
|
|
|
|||
|
|
@ -69,12 +69,7 @@ class TwitchCategorySelection : public FilterComboBox {
|
|||
|
||||
public:
|
||||
TwitchCategorySelection(QWidget *parent);
|
||||
|
||||
// Will *not* verify if ID is still valid or populate the selection
|
||||
// list as that would take too long
|
||||
void SetCategory(const TwitchCategory &);
|
||||
|
||||
// Used for populating the category list
|
||||
void SetToken(const std::weak_ptr<TwitchToken> &);
|
||||
|
||||
private slots:
|
||||
|
|
@ -103,7 +98,7 @@ class TwitchCategorySearchButton : public QPushButton {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TwitchCategorySearchButton();
|
||||
TwitchCategorySearchButton(QWidget *parent);
|
||||
void SetToken(const std::weak_ptr<TwitchToken> &);
|
||||
|
||||
private slots:
|
||||
|
|
@ -116,6 +111,28 @@ private:
|
|||
std::weak_ptr<TwitchToken> _token;
|
||||
};
|
||||
|
||||
class TwitchCategoryWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TwitchCategoryWidget(QWidget *parent);
|
||||
// Will *not* verify if ID is still valid or populate the selection
|
||||
// list as that would take too long
|
||||
void SetCategory(const TwitchCategory &);
|
||||
|
||||
// Used for populating the category list
|
||||
void SetToken(const std::weak_ptr<TwitchToken> &);
|
||||
|
||||
signals:
|
||||
void CategoreyChanged(const TwitchCategory &);
|
||||
|
||||
private:
|
||||
TwitchCategorySelection *_selection;
|
||||
TwitchCategorySearchButton *_manualSearch;
|
||||
|
||||
std::weak_ptr<TwitchToken> _token;
|
||||
};
|
||||
|
||||
// Helper class to ease singal / slot handling
|
||||
class TwitchCategorySignalManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
|
|
|||
|
|
@ -360,8 +360,7 @@ MacroActionTwitchEdit::MacroActionTwitchEdit(
|
|||
_tokenPermissionWarning(new QLabel(obs_module_text(
|
||||
"AdvSceneSwitcher.action.twitch.tokenPermissionsInsufficient"))),
|
||||
_streamTitle(new VariableLineEdit(this)),
|
||||
_category(new TwitchCategorySelection(this)),
|
||||
_manualCategorySearch(new TwitchCategorySearchButton()),
|
||||
_category(new TwitchCategoryWidget(this)),
|
||||
_markerDescription(new VariableLineEdit(this)),
|
||||
_clipHasDelay(new QCheckBox(obs_module_text(
|
||||
"AdvSceneSwitcher.action.twitch.clip.hasDelay"))),
|
||||
|
|
@ -421,7 +420,6 @@ MacroActionTwitchEdit::MacroActionTwitchEdit(
|
|||
{"{{actions}}", _actions},
|
||||
{"{{streamTitle}}", _streamTitle},
|
||||
{"{{category}}", _category},
|
||||
{"{{manualCategorySearch}}", _manualCategorySearch},
|
||||
{"{{markerDescription}}", _markerDescription},
|
||||
{"{{clipHasDelay}}", _clipHasDelay},
|
||||
{"{{duration}}", _duration},
|
||||
|
|
@ -451,7 +449,6 @@ void MacroActionTwitchEdit::TwitchTokenChanged(const QString &token)
|
|||
auto lock = LockContext();
|
||||
_entryData->_token = GetWeakTwitchTokenByQString(token);
|
||||
_category->SetToken(_entryData->_token);
|
||||
_manualCategorySearch->SetToken(_entryData->_token);
|
||||
SetupWidgetVisibility();
|
||||
emit(HeaderInfoChanged(token));
|
||||
}
|
||||
|
|
@ -546,8 +543,6 @@ void MacroActionTwitchEdit::SetupWidgetVisibility()
|
|||
MacroActionTwitch::Action::TITLE);
|
||||
_category->setVisible(_entryData->_action ==
|
||||
MacroActionTwitch::Action::CATEGORY);
|
||||
_manualCategorySearch->setVisible(_entryData->_action ==
|
||||
MacroActionTwitch::Action::CATEGORY);
|
||||
_markerDescription->setVisible(_entryData->_action ==
|
||||
MacroActionTwitch::Action::MARKER);
|
||||
_clipHasDelay->setVisible(_entryData->_action ==
|
||||
|
|
@ -596,7 +591,6 @@ void MacroActionTwitchEdit::UpdateEntryData()
|
|||
_tokens->SetToken(_entryData->_token);
|
||||
_streamTitle->setText(_entryData->_streamTitle);
|
||||
_category->SetToken(_entryData->_token);
|
||||
_manualCategorySearch->SetToken(_entryData->_token);
|
||||
_category->SetCategory(_entryData->_category);
|
||||
_markerDescription->setText(_entryData->_markerDescription);
|
||||
_clipHasDelay->setChecked(_entryData->_clipHasDelay);
|
||||
|
|
|
|||
|
|
@ -119,8 +119,7 @@ private:
|
|||
QTimer _tokenPermissionCheckTimer;
|
||||
|
||||
VariableLineEdit *_streamTitle;
|
||||
TwitchCategorySelection *_category;
|
||||
TwitchCategorySearchButton *_manualCategorySearch;
|
||||
TwitchCategoryWidget *_category;
|
||||
VariableLineEdit *_markerDescription;
|
||||
QCheckBox *_clipHasDelay;
|
||||
DurationSelection *_duration;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user