From cb71b06afc860233af4f3080f8501ece68edb489 Mon Sep 17 00:00:00 2001 From: spycrab Date: Sat, 24 Mar 2018 02:13:56 +0100 Subject: [PATCH] Qt: Show shader generation window --- Source/Core/DolphinQt2/Host.cpp | 2 ++ Source/Core/DolphinQt2/Host.h | 1 + Source/Core/DolphinQt2/MainWindow.cpp | 28 +++++++++++++++++++++++++++ Source/Core/DolphinQt2/MainWindow.h | 16 ++++++++++----- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/Source/Core/DolphinQt2/Host.cpp b/Source/Core/DolphinQt2/Host.cpp index dd9e57f421..a788a76af0 100644 --- a/Source/Core/DolphinQt2/Host.cpp +++ b/Source/Core/DolphinQt2/Host.cpp @@ -6,6 +6,7 @@ #include #include +#include #include "Common/Common.h" #include "Core/ConfigManager.h" @@ -105,6 +106,7 @@ void Host_UpdateDisasmDialog() void Host_UpdateProgressDialog(const char* caption, int position, int total) { + emit Host::GetInstance()->UpdateProgressDialog(QString::fromUtf8(caption), position, total); } // We ignore these, and their purpose should be questioned individually. diff --git a/Source/Core/DolphinQt2/Host.h b/Source/Core/DolphinQt2/Host.h index dc74882ae5..c5f0f071fb 100644 --- a/Source/Core/DolphinQt2/Host.h +++ b/Source/Core/DolphinQt2/Host.h @@ -32,6 +32,7 @@ signals: void RequestTitle(const QString& title); void RequestStop(); void RequestRenderSize(int w, int h); + void UpdateProgressDialog(QString label, int position, int maximum); private: Host(); diff --git a/Source/Core/DolphinQt2/MainWindow.cpp b/Source/Core/DolphinQt2/MainWindow.cpp index 1afa2bafdd..a1f4812e78 100644 --- a/Source/Core/DolphinQt2/MainWindow.cpp +++ b/Source/Core/DolphinQt2/MainWindow.cpp @@ -93,6 +93,7 @@ MainWindow::MainWindow(std::unique_ptr boot_parameters) : QMainW CreateComponents(); ConnectGameList(); + ConnectHost(); ConnectToolBar(); ConnectRenderWidget(); ConnectStack(); @@ -375,6 +376,12 @@ void MainWindow::ConnectRenderWidget() connect(m_render_widget, &RenderWidget::Closed, this, &MainWindow::ForceStop); } +void MainWindow::ConnectHost() +{ + connect(Host::GetInstance(), &Host::UpdateProgressDialog, this, + &MainWindow::OnUpdateProgressDialog); +} + void MainWindow::ConnectStack() { auto* widget = new QWidget; @@ -1194,3 +1201,24 @@ void MainWindow::ShowMemcardManager() manager.exec(); } + +void MainWindow::OnUpdateProgressDialog(QString title, int progress, int total) +{ + if (!m_progress_dialog) + { + m_progress_dialog = new QProgressDialog(m_render_widget); + m_progress_dialog->show(); + } + + m_progress_dialog->setValue(progress); + m_progress_dialog->setLabelText(title); + m_progress_dialog->setWindowTitle(title); + m_progress_dialog->setMaximum(total); + + if (total < 0 || progress >= total) + { + m_progress_dialog->hide(); + m_progress_dialog->deleteLater(); + m_progress_dialog = nullptr; + } +} diff --git a/Source/Core/DolphinQt2/MainWindow.h b/Source/Core/DolphinQt2/MainWindow.h index e324185385..0e25d932c5 100644 --- a/Source/Core/DolphinQt2/MainWindow.h +++ b/Source/Core/DolphinQt2/MainWindow.h @@ -18,10 +18,16 @@ #include "DolphinQt2/RenderWidget.h" #include "DolphinQt2/ToolBar.h" +class QProgressDialog; + class BreakpointWidget; struct BootParameters; class CodeWidget; +class ControllersWindow; +class DragEnterEvent; class FIFOPlayerWindow; +class GCTASInputWindow; +class GraphicsWindow; class HotkeyScheduler; class LogConfigWidget; class LogWidget; @@ -30,14 +36,10 @@ class NetPlayClient; class NetPlayDialog; class NetPlayServer; class NetPlaySetupDialog; +class RegisterWidget; class SearchBar; class SettingsWindow; -class ControllersWindow; -class DragEnterEvent; -class GraphicsWindow; -class RegisterWidget; class WatchWidget; -class GCTASInputWindow; class WiiTASInputWindow; class MainWindow final : public QMainWindow @@ -85,6 +87,7 @@ private: void CreateComponents(); void ConnectGameList(); + void ConnectHost(); void ConnectHotkeys(); void ConnectMenuBar(); void ConnectRenderWidget(); @@ -122,6 +125,8 @@ private: void OnImportNANDBackup(); void OnConnectWiiRemote(int id); + void OnUpdateProgressDialog(QString label, int progress, int total); + void OnPlayRecording(); void OnStartRecording(); void OnStopRecording(); @@ -135,6 +140,7 @@ private: void dropEvent(QDropEvent* event) override; QSize sizeHint() const override; + QProgressDialog* m_progress_dialog = nullptr; QStackedWidget* m_stack; ToolBar* m_tool_bar; MenuBar* m_menu_bar;