2018-03-19 01:36:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "settings/SettingsObject.h"
|
2022-07-14 20:13:23 +01:00
|
|
|
#include "tasks/Task.h"
|
|
|
|
|
2022-09-11 17:16:25 +01:00
|
|
|
/* Helpers */
|
|
|
|
enum class InstanceNameChange { ShouldChange, ShouldKeep };
|
2022-09-26 10:50:31 +01:00
|
|
|
[[nodiscard]] InstanceNameChange askForChangingInstanceName(QWidget* parent, const QString& old_name, const QString& new_name);
|
2022-10-14 18:22:13 +01:00
|
|
|
enum class ShouldUpdate { Update, SkipUpdating, Cancel };
|
|
|
|
[[nodiscard]] ShouldUpdate askIfShouldUpdate(QWidget* parent, QString original_version_name);
|
2022-09-11 17:16:25 +01:00
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
struct InstanceName {
|
|
|
|
public:
|
|
|
|
InstanceName() = default;
|
|
|
|
InstanceName(QString name, QString version) : m_original_name(std::move(name)), m_original_version(std::move(version)) {}
|
|
|
|
|
|
|
|
[[nodiscard]] QString modifiedName() const;
|
|
|
|
[[nodiscard]] QString originalName() const;
|
|
|
|
[[nodiscard]] QString name() const;
|
|
|
|
[[nodiscard]] QString version() const;
|
|
|
|
|
|
|
|
void setName(QString name) { m_modified_name = name; }
|
|
|
|
void setName(InstanceName& other);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
QString m_original_name;
|
|
|
|
QString m_original_version;
|
2018-03-19 01:36:12 +00:00
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
QString m_modified_name;
|
|
|
|
};
|
|
|
|
|
|
|
|
class InstanceTask : public Task, public InstanceName {
|
2018-03-19 01:36:12 +00:00
|
|
|
Q_OBJECT
|
2022-07-14 20:13:23 +01:00
|
|
|
public:
|
|
|
|
InstanceTask();
|
|
|
|
~InstanceTask() override = default;
|
|
|
|
|
|
|
|
void setParentSettings(SettingsObjectPtr settings) { m_globalSettings = settings; }
|
|
|
|
|
|
|
|
void setStagingPath(const QString& stagingPath) { m_stagingPath = stagingPath; }
|
|
|
|
|
|
|
|
void setIcon(const QString& icon) { m_instIcon = icon; }
|
|
|
|
|
|
|
|
void setGroup(const QString& group) { m_instGroup = group; }
|
|
|
|
QString group() const { return m_instGroup; }
|
2018-03-19 01:36:12 +00:00
|
|
|
|
2022-10-14 18:23:55 +01:00
|
|
|
[[nodiscard]] bool shouldConfirmUpdate() const { return m_confirm_update; }
|
|
|
|
void setConfirmUpdate(bool confirm) { m_confirm_update = confirm; }
|
|
|
|
|
2022-07-08 17:00:44 +01:00
|
|
|
bool shouldOverride() const { return m_override_existing; }
|
|
|
|
|
2022-12-03 13:15:38 +00:00
|
|
|
[[nodiscard]] QString originalInstanceID() const { return m_original_instance_id; };
|
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
protected:
|
2022-12-03 13:15:38 +00:00
|
|
|
void setOverride(bool override, QString instance_id_to_override = {})
|
|
|
|
{
|
|
|
|
m_override_existing = override;
|
|
|
|
if (!instance_id_to_override.isEmpty())
|
|
|
|
m_original_instance_id = instance_id_to_override;
|
|
|
|
}
|
2022-07-08 17:00:44 +01:00
|
|
|
|
2022-07-14 20:13:23 +01:00
|
|
|
protected: /* data */
|
2018-03-19 01:36:12 +00:00
|
|
|
SettingsObjectPtr m_globalSettings;
|
|
|
|
QString m_instIcon;
|
|
|
|
QString m_instGroup;
|
|
|
|
QString m_stagingPath;
|
2022-07-08 17:00:44 +01:00
|
|
|
|
|
|
|
bool m_override_existing = false;
|
2022-10-14 18:23:55 +01:00
|
|
|
bool m_confirm_update = true;
|
2022-12-03 13:15:38 +00:00
|
|
|
|
|
|
|
QString m_original_instance_id;
|
2018-03-19 01:36:12 +00:00
|
|
|
};
|