Limo
A simple mod manager
Loading...
Searching...
No Matches
edittoolwidget.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "core/tool.h"
10#include "validatinglineedit.h"
11#include <QComboBox>
12#include <QLabel>
13#include <QLineEdit>
14#include <QPushButton>
15#include <QTableWidget>
16#include <QWidget>
17
18
22class EditToolWidget : public QWidget
23{
24 Q_OBJECT
25public:
26
31 explicit EditToolWidget(QWidget* parent = nullptr);
36 Tool getTool();
41 bool hasValidInput() const;
43 void init();
48 void init(const Tool& tool);
49
50private:
52 static constexpr int MODE_GUIDED_INDEX = 0;
54 static constexpr int MODE_MANUAL_INDEX = 1;
56 static constexpr int RUNTIME_NATIVE_INDEX = 0;
58 static constexpr int RUNTIME_WINE_INDEX = 1;
60 static constexpr int RUNTIME_PROTONTRICKS_INDEX = 2;
62 static constexpr int RUNTIME_STEAM_INDEX = 3;
64 static constexpr int ENVIRONMENT_ACTION_COL = 0;
66 static constexpr int ENVIRONMENT_VARIABLE_COL = 1;
68 static constexpr int ENVIRONMENT_VALUE_COL = 2;
70 static constexpr int VERSION_NATIVE_INDEX = 0;
72 static constexpr int VERSION_FLATPAK_INDEX = 1;
73
75 QLabel* mode_label_;
77 QComboBox* mode_box_;
79 QLabel* name_label_;
83 QLabel* icon_label_;
87 QPushButton* icon_picker_;
93 QPushButton* executable_picker_;
97 QComboBox* runtime_box_;
107 QPushButton* prefix_picker_;
123 QTableWidget* environment_table_;
138
140 std::vector<std::pair<QString, QString>> environment_variables;
142 bool has_valid_input_ = false;
143
152 void runFileDialog(QLineEdit* target_field, const QString& title, bool directories_only);
155
156signals:
161 void inputValidityChanged(bool is_valid);
162
163private slots:
168 void modeBoxIndexChanged(int index);
173 void runtimeBoxIndexChanged(int index);
177 void prefixPickerClicked();
181 void iconPickerClicked();
188 void environmentVariableRemoved(int row, int col);
197 void environmentTableCellChanged(int row, int col);
202 void textFieldEdited(QString new_text);
204 void importButtonClicked();
214 void steamAppImported(QString name,
215 QString app_id,
216 QString install_dir,
217 QString prefix_path,
218 QString icon_path);
219};
void runFileDialog(QLineEdit *target_field, const QString &title, bool directories_only)
Shows a file dialog and writes the selected path to the given line edit.
Definition edittoolwidget.cpp:378
QLabel * runtime_label_
Label used for the runtime.
Definition edittoolwidget.h:95
ValidatingLineEdit * name_field_
Input field for the name.
Definition edittoolwidget.h:81
QPushButton * working_directory_picker_
Push button to open a file dialog for selecting the working directory.
Definition edittoolwidget.h:119
QLineEdit * protontricks_arguments_field_
Input field for the protontricks arguments.
Definition edittoolwidget.h:131
QLabel * command_label_
Label used for the command.
Definition edittoolwidget.h:133
QComboBox * runtime_version_box_
Combo box used to select the runtime version.
Definition edittoolwidget.h:101
ValidatingLineEdit * app_id_field_
Input field for the app id.
Definition edittoolwidget.h:111
QLabel * prefix_label_
Label used for the prefix path.
Definition edittoolwidget.h:103
std::vector< std::pair< QString, QString > > environment_variables
Contains pairs of environment variables and their assigned values.
Definition edittoolwidget.h:140
QLabel * arguments_label_
Label used for the arguments.
Definition edittoolwidget.h:125
void runtimeBoxIndexChanged(int index)
Updates children visibility according to selected runtime.
Definition edittoolwidget.cpp:453
bool has_valid_input_
If true: Current input is valid.
Definition edittoolwidget.h:142
QLabel * name_label_
Label used for the name.
Definition edittoolwidget.h:79
bool hasValidInput() const
Returns whether or not the current input is valid.
Definition edittoolwidget.cpp:233
QLabel * icon_label_
Label used for the icon.
Definition edittoolwidget.h:83
void iconPickerClicked()
Opens a file dialog to select an icon path.
Definition edittoolwidget.cpp:474
QTableWidget * environment_table_
Table used to display environment variables.
Definition edittoolwidget.h:123
void importButtonClicked()
Opens an ImportFromSteamDialog.
Definition edittoolwidget.cpp:518
static constexpr int ENVIRONMENT_ACTION_COL
Index representing the action column in the environment table.
Definition edittoolwidget.h:64
void environmentVariableAdded()
Adds a new empty environment variable.
Definition edittoolwidget.cpp:492
static constexpr int VERSION_NATIVE_INDEX
Index representing native version in the runtime version box.
Definition edittoolwidget.h:70
QLabel * runtime_version_label_
Label used for the runtime version.
Definition edittoolwidget.h:99
QLineEdit * arguments_field_
Input field for the arguments.
Definition edittoolwidget.h:127
void textFieldEdited(QString new_text)
Updates input validity status.
Definition edittoolwidget.cpp:510
QPushButton * icon_picker_
Push button to open a file dialog for selecting the icon path.
Definition edittoolwidget.h:87
QLabel * protontricks_arguments_label_
Label used for the protontricks arguments.
Definition edittoolwidget.h:129
void updateChildrenVisibility()
Updates the visibility of child widgets according to the selected mode and runtime.
Definition edittoolwidget.cpp:315
void modeBoxIndexChanged(int index)
Updates children visibility according to selected mode.
Definition edittoolwidget.cpp:447
static constexpr int RUNTIME_STEAM_INDEX
Index representing steam runtime in the runtime box.
Definition edittoolwidget.h:62
void updateEnvironmentTable()
Updates the environment table with the data in environment_variables.
Definition edittoolwidget.cpp:402
QLabel * environment_label_
Label used for the environment table.
Definition edittoolwidget.h:121
QPushButton * executable_picker_
Push button to open a file dialog for selecting the executable path.
Definition edittoolwidget.h:93
EditToolWidget(QWidget *parent=nullptr)
Initializes the UI.
Definition edittoolwidget.cpp:14
QLabel * executable_label_
Label used for the executable path.
Definition edittoolwidget.h:89
void init()
Initializes the widget with empty fields.
Definition edittoolwidget.cpp:241
void environmentVariableRemoved(int row, int col)
Removes the environment variable in the given row in the environment table from environment_variables...
Definition edittoolwidget.cpp:485
void prefixPickerClicked()
Opens a file dialog to select a prefix path.
Definition edittoolwidget.cpp:464
void executablePickerClicked()
Opens a file dialog to select an executable path.
Definition edittoolwidget.cpp:459
QLabel * app_id_label_
Label used for the app id.
Definition edittoolwidget.h:109
ValidatingLineEdit * working_directory_field_
Input field for the working directory.
Definition edittoolwidget.h:117
void workingDirPickerClicked()
Opens a file dialog to select a working directory.
Definition edittoolwidget.cpp:469
void inputValidityChanged(bool is_valid)
Signals the the validity of current input data has changed.
static constexpr int RUNTIME_PROTONTRICKS_INDEX
Index representing protontricks runtime in the runtime box.
Definition edittoolwidget.h:60
QComboBox * runtime_box_
Combo box used to select the runtime.
Definition edittoolwidget.h:97
QComboBox * mode_box_
Combo box used to select the mode.
Definition edittoolwidget.h:77
ValidatingLineEdit * icon_field_
Input field for the icon path.
Definition edittoolwidget.h:85
static constexpr int MODE_GUIDED_INDEX
Index representing guided mode in the mode box.
Definition edittoolwidget.h:52
ValidatingLineEdit * command_field_
Input field for the command.
Definition edittoolwidget.h:135
ValidatingLineEdit * executable_field_
Input field for the executable path.
Definition edittoolwidget.h:91
static constexpr int MODE_MANUAL_INDEX
Index representing manual mode in the mode box.
Definition edittoolwidget.h:54
static constexpr int RUNTIME_NATIVE_INDEX
Index representing native runtime in the runtime box.
Definition edittoolwidget.h:56
static constexpr int ENVIRONMENT_VALUE_COL
Index representing the value column in the environment table.
Definition edittoolwidget.h:68
void steamAppImported(QString name, QString app_id, QString install_dir, QString prefix_path, QString icon_path)
Updates the app id field and if runtime is steam also the icon path field with given data.
Definition edittoolwidget.cpp:524
QLabel * mode_label_
Label used for the mode.
Definition edittoolwidget.h:75
static constexpr int VERSION_FLATPAK_INDEX
Index representing flatpak version in the runtime version box.
Definition edittoolwidget.h:72
static constexpr int ENVIRONMENT_VARIABLE_COL
Index representing the variable column in the environment table.
Definition edittoolwidget.h:66
QLabel * working_directory_label_
Label used for the working directory.
Definition edittoolwidget.h:115
QPushButton * app_id_import_button_
Push button to open the ImportFromSteamDialog.
Definition edittoolwidget.h:113
QPushButton * prefix_picker_
Push button to open a file dialog for selecting the prefix path.
Definition edittoolwidget.h:107
ImportFromSteamDialog * import_dialog_
Dialog used to import app ids and icon paths from steam.
Definition edittoolwidget.h:137
void environmentTableCellChanged(int row, int col)
Updates the environment variable in the given row in the environment table in environment_variables.
Definition edittoolwidget.cpp:498
ValidatingLineEdit * prefix_field_
Input field for the prefix path.
Definition edittoolwidget.h:105
static constexpr int RUNTIME_WINE_INDEX
Index representing wine runtime in the runtime box.
Definition edittoolwidget.h:58
Tool getTool()
Constructs a Tool from the input data.
Definition edittoolwidget.cpp:185
Definition importfromsteamdialog.h:18
Represents a third party tool to be run from within Limo.
Definition tool.h:17
A line edit which automatically validates its input and shows a visual indicator for invalid inputs.
Definition validatinglineedit.h:15
Header for the ImportFromSteamDialog class.
Header for the Tool class.
Header for the ValidatingLineEdit class.