diff --git a/Externals/Qt b/Externals/Qt index e800367547..9dca8d6c71 160000 --- a/Externals/Qt +++ b/Externals/Qt @@ -1 +1 @@ -Subproject commit e800367547f23b981d1de8e6c13c1d6a88d56746 +Subproject commit 9dca8d6c716ad304d9382116ee29b5e2e4cde8d8 diff --git a/Source/Core/DolphinQt/AboutDialog.h b/Source/Core/DolphinQt/AboutDialog.h index 40f128ae7f..fa476a1024 100644 --- a/Source/Core/DolphinQt/AboutDialog.h +++ b/Source/Core/DolphinQt/AboutDialog.h @@ -13,7 +13,7 @@ namespace Ui class DAboutDialog; } -class DAboutDialog : public QDialog +class DAboutDialog final : public QDialog { Q_OBJECT diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 718cdee343..abb186303c 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -47,6 +47,7 @@ true $(ExternalsDir)OpenAL\$(PlatformName);%(AdditionalLibraryDirectories) iphlpapi.lib;winmm.lib;setupapi.lib;vfw32.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies) + Windows $(ProjectDir)\VideoInterface;$(ProjectDir)\GameList;%(AdditionalIncludeDirectories) @@ -171,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/GameList/GameGrid.h b/Source/Core/DolphinQt/GameList/GameGrid.h index 50a70dc2fb..63e665e8a4 100644 --- a/Source/Core/DolphinQt/GameList/GameGrid.h +++ b/Source/Core/DolphinQt/GameList/GameGrid.h @@ -16,7 +16,7 @@ namespace Ui class DGameGrid; } -class DGameGrid : public QListWidget, public AbstractGameList +class DGameGrid final : public QListWidget, public AbstractGameList { Q_OBJECT diff --git a/Source/Core/DolphinQt/GameList/GameTracker.h b/Source/Core/DolphinQt/GameList/GameTracker.h index 7501874613..7f92ac2c00 100644 --- a/Source/Core/DolphinQt/GameList/GameTracker.h +++ b/Source/Core/DolphinQt/GameList/GameTracker.h @@ -38,7 +38,7 @@ public: void RemoveGames(QList items); }; -class DGameTracker : public QStackedWidget +class DGameTracker final : public QStackedWidget { Q_OBJECT diff --git a/Source/Core/DolphinQt/GameList/GameTree.h b/Source/Core/DolphinQt/GameList/GameTree.h index 2e379f99e7..37a1d0dfc7 100644 --- a/Source/Core/DolphinQt/GameList/GameTree.h +++ b/Source/Core/DolphinQt/GameList/GameTree.h @@ -16,7 +16,7 @@ namespace Ui class DGameTree; } -class DGameTree : public QTreeWidget, public AbstractGameList +class DGameTree final : public QTreeWidget, public AbstractGameList { Q_OBJECT 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/Main.cpp b/Source/Core/DolphinQt/Main.cpp index 289fbeedc0..4719de7051 100644 --- a/Source/Core/DolphinQt/Main.cpp +++ b/Source/Core/DolphinQt/Main.cpp @@ -60,6 +60,7 @@ int main(int argc, char* argv[]) int retcode = app.exec(); delete g_main_window; + Core::Shutdown(); UICommon::Shutdown(); return retcode; } diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index 5ca60c22b2..4437147cf9 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -16,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" @@ -62,7 +64,9 @@ DMainWindow::DMainWindow(QWidget* parent_widget) StartGame(filename); }); connect(m_ui->actionBrowse, &QAction::triggered, this, &DMainWindow::OnBrowse); - connect(m_ui->actionExit, &QAction::triggered, this, &DMainWindow::OnExit); + connect(m_ui->actionExit, &QAction::triggered, this, [&]() { + close(); + }); connect(m_ui->actionListView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged); connect(m_ui->actionTreeView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged); @@ -70,19 +74,20 @@ DMainWindow::DMainWindow(QWidget* parent_widget) connect(m_ui->actionIconView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged); connect(m_ui->actionPlay, &QAction::triggered, this, &DMainWindow::OnPlay); - connect(m_ui->actionPlay_mnu, &QAction::triggered, this, &DMainWindow::OnPlay); connect(m_game_tracker, &DGameTracker::StartGame, this, &DMainWindow::OnPlay); connect(m_ui->actionStop, &QAction::triggered, this, &DMainWindow::OnStop); - connect(m_ui->actionStop_mnu, &QAction::triggered, this, &DMainWindow::OnStop); connect(m_ui->actionReset, &QAction::triggered, this, &DMainWindow::OnReset); + connect(m_ui->actionScreenshot, &QAction::triggered, this, []() { + Core::SaveScreenShot(); + }); - connect(m_ui->actionWebsite, &QAction::triggered, this, [&]() { + connect(m_ui->actionWebsite, &QAction::triggered, this, []() { QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/"))); }); - connect(m_ui->actionOnlineDocs, &QAction::triggered, this, [&]() { + connect(m_ui->actionOnlineDocs, &QAction::triggered, this, []() { QDesktopServices::openUrl(QUrl(SL("https://dolphin-emu.org/docs/guides/"))); }); - connect(m_ui->actionGitHub, &QAction::triggered, this, [&]() { + connect(m_ui->actionGitHub, &QAction::triggered, this, []() { QDesktopServices::openUrl(QUrl(SL("https://github.com/dolphin-emu/dolphin"))); }); connect(m_ui->actionSystemInfo, &QAction::triggered, this, [&]() { @@ -110,9 +115,23 @@ 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) { - Stop(); + if (!OnStop()) + ce->ignore(); + else + QMainWindow::closeEvent(ce); } // Emulation @@ -181,7 +200,7 @@ QString DMainWindow::RequestBootFilename() { // If a game is already selected, just return the filename if (m_game_tracker->SelectedGame() != nullptr) - return m_game_tracker->SelectedGame()->GetFileName(); + return m_game_tracker->SelectedGame()->GetFileName(); return ShowFileDialog(); } @@ -196,8 +215,7 @@ QString DMainWindow::ShowFileDialog() QString DMainWindow::ShowFolderDialog() { return QFileDialog::getExistingDirectory(this, tr("Browse for a directory to add"), - QDir::homePath(), - QFileDialog::ShowDirsOnly); + QDir::homePath(), QFileDialog::ShowDirsOnly); } void DMainWindow::DoStartPause() @@ -233,14 +251,6 @@ void DMainWindow::OnBrowse() m_game_tracker->ScanForGames(); } -void DMainWindow::OnExit() -{ - close(); - if (Core::GetState() == Core::CORE_UNINITIALIZED || m_isStopping) - return; - Stop(); -} - void DMainWindow::OnPlay() { if (Core::GetState() != Core::CORE_UNINITIALIZED) @@ -264,9 +274,17 @@ bool DMainWindow::OnStop() // Ask for confirmation in case the user accidentally clicked Stop / Escape if (SConfig::GetInstance().bConfirmStop) { - // Pause emulation - Core::SetState(Core::CORE_PAUSE); - emit CoreStateChanged(Core::CORE_PAUSE); + // Pause emulation if it isn't already + bool wasPaused = false; + if (Core::GetState() == Core::CORE_PAUSE) + { + wasPaused = true; + } + else + { + Core::SetState(Core::CORE_PAUSE); + emit CoreStateChanged(Core::CORE_PAUSE); + } QMessageBox::StandardButton ret = QMessageBox::question(m_render_widget.get(), tr("Please confirm..."), tr("Do you want to stop the current emulation?"), @@ -274,7 +292,8 @@ bool DMainWindow::OnStop() if (ret == QMessageBox::No) { - DoStartPause(); + if (!wasPaused) + DoStartPause(); return false; } } @@ -339,13 +358,11 @@ void DMainWindow::OnCoreStateChanged(Core::EState state) { m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PAUSE)); m_ui->actionPlay->setText(tr("Pause")); - m_ui->actionPlay_mnu->setText(tr("Pause")); } else if (is_paused || is_not_initialized) { m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PLAY)); m_ui->actionPlay->setText(tr("Play")); - m_ui->actionPlay_mnu->setText(tr("Play")); } m_ui->actionStop->setEnabled(!is_not_initialized); @@ -359,4 +376,5 @@ void DMainWindow::UpdateIcons() { // Play/Pause is handled in OnCoreStateChanged(). m_ui->actionStop->setIcon(Resources::GetIcon(Resources::TOOLBAR_STOP)); + m_ui->actionScreenshot->setIcon(Resources::GetIcon(Resources::TOOLBAR_SCREENSHOT)); } diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index 0644d57d84..0b2eb74b91 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -18,7 +18,7 @@ namespace Ui class DMainWindow; } -class DMainWindow : public QMainWindow +class DMainWindow final : public QMainWindow { Q_OBJECT @@ -44,7 +44,6 @@ private slots: // Main toolbar void OnBrowse(); - void OnExit(); void OnPlay(); void OnReset(); @@ -55,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; diff --git a/Source/Core/DolphinQt/MainWindow.ui b/Source/Core/DolphinQt/MainWindow.ui index 966486f29f..4f1a209d09 100644 --- a/Source/Core/DolphinQt/MainWindow.ui +++ b/Source/Core/DolphinQt/MainWindow.ui @@ -19,9 +19,6 @@ 32 - - Qt::ToolButtonTextUnderIcon - true @@ -32,9 +29,12 @@ 0 0 990 - 19 + 21 + + true + Fi&le @@ -49,9 +49,11 @@ E&mulation - - + + + + @@ -108,6 +110,9 @@ Toolbar + + Qt::ToolButtonTextUnderIcon + TopToolBarArea @@ -116,6 +121,7 @@ + @@ -160,11 +166,23 @@ Play + + F10 + + + false + Stop + + Esc + + + false + @@ -216,27 +234,19 @@ Exit - - - &Play - - - F10 - - - - - &Stop - - - Esc - - &Reset + + + Screenshot + + + false + + diff --git a/Source/Core/DolphinQt/SystemInfo.cpp b/Source/Core/DolphinQt/SystemInfo.cpp index 0693ea9189..5c16b9ba80 100644 --- a/Source/Core/DolphinQt/SystemInfo.cpp +++ b/Source/Core/DolphinQt/SystemInfo.cpp @@ -46,7 +46,7 @@ void DSystemInfo::UpdateSystemInfo() sysinfo += SL("System\n===========================\n"); sysinfo += SL("OS: %1\n").arg(GetOS()); - sysinfo += SL("CPU: %1, %2 cores\n").arg(QString::fromStdString(cpu_info.Summarize())) + sysinfo += SL("CPU: %1, %2 logical processors\n").arg(QString::fromStdString(cpu_info.Summarize())) .arg(QThread::idealThreadCount()); sysinfo += SL("\nDolphin\n===========================\n"); @@ -69,12 +69,16 @@ QString DSystemInfo::GetOS() const case QSysInfo::WV_VISTA: ret += SL("Vista"); break; case QSysInfo::WV_WINDOWS7: ret += SL("7"); break; case QSysInfo::WV_WINDOWS8: ret += SL("8"); break; + case QSysInfo::WV_WINDOWS8_1: ret += SL("8.1"); break; + case QSysInfo::WV_WINDOWS10: ret += SL("10"); break; default: ret += SL("(unknown)"); break; } #elif defined(Q_OS_MAC) ret += SL("Mac OS X "); switch (QSysInfo::MacintoshVersion) { case QSysInfo::MV_10_9: ret += SL("10.9"); break; + case QSysInfo::MV_10_10: ret += SL("10.10"); break; + case QSysInfo::MV_10_11: ret += SL("10.11"); break; default: ret += SL("(unknown)"); break; } #elif defined(Q_OS_LINUX) diff --git a/Source/Core/DolphinQt/SystemInfo.h b/Source/Core/DolphinQt/SystemInfo.h index b7906d2b47..3e010b0259 100644 --- a/Source/Core/DolphinQt/SystemInfo.h +++ b/Source/Core/DolphinQt/SystemInfo.h @@ -12,7 +12,7 @@ namespace Ui class DSystemInfo; } -class DSystemInfo : public QDialog +class DSystemInfo final : public QDialog { Q_OBJECT diff --git a/Source/Core/DolphinQt/VideoInterface/RenderWidget.h b/Source/Core/DolphinQt/VideoInterface/RenderWidget.h index 3f6be38ff2..67639e7322 100644 --- a/Source/Core/DolphinQt/VideoInterface/RenderWidget.h +++ b/Source/Core/DolphinQt/VideoInterface/RenderWidget.h @@ -6,7 +6,7 @@ #include -class DRenderWidget : public QWidget +class DRenderWidget final : public QWidget { Q_OBJECT @@ -19,10 +19,7 @@ protected: void mousePressEvent(QMouseEvent*) override {} void paintEvent(QPaintEvent*) override {} -private slots: +private: void closeEvent(QCloseEvent* e) override; - -signals: - void Closed(); };