diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/editexecutablesdialog.cpp | 134 | ||||
| -rw-r--r-- | src/editexecutablesdialog.h | 9 | ||||
| -rw-r--r-- | src/editexecutablesdialog.ui | 405 | ||||
| -rw-r--r-- | src/executableslist.cpp | 4 |
4 files changed, 328 insertions, 224 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index f7348889..8494c892 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -47,15 +47,96 @@ EditExecutablesDialog::EditExecutablesDialog( ui->splitter->setStretchFactor(1, 1); refreshExecutablesWidget(); - ui->newFilesModBox->addItems(modList.allMods()); m_ForcedLibraries = m_Profile->determineForcedLibraries(ui->titleEdit->text()); + + updateUI(nullptr); } -EditExecutablesDialog::~EditExecutablesDialog() +EditExecutablesDialog::~EditExecutablesDialog() = default; + +void EditExecutablesDialog::updateUI(const Executable* e) { - delete ui; + if (e) { + setEdits(*e); + } else { + clearEdits(); + ui->removeButton->setEnabled(false); + } +} + +void EditExecutablesDialog::clearEdits() +{ + ui->titleEdit->clear(); + ui->binaryEdit->clear(); + ui->workingDirEdit->clear(); + ui->argumentsEdit->clear(); + ui->overwriteAppIDBox->setChecked(false); + ui->appIDOverwriteEdit->clear(); + ui->newFilesModCheckBox->setChecked(false); + ui->newFilesModBox->setCurrentIndex(-1); + ui->forceLoadCheckBox->setChecked(false); + ui->useAppIconCheckBox->setChecked(false); + + ui->pluginProvidedLabel->setVisible(false); +} + +void EditExecutablesDialog::setEdits(const Executable& e) +{ + ui->titleEdit->setText(e.title()); + ui->binaryEdit->setText(QDir::toNativeSeparators(e.binaryInfo().absoluteFilePath())); + ui->workingDirEdit->setText(QDir::toNativeSeparators(e.workingDirectory())); + ui->argumentsEdit->setText(e.arguments()); + ui->overwriteAppIDBox->setChecked(!e.steamAppID().isEmpty()); + ui->appIDOverwriteEdit->setText(e.steamAppID()); + ui->useAppIconCheckBox->setChecked(e.usesOwnIcon()); + + int modIndex = -1; + + QString customOverwrite = m_Profile->setting("custom_overwrites", e.title()).toString(); + if (!customOverwrite.isEmpty()) { + modIndex = ui->newFilesModBox->findText(customOverwrite); + } + + ui->newFilesModCheckBox->setChecked(modIndex != -1); + ui->newFilesModBox->setCurrentIndex(modIndex); + + const bool forcedLibraries = m_Profile->forcedLibrariesEnabled(e.title()); + ui->forceLoadCheckBox->setChecked(forcedLibraries); + ui->forceLoadButton->setEnabled(forcedLibraries); + + ui->pluginProvidedLabel->setVisible(!e.isCustom()); + + // only enabled for custom executables + ui->titleEdit->setEnabled(e.isCustom()); + ui->binaryEdit->setEnabled(e.isCustom()); + ui->browseBinaryButton->setEnabled(e.isCustom()); + ui->workingDirEdit->setEnabled(e.isCustom()); + ui->browseWorkingDirButton->setEnabled(e.isCustom()); + ui->argumentsEdit->setEnabled(e.isCustom()); + ui->overwriteAppIDBox->setEnabled(e.isCustom()); + ui->appIDOverwriteEdit->setEnabled(e.isCustom()); + ui->useAppIconCheckBox->setEnabled(e.isCustom()); + + // always enabled + ui->newFilesModCheckBox->setEnabled(true); + ui->newFilesModBox->setEnabled(true); + ui->forceLoadCheckBox->setEnabled(true); +} + +void EditExecutablesDialog::resetInput() +{ + ui->binaryEdit->setText(""); + ui->titleEdit->setText(""); + ui->workingDirEdit->clear(); + ui->argumentsEdit->setText(""); + ui->appIDOverwriteEdit->clear(); + ui->overwriteAppIDBox->setChecked(false); + ui->useAppIconCheckBox->setChecked(false); + ui->newFilesModCheckBox->setChecked(false); + ui->forceLoadCheckBox->setChecked(false); + m_CurrentItem = nullptr; } ExecutablesList EditExecutablesDialog::getExecutablesList() const @@ -95,8 +176,8 @@ void EditExecutablesDialog::refreshExecutablesWidget() ui->executablesListBox->addItem(newItem); } - ui->addButton->setEnabled(false); - ui->removeButton->setEnabled(false); + //ui->addButton->setEnabled(false); + //ui->removeButton->setEnabled(false); } @@ -131,20 +212,6 @@ void EditExecutablesDialog::updateButtonStates() ui->addButton->setEnabled(enabled); } -void EditExecutablesDialog::resetInput() -{ - ui->binaryEdit->setText(""); - ui->titleEdit->setText(""); - ui->workingDirEdit->clear(); - ui->argumentsEdit->setText(""); - ui->appIDOverwriteEdit->clear(); - ui->overwriteAppIDBox->setChecked(false); - ui->useAppIconCheckBox->setChecked(false); - ui->newFilesModCheckBox->setChecked(false); - ui->forceLoadCheckBox->setChecked(false); - m_CurrentItem = nullptr; -} - void EditExecutablesDialog::saveExecutable() { @@ -260,7 +327,7 @@ void EditExecutablesDialog::on_browseBinaryButton_clicked() } } -void EditExecutablesDialog::on_browseDirButton_clicked() +void EditExecutablesDialog::on_browseWorkingDirButton_clicked() { QString dirName = FileDialogMemory::getExistingDirectory("editExecutableDirectory", this, tr("Select a directory")); @@ -359,10 +426,27 @@ bool EditExecutablesDialog::executableChanged() } void EditExecutablesDialog::on_executablesListBox_itemSelectionChanged() { - if (ui->executablesListBox->selectedItems().size() == 0) { - // deselected - resetInput(); + const auto selection = ui->executablesListBox->selectedItems(); + + if (selection.empty()) { + updateUI(nullptr); + return; + } + + auto* item = selection[0]; + if (!item) { + return; + } + + const auto& title = item->text(); + auto itor = m_ExecutablesList.find(title); + + if (itor == m_ExecutablesList.end()) { + qWarning().nospace() << "selection: executable '" << title << "' not found"; + return; } + + updateUI(&*itor); } void EditExecutablesDialog::on_overwriteAppIDBox_toggled(bool checked) @@ -395,7 +479,7 @@ void EditExecutablesDialog::on_buttonBox_rejected() } void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex ¤t) -{ +{/* if (current.isValid()) { if (executableChanged()) { @@ -459,7 +543,7 @@ void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &cur bool forcedLibraries = m_Profile->forcedLibrariesEnabled(ui->titleEdit->text()); ui->forceLoadButton->setEnabled(forcedLibraries); ui->forceLoadCheckBox->setChecked(forcedLibraries); - } + }*/ } void EditExecutablesDialog::on_newFilesModCheckBox_toggled(bool checked) diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h index 7f389b24..bb1538ef 100644 --- a/src/editexecutablesdialog.h +++ b/src/editexecutablesdialog.h @@ -87,7 +87,7 @@ private slots: void on_overwriteAppIDBox_toggled(bool checked);
- void on_browseDirButton_clicked();
+ void on_browseWorkingDirButton_clicked();
void on_buttonBox_accepted();
void on_buttonBox_rejected();
@@ -113,7 +113,7 @@ private: void updateButtonStates();
private:
- Ui::EditExecutablesDialog *ui;
+ std::unique_ptr<Ui::EditExecutablesDialog> ui;
QListWidgetItem *m_CurrentItem;
@@ -124,6 +124,11 @@ private: QList<MOBase::ExecutableForcedLoadSetting> m_ForcedLibraries;
const MOBase::IPluginGame *m_GamePlugin;
+
+
+ void updateUI(const Executable* e);
+ void clearEdits();
+ void setEdits(const Executable& e);
};
#endif // EDITEXECUTABLESDIALOG_H
diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index 52bbf187..2c9a74f3 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -7,15 +7,9 @@ <x>0</x>
<y>0</y>
<width>710</width>
- <height>293</height>
+ <height>348</height>
</rect>
</property>
- <property name="minimumSize">
- <size>
- <width>200</width>
- <height>200</height>
- </size>
- </property>
<property name="windowTitle">
<string>Modify Executables</string>
</property>
@@ -77,9 +71,6 @@ <property name="defaultDropAction">
<enum>Qt::TargetMoveAction</enum>
</property>
- <property name="selectionMode">
- <enum>QAbstractItemView::ExtendedSelection</enum>
- </property>
</widget>
</item>
<item>
@@ -163,197 +154,221 @@ <number>0</number>
</property>
<item>
- <layout class="QFormLayout" name="formLayout">
- <property name="bottomMargin">
- <number>20</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Title</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="titleEdit">
- <property name="toolTip">
- <string>Name of the executable. This is only for display purposes.</string>
- </property>
- <property name="whatsThis">
- <string>Name of the executable. This is only for display purposes.</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Binary</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
- <item>
- <widget class="QLineEdit" name="binaryEdit">
- <property name="toolTip">
- <string>Binary to run</string>
- </property>
- <property name="whatsThis">
- <string>Binary to run</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="browseBinaryButton">
- <property name="toolTip">
- <string>Browse filesystem</string>
- </property>
- <property name="whatsThis">
- <string>Browse filesystem for the executable to run.</string>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Start in</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0">
- <item>
- <widget class="QLineEdit" name="workingDirEdit"/>
- </item>
- <item>
- <widget class="QPushButton" name="browseDirButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Arguments</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QLineEdit" name="argumentsEdit">
- <property name="toolTip">
- <string>Arguments to pass to the application</string>
- </property>
- <property name="whatsThis">
- <string>Arguments to pass to the application</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QCheckBox" name="overwriteAppIDBox">
- <property name="toolTip">
- <string>Allow the Steam AppID to be used for this executable to be changed.</string>
- </property>
- <property name="whatsThis">
- <string>Allow the Steam AppID to be used for this executable to be changed.
+ <widget class="QWidget" name="widget_4" native="true">
+ <layout class="QVBoxLayout" name="verticalLayout_5">
+ <property name="bottomMargin">
+ <number>10</number>
+ </property>
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="bottomMargin">
+ <number>20</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Title</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="titleEdit">
+ <property name="toolTip">
+ <string>Name of the executable. This is only for display purposes.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Name of the executable. This is only for display purposes.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Binary</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0">
+ <item>
+ <widget class="QLineEdit" name="binaryEdit">
+ <property name="toolTip">
+ <string>Binary to run</string>
+ </property>
+ <property name="whatsThis">
+ <string>Binary to run</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseBinaryButton">
+ <property name="toolTip">
+ <string>Browse filesystem</string>
+ </property>
+ <property name="whatsThis">
+ <string>Browse filesystem for the executable to run.</string>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Start in</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_6" stretch="1,0">
+ <item>
+ <widget class="QLineEdit" name="workingDirEdit"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseWorkingDirButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Arguments</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="argumentsEdit">
+ <property name="toolTip">
+ <string>Arguments to pass to the application</string>
+ </property>
+ <property name="whatsThis">
+ <string>Arguments to pass to the application</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QCheckBox" name="overwriteAppIDBox">
+ <property name="toolTip">
+ <string>Allow the Steam AppID to be used for this executable to be changed.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Allow the Steam AppID to be used for this executable to be changed.
Every game/tool distributed through Steam has a unique ID. MO needs to know this ID to start those programs directly, otherwise the program is started by steam and then MO will not work. By default, MO will use the AppID for the game.
Right now the only case I know of where this needs to be overwritten is for the Skyrim Creation Kit which has its own AppID. This overwrite is already preconfigured.</string>
- </property>
- <property name="text">
- <string>Overwrite Steam AppID</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="appIDOverwriteEdit">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="toolTip">
- <string>Steam AppID to use for this executable that differs from the games AppID.</string>
- </property>
- <property name="whatsThis">
- <string>Steam AppID to use for this executable that differs from the games AppID.
+ </property>
+ <property name="text">
+ <string>Overwrite Steam AppID</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="appIDOverwriteEdit">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>Steam AppID to use for this executable that differs from the games AppID.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Steam AppID to use for this executable that differs from the games AppID.
Every game/tool distributed through Steam has a unique ID. MO needs to know this ID to start those programs directly, otherwise the program is started by steam and then MO will not work. By default, MO will use the AppID for the game (usually 72850).
Right now the only case I know of where this needs to be overwritten is for the Skyrim Creation Kit which has its own AppID (usually 202480). This overwrite is already preconfigured.</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_9" stretch="0,1">
- <item>
- <widget class="QCheckBox" name="newFilesModCheckBox">
- <property name="toolTip">
- <string>If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod.</string>
- </property>
- <property name="text">
- <string>Create Files in Mod instead of Overwrite (*)</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="newFilesModBox">
- <property name="enabled">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QCheckBox" name="forceLoadCheckBox">
- <property name="toolTip">
- <string>If this is enabled, the configured libraries will be automatically loaded when this executable is launched.</string>
- </property>
- <property name="text">
- <string>Force Load Libraries (Profile Specific)</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="forceLoadButton">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Configure Libraries</string>
- </property>
- </widget>
- </item>
- </layout>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_9" stretch="0,1">
+ <item>
+ <widget class="QCheckBox" name="newFilesModCheckBox">
+ <property name="toolTip">
+ <string>If this is enabled, new files are created in the specified mod instead of the "Overwrite" mod.</string>
+ </property>
+ <property name="text">
+ <string>Create Files in Mod instead of Overwrite (*)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="newFilesModBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
+ <item>
+ <widget class="QCheckBox" name="forceLoadCheckBox">
+ <property name="toolTip">
+ <string>If this is enabled, the configured libraries will be automatically loaded when this executable is launched.</string>
+ </property>
+ <property name="text">
+ <string>Force Load Libraries (Profile Specific)</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="forceLoadButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Configure Libraries</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="useAppIconCheckBox">
+ <property name="text">
+ <string>Use Application's Icon for shortcuts</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
</item>
<item>
- <widget class="QCheckBox" name="useAppIconCheckBox">
+ <widget class="QLabel" name="pluginProvidedLabel">
+ <property name="font">
+ <font>
+ <italic>true</italic>
+ </font>
+ </property>
<property name="text">
- <string>Use Application's Icon for shortcuts</string>
+ <string>This executable is provided by the game plugin</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
</item>
@@ -390,7 +405,7 @@ Right now the only case I know of where this needs to be overwritten is for the <tabstop>binaryEdit</tabstop>
<tabstop>browseBinaryButton</tabstop>
<tabstop>workingDirEdit</tabstop>
- <tabstop>browseDirButton</tabstop>
+ <tabstop>browseWorkingDirButton</tabstop>
<tabstop>overwriteAppIDBox</tabstop>
<tabstop>appIDOverwriteEdit</tabstop>
<tabstop>newFilesModCheckBox</tabstop>
diff --git a/src/executableslist.cpp b/src/executableslist.cpp index d884bdf2..8174eb1b 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -65,8 +65,6 @@ bool ExecutablesList::empty() const void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings)
{
- addFromPlugin(game);
-
qDebug("setting up configured executables");
int numCustomExecutables = settings.beginReadArray("customExecutables");
@@ -91,6 +89,8 @@ void ExecutablesList::load(const MOBase::IPluginGame* game, QSettings& settings) }
settings.endArray();
+
+ addFromPlugin(game);
}
void ExecutablesList::store(QSettings& settings)
|
