mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-03 07:13:50 +00:00
Merge pull request #7718 from cristian64/display_listcolumns_via_rightclick_on_header
Qt/MainWindow: Also display "List Columns" menu via right-click on table's header.
This commit is contained in:
commit
e05cc3f61d
@ -42,6 +42,7 @@
|
|||||||
#include "DolphinQt/GameList/GameListModel.h"
|
#include "DolphinQt/GameList/GameListModel.h"
|
||||||
#include "DolphinQt/GameList/GridProxyModel.h"
|
#include "DolphinQt/GameList/GridProxyModel.h"
|
||||||
#include "DolphinQt/GameList/ListProxyModel.h"
|
#include "DolphinQt/GameList/ListProxyModel.h"
|
||||||
|
#include "DolphinQt/MenuBar.h"
|
||||||
#include "DolphinQt/QtUtils/DoubleClickEventFilter.h"
|
#include "DolphinQt/QtUtils/DoubleClickEventFilter.h"
|
||||||
#include "DolphinQt/Resources.h"
|
#include "DolphinQt/Resources.h"
|
||||||
#include "DolphinQt/Settings.h"
|
#include "DolphinQt/Settings.h"
|
||||||
@ -121,6 +122,9 @@ void GameList::MakeListView()
|
|||||||
hor_header->restoreState(
|
hor_header->restoreState(
|
||||||
Settings::GetQSettings().value(QStringLiteral("tableheader/state")).toByteArray());
|
Settings::GetQSettings().value(QStringLiteral("tableheader/state")).toByteArray());
|
||||||
|
|
||||||
|
hor_header->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(hor_header, &QWidget::customContextMenuRequested, this, &GameList::ShowHeaderContextMenu);
|
||||||
|
|
||||||
connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged);
|
connect(hor_header, &QHeaderView::sortIndicatorChanged, this, &GameList::OnHeaderViewChanged);
|
||||||
connect(hor_header, &QHeaderView::sectionCountChanged, this, &GameList::OnHeaderViewChanged);
|
connect(hor_header, &QHeaderView::sectionCountChanged, this, &GameList::OnHeaderViewChanged);
|
||||||
connect(hor_header, &QHeaderView::sectionMoved, this, &GameList::OnHeaderViewChanged);
|
connect(hor_header, &QHeaderView::sectionMoved, this, &GameList::OnHeaderViewChanged);
|
||||||
@ -223,6 +227,20 @@ void GameList::MakeGridView()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameList::ShowHeaderContextMenu(const QPoint& pos)
|
||||||
|
{
|
||||||
|
const MenuBar* const menu_bar = MenuBar::GetMenuBar();
|
||||||
|
if (!menu_bar)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QMenu* const list_columns_menu = menu_bar->GetListColumnsMenu();
|
||||||
|
if (!list_columns_menu)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const QWidget* const widget = qobject_cast<QWidget*>(sender());
|
||||||
|
list_columns_menu->exec(widget ? widget->mapToGlobal(pos) : pos);
|
||||||
|
}
|
||||||
|
|
||||||
void GameList::ShowContextMenu(const QPoint&)
|
void GameList::ShowContextMenu(const QPoint&)
|
||||||
{
|
{
|
||||||
if (!GetSelectedGame())
|
if (!GetSelectedGame())
|
||||||
|
@ -52,6 +52,7 @@ signals:
|
|||||||
void OpenGeneralSettings();
|
void OpenGeneralSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void ShowHeaderContextMenu(const QPoint& pos);
|
||||||
void ShowContextMenu(const QPoint&);
|
void ShowContextMenu(const QPoint&);
|
||||||
void OpenContainingFolder();
|
void OpenContainingFolder();
|
||||||
void OpenProperties();
|
void OpenProperties();
|
||||||
|
@ -53,8 +53,12 @@
|
|||||||
|
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
|
|
||||||
|
QPointer<MenuBar> MenuBar::s_menu_bar;
|
||||||
|
|
||||||
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
MenuBar::MenuBar(QWidget* parent) : QMenuBar(parent)
|
||||||
{
|
{
|
||||||
|
s_menu_bar = this;
|
||||||
|
|
||||||
AddFileMenu();
|
AddFileMenu();
|
||||||
AddEmulationMenu();
|
AddEmulationMenu();
|
||||||
AddMovieMenu();
|
AddMovieMenu();
|
||||||
@ -584,13 +588,13 @@ void MenuBar::AddListColumnsMenu(QMenu* view_menu)
|
|||||||
{tr("Tags"), &SConfig::GetInstance().m_showTagsColumn}};
|
{tr("Tags"), &SConfig::GetInstance().m_showTagsColumn}};
|
||||||
|
|
||||||
QActionGroup* column_group = new QActionGroup(this);
|
QActionGroup* column_group = new QActionGroup(this);
|
||||||
QMenu* cols_menu = view_menu->addMenu(tr("List Columns"));
|
m_cols_menu = view_menu->addMenu(tr("List Columns"));
|
||||||
column_group->setExclusive(false);
|
column_group->setExclusive(false);
|
||||||
|
|
||||||
for (const auto& key : columns.keys())
|
for (const auto& key : columns.keys())
|
||||||
{
|
{
|
||||||
bool* config = columns[key];
|
bool* config = columns[key];
|
||||||
QAction* action = column_group->addAction(cols_menu->addAction(key));
|
QAction* action = column_group->addAction(m_cols_menu->addAction(key));
|
||||||
action->setCheckable(true);
|
action->setCheckable(true);
|
||||||
action->setChecked(*config);
|
action->setChecked(*config);
|
||||||
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
connect(action, &QAction::toggled, [this, config, key](bool value) {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
#include <QMenuBar>
|
||||||
|
#include <QPointer>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
@ -31,11 +32,15 @@ class MenuBar final : public QMenuBar
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static MenuBar* GetMenuBar() { return s_menu_bar; }
|
||||||
|
|
||||||
explicit MenuBar(QWidget* parent = nullptr);
|
explicit MenuBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
void UpdateStateSlotMenu();
|
void UpdateStateSlotMenu();
|
||||||
void UpdateToolsMenu(bool emulation_started);
|
void UpdateToolsMenu(bool emulation_started);
|
||||||
|
|
||||||
|
QMenu* GetListColumnsMenu() const { return m_cols_menu; }
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void InstallUpdateManually();
|
void InstallUpdateManually();
|
||||||
#endif
|
#endif
|
||||||
@ -169,6 +174,8 @@ private:
|
|||||||
void OnReadOnlyModeChanged(bool read_only);
|
void OnReadOnlyModeChanged(bool read_only);
|
||||||
void OnDebugModeToggled(bool enabled);
|
void OnDebugModeToggled(bool enabled);
|
||||||
|
|
||||||
|
static QPointer<MenuBar> s_menu_bar;
|
||||||
|
|
||||||
// File
|
// File
|
||||||
QAction* m_open_action;
|
QAction* m_open_action;
|
||||||
QAction* m_exit_action;
|
QAction* m_exit_action;
|
||||||
@ -225,6 +232,7 @@ private:
|
|||||||
QAction* m_show_breakpoints;
|
QAction* m_show_breakpoints;
|
||||||
QAction* m_show_memory;
|
QAction* m_show_memory;
|
||||||
QAction* m_show_jit;
|
QAction* m_show_jit;
|
||||||
|
QMenu* m_cols_menu;
|
||||||
|
|
||||||
// JIT
|
// JIT
|
||||||
QMenu* m_jit;
|
QMenu* m_jit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user