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 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/editexecutablesdialog.cpp') 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) { -- cgit v1.3.1