Limo
A simple mod manager
Loading...
Searching...
No Matches
addappdialog.h
Go to the documentation of this file.
1
5
6#pragma once
7
11#include <QDialog>
12#include <json/json.h>
13
14
15namespace Ui
16{
17class AddAppDialog;
18}
19
23class AddAppDialog : public QDialog
24{
25 Q_OBJECT
26
27public:
32 explicit AddAppDialog(bool is_flatpak, QWidget* parent = nullptr);
35
36private:
38 Ui::AddAppDialog* ui;
39
41 constexpr static inline std::string JSON_DEPLOYERS_GROUP = "deployers";
43 constexpr static inline std::string JSON_DEPLOYERS_TYPE = "type";
45 constexpr static inline std::string JSON_DEPLOYERS_NAME = "name";
47 constexpr static inline std::string JSON_DEPLOYERS_TARGET = "target_dir";
49 constexpr static inline std::string JSON_DEPLOYERS_MODE = "deploy_mode";
51 constexpr static inline std::string JSON_DEPLOYERS_SOURCE = "source_dir";
56 constexpr static inline char JSON_DEPLOYERS_SEPARATE_DIRS[] = "uses_separate_dirs";
61 constexpr static inline char JSON_DEPLOYERS_UPDATE_IGNORE_LIST[] = "update_ignore_list";
67
68 constexpr static inline std::string JSON_AUTO_TAGS_GROUP = "auto_tags";
70 constexpr static inline std::string JSON_NAME = "name";
71
73 bool edit_mode_ = false;
75 QString name_;
77 QString path_;
79 QString command_;
83 QString steam_install_path_ = "";
85 QString steam_prefix_path_ = "";
87 bool dialog_completed_ = false;
89 std::vector<EditDeployerInfo> deployers_;
91 std::vector<Json::Value> auto_tags_;
95 std::unique_ptr<ImportFromSteamDialog> import_from_steam_dialog_;
96
101 void enableOkButton(bool state);
103 bool pathIsValid();
108 bool iconIsValid(const QString& path = "");
113 void initConfigForApp();
119
120public:
131 void setEditMode(const QString& name,
132 const QString& app_version,
133 const QString& path,
134 const QString& command,
135 const QString& icon_path,
136 int app_id);
141 void setAddMode();
142
143private slots:
147 void on_name_field_textChanged(const QString& text);
149 void on_path_field_textChanged(const QString& text);
163 void onApplicationImported(QString name,
164 QString app_id,
165 QString install_dir,
166 QString prefix_path,
167 QString icon_path);
172 void onFileDialogAccepted(const QString& path);
179 void onIconPathDialogComplete(const QString& path);
180
181signals:
192 void applicationEdited(EditApplicationInfo edit_app_info, int app_id);
193};
AddAppDialog(bool is_flatpak, QWidget *parent=nullptr)
Initializes the UI.
Definition addappdialog.cpp:21
void on_buttonBox_accepted()
Closes the dialog and emits a signal for completion.
Definition addappdialog.cpp:360
static constexpr std::array< std::string, 4 > JSON_DEPLOYER_MANDATORY_KEYS
Contains all mandatory valid keys used in a deployer group in the apps config file.
Definition addappdialog.h:63
static constexpr std::string JSON_DEPLOYERS_TYPE
Name of the key used to identify deployer type in the apps config file.
Definition addappdialog.h:43
void on_name_field_textChanged(const QString &text)
Only enable the OK button if a name has been entered.
Definition addappdialog.cpp:57
void on_import_button_clicked()
Opens a dialog to import currently installed steam app.
Definition addappdialog.cpp:386
Ui::AddAppDialog * ui
Contains auto-generated UI elements.
Definition addappdialog.h:38
void initConfigForApp()
Initializes default settings for deployers and auto tags from a file named "app_id_....
Definition addappdialog.cpp:105
static constexpr char JSON_DEPLOYERS_UPDATE_IGNORE_LIST[]
Name of the key used to determine whether a reverse deployer should update the ignore list upon creat...
Definition addappdialog.h:61
void applicationAdded(EditApplicationInfo edit_app_info)
Signals completion of the dialog in add mode.
static constexpr std::string JSON_DEPLOYERS_NAME
Name of the key used to identify deployer name in the apps config file.
Definition addappdialog.h:45
bool edit_mode_
If true: Dialog is used to edit, else: Dialog is used to create.
Definition addappdialog.h:73
static constexpr std::string JSON_DEPLOYERS_GROUP
Name of the key used to identify deployers in the apps config file.
Definition addappdialog.h:41
static constexpr std::string JSON_DEPLOYERS_TARGET
Name of the key used to identify deployer target dir in the apps config file.
Definition addappdialog.h:47
void initDefaultAppConfig()
Initializes deployers targeting the currently selected steam app's installation and,...
Definition addappdialog.cpp:283
std::unique_ptr< ImportFromSteamDialog > import_from_steam_dialog_
Reusable dialog for importing data from installed Steam apps.
Definition addappdialog.h:95
bool iconIsValid(const QString &path="")
Checks whether the currently entered icon path refers to a valid icon file.
Definition addappdialog.cpp:99
bool pathIsValid()
Checks whether the currently entered path exists.
Definition addappdialog.cpp:91
static constexpr std::string JSON_DEPLOYERS_MODE
Name of the key used to identify deployer mode in the apps config file.
Definition addappdialog.h:49
std::vector< Json::Value > auto_tags_
Contains Json objects representing imported auto tags.
Definition addappdialog.h:91
static constexpr char JSON_DEPLOYERS_SEPARATE_DIRS[]
Name of the key used to determine whether a reverse deployer uses separate dirctories for profiles.
Definition addappdialog.h:56
void enableOkButton(bool state)
Set the enabled state of this dialogs OK button.
Definition addappdialog.cpp:86
QString command_
Current command to run the edited application.
Definition addappdialog.h:79
void on_file_picker_button_clicked()
Shows a file dialog for the staging directory path.
Definition addappdialog.cpp:43
void onFileDialogAccepted(const QString &path)
Updates the staging directory path to given path.
Definition addappdialog.cpp:410
QString name_
Current name of the edited application.
Definition addappdialog.h:75
void on_path_field_textChanged(const QString &text)
Only enable the OK button if a valid staging directory path has been entered.
Definition addappdialog.cpp:65
QString path_
Current staging directory path of the edited application.
Definition addappdialog.h:77
QString steam_install_path_
Path to imported steam applications installation directory.
Definition addappdialog.h:83
static constexpr std::string JSON_AUTO_TAGS_GROUP
Name of the key used to identify auto tags in the apps config file.
Definition addappdialog.h:68
void on_icon_picker_button_clicked()
Called when icon path picker button is clicked.
Definition addappdialog.cpp:416
bool dialog_completed_
Indicates whether the dialog has been completed.
Definition addappdialog.h:87
~AddAppDialog()
Deletes the UI.
Definition addappdialog.cpp:38
void setAddMode()
Initializes this dialog to allow creating a new application.
Definition addappdialog.cpp:337
void onIconPathDialogComplete(const QString &path)
Updates the icon path to the given path if the given path refers to a valid icon.
Definition addappdialog.cpp:430
static constexpr std::string JSON_NAME
Name of the key used to identify the apps name in the apps config file.
Definition addappdialog.h:70
bool is_flatpak_
Whether or not this application is running as a flatpak.
Definition addappdialog.h:93
static constexpr std::string JSON_DEPLOYERS_SOURCE
Name of the key used to identify deployer source dir in the apps config file.
Definition addappdialog.h:51
void applicationEdited(EditApplicationInfo edit_app_info, int app_id)
Signals completion of the dialog in edit mode.
int app_id_
Id of the edited application.
Definition addappdialog.h:81
void setEditMode(const QString &name, const QString &app_version, const QString &path, const QString &command, const QString &icon_path, int app_id)
Initializes this dialog to allow editing of an existing application.
Definition addappdialog.cpp:301
void onApplicationImported(QString name, QString app_id, QString install_dir, QString prefix_path, QString icon_path)
Called when the import steam application dialog has been completed.
Definition addappdialog.cpp:392
std::vector< EditDeployerInfo > deployers_
Contains deployers which will be created upon adding a new application.
Definition addappdialog.h:89
QString steam_prefix_path_
Path to imported steam applications prefix directory.
Definition addappdialog.h:85
Contains the EditApplicationInfo struct.
Contains the EditDeployerInfo struct.
Header for the ImportFromSteamDialog class.
char path[256]
Path to which to extract the file.
Definition lspakfilelistentry.h:1
Stores data needed to either create a new or edit an existing application.
Definition editapplicationinfo.h:19