diff options
| author | Scott Mansell <phiren@gmail.com> | 2015-11-23 21:45:28 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2015-11-23 21:45:28 +1300 |
| commit | ffb9722f2d8d5283d79efa327adb880bbd1571b7 (patch) | |
| tree | 3ed7a7e93205ffc5a6f47745d3c105435dd8edcf /Source/Core | |
| parent | deacff4adb43727be723197742dcac888f04574e (diff) | |
| parent | 2d9c5ce6b33e466d364e929080d512b6bd525430 (diff) | |
Merge pull request #3032 from waddlesplash/dolphin-qt
Lots more minor DolphinQt stuffs.
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DolphinQt/AboutDialog.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/DolphinQt.vcxproj | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/DolphinQt.vcxproj.filters | 1 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/GameList/GameGrid.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/GameList/GameTracker.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/GameList/GameTree.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Host.cpp | 9 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Host.h | 19 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/Main.cpp | 1 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/MainWindow.cpp | 66 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/MainWindow.h | 6 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/MainWindow.ui | 50 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/SystemInfo.cpp | 6 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/SystemInfo.h | 2 | ||||
| -rw-r--r-- | Source/Core/DolphinQt/VideoInterface/RenderWidget.h | 7 |
15 files changed, 118 insertions, 59 deletions
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 @@ <FixedBaseAddress>true</FixedBaseAddress>
<AdditionalLibraryDirectories>$(ExternalsDir)OpenAL\$(PlatformName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>iphlpapi.lib;winmm.lib;setupapi.lib;vfw32.lib;opengl32.lib;glu32.lib;rpcrt4.lib;comctl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Windows</SubSystem>
</Link>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\VideoInterface;$(ProjectDir)\GameList;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -171,6 +172,7 @@ <ClInclude Include="GameList\GameGrid.h" />
<ClInclude Include="GameList\GameTracker.h" />
<ClInclude Include="GameList\GameTree.h" />
+ <ClInclude Include="Host.h" />
<ClInclude Include="Utils\Resources.h" />
<ClInclude Include="Utils\Utils.h" />
<ClInclude Include="VideoInterface\RenderWidget.h" />
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 @@ </Filter>
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="Host.h" />
<ClInclude Include="Utils\Resources.h">
<Filter>Utils</Filter>
</ClInclude>
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<GameFile*> 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 <QEvent> +#include <string> + +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 <memory> #include <QActionGroup> +#include <QCloseEvent> #include <QDesktopServices> #include <QFileDialog> #include <QMessageBox> @@ -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<Ui::DMainWindow> 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 @@ <height>32</height> </size> </property> - <property name="toolButtonStyle"> - <enum>Qt::ToolButtonTextUnderIcon</enum> - </property> <property name="unifiedTitleAndToolBarOnMac"> <bool>true</bool> </property> @@ -32,9 +29,12 @@ <x>0</x> <y>0</y> <width>990</width> - <height>19</height> + <height>21</height> </rect> </property> + <property name="nativeMenuBar"> + <bool>true</bool> + </property> <widget class="QMenu" name="mnuFile"> <property name="title"> <string>Fi&le</string> @@ -49,9 +49,11 @@ <property name="title"> <string>E&mulation</string> </property> - <addaction name="actionPlay_mnu"/> - <addaction name="actionStop_mnu"/> + <addaction name="actionPlay"/> + <addaction name="actionStop"/> <addaction name="actionReset"/> + <addaction name="separator"/> + <addaction name="actionScreenshot"/> </widget> <widget class="QMenu" name="mnuOptions"> <property name="title"> @@ -108,6 +110,9 @@ <property name="windowTitle"> <string>Toolbar</string> </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextUnderIcon</enum> + </property> <attribute name="toolBarArea"> <enum>TopToolBarArea</enum> </attribute> @@ -116,6 +121,7 @@ </attribute> <addaction name="actionPlay"/> <addaction name="actionStop"/> + <addaction name="actionScreenshot"/> </widget> <action name="actionWebsite"> <property name="text"> @@ -160,11 +166,23 @@ <property name="text"> <string>Play</string> </property> + <property name="shortcut"> + <string>F10</string> + </property> + <property name="iconVisibleInMenu"> + <bool>false</bool> + </property> </action> <action name="actionStop"> <property name="text"> <string>Stop</string> </property> + <property name="shortcut"> + <string>Esc</string> + </property> + <property name="iconVisibleInMenu"> + <bool>false</bool> + </property> </action> <action name="actionAboutQt"> <property name="text"> @@ -216,25 +234,17 @@ <string>Exit</string> </property> </action> - <action name="actionPlay_mnu"> + <action name="actionReset"> <property name="text"> - <string>&Play</string> - </property> - <property name="shortcut"> - <string>F10</string> + <string>&Reset</string> </property> </action> - <action name="actionStop_mnu"> + <action name="actionScreenshot"> <property name="text"> - <string>&Stop</string> - </property> - <property name="shortcut"> - <string>Esc</string> + <string>Screenshot</string> </property> - </action> - <action name="actionReset"> - <property name="text"> - <string>&Reset</string> + <property name="iconVisibleInMenu"> + <bool>false</bool> </property> </action> </widget> 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 <QWidget> -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(); }; |
