Limo
A simple mod manager
Loading...
Searching...
No Matches
addmoddialog.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "ui/fomoddialog.h"
9#include <QButtonGroup>
10#include <QCompleter>
11#include <QDialog>
12#include <QFrame>
13#include <QTreeWidgetItem>
14#include <QVBoxLayout>
15#include <filesystem>
16
17
18namespace Ui
19{
20class AddModDialog;
21}
22
26class AddModDialog : public QDialog
27{
28 Q_OBJECT
29
30public:
35 explicit AddModDialog(QWidget* parent = nullptr);
38
60 bool setupDialog(const QString& name,
61 const QStringList& deployers,
62 int cur_deployer,
63 const QStringList& groups,
64 const std::vector<int>& mod_ids,
65 const QString& path,
66 const QStringList& deployer_paths,
67 int app_id,
68 const std::vector<bool>& autonomous_deployers,
69 const QString& app_version,
70 const QString& local_source,
71 const QString& remote_source,
72 int mod_id,
73 const QStringList& mod_names,
74 const QStringList& mod_versions,
75 const QString& version_overwrite,
76 const QString& name_overwrite);
81 void closeEvent(QCloseEvent* event) override;
83 void reject() override;
84
85private:
87 Ui::AddModDialog* ui;
89 std::vector<int> mod_ids_;
91 QString mod_path_;
95 QList<QButtonGroup*> option_groups_;
97 const QColor COLOR_KEEP_{ 0x2ca02c };
99 const QColor COLOR_REMOVE_{ 0xd62728 };
101 QStringList deployer_paths_;
105 QStringList groups_;
107 std::unique_ptr<QCompleter> completer_;
109 std::unique_ptr<FomodDialog> fomod_dialog_;
111 static constexpr int ADD_TO_GROUP_INDEX = 0;
113 static constexpr int REPLACE_MOD_INDEX = 1;
121 bool dialog_completed_ = false;
122
128 void updateOkButton();
135 int addTreeNode(QTreeWidget* tree, const std::filesystem::path& cur_path);
143 int addTreeNode(QTreeWidgetItem* parent, const std::filesystem::path& cur_path);
150 std::filesystem::path removeRoot(const std::filesystem::path& source);
158 void colorTreeNodes(QTreeWidgetItem* node, int cur_depth, int root_level);
163 void showError(const std::runtime_error& error);
164
165private slots:
169 void on_group_check_stateChanged(int state);
173 void on_name_text_textChanged(const QString& text);
175 void on_version_text_textChanged(const QString& text);
180 void on_root_level_box_valueChanged(int value);
190 void on_group_field_textChanged(const QString& arg1);
201 void onFomodDialogComplete(int app_id, AddModInfo info);
204
205signals:
211 void addModAccepted(int app_id, AddModInfo info);
216 void addModAborted(QString temp_dir);
217};
void on_installer_box_currentIndexChanged(int index)
Enables/ disables ui elements based on chosen installer.
Definition addmoddialog.cpp:424
bool setupDialog(const QString &name, const QStringList &deployers, int cur_deployer, const QStringList &groups, const std::vector< int > &mod_ids, const QString &path, const QStringList &deployer_paths, int app_id, const std::vector< bool > &autonomous_deployers, const QString &app_version, const QString &local_source, const QString &remote_source, int mod_id, const QStringList &mod_names, const QStringList &mod_versions, const QString &version_overwrite, const QString &name_overwrite)
Initializes this dialog with data needed for mod installation.
Definition addmoddialog.cpp:89
QStringList groups_
Contains names of all available groups.
Definition addmoddialog.h:105
AddModDialog(QWidget *parent=nullptr)
Initializes the UI.
Definition addmoddialog.cpp:21
void on_root_level_box_valueChanged(int value)
Called when the value of the root level box has been changed by a user.
Definition addmoddialog.cpp:418
std::unique_ptr< FomodDialog > fomod_dialog_
Dialog for fomod installation.
Definition addmoddialog.h:109
~AddModDialog()
Deletes the UI.
Definition addmoddialog.cpp:60
QString mod_path_
Source path for the new mod data.
Definition addmoddialog.h:91
void addModAccepted(int app_id, AddModInfo info)
Signals dialog completion.
void updateOkButton()
Updates the enabled state of this dialog's OK button to only be enabled when both a name and a versio...
Definition addmoddialog.cpp:65
void showError(const std::runtime_error &error)
Shows a message box with a message constructed from given exception.
Definition addmoddialog.cpp:80
Ui::AddModDialog * ui
Contains auto-generated UI elements.
Definition addmoddialog.h:87
std::unique_ptr< QCompleter > completer_
Completer used for group names.
Definition addmoddialog.h:107
void on_group_field_textChanged(const QString &arg1)
Updates the Ok buttons enabled state.
Definition addmoddialog.cpp:441
const QColor COLOR_REMOVE_
Used to color tree nodes which will be removed.
Definition addmoddialog.h:99
QList< QButtonGroup * > option_groups_
Holds radio button groups used to select installation options.
Definition addmoddialog.h:95
void reject() override
Closes the dialog and emits a signal indicating installation has been canceled.
Definition addmoddialog.cpp:273
void onFomodDialogAborted()
Called when fomod dialog has been canceled. Emits addModAborted.
Definition addmoddialog.cpp:457
QString remote_source_
URL from where the mod was downloaded.
Definition addmoddialog.h:119
std::vector< int > mod_ids_
Contains mod ids corresponding to entries in the field.
Definition addmoddialog.h:89
bool dialog_completed_
Indicates whether the dialog has been completed.
Definition addmoddialog.h:121
void on_buttonBox_accepted()
Closes the dialog and emits a signal for completion.
Definition addmoddialog.cpp:329
int app_id_
Stores the id of the currently active application.
Definition addmoddialog.h:93
QString local_source_
Path to the source archive for the mod.
Definition addmoddialog.h:117
void on_group_check_stateChanged(int state)
Enables or disables the group combo box depending on the check box state.
Definition addmoddialog.cpp:391
void on_name_text_textChanged(const QString &text)
Only enable the OK button if a name has been entered.
Definition addmoddialog.cpp:408
void closeEvent(QCloseEvent *event) override
Closes the dialog and emits a signal indicating installation has been canceled.
Definition addmoddialog.cpp:264
int addTreeNode(QTreeWidgetItem *parent, const std::filesystem::path &cur_path)
Adds the root path element of given path as a root node to the given parent node. Then adds all subse...
void on_version_text_textChanged(const QString &text)
Only enable the OK button if a version has been entered.
Definition addmoddialog.cpp:413
void addModAborted(QString temp_dir)
Signals mod installation has been aborted.
QString app_version_
App version used for fomod conditions.
Definition addmoddialog.h:115
QStringList deployer_paths_
Contains target paths for all deployers.
Definition addmoddialog.h:101
void onFomodDialogComplete(int app_id, AddModInfo info)
Called when the fomod dialog has been completed. Emits addModAccepted.
Definition addmoddialog.cpp:452
static constexpr int REPLACE_MOD_INDEX
Index in ui->group_combo_box representing the option of replacing an existing mod.
Definition addmoddialog.h:113
int addTreeNode(QTreeWidget *tree, const std::filesystem::path &cur_path)
Adds the root path element of given path as a root node to the given tree. Then adds all subsequent p...
void on_buttonBox_rejected()
Closes the dialog and emits a signal indicating installation has been canceled.
Definition addmoddialog.cpp:400
void colorTreeNodes(QTreeWidgetItem *node, int cur_depth, int root_level)
Changes the color of the given node and its children, depending on whether or not the nodes depth is ...
Definition addmoddialog.cpp:72
static constexpr int ADD_TO_GROUP_INDEX
Index in ui->group_combo_box representing the option of adding a mod to a group.
Definition addmoddialog.h:111
const QColor COLOR_KEEP_
Used to color tree nodes which will not be removed.
Definition addmoddialog.h:97
std::filesystem::path removeRoot(const std::filesystem::path &source)
Removes the root path component from the given path.
Definition addmoddialog.cpp:282
void on_group_combo_box_currentIndexChanged(int index)
Disables the deployer list if the new mod is to replace an existing mod.
Definition addmoddialog.cpp:446
QString path_prefix_
Prefix for fomod installer source path.
Definition addmoddialog.h:103
char path[256]
Path to which to extract the file.
Definition lspakfilelistentry.h:1
Stores data needed to install a new mod.
Definition addmodinfo.h:17