mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Add change count to var tab tooltip
This commit is contained in:
parent
eec9244e4c
commit
7fa0ba3355
|
|
@ -84,7 +84,7 @@ AdvSceneSwitcher.variableTab.lastUsed.text.never="Never"
|
|||
AdvSceneSwitcher.variableTab.lastChanged.header="Last changed"
|
||||
AdvSceneSwitcher.variableTab.lastChanged.text="%1 seconds ago"
|
||||
AdvSceneSwitcher.variableTab.lastChanged.text.none="No change since launch"
|
||||
AdvSceneSwitcher.variableTab.lastChanged.tooltip="Previous value: %1"
|
||||
AdvSceneSwitcher.variableTab.lastChanged.tooltip="Times changed: %1\n\nPrevious value: %2"
|
||||
|
||||
; Macro Tab
|
||||
AdvSceneSwitcher.macroTab.title="Macro"
|
||||
|
|
|
|||
|
|
@ -85,7 +85,8 @@ static QString formatLastChangedTooltip(Variable *variable)
|
|||
|
||||
QString tooltip = obs_module_text(
|
||||
"AdvSceneSwitcher.variableTab.lastChanged.tooltip");
|
||||
return tooltip.arg(QString::fromStdString(variable->GetPreviousValue()));
|
||||
return tooltip.arg(QString::number(variable->GetValueChangeCount()))
|
||||
.arg(QString::fromStdString(variable->GetPreviousValue()));
|
||||
}
|
||||
|
||||
static void addVariableRow(QTableWidget *table, Variable *variable)
|
||||
|
|
|
|||
|
|
@ -113,10 +113,11 @@ void Variable::UpdateLastUsed() const
|
|||
_lastUsed = std::chrono::high_resolution_clock::now();
|
||||
}
|
||||
|
||||
void Variable::UpdateLastChanged() const
|
||||
void Variable::UpdateLastChanged()
|
||||
{
|
||||
if (_previousValue != _value) {
|
||||
_lastChanged = std::chrono::high_resolution_clock::now();
|
||||
++_valueChangeCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,18 @@ public:
|
|||
void SetValue(const std::string &value);
|
||||
void SetValue(double value);
|
||||
SaveAction GetSaveAction() const { return _saveAction; }
|
||||
int GetValueChangeCount() const { return _valueChangeCount; }
|
||||
std::optional<uint64_t> GetSecondsSinceLastUse() const;
|
||||
std::optional<uint64_t> GetSecondsSinceLastChange() const;
|
||||
void UpdateLastUsed() const;
|
||||
void UpdateLastChanged() const;
|
||||
void UpdateLastChanged();
|
||||
|
||||
private:
|
||||
SaveAction _saveAction = SaveAction::DONT_SAVE;
|
||||
std::string _value = "";
|
||||
std::string _previousValue = "";
|
||||
std::string _defaultValue = "";
|
||||
int _valueChangeCount = 0;
|
||||
mutable std::chrono::high_resolution_clock::time_point _lastUsed;
|
||||
mutable std::chrono::high_resolution_clock::time_point _lastChanged;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,15 +9,20 @@ TEST_CASE("Variable", "[variable]")
|
|||
REQUIRE_FALSE(variable.GetSecondsSinceLastUse());
|
||||
|
||||
REQUIRE(variable.Value() == "");
|
||||
REQUIRE(variable.GetPreviousValue() == "");
|
||||
REQUIRE(variable.GetDefaultValue() == "");
|
||||
REQUIRE(variable.GetSaveAction() ==
|
||||
advss::Variable::SaveAction::DONT_SAVE);
|
||||
REQUIRE(variable.GetValueChangeCount() == 0);
|
||||
|
||||
variable.SetValue("testing");
|
||||
REQUIRE(variable.Value() == "testing");
|
||||
REQUIRE(variable.GetPreviousValue() == "");
|
||||
REQUIRE(variable.GetValueChangeCount() == 1);
|
||||
|
||||
variable.SetValue(123);
|
||||
REQUIRE(variable.Value() == "123");
|
||||
REQUIRE(variable.GetPreviousValue() == "testing");
|
||||
|
||||
variable.SetValue(123.0);
|
||||
REQUIRE(variable.Value() == "123");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user