mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-19 00:27:23 -05:00
Cleanup
This commit is contained in:
parent
54b81d1a42
commit
0939dcacb6
|
|
@ -116,6 +116,7 @@ class TwitchCategoryWidget : public QWidget {
|
|||
|
||||
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 &);
|
||||
|
|
@ -129,8 +130,6 @@ signals:
|
|||
private:
|
||||
TwitchCategorySelection *_selection;
|
||||
TwitchCategorySearchButton *_manualSearch;
|
||||
|
||||
std::weak_ptr<TwitchToken> _token;
|
||||
};
|
||||
|
||||
// Helper class to ease singal / slot handling
|
||||
|
|
|
|||
|
|
@ -13,6 +13,11 @@ bool MacroActionTwitch::_registered = MacroActionFactory::Register(
|
|||
{MacroActionTwitch::Create, MacroActionTwitchEdit::Create,
|
||||
"AdvSceneSwitcher.action.twitch"});
|
||||
|
||||
std::string MacroActionTwitch::GetShortDesc() const
|
||||
{
|
||||
return GetWeakTwitchTokenName(_token);
|
||||
}
|
||||
|
||||
const static std::map<MacroActionTwitch::Action, std::string> actionTypes = {
|
||||
{MacroActionTwitch::Action::TITLE,
|
||||
"AdvSceneSwitcher.action.twitch.type.title"},
|
||||
|
|
@ -273,6 +278,7 @@ void MacroActionTwitch::LogAction() const
|
|||
bool MacroActionTwitch::Save(obs_data_t *obj) const
|
||||
{
|
||||
MacroAction::Save(obj);
|
||||
|
||||
obs_data_set_int(obj, "action", static_cast<int>(_action));
|
||||
obs_data_set_string(obj, "token",
|
||||
GetWeakTwitchTokenName(_token).c_str());
|
||||
|
|
@ -285,12 +291,14 @@ bool MacroActionTwitch::Save(obs_data_t *obj) const
|
|||
obs_data_set_int(obj, "announcementColor",
|
||||
static_cast<int>(_announcementColor));
|
||||
_channel.Save(obj);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroActionTwitch::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroAction::Load(obj);
|
||||
|
||||
_action = static_cast<Action>(obs_data_get_int(obj, "action"));
|
||||
_token = GetWeakTwitchTokenByName(obs_data_get_string(obj, "token"));
|
||||
_streamTitle.Load(obj, "streamTitle");
|
||||
|
|
@ -302,12 +310,8 @@ bool MacroActionTwitch::Load(obs_data_t *obj)
|
|||
_announcementColor = static_cast<AnnouncementColor>(
|
||||
obs_data_get_int(obj, "announcementColor"));
|
||||
_channel.Load(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string MacroActionTwitch::GetShortDesc() const
|
||||
{
|
||||
return GetWeakTwitchTokenName(_token);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MacroActionTwitch::ActionIsSupportedByToken()
|
||||
|
|
@ -410,8 +414,6 @@ MacroActionTwitchEdit::MacroActionTwitchEdit(
|
|||
QWidget::connect(_channel,
|
||||
SIGNAL(ChannelChanged(const TwitchChannel &)), this,
|
||||
SLOT(ChannelChanged(const TwitchChannel &)));
|
||||
QWidget::connect(&_tokenPermissionCheckTimer, SIGNAL(timeout()), this,
|
||||
SLOT(CheckTokenPermissions()));
|
||||
|
||||
PlaceWidgets(
|
||||
obs_module_text("AdvSceneSwitcher.action.twitch.entry.line1"),
|
||||
|
|
@ -440,6 +442,25 @@ MacroActionTwitchEdit::MacroActionTwitchEdit(
|
|||
_loading = false;
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::ActionChanged(int idx)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (idx == -1) { // Reset to previous selection
|
||||
const QSignalBlocker b(_actions);
|
||||
_actions->setCurrentIndex(_actions->findData(
|
||||
static_cast<int>(_entryData->_action)));
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
_entryData->_action = static_cast<MacroActionTwitch::Action>(
|
||||
_actions->itemData(idx).toInt());
|
||||
SetupWidgetVisibility();
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::TwitchTokenChanged(const QString &token)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
|
|
@ -449,10 +470,20 @@ void MacroActionTwitchEdit::TwitchTokenChanged(const QString &token)
|
|||
auto lock = LockContext();
|
||||
_entryData->_token = GetWeakTwitchTokenByQString(token);
|
||||
_category->SetToken(_entryData->_token);
|
||||
_channel->SetToken(_entryData->_token);
|
||||
|
||||
SetupWidgetVisibility();
|
||||
emit(HeaderInfoChanged(token));
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::CheckTokenPermissions()
|
||||
{
|
||||
_tokenPermissionWarning->setVisible(
|
||||
_entryData && !_entryData->ActionIsSupportedByToken());
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::StreamTitleChanged()
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
|
|
@ -529,14 +560,6 @@ void MacroActionTwitchEdit::AnnouncementColorChanged(int index)
|
|||
static_cast<MacroActionTwitch::AnnouncementColor>(index);
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::CheckTokenPermissions()
|
||||
{
|
||||
_tokenPermissionWarning->setVisible(
|
||||
_entryData && !_entryData->ActionIsSupportedByToken());
|
||||
adjustSize();
|
||||
updateGeometry();
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::SetupWidgetVisibility()
|
||||
{
|
||||
_streamTitle->setVisible(_entryData->_action ==
|
||||
|
|
@ -598,27 +621,9 @@ void MacroActionTwitchEdit::UpdateEntryData()
|
|||
_announcementMessage->setPlainText(_entryData->_announcementMessage);
|
||||
_announcementColor->setCurrentIndex(
|
||||
static_cast<int>(_entryData->_announcementColor));
|
||||
|
||||
_channel->SetToken(_entryData->_token);
|
||||
_channel->SetChannel(_entryData->_channel);
|
||||
SetupWidgetVisibility();
|
||||
}
|
||||
|
||||
void MacroActionTwitchEdit::ActionChanged(int idx)
|
||||
{
|
||||
if (_loading || !_entryData) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (idx == -1) { // Reset to previous selection
|
||||
const QSignalBlocker b(_actions);
|
||||
_actions->setCurrentIndex(_actions->findData(
|
||||
static_cast<int>(_entryData->_action)));
|
||||
return;
|
||||
}
|
||||
|
||||
auto lock = LockContext();
|
||||
_entryData->_action = static_cast<MacroActionTwitch::Action>(
|
||||
_actions->itemData(idx).toInt());
|
||||
SetupWidgetVisibility();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,17 +13,12 @@ namespace advss {
|
|||
class MacroActionTwitch : public MacroAction {
|
||||
public:
|
||||
MacroActionTwitch(Macro *m) : MacroAction(m) {}
|
||||
bool PerformAction();
|
||||
void LogAction() const;
|
||||
bool Save(obs_data_t *obj) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
std::string GetShortDesc() const;
|
||||
std::string GetId() const { return id; };
|
||||
static std::shared_ptr<MacroAction> Create(Macro *m)
|
||||
{
|
||||
return std::make_shared<MacroActionTwitch>(m);
|
||||
}
|
||||
bool ActionIsSupportedByToken();
|
||||
std::string GetId() const { return id; };
|
||||
std::string GetShortDesc() const;
|
||||
|
||||
enum class Action {
|
||||
TITLE,
|
||||
|
|
@ -45,6 +40,12 @@ public:
|
|||
PURPLE,
|
||||
};
|
||||
|
||||
bool PerformAction();
|
||||
void LogAction() const;
|
||||
bool Save(obs_data_t *obj) const;
|
||||
bool Load(obs_data_t *obj);
|
||||
bool ActionIsSupportedByToken();
|
||||
|
||||
Action _action = Action::TITLE;
|
||||
std::weak_ptr<TwitchToken> _token;
|
||||
StringVariable _streamTitle =
|
||||
|
|
@ -81,7 +82,6 @@ public:
|
|||
MacroActionTwitchEdit(
|
||||
QWidget *parent,
|
||||
std::shared_ptr<MacroActionTwitch> entryData = nullptr);
|
||||
void UpdateEntryData();
|
||||
static QWidget *Create(QWidget *parent,
|
||||
std::shared_ptr<MacroAction> action)
|
||||
{
|
||||
|
|
@ -89,6 +89,7 @@ public:
|
|||
parent,
|
||||
std::dynamic_pointer_cast<MacroActionTwitch>(action));
|
||||
}
|
||||
void UpdateEntryData();
|
||||
|
||||
private slots:
|
||||
void ActionChanged(int);
|
||||
|
|
@ -112,12 +113,13 @@ protected:
|
|||
private:
|
||||
void SetupWidgetVisibility();
|
||||
|
||||
bool _loading = true;
|
||||
|
||||
QHBoxLayout *_layout;
|
||||
FilterComboBox *_actions;
|
||||
TwitchConnectionSelection *_tokens;
|
||||
QLabel *_tokenPermissionWarning;
|
||||
QTimer _tokenPermissionCheckTimer;
|
||||
|
||||
VariableLineEdit *_streamTitle;
|
||||
TwitchCategoryWidget *_category;
|
||||
VariableLineEdit *_markerDescription;
|
||||
|
|
@ -126,8 +128,6 @@ private:
|
|||
VariableTextEdit *_announcementMessage;
|
||||
QComboBox *_announcementColor;
|
||||
TwitchChannelSelection *_channel;
|
||||
|
||||
bool _loading = true;
|
||||
};
|
||||
|
||||
} // namespace advss
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user