project: remove ProjectSettings

This commit is contained in:
itsmattkc
2023-02-28 11:59:05 -08:00
parent cb9008a623
commit f12c3b01d5
18 changed files with 321 additions and 255 deletions
-1
View File
@@ -16,7 +16,6 @@
add_subdirectory(folder)
add_subdirectory(footage)
add_subdirectory(projectsettings)
add_subdirectory(sequence)
add_subdirectory(serializer)
@@ -1,22 +0,0 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2022 Olive Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
node/project/projectsettings/projectsettings.cpp
node/project/projectsettings/projectsettings.h
PARENT_SCOPE
)
@@ -1,64 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "projectsettings.h"
namespace olive {
const QString ProjectSettingsNode::kCacheSetting = QStringLiteral("cache_setting");
const QString ProjectSettingsNode::kCachePath = QStringLiteral("cache_path");
#define super Node
ProjectSettingsNode::ProjectSettingsNode()
{
AddInput(kCacheSetting, NodeValue::kCombo, 0, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
AddInput(kCachePath, NodeValue::kFile, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable));
SetInputProperty(kCachePath, QStringLiteral("directory"), true);
UpdateCachePathEnabled();
}
void ProjectSettingsNode::Retranslate()
{
super::Retranslate();
SetInputName(kCacheSetting, tr("Disk Cache Location"));
SetInputName(kCachePath, tr("Disk Cache Path"));
SetComboBoxStrings(kCacheSetting, {tr("Use Default Location"), tr("Store Alongside Project"), tr("Use Custom Location")});
SetInputProperty(kCachePath, QStringLiteral("placeholder"), tr("(default)"));
}
void ProjectSettingsNode::InputValueChangedEvent(const QString &input, int element)
{
Q_UNUSED(element)
if (input == kCacheSetting) {
UpdateCachePathEnabled();
}
}
void ProjectSettingsNode::UpdateCachePathEnabled()
{
CacheSetting setting = GetCacheSetting();
SetInputProperty(kCachePath, QStringLiteral("enabled"), (setting == kCacheCustomPath));
}
}
@@ -1,92 +0,0 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2022 Olive Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef PROJECTSETTINGSNODE_H
#define PROJECTSETTINGSNODE_H
#include "node/node.h"
namespace olive {
class ProjectSettingsNode : public Node
{
Q_OBJECT
public:
ProjectSettingsNode();
NODE_DEFAULT_FUNCTIONS(ProjectSettingsNode)
virtual QString Name() const override
{
return tr("Project Settings");
}
virtual QString id() const override
{
return QStringLiteral("org.olivevideoeditor.Olive.projectsettings");
}
virtual QVector<CategoryID> Category() const override
{
return {kCategoryProject};
}
virtual QString Description() const override
{
return tr("Settings used throughout the project.");
}
enum CacheSetting {
kCacheUseDefaultLocation,
kCacheStoreAlongsideProject,
kCacheCustomPath
};
static const QString kCacheSetting;
static const QString kCachePath;
virtual void Retranslate() override;
CacheSetting GetCacheSetting() const
{
return static_cast<CacheSetting>(GetStandardValue(kCacheSetting).toInt());
}
QString GetCustomCachePath() const
{
return GetStandardValue(kCachePath).toString();
}
void SetCustomCachePath(const QString& s)
{
SetStandardValue(kCachePath, s);
}
protected:
virtual void InputValueChangedEvent(const QString &input, int element) override;
private:
void UpdateCachePathEnabled();
};
}
#endif // PROJECTSETTINGSNODE_H
@@ -63,23 +63,27 @@ ProjectSerializer210528::LoadData ProjectSerializer210528::Load(Project *project
reader->skipCurrentElement();
} else {
Node* node;
bool handled_elsewhere = false;
if (is_root) {
node = project->root();
} else if (is_cm) {
node = project->color_manager();
} else if (is_settings) {
node = project->settings();
LoadProjectSettings(reader, project);
handled_elsewhere = true;
} else {
node = NodeFactory::CreateFromID(id);
}
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
if (!handled_elsewhere) {
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
}
}
}
} else {
@@ -253,6 +257,54 @@ void ProjectSerializer210528::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
node->LoadFinishedEvent();
}
void ProjectSerializer210528::LoadProjectSettings(QXmlStreamReader *reader, Project *project) const
{
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("input")) {
QString id;
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
id = attr.value().toString();
}
}
if (id == QStringLiteral("cache_setting") || id == QStringLiteral("cache_path")) {
QString value;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("primary")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("standard")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("track")) {
value = reader->readElementText();
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
if (id == QStringLiteral("cache_setting")) {
project->SetCacheLocationSetting(static_cast<Project::CacheSetting>(value.toInt()));
} else {
project->SetCustomCachePath(value);
}
} else {
reader->skipCurrentElement();
}
} else {
reader->skipCurrentElement();
}
}
}
void ProjectSerializer210528::LoadInput(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const
{
QString param_id;
@@ -68,6 +68,8 @@ private:
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadProjectSettings(QXmlStreamReader* reader, Project *project) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
void LoadImmediate(QXmlStreamReader *reader, Node *node, const QString& input, int element, XMLNodeData& xml_node_data) const;
@@ -63,23 +63,27 @@ ProjectSerializer210907::LoadData ProjectSerializer210907::Load(Project *project
reader->skipCurrentElement();
} else {
Node* node;
bool handled_elsewhere = false;
if (is_root) {
node = project->root();
} else if (is_cm) {
node = project->color_manager();
} else if (is_settings) {
node = project->settings();
LoadProjectSettings(reader, project);
handled_elsewhere = true;
} else {
node = NodeFactory::CreateFromID(id);
}
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
if (!handled_elsewhere) {
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
}
}
}
} else {
@@ -250,6 +254,54 @@ void ProjectSerializer210907::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
node->LoadFinishedEvent();
}
void ProjectSerializer210907::LoadProjectSettings(QXmlStreamReader *reader, Project *project) const
{
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("input")) {
QString id;
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
id = attr.value().toString();
}
}
if (id == QStringLiteral("cache_setting") || id == QStringLiteral("cache_path")) {
QString value;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("primary")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("standard")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("track")) {
value = reader->readElementText();
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
if (id == QStringLiteral("cache_setting")) {
project->SetCacheLocationSetting(static_cast<Project::CacheSetting>(value.toInt()));
} else {
project->SetCustomCachePath(value);
}
} else {
reader->skipCurrentElement();
}
} else {
reader->skipCurrentElement();
}
}
}
void ProjectSerializer210907::LoadInput(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const
{
QString param_id;
@@ -67,6 +67,8 @@ private:
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadProjectSettings(QXmlStreamReader* reader, Project *project) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
void LoadImmediate(QXmlStreamReader *reader, Node *node, const QString& input, int element, XMLNodeData& xml_node_data) const;
@@ -65,23 +65,27 @@ ProjectSerializer211228::LoadData ProjectSerializer211228::Load(Project *project
reader->skipCurrentElement();
} else {
Node* node;
bool handled_elsewhere = false;
if (is_root) {
node = project->root();
} else if (is_cm) {
node = project->color_manager();
} else if (is_settings) {
node = project->settings();
LoadProjectSettings(reader, project);
handled_elsewhere = true;
} else {
node = NodeFactory::CreateFromID(id);
}
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
if (!handled_elsewhere) {
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
LoadNode(node, xml_node_data, reader);
node->setParent(project);
}
}
}
} else {
@@ -300,6 +304,54 @@ void ProjectSerializer211228::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
node->LoadFinishedEvent();
}
void ProjectSerializer211228::LoadProjectSettings(QXmlStreamReader *reader, Project *project) const
{
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("input")) {
QString id;
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
id = attr.value().toString();
}
}
if (id == QStringLiteral("cache_setting") || id == QStringLiteral("cache_path")) {
QString value;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("primary")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("standard")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("track")) {
value = reader->readElementText();
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
if (id == QStringLiteral("cache_setting")) {
project->SetCacheLocationSetting(static_cast<Project::CacheSetting>(value.toInt()));
} else {
project->SetCustomCachePath(value);
}
} else {
reader->skipCurrentElement();
}
} else {
reader->skipCurrentElement();
}
}
}
void ProjectSerializer211228::LoadInput(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const
{
QString param_id;
@@ -68,6 +68,8 @@ private:
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadProjectSettings(QXmlStreamReader* reader, Project *project) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
void LoadImmediate(QXmlStreamReader *reader, Node *node, const QString& input, int element, XMLNodeData& xml_node_data) const;
@@ -84,30 +84,26 @@ ProjectSerializer220403::LoadData ProjectSerializer220403::Load(Project *project
reader->skipCurrentElement();
} else {
Node* node;
bool handled_elsewhere = false;
if (is_root) {
node = project->root();
} else if (is_cm) {
node = project->color_manager();
} else if (is_settings) {
node = project->settings();
LoadProjectSettings(reader, project);
handled_elsewhere = true;
} else {
node = NodeFactory::CreateFromID(id);
}
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
// Disable cache while node is being loaded (we'll re-enable it later)
node->SetCachesEnabled(false);
LoadNode(node, xml_node_data, reader);
if (project) {
node->setParent(project);
if (!handled_elsewhere) {
if (!node) {
qWarning() << "Failed to find node with ID" << id;
reader->skipCurrentElement();
} else {
load_data.nodes.append(node);
LoadNode(node, xml_node_data, reader);
node->setParent(project);
}
}
}
@@ -456,6 +452,54 @@ void ProjectSerializer220403::LoadNode(Node *node, XMLNodeData &xml_node_data, Q
node->LoadFinishedEvent();
}
void ProjectSerializer220403::LoadProjectSettings(QXmlStreamReader *reader, Project *project) const
{
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("input")) {
QString id;
XMLAttributeLoop(reader, attr) {
if (attr.name() == QStringLiteral("id")) {
id = attr.value().toString();
}
}
if (id == QStringLiteral("cache_setting") || id == QStringLiteral("cache_path")) {
QString value;
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("primary")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("standard")) {
while (XMLReadNextStartElement(reader)) {
if (reader->name() == QStringLiteral("track")) {
value = reader->readElementText();
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
} else {
reader->skipCurrentElement();
}
}
if (id == QStringLiteral("cache_setting")) {
project->SetCacheLocationSetting(static_cast<Project::CacheSetting>(value.toInt()));
} else {
project->SetCustomCachePath(value);
}
} else {
reader->skipCurrentElement();
}
} else {
reader->skipCurrentElement();
}
}
}
void ProjectSerializer220403::LoadInput(Node *node, QXmlStreamReader *reader, XMLNodeData &xml_node_data) const
{
if (dynamic_cast<NodeGroup*>(node)) {
@@ -74,6 +74,8 @@ private:
void LoadNode(Node *node, XMLNodeData &xml_node_data, QXmlStreamReader *reader) const;
void LoadProjectSettings(QXmlStreamReader* reader, Project *project) const;
void LoadInput(Node *node, QXmlStreamReader* reader, XMLNodeData &xml_node_data) const;
void LoadImmediate(QXmlStreamReader *reader, Node *node, const QString& input, int element, XMLNodeData& xml_node_data) const;