Limo
A simple mod manager
Loading...
Searching...
No Matches
AddModDialog Class Reference

Dialog for installing new mods. More...

#include <addmoddialog.h>

Inheritance diagram for AddModDialog:
Collaboration diagram for AddModDialog:

Signals

void addModAccepted (int app_id, AddModInfo info)
 Signals dialog completion.
 
void addModAborted (QString temp_dir)
 Signals mod installation has been aborted.
 

Public Member Functions

 AddModDialog (QWidget *parent=nullptr)
 Initializes the UI.
 
 ~AddModDialog ()
 Deletes the UI.
 
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.
 
void closeEvent (QCloseEvent *event) override
 Closes the dialog and emits a signal indicating installation has been canceled.
 
void reject () override
 Closes the dialog and emits a signal indicating installation has been canceled.
 

Private Slots

void on_buttonBox_accepted ()
 Closes the dialog and emits a signal for completion.
 
void on_group_check_stateChanged (int state)
 Enables or disables the group combo box depending on the check box state.
 
void on_buttonBox_rejected ()
 Closes the dialog and emits a signal indicating installation has been canceled.
 
void on_name_text_textChanged (const QString &text)
 Only enable the OK button if a name has been entered.
 
void on_version_text_textChanged (const QString &text)
 Only enable the OK button if a version has been entered.
 
void on_root_level_box_valueChanged (int value)
 Called when the value of the root level box has been changed by a user.
 
void on_installer_box_currentIndexChanged (int index)
 Enables/ disables ui elements based on chosen installer.
 
void on_group_field_textChanged (const QString &arg1)
 Updates the Ok buttons enabled state.
 
void on_group_combo_box_currentIndexChanged (int index)
 Disables the deployer list if the new mod is to replace an existing mod.
 
void onFomodDialogComplete (int app_id, AddModInfo info)
 Called when the fomod dialog has been completed. Emits addModAccepted.
 
void onFomodDialogAborted ()
 Called when fomod dialog has been canceled. Emits addModAborted.
 

Private Member Functions

void updateOkButton ()
 Updates the enabled state of this dialog's OK button to only be enabled when both a name and a version has been entered and an existing group or no group has been selected.
 
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 path components as children to the new node.
 
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 subsequent path components as children to the new node.
 
std::filesystem::path removeRoot (const std::filesystem::path &source)
 Removes the root path component from the given path.
 
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 less than the given root level.
 
void showError (const std::runtime_error &error)
 Shows a message box with a message constructed from given exception.
 

Private Attributes

Ui::AddModDialog * ui
 Contains auto-generated UI elements.
 
std::vector< int > mod_ids_
 Contains mod ids corresponding to entries in the field.
 
QString mod_path_
 Source path for the new mod data.
 
int app_id_
 Stores the id of the currently active application.
 
QList< QButtonGroup * > option_groups_
 Holds radio button groups used to select installation options.
 
const QColor COLOR_KEEP_ { 0x2ca02c }
 Used to color tree nodes which will not be removed.
 
const QColor COLOR_REMOVE_ { 0xd62728 }
 Used to color tree nodes which will be removed.
 
QStringList deployer_paths_
 Contains target paths for all deployers.
 
QString path_prefix_
 Prefix for fomod installer source path.
 
QStringList groups_
 Contains names of all available groups.
 
std::unique_ptr< QCompleter > completer_
 Completer used for group names.
 
std::unique_ptr< FomodDialogfomod_dialog_
 Dialog for fomod installation.
 
QString app_version_
 App version used for fomod conditions.
 
QString local_source_
 Path to the source archive for the mod.
 
QString remote_source_
 URL from where the mod was downloaded.
 
bool dialog_completed_ = false
 Indicates whether the dialog has been completed.
 

Static Private Attributes

static constexpr int ADD_TO_GROUP_INDEX = 0
 Index in ui->group_combo_box representing the option of adding a mod to a group.
 
static constexpr int REPLACE_MOD_INDEX = 1
 Index in ui->group_combo_box representing the option of replacing an existing mod.
 

Detailed Description

Dialog for installing new mods.

Constructor & Destructor Documentation

◆ AddModDialog()

AddModDialog::AddModDialog ( QWidget * parent = nullptr)
explicit

Initializes the UI.

Parameters
parentParent for this widget, this is passed to the constructor of QDialog.

Member Function Documentation

◆ addModAborted

void AddModDialog::addModAborted ( QString temp_dir)
signal

Signals mod installation has been aborted.

Parameters
temp_dirDirectory used for mod extraction.

◆ addModAccepted

void AddModDialog::addModAccepted ( int app_id,
AddModInfo info )
signal

Signals dialog completion.

Parameters
app_idApplication for which the new mod is to be installed.
infoContains all data needed to install the mod.

◆ addTreeNode() [1/2]

int AddModDialog::addTreeNode ( QTreeWidget * tree,
const std::filesystem::path & cur_path )
private

Adds the root path element of given path as a root node to the given tree. Then adds all subsequent path components as children to the new node.

Parameters
treeTarget QTreeWidget.
cur_pathSource path.

◆ addTreeNode() [2/2]

int AddModDialog::addTreeNode ( QTreeWidgetItem * parent,
const std::filesystem::path & cur_path )
private

Adds the root path element of given path as a root node to the given parent node. Then adds all subsequent path components as children to the new node.

Parameters
treeTarget QTreeWidget.
cur_pathSource path.
Returns
The depth of the given path.

◆ closeEvent()

void AddModDialog::closeEvent ( QCloseEvent * event)
override

Closes the dialog and emits a signal indicating installation has been canceled.

Parameters
eventThe close even sent upon closing the dialog.

◆ colorTreeNodes()

void AddModDialog::colorTreeNodes ( QTreeWidgetItem * node,
int cur_depth,
int root_level )
private

Changes the color of the given node and its children, depending on whether or not the nodes depth is less than the given root level.

Parameters
nodeNode to be colored.
cur_depthDepth of current node.
root_levelTarget depth.

◆ on_group_combo_box_currentIndexChanged

void AddModDialog::on_group_combo_box_currentIndexChanged ( int index)
privateslot

Disables the deployer list if the new mod is to replace an existing mod.

Parameters
indexThe new index.

◆ on_group_field_textChanged

void AddModDialog::on_group_field_textChanged ( const QString & arg1)
privateslot

Updates the Ok buttons enabled state.

Parameters
arg1Ignored.

◆ on_installer_box_currentIndexChanged

void AddModDialog::on_installer_box_currentIndexChanged ( int index)
privateslot

Enables/ disables ui elements based on chosen installer.

Parameters
indexNew index.

◆ on_root_level_box_valueChanged

void AddModDialog::on_root_level_box_valueChanged ( int value)
privateslot

Called when the value of the root level box has been changed by a user.

Parameters
Thenew value.

◆ onFomodDialogComplete

void AddModDialog::onFomodDialogComplete ( int app_id,
AddModInfo info )
privateslot

Called when the fomod dialog has been completed. Emits addModAccepted.

Parameters
app_idApplication for which the new mod is to be installed.
infoContains all data needed to install the mod.

◆ removeRoot()

sfs::path AddModDialog::removeRoot ( const std::filesystem::path & source)
private

Removes the root path component from the given path.

Parameters
sourceSource path.
Returns
source without its root component.
The depth of the given path.

◆ setupDialog()

bool AddModDialog::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.

Parameters
nameDefault mod name.
deployersContains all available deployers.
cur_deployerThe currently active Deployer.
groupsContains all mod names which act as targets for groups.
mod_idsIds of all currently installed mods.
pathSource path for the new mod.
deployer_pathsContains target paths for all non autonomous deployers.
app_idId of currently active application.
autonomous_deployersVector of bools indicating for each deployer if that deployer is autonomous.
local_sourceSource archive for the mod.
remote_sourceURL from where the mod was downloaded.
mod_idIf =! -1: Id of the mod to the group of which the new mod should be added by default.
mod_namesContains the name of all currently installed mods.
mod_versionsContains the versions of all currently installed mods.
version_overwriteIf not empty: Use this to overwrite the default version.
name_overwriteIf not empty: Use this to overwrite the default name.
Returns
True if dialog creation was successful.

◆ showError()

void AddModDialog::showError ( const std::runtime_error & error)
private

Shows a message box with a message constructed from given exception.

Parameters
errorSource of error.

The documentation for this class was generated from the following files: