From 5fa7fd7fb9f3a8f67e8842420d7a2ad600722119 Mon Sep 17 00:00:00 2001 From: isanae <14251494+isanae@users.noreply.github.com> Date: Sun, 9 Jun 2019 17:05:51 -0400 Subject: moved add/remove to the top, changed them to tool buttons with icons, added up/down buttons --- src/editexecutablesdialog.cpp | 48 +++++++++++++++++++++++++ src/editexecutablesdialog.h | 3 ++ src/editexecutablesdialog.ui | 84 +++++++++++++++++++++++++------------------ 3 files changed, 101 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 96f4660a..9747a86f 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -348,6 +348,44 @@ void EditExecutablesDialog::save() } } +void EditExecutablesDialog::moveSelection(int by) +{ + auto* item = selectedItem(); + if (!item) { + return; + } + + // moving down the list + while (by > 0) { + const auto row = ui->list->row(item); + + if (row >= (ui->list->count() - 1)) { + break; + } + + ui->list->takeItem(row); + ui->list->insertItem(row + 1, item); + item->setSelected(true); + + --by; + } + + // moving up the list + while (by < 0) { + const auto row = ui->list->row(item); + + if (row <= 0) { + break; + } + + ui->list->takeItem(row); + ui->list->insertItem(row - 1, item); + item->setSelected(true); + + ++by; + } +} + void EditExecutablesDialog::on_list_itemSelectionChanged() { updateUI(selectedExe()); @@ -408,6 +446,16 @@ void EditExecutablesDialog::on_remove_clicked() } } +void EditExecutablesDialog::on_up_clicked() +{ + moveSelection(-1); +} + +void EditExecutablesDialog::on_down_clicked() +{ + moveSelection(+1); +} + bool EditExecutablesDialog::isTitleConflicting(const QString& s) { for (const auto& exe : m_executablesList) { diff --git a/src/editexecutablesdialog.h b/src/editexecutablesdialog.h index 4957ebff..80ec56df 100644 --- a/src/editexecutablesdialog.h +++ b/src/editexecutablesdialog.h @@ -112,6 +112,8 @@ private slots: void on_add_clicked(); void on_remove_clicked(); + void on_up_clicked(); + void on_down_clicked(); void on_title_textChanged(const QString& s); void on_overwriteSteamAppID_toggled(bool checked); @@ -144,6 +146,7 @@ private: void clearEdits(); void setEdits(const Executable& e); void save(); + void moveSelection(int by); void setJarBinary(const QString& binaryName); std::optional makeNonConflictingTitle(const QString& prefix); bool isTitleConflicting(const QString& s); diff --git a/src/editexecutablesdialog.ui b/src/editexecutablesdialog.ui index e85256c8..9801a75c 100644 --- a/src/editexecutablesdialog.ui +++ b/src/editexecutablesdialog.ui @@ -57,24 +57,15 @@ 0 - - - - List of configured executables - - - This is a list of your configured executables. Executables in grey are automatically recognised and can not be modified. - - - QAbstractItemView::InternalMove - - - Qt::TargetMoveAction - - - + + + + Executables + + + @@ -89,7 +80,7 @@ - + Add an executable @@ -100,13 +91,13 @@ Add - - :/new/guiresources/resources/list-add.png:/new/guiresources/resources/list-add.png + + :/MO/gui/add:/MO/gui/add - + Remove the selected executable @@ -117,26 +108,51 @@ Remove - - :/new/guiresources/resources/list-remove.png:/new/guiresources/resources/list-remove.png + + :/MO/gui/resources/list-remove.png:/MO/gui/resources/list-remove.png - - - Qt::Horizontal + + + Move the executable up in the list - - - 40 - 20 - + + + :/MO/gui/resources/go-up.png:/MO/gui/resources/go-up.png - + + + + + + Move the executable down in the list + + + + :/MO/gui/resources/go-down.png:/MO/gui/resources/go-down.png + + + + + + List of configured executables + + + This is a list of your configured executables. Executables in grey are automatically recognised and can not be modified. + + + QAbstractItemView::InternalMove + + + Qt::TargetMoveAction + + + @@ -420,9 +436,9 @@ Right now the only case I know of where this needs to be overwritten is for the steamAppID createFilesInMod mods - add - remove - + + + -- cgit v1.3.1