From f5743f5ee91586525046b4bb3e116fb7fe7f8d99 Mon Sep 17 00:00:00 2001 From: waddlesplash Date: Sat, 12 Sep 2015 14:00:08 -0400 Subject: [PATCH] DolphinQt: Handle the Host_UpdateTitle callback. --- Source/Core/DolphinQt/DolphinQt.vcxproj | 1 + .../Core/DolphinQt/DolphinQt.vcxproj.filters | 1 + Source/Core/DolphinQt/Host.cpp | 9 ++++++++- Source/Core/DolphinQt/Host.h | 19 +++++++++++++++++++ Source/Core/DolphinQt/MainWindow.cpp | 12 ++++++++++++ Source/Core/DolphinQt/MainWindow.h | 3 ++- 6 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Source/Core/DolphinQt/Host.h diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index c620893958..abb186303c 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -172,6 +172,7 @@ + diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj.filters b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters index 6eb3c010bc..2c58321344 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj.filters +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters @@ -83,6 +83,7 @@ + Utils diff --git a/Source/Core/DolphinQt/Host.cpp b/Source/Core/DolphinQt/Host.cpp index 150c0ba88b..e07796a18b 100644 --- a/Source/Core/DolphinQt/Host.cpp +++ b/Source/Core/DolphinQt/Host.cpp @@ -10,8 +10,15 @@ #include "Common/MsgHandler.h" #include "Core/Host.h" +#include "DolphinQt/Host.h" #include "DolphinQt/MainWindow.h" +HostTitleEvent::HostTitleEvent(const std::string& title) + : QEvent((QEvent::Type)HostEvent::TitleEvent), + m_title(title) +{ +} + void Host_Message(int id) { // TODO @@ -24,7 +31,7 @@ void Host_UpdateMainFrame() void Host_UpdateTitle(const std::string& title) { - // TODO + qApp->postEvent(g_main_window, new HostTitleEvent(title)); } void* Host_GetRenderHandle() diff --git a/Source/Core/DolphinQt/Host.h b/Source/Core/DolphinQt/Host.h new file mode 100644 index 0000000000..40c4b6c54a --- /dev/null +++ b/Source/Core/DolphinQt/Host.h @@ -0,0 +1,19 @@ +// Copyright 2015 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +enum HostEvent { + TitleEvent = QEvent::User + 1, +}; + +class HostTitleEvent final : public QEvent +{ +public: + HostTitleEvent(const std::string& title); + const std::string m_title; +}; diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index a4806d0e46..4437147cf9 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -17,6 +17,7 @@ #include "Core/HW/ProcessorInterface.h" #include "DolphinQt/AboutDialog.h" +#include "DolphinQt/Host.h" #include "DolphinQt/MainWindow.h" #include "DolphinQt/SystemInfo.h" #include "DolphinQt/Utils/Resources.h" @@ -114,6 +115,17 @@ DMainWindow::~DMainWindow() { } +bool DMainWindow::event(QEvent* e) +{ + if (e->type() == HostEvent::TitleEvent) + { + HostTitleEvent* htev = (HostTitleEvent*)e; + m_ui->statusbar->showMessage(QString::fromStdString(htev->m_title), 1500); + return true; + } + return QMainWindow::event(e); +} + void DMainWindow::closeEvent(QCloseEvent* ce) { if (!OnStop()) diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index c36284fa09..0b2eb74b91 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -54,7 +54,8 @@ private slots: void UpdateIcons(); private: - void closeEvent(QCloseEvent* ce); + bool event(QEvent* e) override; + void closeEvent(QCloseEvent* ce) override; std::unique_ptr m_ui; DGameTracker* m_game_tracker;