mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Move the menu bar into its own file.
This commit is contained in:
parent
c683b54921
commit
f9f2b2fd36
@ -4,18 +4,19 @@ add_definitions(-DQT_USE_QSTRINGBUILDER -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_
|
|||||||
set(CMAKE_AUTOMOC ON)
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
set(SRCS
|
set(SRCS
|
||||||
|
Host.cpp
|
||||||
Main.cpp
|
Main.cpp
|
||||||
MainWindow.cpp
|
MainWindow.cpp
|
||||||
Host.cpp
|
MenuBar.cpp
|
||||||
RenderWidget.cpp
|
RenderWidget.cpp
|
||||||
Resources.cpp
|
Resources.cpp
|
||||||
ToolBar.cpp
|
ToolBar.cpp
|
||||||
GameList/GameFile.cpp
|
GameList/GameFile.cpp
|
||||||
GameList/GameList.cpp
|
GameList/GameList.cpp
|
||||||
GameList/GameTracker.cpp
|
|
||||||
GameList/GameListModel.cpp
|
GameList/GameListModel.cpp
|
||||||
GameList/TableProxyModel.cpp
|
GameList/GameTracker.cpp
|
||||||
GameList/ListProxyModel.cpp
|
GameList/ListProxyModel.cpp
|
||||||
|
GameList/TableProxyModel.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND LIBS core uicommon)
|
list(APPEND LIBS core uicommon)
|
||||||
|
@ -40,6 +40,17 @@ void GameList::MakeTableView()
|
|||||||
m_table->setSortingEnabled(true);
|
m_table->setSortingEnabled(true);
|
||||||
m_table->setCurrentIndex(QModelIndex());
|
m_table->setCurrentIndex(QModelIndex());
|
||||||
|
|
||||||
|
// TODO load from config
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_PLATFORM, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_ID, true);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_BANNER, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_TITLE, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_DESCRIPTION, true);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_MAKER, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_SIZE, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_COUNTRY, false);
|
||||||
|
m_table->setColumnHidden(GameListModel::COL_RATING, false);
|
||||||
|
|
||||||
// FIXME These icon image are overly wide and should be cut down to size,
|
// FIXME These icon image are overly wide and should be cut down to size,
|
||||||
// then we can remove these lines.
|
// then we can remove these lines.
|
||||||
m_table->setColumnWidth(GameListModel::COL_PLATFORM, 52);
|
m_table->setColumnWidth(GameListModel::COL_PLATFORM, 52);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMenuBar>
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
@ -30,7 +29,7 @@ MainWindow::MainWindow() : QMainWindow(nullptr)
|
|||||||
MakeToolBar();
|
MakeToolBar();
|
||||||
MakeRenderWidget();
|
MakeRenderWidget();
|
||||||
MakeStack();
|
MakeStack();
|
||||||
MakeMenus();
|
MakeMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -38,115 +37,14 @@ MainWindow::~MainWindow()
|
|||||||
m_render_widget->deleteLater();
|
m_render_widget->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeMenus()
|
void MainWindow::MakeMenuBar()
|
||||||
{
|
{
|
||||||
MakeFileMenu();
|
m_menu_bar = new MenuBar(this);
|
||||||
menuBar()->addMenu(tr("Emulation"));
|
setMenuBar(m_menu_bar);
|
||||||
menuBar()->addMenu(tr("Movie"));
|
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
||||||
menuBar()->addMenu(tr("Options"));
|
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
||||||
menuBar()->addMenu(tr("Tools"));
|
connect(m_menu_bar, &MenuBar::ShowTable, m_game_list, &GameList::SetTableView);
|
||||||
MakeViewMenu();
|
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||||
menuBar()->addMenu(tr("Help"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::MakeFileMenu()
|
|
||||||
{
|
|
||||||
QMenu* file_menu = menuBar()->addMenu(tr("File"));
|
|
||||||
file_menu->addAction(tr("Open"), this, SLOT(Open()));
|
|
||||||
file_menu->addAction(tr("Exit"), this, SLOT(close()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::MakeViewMenu()
|
|
||||||
{
|
|
||||||
QMenu* view_menu = menuBar()->addMenu(tr("View"));
|
|
||||||
AddTableColumnsMenu(view_menu);
|
|
||||||
AddListTypePicker(view_menu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::AddTableColumnsMenu(QMenu* view_menu)
|
|
||||||
{
|
|
||||||
QActionGroup* column_group = new QActionGroup(this);
|
|
||||||
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
|
|
||||||
column_group->setExclusive(false);
|
|
||||||
|
|
||||||
QStringList col_names{
|
|
||||||
tr("Platform"),
|
|
||||||
tr("ID"),
|
|
||||||
tr("Banner"),
|
|
||||||
tr("Title"),
|
|
||||||
tr("Description"),
|
|
||||||
tr("Maker"),
|
|
||||||
tr("Size"),
|
|
||||||
tr("Country"),
|
|
||||||
tr("Quality")
|
|
||||||
};
|
|
||||||
// TODO we'll need to update SConfig with the extra columns. Then we can
|
|
||||||
// clean this up significantly.
|
|
||||||
QList<bool> show_cols{
|
|
||||||
SConfig::GetInstance().m_showSystemColumn,
|
|
||||||
SConfig::GetInstance().m_showIDColumn,
|
|
||||||
SConfig::GetInstance().m_showBannerColumn,
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
SConfig::GetInstance().m_showMakerColumn,
|
|
||||||
SConfig::GetInstance().m_showSizeColumn,
|
|
||||||
SConfig::GetInstance().m_showRegionColumn,
|
|
||||||
SConfig::GetInstance().m_showStateColumn,
|
|
||||||
};
|
|
||||||
for (int i = 0; i < GameListModel::NUM_COLS; i++)
|
|
||||||
{
|
|
||||||
QAction* action = column_group->addAction(cols_menu->addAction(col_names[i]));
|
|
||||||
action->setCheckable(true);
|
|
||||||
action->setChecked(show_cols[i]);
|
|
||||||
m_game_list->SetViewColumn(i, show_cols[i]);
|
|
||||||
connect(action, &QAction::triggered, [=]()
|
|
||||||
{
|
|
||||||
m_game_list->SetViewColumn(i, action->isChecked());
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case GameListModel::COL_PLATFORM:
|
|
||||||
SConfig::GetInstance().m_showSystemColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_ID:
|
|
||||||
SConfig::GetInstance().m_showIDColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_TITLE:
|
|
||||||
SConfig::GetInstance().m_showBannerColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_MAKER:
|
|
||||||
SConfig::GetInstance().m_showMakerColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_SIZE:
|
|
||||||
SConfig::GetInstance().m_showSizeColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_COUNTRY:
|
|
||||||
SConfig::GetInstance().m_showRegionColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
case GameListModel::COL_RATING:
|
|
||||||
SConfig::GetInstance().m_showStateColumn = action->isChecked();
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
SConfig::GetInstance().SaveSettings();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::AddListTypePicker(QMenu* view_menu)
|
|
||||||
{
|
|
||||||
QActionGroup* list_group = new QActionGroup(this);
|
|
||||||
view_menu->addSection(tr("List Type"));
|
|
||||||
list_group->setExclusive(true);
|
|
||||||
|
|
||||||
QAction* set_table = list_group->addAction(view_menu->addAction(tr("Table")));
|
|
||||||
QAction* set_list = list_group->addAction(view_menu->addAction(tr("List")));
|
|
||||||
|
|
||||||
set_table->setCheckable(true);
|
|
||||||
set_table->setChecked(true);
|
|
||||||
set_list->setCheckable(true);
|
|
||||||
|
|
||||||
connect(set_table, &QAction::triggered, m_game_list, &GameList::SetTableView);
|
|
||||||
connect(set_list, &QAction::triggered, m_game_list, &GameList::SetListView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeToolBar()
|
void MainWindow::MakeToolBar()
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
|
#include "DolphinQt2/MenuBar.h"
|
||||||
#include "DolphinQt2/RenderWidget.h"
|
#include "DolphinQt2/RenderWidget.h"
|
||||||
#include "DolphinQt2/ToolBar.h"
|
#include "DolphinQt2/ToolBar.h"
|
||||||
#include "DolphinQt2/GameList/GameList.h"
|
#include "DolphinQt2/GameList/GameList.h"
|
||||||
@ -37,16 +38,11 @@ private slots:
|
|||||||
void ScreenShot();
|
void ScreenShot();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeToolBar();
|
|
||||||
void MakeStack();
|
|
||||||
void MakeGameList();
|
void MakeGameList();
|
||||||
|
void MakeMenuBar();
|
||||||
void MakeRenderWidget();
|
void MakeRenderWidget();
|
||||||
|
void MakeStack();
|
||||||
void MakeMenus();
|
void MakeToolBar();
|
||||||
void MakeFileMenu();
|
|
||||||
void MakeViewMenu();
|
|
||||||
void AddTableColumnsMenu(QMenu* view_menu);
|
|
||||||
void AddListTypePicker(QMenu* view_menu);
|
|
||||||
|
|
||||||
void StartGame(QString path);
|
void StartGame(QString path);
|
||||||
void ShowRenderWidget();
|
void ShowRenderWidget();
|
||||||
@ -54,6 +50,7 @@ private:
|
|||||||
|
|
||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
ToolBar* m_tool_bar;
|
ToolBar* m_tool_bar;
|
||||||
|
MenuBar* m_menu_bar;
|
||||||
GameList* m_game_list;
|
GameList* m_game_list;
|
||||||
RenderWidget* m_render_widget;
|
RenderWidget* m_render_widget;
|
||||||
bool m_rendering_to_main;
|
bool m_rendering_to_main;
|
||||||
|
80
Source/Core/DolphinQt2/MenuBar.cpp
Normal file
80
Source/Core/DolphinQt2/MenuBar.cpp
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
// Copyright 2015 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QActionGroup>
|
||||||
|
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
|
#include "DolphinQt2/MenuBar.h"
|
||||||
|
|
||||||
|
MenuBar::MenuBar(QWidget* parent)
|
||||||
|
: QMenuBar(parent)
|
||||||
|
{
|
||||||
|
AddFileMenu();
|
||||||
|
addMenu(tr("Emulation"));
|
||||||
|
addMenu(tr("Movie"));
|
||||||
|
addMenu(tr("Options"));
|
||||||
|
addMenu(tr("Tools"));
|
||||||
|
AddViewMenu();
|
||||||
|
addMenu(tr("Help"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddFileMenu()
|
||||||
|
{
|
||||||
|
QMenu* file_menu = addMenu(tr("File"));
|
||||||
|
file_menu->addAction(tr("Open"), this, SIGNAL(Open()));
|
||||||
|
file_menu->addAction(tr("Exit"), this, SIGNAL(Exit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddViewMenu()
|
||||||
|
{
|
||||||
|
QMenu* view_menu = addMenu(tr("View"));
|
||||||
|
AddGameListTypeSection(view_menu);
|
||||||
|
view_menu->addSeparator();
|
||||||
|
AddTableColumnsMenu(view_menu);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
||||||
|
{
|
||||||
|
QAction* table_view = view_menu->addAction(tr("Table"));
|
||||||
|
table_view->setCheckable(true);
|
||||||
|
|
||||||
|
QAction* list_view = view_menu->addAction(tr("List"));
|
||||||
|
list_view->setCheckable(true);
|
||||||
|
|
||||||
|
QActionGroup* list_group = new QActionGroup(this);
|
||||||
|
list_group->addAction(table_view);
|
||||||
|
list_group->addAction(list_view);
|
||||||
|
|
||||||
|
// TODO load this from settings
|
||||||
|
table_view->setChecked(true);
|
||||||
|
|
||||||
|
connect(table_view, &QAction::triggered, this, &MenuBar::ShowTable);
|
||||||
|
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO implement this after we stop using SConfig.
|
||||||
|
void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
||||||
|
{
|
||||||
|
QActionGroup* column_group = new QActionGroup(this);
|
||||||
|
QMenu* cols_menu = view_menu->addMenu(tr("Table Columns"));
|
||||||
|
column_group->setExclusive(false);
|
||||||
|
|
||||||
|
QStringList col_names{
|
||||||
|
tr("Platform"),
|
||||||
|
tr("ID"),
|
||||||
|
tr("Banner"),
|
||||||
|
tr("Title"),
|
||||||
|
tr("Description"),
|
||||||
|
tr("Maker"),
|
||||||
|
tr("Size"),
|
||||||
|
tr("Country"),
|
||||||
|
tr("Quality")
|
||||||
|
};
|
||||||
|
for (int i = 0; i < col_names.count(); i++)
|
||||||
|
{
|
||||||
|
QAction* action = column_group->addAction(cols_menu->addAction(col_names[i]));
|
||||||
|
action->setCheckable(true);
|
||||||
|
}
|
||||||
|
}
|
30
Source/Core/DolphinQt2/MenuBar.h
Normal file
30
Source/Core/DolphinQt2/MenuBar.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright 2015 Dolphin Emulator Project
|
||||||
|
// Licensed under GPLv2+
|
||||||
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QMenuBar>
|
||||||
|
|
||||||
|
class MenuBar final : public QMenuBar
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MenuBar(QWidget* parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void Open();
|
||||||
|
void Exit();
|
||||||
|
|
||||||
|
void ShowTable();
|
||||||
|
void ShowList();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void AddFileMenu();
|
||||||
|
void AddViewMenu();
|
||||||
|
|
||||||
|
void AddGameListTypeSection(QMenu* view_menu);
|
||||||
|
void AddTableColumnsMenu(QMenu* view_menu);
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user