Skip to content

Commit

Permalink
Adds double clicking of items in add source panel lists (#40)
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
FiniteSingularity authored Jul 5, 2024
1 parent 73f15b3 commit 144ae8a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/quick-access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,9 @@ QDialog *QuickAccess::CreateAddSourcePopupMenu()
}
_ClearMenuSources();

/*
* Handle selection changes in lists.
*/
connect(allSourcesList, &QListWidget::itemSelectionChanged, popup,
[allSourcesList, addButton, removeButton, dockSourcesList]() {
auto selectedItem = allSourcesList->currentItem();
Expand All @@ -860,6 +863,9 @@ QDialog *QuickAccess::CreateAddSourcePopupMenu()
}
});

/*
* Handle Add/Remove button clicks.
*/
connect(addButton, &QPushButton::released, popup,
[addButton, allSourcesList, dockSourcesList]() {
auto selectedItem = allSourcesList->takeItem(
Expand All @@ -881,6 +887,32 @@ QDialog *QuickAccess::CreateAddSourcePopupMenu()
removeButton->setDisabled(true);
});

/*
* Handle Double-clicking of items in lists.
*/
connect(allSourcesList, &QListWidget::itemDoubleClicked, popup,
[dockSourcesList, allSourcesList,
addButton](QListWidgetItem *item) {
allSourcesList->takeItem(allSourcesList->row(item));
dockSourcesList->addItem(item);
allSourcesList->clearSelection();
addButton->setDisabled(true);
});

connect(dockSourcesList, &QListWidget::itemDoubleClicked, popup,
[dockSourcesList, allSourcesList, removeButton,
getItemInsert](QListWidgetItem *item) {
dockSourcesList->takeItem(dockSourcesList->row(item));
auto insertIdx =
getItemInsert(allSourcesList, item->text());
allSourcesList->insertItem(insertIdx, item);
dockSourcesList->clearSelection();
removeButton->setDisabled(true);
});

/*
* Handle Cancel/Save button clicks.
*/
connect(cancelButton, &QPushButton::released, popup,
[popup]() { popup->reject(); });

Expand Down

0 comments on commit 144ae8a

Please sign in to comment.