* Minor style changes
* Move function definitions
* Split utility.hpp
* Enable include of export-symbol-helper.hpp in tests
This commit is contained in:
Przemek Pawlas
2024-02-22 23:38:49 +01:00
committed by WarmUpTill
parent dcba7c535d
commit 01cf000cbe
22 changed files with 125 additions and 81 deletions

View File

@@ -1,12 +1,6 @@
#include "utility.hpp"
#include "obs-module-helper.hpp"
#include "obs.hpp"
#include <nlohmann/json.hpp>
#include <obs-frontend-api.h>
#include <QDateTime>
#include <QFile>
#include <QStandardPaths>
#include <sstream>
namespace advss {
@@ -17,11 +11,6 @@ std::pair<int, int> GetCursorPos()
return {cursorPos.x(), cursorPos.y()};
}
bool DoubleEquals(double left, double right, double epsilon)
{
return (fabs(left - right) < epsilon);
}
bool ReplaceAll(std::string &str, const std::string &from,
const std::string &to)
{
@@ -85,51 +74,11 @@ std::string ToString(double value)
return stream.str();
}
std::string GetDataFilePath(const std::string &file)
{
std::string root_path = obs_get_module_data_path(obs_current_module());
if (!root_path.empty()) {
return root_path + "/" + file;
}
return "";
}
QString GetDefaultSettingsSaveLocation()
{
QString desktopPath = QStandardPaths::writableLocation(
QStandardPaths::DesktopLocation);
auto scName = obs_frontend_get_current_scene_collection();
QString sceneCollectionName(scName);
bfree(scName);
auto timestamp = QDateTime::currentDateTime();
auto path = desktopPath + "/adv-ss-" + sceneCollectionName + "-" +
timestamp.toString("yyyy.MM.dd.hh.mm.ss");
// Check if scene collection name contains invalid path characters
QFile file(path);
if (file.exists()) {
return path;
}
bool validPath = file.open(QIODevice::WriteOnly);
if (validPath) {
file.remove();
return path;
}
return desktopPath + "/adv-ss-" +
timestamp.toString("yyyy.MM.dd.hh.mm.ss");
}
void listAddClicked(QListWidget *list, QWidget *newWidget,
QPushButton *addButton,
QMetaObject::Connection *addHighlight)
{
if (!list || !newWidget) {
blog(LOG_WARNING,
"listAddClicked called without valid list or widget");
return;
}