From 4c3ceae0e456399e974b00a593b5b7d2f85aa73c Mon Sep 17 00:00:00 2001 From: RickyRister <42636155+RickyRister@users.noreply.github.com> Date: Tue, 24 Dec 2024 21:34:43 -0800 Subject: [PATCH] open replays on double-click in replays tab (#5323) --- cockatrice/src/client/tabs/tab_replays.cpp | 14 ++++++++++++++ cockatrice/src/client/tabs/tab_replays.h | 2 ++ .../remote/remote_replay_list_tree_widget.cpp | 9 +++++++++ .../server/remote/remote_replay_list_tree_widget.h | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/client/tabs/tab_replays.cpp b/cockatrice/src/client/tabs/tab_replays.cpp index 6512381e3..fb1375f52 100644 --- a/cockatrice/src/client/tabs/tab_replays.cpp +++ b/cockatrice/src/client/tabs/tab_replays.cpp @@ -131,6 +131,13 @@ void TabReplays::retranslateUi() aDeleteRemoteReplay->setText(tr("Delete")); } +void TabReplays::actLocalDoubleClick(const QModelIndex &curLeft) +{ + if (!localDirModel->isDir(curLeft)) { + actOpenLocalReplay(); + } +} + void TabReplays::actOpenLocalReplay() { QModelIndexList curLefts = localDirView->selectionModel()->selectedRows(); @@ -192,6 +199,13 @@ void TabReplays::actDeleteLocalReplay() } } +void TabReplays::actRemoteDoubleClick(const QModelIndex &curRight) +{ + if (serverDirView->getReplay(curRight)) { + actOpenRemoteReplay(); + } +} + void TabReplays::actOpenRemoteReplay() { auto const curRights = serverDirView->getSelectedReplays(); diff --git a/cockatrice/src/client/tabs/tab_replays.h b/cockatrice/src/client/tabs/tab_replays.h index 7e879719f..3f127613b 100644 --- a/cockatrice/src/client/tabs/tab_replays.h +++ b/cockatrice/src/client/tabs/tab_replays.h @@ -28,10 +28,12 @@ private: QAction *aOpenLocalReplay, *aNewLocalFolder, *aDeleteLocalReplay; QAction *aOpenRemoteReplay, *aDownload, *aKeep, *aDeleteRemoteReplay; private slots: + void actLocalDoubleClick(const QModelIndex &curLeft); void actOpenLocalReplay(); void actNewLocalFolder(); void actDeleteLocalReplay(); + void actRemoteDoubleClick(const QModelIndex &curLeft); void actOpenRemoteReplay(); void openRemoteReplayFinished(const Response &r); diff --git a/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp b/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp index ee24aa817..838524519 100644 --- a/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp +++ b/cockatrice/src/server/remote/remote_replay_list_tree_widget.cpp @@ -309,6 +309,15 @@ RemoteReplayList_TreeWidget::RemoteReplayList_TreeWidget(AbstractClient *_client setSelectionMode(QAbstractItemView::ExtendedSelection); } +/** + * Gets the replay at the given index + * @return The replay. Returns nullptr if there is no replay at the index. + */ +ServerInfo_Replay const *RemoteReplayList_TreeWidget::getReplay(const QModelIndex &ind) const +{ + return treeModel->getReplay(proxyModel->mapToSource(ind)); +} + /** * Gets all currently selected replays. * Any selection that isn't a replay file (e.g. a folder) will appear as a nullptr in the list. diff --git a/cockatrice/src/server/remote/remote_replay_list_tree_widget.h b/cockatrice/src/server/remote/remote_replay_list_tree_widget.h index d05957ecd..a93e693fa 100644 --- a/cockatrice/src/server/remote/remote_replay_list_tree_widget.h +++ b/cockatrice/src/server/remote/remote_replay_list_tree_widget.h @@ -107,10 +107,10 @@ class RemoteReplayList_TreeWidget : public QTreeView private: RemoteReplayList_TreeModel *treeModel; QSortFilterProxyModel *proxyModel; - ServerInfo_Replay const *getNode(const QModelIndex &ind) const; public: RemoteReplayList_TreeWidget(AbstractClient *_client, QWidget *parent = nullptr); + ServerInfo_Replay const *getReplay(const QModelIndex &ind) const; QList getSelectedReplays() const; QSet getSelectedReplayMatches() const; void refreshTree();