Make paths dialog modeless.
This commit is contained in:
parent
35d7c2bc78
commit
726d6c17af
|
@ -21,7 +21,6 @@ PathDialog::PathDialog(QWidget* parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Paths"));
|
setWindowTitle(tr("Paths"));
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout;
|
QVBoxLayout* layout = new QVBoxLayout;
|
||||||
layout->addWidget(MakeGameFolderBox());
|
layout->addWidget(MakeGameFolderBox());
|
||||||
|
|
|
@ -22,21 +22,28 @@ MainWindow::MainWindow() : QMainWindow(nullptr)
|
||||||
setWindowTitle(tr("Dolphin"));
|
setWindowTitle(tr("Dolphin"));
|
||||||
setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
|
setWindowIcon(QIcon(Resources::GetMisc(Resources::LOGO_SMALL)));
|
||||||
|
|
||||||
MakeGameList();
|
CreateComponents();
|
||||||
MakeToolBar();
|
|
||||||
MakeRenderWidget();
|
ConnectGameList();
|
||||||
MakeStack();
|
ConnectPathsDialog();
|
||||||
MakeMenuBar();
|
ConnectToolBar();
|
||||||
|
ConnectRenderWidget();
|
||||||
|
ConnectStack();
|
||||||
|
ConnectMenuBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
void MainWindow::CreateComponents()
|
||||||
{
|
|
||||||
m_render_widget->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::MakeMenuBar()
|
|
||||||
{
|
{
|
||||||
m_menu_bar = new MenuBar(this);
|
m_menu_bar = new MenuBar(this);
|
||||||
|
m_tool_bar = new ToolBar(this);
|
||||||
|
m_game_list = new GameList(this);
|
||||||
|
m_render_widget = new RenderWidget(this);
|
||||||
|
m_stack = new QStackedWidget(this);
|
||||||
|
m_paths_dialog = new PathDialog(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ConnectMenuBar()
|
||||||
|
{
|
||||||
setMenuBar(m_menu_bar);
|
setMenuBar(m_menu_bar);
|
||||||
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
connect(m_menu_bar, &MenuBar::Open, this, &MainWindow::Open);
|
||||||
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
connect(m_menu_bar, &MenuBar::Exit, this, &MainWindow::close);
|
||||||
|
@ -44,47 +51,48 @@ void MainWindow::MakeMenuBar()
|
||||||
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
connect(m_menu_bar, &MenuBar::ShowList, m_game_list, &GameList::SetListView);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeToolBar()
|
void MainWindow::ConnectToolBar()
|
||||||
{
|
{
|
||||||
m_tool_bar = new ToolBar(this);
|
|
||||||
addToolBar(m_tool_bar);
|
addToolBar(m_tool_bar);
|
||||||
|
|
||||||
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
|
connect(m_tool_bar, &ToolBar::OpenPressed, this, &MainWindow::Open);
|
||||||
connect(m_tool_bar, &ToolBar::PlayPressed, this, &MainWindow::Play);
|
connect(m_tool_bar, &ToolBar::PlayPressed, this, &MainWindow::Play);
|
||||||
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
|
connect(m_tool_bar, &ToolBar::PausePressed, this, &MainWindow::Pause);
|
||||||
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::Stop);
|
connect(m_tool_bar, &ToolBar::StopPressed, this, &MainWindow::Stop);
|
||||||
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
|
connect(m_tool_bar, &ToolBar::FullScreenPressed, this, &MainWindow::FullScreen);
|
||||||
connect(m_tool_bar, &ToolBar::ScreenShotPressed, this, &MainWindow::ScreenShot);
|
connect(m_tool_bar, &ToolBar::ScreenShotPressed, this, &MainWindow::ScreenShot);
|
||||||
connect(m_tool_bar, &ToolBar::PathsPressed, this, &MainWindow::PathsConfig);
|
connect(m_tool_bar, &ToolBar::PathsPressed, this, &MainWindow::ShowPathsDialog);
|
||||||
|
|
||||||
connect(this, &MainWindow::EmulationStarted, m_tool_bar, &ToolBar::EmulationStarted);
|
connect(this, &MainWindow::EmulationStarted, m_tool_bar, &ToolBar::EmulationStarted);
|
||||||
connect(this, &MainWindow::EmulationPaused, m_tool_bar, &ToolBar::EmulationPaused);
|
connect(this, &MainWindow::EmulationPaused, m_tool_bar, &ToolBar::EmulationPaused);
|
||||||
connect(this, &MainWindow::EmulationStopped, m_tool_bar, &ToolBar::EmulationStopped);
|
connect(this, &MainWindow::EmulationStopped, m_tool_bar, &ToolBar::EmulationStopped);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeGameList()
|
void MainWindow::ConnectGameList()
|
||||||
{
|
{
|
||||||
m_game_list = new GameList(this);
|
|
||||||
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
connect(m_game_list, &GameList::GameSelected, this, &MainWindow::Play);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeRenderWidget()
|
void MainWindow::ConnectRenderWidget()
|
||||||
{
|
{
|
||||||
m_render_widget = new RenderWidget;
|
m_rendering_to_main = false;
|
||||||
|
m_render_widget->hide();
|
||||||
connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::Stop);
|
connect(m_render_widget, &RenderWidget::EscapePressed, this, &MainWindow::Stop);
|
||||||
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop);
|
||||||
m_render_widget->hide();
|
|
||||||
m_rendering_to_main = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MakeStack()
|
void MainWindow::ConnectStack()
|
||||||
{
|
{
|
||||||
m_stack = new QStackedWidget;
|
|
||||||
m_stack->setMinimumSize(800, 600);
|
m_stack->setMinimumSize(800, 600);
|
||||||
m_stack->addWidget(m_game_list);
|
m_stack->addWidget(m_game_list);
|
||||||
setCentralWidget(m_stack);
|
setCentralWidget(m_stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ConnectPathsDialog()
|
||||||
|
{
|
||||||
|
connect(m_paths_dialog, &PathDialog::PathAdded, m_game_list, &GameList::DirectoryAdded);
|
||||||
|
connect(m_paths_dialog, &PathDialog::PathRemoved, m_game_list, &GameList::DirectoryRemoved);
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::Open()
|
void MainWindow::Open()
|
||||||
{
|
{
|
||||||
QString file = QFileDialog::getOpenFileName(this,
|
QString file = QFileDialog::getOpenFileName(this,
|
||||||
|
@ -182,14 +190,6 @@ void MainWindow::ScreenShot()
|
||||||
Core::SaveScreenShot();
|
Core::SaveScreenShot();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::PathsConfig()
|
|
||||||
{
|
|
||||||
PathDialog* paths = new PathDialog(this);
|
|
||||||
connect(paths, &PathDialog::PathAdded, m_game_list, &GameList::DirectoryAdded);
|
|
||||||
connect(paths, &PathDialog::PathRemoved, m_game_list, &GameList::DirectoryRemoved);
|
|
||||||
paths->exec();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::StartGame(const QString& path)
|
void MainWindow::StartGame(const QString& path)
|
||||||
{
|
{
|
||||||
// If we're running, only start a new game once we've stopped the last.
|
// If we're running, only start a new game once we've stopped the last.
|
||||||
|
@ -249,3 +249,10 @@ void MainWindow::HideRenderWidget()
|
||||||
}
|
}
|
||||||
m_render_widget->hide();
|
m_render_widget->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::ShowPathsDialog()
|
||||||
|
{
|
||||||
|
m_paths_dialog->show();
|
||||||
|
m_paths_dialog->raise();
|
||||||
|
m_paths_dialog->activateWindow();
|
||||||
|
}
|
||||||
|
|
|
@ -14,13 +14,14 @@
|
||||||
#include "DolphinQt2/ToolBar.h"
|
#include "DolphinQt2/ToolBar.h"
|
||||||
#include "DolphinQt2/GameList/GameList.h"
|
#include "DolphinQt2/GameList/GameList.h"
|
||||||
|
|
||||||
|
class PathDialog;
|
||||||
|
|
||||||
class MainWindow final : public QMainWindow
|
class MainWindow final : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow();
|
explicit MainWindow();
|
||||||
~MainWindow();
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void EmulationStarted();
|
void EmulationStarted();
|
||||||
|
@ -39,23 +40,28 @@ private slots:
|
||||||
void FullScreen();
|
void FullScreen();
|
||||||
void ScreenShot();
|
void ScreenShot();
|
||||||
|
|
||||||
void PathsConfig();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeGameList();
|
void CreateComponents();
|
||||||
void MakeMenuBar();
|
|
||||||
void MakeRenderWidget();
|
void ConnectGameList();
|
||||||
void MakeStack();
|
void ConnectMenuBar();
|
||||||
void MakeToolBar();
|
void ConnectRenderWidget();
|
||||||
|
void ConnectStack();
|
||||||
|
void ConnectToolBar();
|
||||||
|
void ConnectPathsDialog();
|
||||||
|
|
||||||
void StartGame(const QString& path);
|
void StartGame(const QString& path);
|
||||||
void ShowRenderWidget();
|
void ShowRenderWidget();
|
||||||
void HideRenderWidget();
|
void HideRenderWidget();
|
||||||
|
|
||||||
|
void ShowPathsDialog();
|
||||||
|
|
||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
ToolBar* m_tool_bar;
|
ToolBar* m_tool_bar;
|
||||||
MenuBar* m_menu_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;
|
||||||
|
|
||||||
|
PathDialog* m_paths_dialog;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue