summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-12-20 14:41:28 +0100
committerTannin <devnull@localhost>2014-12-20 14:41:28 +0100
commita5906f1044d08a870285758d3c93d6252a16a14a (patch)
treef5e56d1194b7784925f3f61b66aa020abecd0f43 /src
parentebfeb2fbf95df4a2246ff2ef1cd6b48f373b70f3 (diff)
workaround to prevent executables dialog from auto-selecting the top-most executable
Diffstat (limited to 'src')
-rw-r--r--src/editexecutablesdialog.cpp94
-rw-r--r--src/editexecutablesdialog.h6
-rw-r--r--src/editexecutablesdialog.ui3
3 files changed, 57 insertions, 46 deletions
diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp
index fe548a9a..da3cc8c4 100644
--- a/src/editexecutablesdialog.cpp
+++ b/src/editexecutablesdialog.cpp
@@ -20,6 +20,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "editexecutablesdialog.h"
#include "ui_editexecutablesdialog.h"
#include "filedialogmemory.h"
+#include "stackdata.h"
#include <QMessageBox>
#include <Shellapi.h>
#include <utility.h>
@@ -218,55 +219,14 @@ bool EditExecutablesDialog::executableChanged()
}
}
-
-void EditExecutablesDialog::on_executablesListBox_currentItemChanged(QListWidgetItem *current, QListWidgetItem*)
+void EditExecutablesDialog::on_executablesListBox_itemSelectionChanged()
{
- if (current == NULL) {
+ if (ui->executablesListBox->selectedItems().size() == 0) {
+ // deselected
resetInput();
- return;
- }
-
- if (executableChanged()) {
- QMessageBox::StandardButton res = QMessageBox::question(this, tr("Save Changes?"),
- tr("You made changes to the current executable, do you want to save them?"),
- QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
- if (res == QMessageBox::Cancel) {
- return;
- } else if (res == QMessageBox::Yes) {
- // this invalidates the item passed as a a parameter
- saveExecutable();
-
- QTimer::singleShot(50, this, SLOT(delayedRefresh()));
- return;
- }
- }
-
- m_CurrentItem = current;
-
- const Executable &selectedExecutable = current->data(Qt::UserRole).value<Executable>();
-
- ui->titleEdit->setText(selectedExecutable.m_Title);
- ui->binaryEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath()));
- ui->argumentsEdit->setText(selectedExecutable.m_Arguments);
- ui->workingDirEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_WorkingDirectory));
- ui->closeCheckBox->setChecked(selectedExecutable.m_CloseMO == DEFAULT_CLOSE);
- if (selectedExecutable.m_CloseMO == NEVER_CLOSE) {
- ui->closeCheckBox->setEnabled(false);
- ui->closeCheckBox->setToolTip(tr("MO must be kept running or this application will not work correctly."));
- } else {
- ui->closeCheckBox->setEnabled(true);
- ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run."));
- }
- ui->removeButton->setEnabled(selectedExecutable.m_Custom);
- ui->overwriteAppIDBox->setChecked(selectedExecutable.m_SteamAppID != 0);
- if (selectedExecutable.m_SteamAppID != 0) {
- ui->appIDOverwriteEdit->setText(selectedExecutable.m_SteamAppID);
- } else {
- ui->appIDOverwriteEdit->clear();
}
}
-
void EditExecutablesDialog::on_overwriteAppIDBox_toggled(bool checked)
{
ui->appIDOverwriteEdit->setEnabled(checked);
@@ -287,3 +247,49 @@ void EditExecutablesDialog::on_closeButton_clicked()
this->accept();
}
+void EditExecutablesDialog::on_executablesListBox_clicked(const QModelIndex &current)
+{
+ if (current.isValid()) {
+ ui->executablesListBox->selectionModel()->clearSelection();
+ ui->executablesListBox->selectionModel()->select(current, QItemSelectionModel::SelectCurrent);
+
+ if (executableChanged()) {
+ QMessageBox::StandardButton res = QMessageBox::question(this, tr("Save Changes?"),
+ tr("You made changes to the current executable, do you want to save them?"),
+ QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
+ if (res == QMessageBox::Cancel) {
+ return;
+ } else if (res == QMessageBox::Yes) {
+ // this invalidates the item passed as a a parameter
+ saveExecutable();
+
+ QTimer::singleShot(50, this, SLOT(delayedRefresh()));
+ return;
+ }
+ }
+
+ m_CurrentItem = ui->executablesListBox->item(current.row());
+
+ const Executable &selectedExecutable = m_CurrentItem->data(Qt::UserRole).value<Executable>();
+
+ ui->titleEdit->setText(selectedExecutable.m_Title);
+ ui->binaryEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_BinaryInfo.absoluteFilePath()));
+ ui->argumentsEdit->setText(selectedExecutable.m_Arguments);
+ ui->workingDirEdit->setText(QDir::toNativeSeparators(selectedExecutable.m_WorkingDirectory));
+ ui->closeCheckBox->setChecked(selectedExecutable.m_CloseMO == DEFAULT_CLOSE);
+ if (selectedExecutable.m_CloseMO == NEVER_CLOSE) {
+ ui->closeCheckBox->setEnabled(false);
+ ui->closeCheckBox->setToolTip(tr("MO must be kept running or this application will not work correctly."));
+ } else {
+ ui->closeCheckBox->setEnabled(true);
+ ui->closeCheckBox->setToolTip(tr("If checked, MO will be closed once the specified executable is run."));
+ }
+ ui->removeButton->setEnabled(selectedExecutable.m_Custom);
+ ui->overwriteAppIDBox->setChecked(selectedExecutable.m_SteamAppID != 0);
+ if (selectedExecutable.m_SteamAppID != 0) {
+ ui->appIDOverwriteEdit->setText(selectedExecutable.m_SteamAppID);
+ } else {
+ ui->appIDOverwriteEdit->clear();
+ }
+ }
+}
diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h
index d27ccb0a..4f6c5315 100644
--- a/src/editexecutablesdialog.h
+++ b/src/editexecutablesdialog.h
@@ -74,10 +74,12 @@ private slots:
void on_closeButton_clicked();
- void on_executablesListBox_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
-
void delayedRefresh();
+ void on_executablesListBox_itemSelectionChanged();
+
+ void on_executablesListBox_clicked(const QModelIndex &index);
+
private:
void resetInput();
diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui
index 4f0462db..708d512c 100644
--- a/src/editexecutablesdialog.ui
+++ b/src/editexecutablesdialog.ui
@@ -28,6 +28,9 @@
<property name="defaultDropAction">
<enum>Qt::MoveAction</enum>
</property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
</widget>
</item>
<item>