mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Use more const refs where applicable
This commit is contained in:
parent
5eb8378612
commit
c2d2a27d44
|
|
@ -618,7 +618,7 @@ bool SwitcherData::checkForMatch(OBSWeakSource &scene,
|
|||
return match;
|
||||
}
|
||||
|
||||
void switchScene(sceneSwitchInfo sceneSwitch)
|
||||
void switchScene(const sceneSwitchInfo &sceneSwitch)
|
||||
{
|
||||
if (!sceneSwitch.scene && switcher->verbose) {
|
||||
blog(LOG_INFO, "nothing to switch to");
|
||||
|
|
|
|||
|
|
@ -286,8 +286,8 @@ private:
|
|||
void GetWindowList(std::vector<std::string> &windows);
|
||||
void GetWindowList(QStringList &windows);
|
||||
void GetCurrentWindowTitle(std::string &title);
|
||||
bool isFullscreen(std::string &title);
|
||||
bool isMaximized(std::string &title);
|
||||
bool isFullscreen(const std::string &title);
|
||||
bool isMaximized(const std::string &title);
|
||||
|
||||
/******************************************************************************
|
||||
* Screenregion helper
|
||||
|
|
@ -309,11 +309,12 @@ bool isInFocus(const QString &executable);
|
|||
* Sceneswitch helper
|
||||
******************************************************************************/
|
||||
|
||||
void setNextTransition(sceneSwitchInfo &ssi, obs_source_t *currentSource,
|
||||
void setNextTransition(const sceneSwitchInfo &ssi, obs_source_t *currentSource,
|
||||
transitionData &td);
|
||||
void overwriteTransitionOverride(sceneSwitchInfo ssi, transitionData &td);
|
||||
void restoreTransitionOverride(obs_source_t *scene, transitionData td);
|
||||
void switchScene(sceneSwitchInfo ssi);
|
||||
void overwriteTransitionOverride(const sceneSwitchInfo &ssi,
|
||||
transitionData &td);
|
||||
void restoreTransitionOverride(obs_source_t *scene, const transitionData &td);
|
||||
void switchScene(const sceneSwitchInfo &ssi);
|
||||
|
||||
/******************************************************************************
|
||||
* Main SwitcherData
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ struct MacroActionInfo {
|
|||
class MacroActionFactory {
|
||||
public:
|
||||
MacroActionFactory() = delete;
|
||||
static bool Register(std::string id, MacroActionInfo);
|
||||
static std::shared_ptr<MacroAction> Create(const std::string id);
|
||||
static QWidget *CreateWidget(const std::string id, QWidget *parent,
|
||||
static bool Register(const std::string &id, MacroActionInfo);
|
||||
static std::shared_ptr<MacroAction> Create(const std::string &id);
|
||||
static QWidget *CreateWidget(const std::string &id, QWidget *parent,
|
||||
std::shared_ptr<MacroAction> action);
|
||||
static auto GetActionTypes() { return _methods; }
|
||||
static std::string GetActionName(const std::string id);
|
||||
static std::string GetActionName(const std::string &id);
|
||||
static std::string GetIdByName(const QString &name);
|
||||
|
||||
private:
|
||||
|
|
@ -38,9 +38,9 @@ class MacroActionEdit : public QWidget {
|
|||
public:
|
||||
MacroActionEdit(QWidget *parent = nullptr,
|
||||
std::shared_ptr<MacroAction> * = nullptr,
|
||||
std::string id = "scene_switch",
|
||||
const std::string &id = "scene_switch",
|
||||
bool startCollapsed = false);
|
||||
void UpdateEntryData(std::string id);
|
||||
void UpdateEntryData(const std::string &id);
|
||||
void Collapse(bool collapsed);
|
||||
|
||||
private slots:
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class MacroConditionFactory {
|
|||
public:
|
||||
MacroConditionFactory() = delete;
|
||||
static bool Register(const std::string &, MacroConditionInfo);
|
||||
static std::shared_ptr<MacroCondition> Create(const std::string);
|
||||
static std::shared_ptr<MacroCondition> Create(const std::string &);
|
||||
static QWidget *CreateWidget(const std::string &id, QWidget *parent,
|
||||
std::shared_ptr<MacroCondition>);
|
||||
static auto GetConditionTypes() { return _methods; }
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public:
|
|||
bool PerformAction();
|
||||
bool Matched() { return _matched; }
|
||||
std::string Name() { return _name; }
|
||||
void SetName(std::string name) { _name = name; }
|
||||
void SetName(const std::string &name) { _name = name; }
|
||||
void SetPaused(bool pause = true) { _paused = pause; }
|
||||
bool Paused() { return _paused; }
|
||||
std::deque<std::shared_ptr<MacroCondition>> &Conditions()
|
||||
|
|
|
|||
|
|
@ -40,9 +40,9 @@ struct SceneGroup {
|
|||
int lastRandomScene = -1;
|
||||
|
||||
inline SceneGroup(){};
|
||||
inline SceneGroup(std::string name_) : name(name_){};
|
||||
inline SceneGroup(std::string name_, AdvanceCondition type_,
|
||||
std::vector<OBSWeakSource> scenes_, int count_,
|
||||
inline SceneGroup(const std::string &name_) : name(name_){};
|
||||
inline SceneGroup(const std::string &name_, AdvanceCondition type_,
|
||||
const std::vector<OBSWeakSource> &scenes_, int count_,
|
||||
double time_, bool repeat_)
|
||||
: name(name_),
|
||||
type(type_),
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ struct SwitcherData {
|
|||
void resetTabOrder();
|
||||
|
||||
void writeSceneInfoToFile();
|
||||
void writeToStatusFile(QString status);
|
||||
void writeToStatusFile(const QString &msg);
|
||||
|
||||
bool checkForMatch(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
int &linger, bool &setPreviousSceneAsMatch,
|
||||
|
|
@ -254,7 +254,7 @@ struct SwitcherData {
|
|||
void saveNetworkSwitches(obs_data_t *obj);
|
||||
void saveGeneralSettings(obs_data_t *obj);
|
||||
void saveHotkeys(obs_data_t *obj);
|
||||
void saveVersion(obs_data_t *obj, std::string currentVersion);
|
||||
void saveVersion(obs_data_t *obj, const std::string ¤tVersion);
|
||||
|
||||
void loadSettings(obs_data_t *obj);
|
||||
void loadMacros(obs_data_t *obj);
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static inline OBSWeakSource GetWeakFilterByQString(OBSWeakSource source,
|
|||
}
|
||||
|
||||
static inline std::string
|
||||
getNextDelim(std::string text,
|
||||
getNextDelim(const std::string &text,
|
||||
std::unordered_map<std::string, QWidget *> placeholders)
|
||||
{
|
||||
size_t pos = std::string::npos;
|
||||
|
|
@ -214,7 +214,7 @@ static inline bool compareIgnoringLineEnding(QString &s1, QString &s2)
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline bool DisplayMessage(QString msg, bool question = false)
|
||||
static inline bool DisplayMessage(const QString &msg, bool question = false)
|
||||
{
|
||||
if (question) {
|
||||
QMessageBox::StandardButton reply;
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ std::pair<int, int> getCursorPos()
|
|||
return pos;
|
||||
}
|
||||
|
||||
bool isMaximized(std::string &title)
|
||||
bool isMaximized(const std::string &title)
|
||||
{
|
||||
if (!ewmhIsSupported())
|
||||
return false;
|
||||
|
|
@ -302,7 +302,7 @@ bool isMaximized(std::string &title)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool isFullscreen(std::string &title)
|
||||
bool isFullscreen(const std::string &title)
|
||||
{
|
||||
if (!ewmhIsSupported())
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
std::map<std::string, MacroActionInfo> MacroActionFactory::_methods;
|
||||
|
||||
bool MacroActionFactory::Register(std::string id, MacroActionInfo info)
|
||||
bool MacroActionFactory::Register(const std::string &id, MacroActionInfo info)
|
||||
{
|
||||
if (auto it = _methods.find(id); it == _methods.end()) {
|
||||
_methods[id] = info;
|
||||
|
|
@ -14,7 +14,7 @@ bool MacroActionFactory::Register(std::string id, MacroActionInfo info)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::shared_ptr<MacroAction> MacroActionFactory::Create(const std::string id)
|
||||
std::shared_ptr<MacroAction> MacroActionFactory::Create(const std::string &id)
|
||||
{
|
||||
if (auto it = _methods.find(id); it != _methods.end())
|
||||
return it->second._createFunc();
|
||||
|
|
@ -22,7 +22,8 @@ std::shared_ptr<MacroAction> MacroActionFactory::Create(const std::string id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
QWidget *MacroActionFactory::CreateWidget(const std::string id, QWidget *parent,
|
||||
QWidget *MacroActionFactory::CreateWidget(const std::string &id,
|
||||
QWidget *parent,
|
||||
std::shared_ptr<MacroAction> action)
|
||||
{
|
||||
if (auto it = _methods.find(id); it != _methods.end())
|
||||
|
|
@ -31,7 +32,7 @@ QWidget *MacroActionFactory::CreateWidget(const std::string id, QWidget *parent,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::string MacroActionFactory::GetActionName(const std::string id)
|
||||
std::string MacroActionFactory::GetActionName(const std::string &id)
|
||||
{
|
||||
if (auto it = _methods.find(id); it != _methods.end()) {
|
||||
return it->second._name;
|
||||
|
|
@ -58,7 +59,7 @@ static inline void populateActionSelection(QComboBox *list)
|
|||
|
||||
MacroActionEdit::MacroActionEdit(QWidget *parent,
|
||||
std::shared_ptr<MacroAction> *entryData,
|
||||
std::string id, bool startCollapsed)
|
||||
const std::string &id, bool startCollapsed)
|
||||
: QWidget(parent)
|
||||
{
|
||||
_actionSelection = new QComboBox();
|
||||
|
|
@ -100,7 +101,7 @@ void MacroActionEdit::ActionSelectionChanged(const QString &text)
|
|||
_section->Collapse(false);
|
||||
}
|
||||
|
||||
void MacroActionEdit::UpdateEntryData(std::string id)
|
||||
void MacroActionEdit::UpdateEntryData(const std::string &id)
|
||||
{
|
||||
_actionSelection->setCurrentText(
|
||||
obs_module_text(MacroActionFactory::GetActionName(id).c_str()));
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ bool MacroConditionFactory::Register(const std::string &id,
|
|||
}
|
||||
|
||||
std::shared_ptr<MacroCondition>
|
||||
MacroConditionFactory::Create(const std::string id)
|
||||
MacroConditionFactory::Create(const std::string &id)
|
||||
{
|
||||
if (auto it = _methods.find(id); it != _methods.end())
|
||||
return it->second._createFunc();
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ bool nameMachesPattern(std::string windowName, std::string pattern)
|
|||
.contains(QRegularExpression(QString::fromStdString(pattern)));
|
||||
}
|
||||
|
||||
bool isMaximized(std::string &title)
|
||||
bool isMaximized(const std::string &title)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSArray *screens = [NSScreen screens];
|
||||
|
|
@ -204,7 +204,7 @@ bool isWindowFullscreenOnScreen(NSDictionary *app, NSScreen *screen)
|
|||
return NSEqualSizes(windowBounds.size, screenFrame.size);
|
||||
}
|
||||
|
||||
bool isFullscreen(std::string &title)
|
||||
bool isFullscreen(const std::string &title)
|
||||
{
|
||||
@autoreleasepool {
|
||||
NSArray *screens = [NSScreen screens];
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ void SwitcherData::writeSceneInfoToFile()
|
|||
obs_source_release(currentSource);
|
||||
}
|
||||
|
||||
void SwitcherData::writeToStatusFile(QString msg)
|
||||
void SwitcherData::writeToStatusFile(const QString &msg)
|
||||
{
|
||||
if (!fileIO.writeEnabled || fileIO.writePath.empty()) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ std::pair<obs_weak_source_t *, int> getNextTransition(obs_weak_source_t *scene1,
|
|||
return std::make_pair(ws, duration);
|
||||
}
|
||||
|
||||
void overwriteTransitionOverride(sceneSwitchInfo ssi, transitionData &td)
|
||||
void overwriteTransitionOverride(const sceneSwitchInfo &ssi, transitionData &td)
|
||||
{
|
||||
obs_source_t *scene = obs_weak_source_get_source(ssi.scene);
|
||||
obs_data_t *data = obs_source_get_private_settings(scene);
|
||||
|
|
@ -257,7 +257,7 @@ void overwriteTransitionOverride(sceneSwitchInfo ssi, transitionData &td)
|
|||
obs_source_release(scene);
|
||||
}
|
||||
|
||||
void restoreTransitionOverride(obs_source_t *scene, transitionData td)
|
||||
void restoreTransitionOverride(obs_source_t *scene, const transitionData &td)
|
||||
{
|
||||
obs_data_t *data = obs_source_get_private_settings(scene);
|
||||
|
||||
|
|
@ -267,7 +267,7 @@ void restoreTransitionOverride(obs_source_t *scene, transitionData td)
|
|||
obs_data_release(data);
|
||||
}
|
||||
|
||||
void setNextTransition(sceneSwitchInfo &sceneSwitch,
|
||||
void setNextTransition(const sceneSwitchInfo &sceneSwitch,
|
||||
obs_source_t *currentSource, transitionData &td)
|
||||
{
|
||||
// Priority:
|
||||
|
|
|
|||
|
|
@ -124,7 +124,8 @@ bool SwitcherData::versionChanged(obs_data_t *obj, std::string currentVersion)
|
|||
return previousVersion != currentVersion;
|
||||
}
|
||||
|
||||
void SwitcherData::saveVersion(obs_data_t *obj, std::string currentVersion)
|
||||
void SwitcherData::saveVersion(obs_data_t *obj,
|
||||
const std::string ¤tVersion)
|
||||
{
|
||||
obs_data_set_string(obj, "version", currentVersion.c_str());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ HWND getHWNDfromTitle(std::string title)
|
|||
return hwnd;
|
||||
}
|
||||
|
||||
bool isMaximized(std::string &title)
|
||||
bool isMaximized(const std::string &title)
|
||||
{
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
|
|
@ -172,7 +172,7 @@ bool isMaximized(std::string &title)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool isFullscreen(std::string &title)
|
||||
bool isFullscreen(const std::string &title)
|
||||
{
|
||||
RECT appBounds;
|
||||
MONITORINFO monitorInfo = {0};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user