diff options
| author | Mathew Maidment <mathew1800@gmail.com> | 2016-02-18 00:07:22 -0500 |
|---|---|---|
| committer | Mathew Maidment <mathew1800@gmail.com> | 2016-02-18 00:07:22 -0500 |
| commit | 58b355223356c7f74f1667dffbe51daf618a2bc2 (patch) | |
| tree | dca8b9b1bb7c435965e48da04811a5fc7ce75a95 /Source/Core | |
| parent | 05e431d5b5b351d67e6d202ad5960e48f7612a58 (diff) | |
| parent | 7cd1a233eb0ab8c1b88c9ad24a8d67183941ddfd (diff) | |
Merge pull request #3616 from rukai/dolphinQtGameContextMenu
DQT2: Add context menu to gamelist
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinQt2/GameList/GameList.cpp | 28 | ||||
| -rw-r--r-- | Source/Core/DolphinQt2/GameList/GameList.h | 6 |
2 files changed, 33 insertions, 1 deletions
diff --git a/Source/Core/DolphinQt2/GameList/GameList.cpp b/Source/Core/DolphinQt2/GameList/GameList.cpp index 861b0115a1..0f2fb89487 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.cpp +++ b/Source/Core/DolphinQt2/GameList/GameList.cpp @@ -2,7 +2,10 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include <QDesktopServices> #include <QHeaderView> +#include <QMenu> +#include <QUrl> #include "DolphinQt2/Settings.h" #include "DolphinQt2/GameList/GameList.h" @@ -45,6 +48,8 @@ void GameList::MakeTableView() m_table->setShowGrid(false); m_table->setSortingEnabled(true); m_table->setCurrentIndex(QModelIndex()); + m_table->setContextMenuPolicy(Qt::CustomContextMenu); + connect(m_table, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); // TODO load from config m_table->setColumnHidden(GameListModel::COL_PLATFORM, false); @@ -87,6 +92,29 @@ void GameList::MakeListView() m_list->setViewMode(QListView::IconMode); m_list->setResizeMode(QListView::Adjust); m_list->setUniformItemSizes(true); + m_list->setContextMenuPolicy(Qt::CustomContextMenu); + connect(m_list, &QTableView::customContextMenuRequested, this, &GameList::ShowContextMenu); +} + +void GameList::ShowContextMenu(const QPoint&) +{ + QMenu* menu = new QMenu(this); + menu->addAction(tr("Properties")); + menu->addAction(tr("Open Wiki Page"), this, SLOT(OpenWiki())); + menu->addAction(tr("Set as Default ISO"), this, SLOT(SetDefaultISO())); + menu->exec(QCursor::pos()); +} + +void GameList::OpenWiki() +{ + QString game_id = GameFile(GetSelectedGame()).GetUniqueID(); + QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id); + QDesktopServices::openUrl(QUrl(url)); +} + +void GameList::SetDefaultISO() +{ + Settings().SetDefaultGame(GetSelectedGame()); } QString GameList::GetSelectedGame() const diff --git a/Source/Core/DolphinQt2/GameList/GameList.h b/Source/Core/DolphinQt2/GameList/GameList.h index 8b6e7628aa..32c8c2292d 100644 --- a/Source/Core/DolphinQt2/GameList/GameList.h +++ b/Source/Core/DolphinQt2/GameList/GameList.h @@ -19,7 +19,6 @@ class GameList final : public QStackedWidget public: explicit GameList(QWidget* parent = nullptr); - QString GetSelectedGame() const; public slots: @@ -27,6 +26,11 @@ public slots: void SetListView() { SetPreferredView(false); } void SetViewColumn(int col, bool view) { m_table->setColumnHidden(col, !view); } +private slots: + void ShowContextMenu(const QPoint&); + void OpenWiki(); + void SetDefaultISO(); + signals: void GameSelected(); void DirectoryAdded(const QString& dir); |
