From 2b9d7538bf20fc81d10242a9e45d54f43c829eb2 Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Tue, 24 Dec 2024 21:33:48 -0800 Subject: [PATCH] open decks on double-click in deck storage tab (#5322) --- .../src/client/tabs/tab_deck_storage.cpp | 18 ++++++++++++++++++ cockatrice/src/client/tabs/tab_deck_storage.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/cockatrice/src/client/tabs/tab_deck_storage.cpp b/cockatrice/src/client/tabs/tab_deck_storage.cpp index 7b2253b5f..5d57fea55 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.cpp +++ b/cockatrice/src/client/tabs/tab_deck_storage.cpp @@ -45,6 +45,8 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c localDirView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); localDirView->header()->setSortIndicator(0, Qt::AscendingOrder); + connect(localDirView, &QTreeView::doubleClicked, this, &TabDeckStorage::actLocalDoubleClick); + leftToolBar = new QToolBar; leftToolBar->setOrientation(Qt::Horizontal); leftToolBar->setIconSize(QSize(32, 32)); @@ -69,6 +71,8 @@ TabDeckStorage::TabDeckStorage(TabSupervisor *_tabSupervisor, AbstractClient *_c serverDirView = new RemoteDeckList_TreeWidget(client); + connect(serverDirView, &QTreeView::doubleClicked, this, &TabDeckStorage::actRemoteDoubleClick); + QVBoxLayout *rightVbox = new QVBoxLayout; rightVbox->addWidget(serverDirView); rightVbox->addLayout(rightToolBarLayout); @@ -154,6 +158,13 @@ QString TabDeckStorage::getTargetPath() const } } +void TabDeckStorage::actLocalDoubleClick(const QModelIndex &curLeft) +{ + if (!localDirModel->isDir(curLeft)) { + actOpenLocalDeck(); + } +} + void TabDeckStorage::actOpenLocalDeck() { QModelIndexList curLefts = localDirView->selectionModel()->selectedRows(); @@ -289,6 +300,13 @@ void TabDeckStorage::actDeleteLocalDeck() } } +void TabDeckStorage::actRemoteDoubleClick(const QModelIndex &curRight) +{ + if (dynamic_cast(serverDirView->getNode(curRight))) { + actOpenRemoteDeck(); + } +} + void TabDeckStorage::actOpenRemoteDeck() { for (const auto &curRight : serverDirView->getCurrentSelection()) { diff --git a/cockatrice/src/client/tabs/tab_deck_storage.h b/cockatrice/src/client/tabs/tab_deck_storage.h index 539a06feb..7dec662dd 100644 --- a/cockatrice/src/client/tabs/tab_deck_storage.h +++ b/cockatrice/src/client/tabs/tab_deck_storage.h @@ -34,6 +34,7 @@ private: void deleteRemoteDeck(const RemoteDeckList_TreeModel::Node *node); private slots: + void actLocalDoubleClick(const QModelIndex &curLeft); void actOpenLocalDeck(); void actUpload(); @@ -42,6 +43,7 @@ private slots: void actNewLocalFolder(); void actDeleteLocalDeck(); + void actRemoteDoubleClick(const QModelIndex &curRight); void actOpenRemoteDeck(); void openRemoteDeckFinished(const Response &r, const CommandContainer &commandContainer);