Merge pull request #3032 from waddlesplash/dolphin-qt

Lots more minor DolphinQt stuffs.
This commit is contained in:
Scott Mansell 2015-11-23 21:45:28 +13:00
commit ffb9722f2d
16 changed files with 121 additions and 62 deletions

2
Externals/Qt vendored

@ -1 +1 @@
Subproject commit e800367547f23b981d1de8e6c13c1d6a88d56746 Subproject commit 9dca8d6c716ad304d9382116ee29b5e2e4cde8d8

View file

@ -13,7 +13,7 @@ namespace Ui
class DAboutDialog; class DAboutDialog;
} }
class DAboutDialog : public QDialog class DAboutDialog final : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -47,6 +47,7 @@
<FixedBaseAddress>true</FixedBaseAddress> <FixedBaseAddress>true</FixedBaseAddress>
<AdditionalLibraryDirectories>$(ExternalsDir)OpenAL\$(PlatformName);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <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> <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> </Link>
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\VideoInterface;$(ProjectDir)\GameList;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)\VideoInterface;$(ProjectDir)\GameList;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@ -171,6 +172,7 @@
<ClInclude Include="GameList\GameGrid.h" /> <ClInclude Include="GameList\GameGrid.h" />
<ClInclude Include="GameList\GameTracker.h" /> <ClInclude Include="GameList\GameTracker.h" />
<ClInclude Include="GameList\GameTree.h" /> <ClInclude Include="GameList\GameTree.h" />
<ClInclude Include="Host.h" />
<ClInclude Include="Utils\Resources.h" /> <ClInclude Include="Utils\Resources.h" />
<ClInclude Include="Utils\Utils.h" /> <ClInclude Include="Utils\Utils.h" />
<ClInclude Include="VideoInterface\RenderWidget.h" /> <ClInclude Include="VideoInterface\RenderWidget.h" />

View file

@ -83,6 +83,7 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Host.h" />
<ClInclude Include="Utils\Resources.h"> <ClInclude Include="Utils\Resources.h">
<Filter>Utils</Filter> <Filter>Utils</Filter>
</ClInclude> </ClInclude>

View file

@ -16,7 +16,7 @@ namespace Ui
class DGameGrid; class DGameGrid;
} }
class DGameGrid : public QListWidget, public AbstractGameList class DGameGrid final : public QListWidget, public AbstractGameList
{ {
Q_OBJECT Q_OBJECT

View file

@ -38,7 +38,7 @@ public:
void RemoveGames(QList<GameFile*> items); void RemoveGames(QList<GameFile*> items);
}; };
class DGameTracker : public QStackedWidget class DGameTracker final : public QStackedWidget
{ {
Q_OBJECT Q_OBJECT

View file

@ -16,7 +16,7 @@ namespace Ui
class DGameTree; class DGameTree;
} }
class DGameTree : public QTreeWidget, public AbstractGameList class DGameTree final : public QTreeWidget, public AbstractGameList
{ {
Q_OBJECT Q_OBJECT

View file

@ -10,8 +10,15 @@
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Core/Host.h" #include "Core/Host.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/MainWindow.h" #include "DolphinQt/MainWindow.h"
HostTitleEvent::HostTitleEvent(const std::string& title)
: QEvent((QEvent::Type)HostEvent::TitleEvent),
m_title(title)
{
}
void Host_Message(int id) void Host_Message(int id)
{ {
// TODO // TODO
@ -24,7 +31,7 @@ void Host_UpdateMainFrame()
void Host_UpdateTitle(const std::string& title) void Host_UpdateTitle(const std::string& title)
{ {
// TODO qApp->postEvent(g_main_window, new HostTitleEvent(title));
} }
void* Host_GetRenderHandle() void* Host_GetRenderHandle()

View file

@ -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;
};

View file

@ -60,6 +60,7 @@ int main(int argc, char* argv[])
int retcode = app.exec(); int retcode = app.exec();
delete g_main_window; delete g_main_window;
Core::Shutdown();
UICommon::Shutdown(); UICommon::Shutdown();
return retcode; return retcode;
} }

View file

@ -4,6 +4,7 @@
#include <memory> #include <memory>
#include <QActionGroup> #include <QActionGroup>
#include <QCloseEvent>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
@ -16,6 +17,7 @@
#include "Core/HW/ProcessorInterface.h" #include "Core/HW/ProcessorInterface.h"
#include "DolphinQt/AboutDialog.h" #include "DolphinQt/AboutDialog.h"
#include "DolphinQt/Host.h"
#include "DolphinQt/MainWindow.h" #include "DolphinQt/MainWindow.h"
#include "DolphinQt/SystemInfo.h" #include "DolphinQt/SystemInfo.h"
#include "DolphinQt/Utils/Resources.h" #include "DolphinQt/Utils/Resources.h"
@ -62,7 +64,9 @@ DMainWindow::DMainWindow(QWidget* parent_widget)
StartGame(filename); StartGame(filename);
}); });
connect(m_ui->actionBrowse, &QAction::triggered, this, &DMainWindow::OnBrowse); 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->actionListView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged);
connect(m_ui->actionTreeView, &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->actionIconView, &QAction::triggered, this, &DMainWindow::OnGameListStyleChanged);
connect(m_ui->actionPlay, &QAction::triggered, this, &DMainWindow::OnPlay); 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_game_tracker, &DGameTracker::StartGame, this, &DMainWindow::OnPlay);
connect(m_ui->actionStop, &QAction::triggered, this, &DMainWindow::OnStop); 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->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/"))); 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/"))); 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"))); QDesktopServices::openUrl(QUrl(SL("https://github.com/dolphin-emu/dolphin")));
}); });
connect(m_ui->actionSystemInfo, &QAction::triggered, this, [&]() { 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) void DMainWindow::closeEvent(QCloseEvent* ce)
{ {
Stop(); if (!OnStop())
ce->ignore();
else
QMainWindow::closeEvent(ce);
} }
// Emulation // Emulation
@ -181,7 +200,7 @@ QString DMainWindow::RequestBootFilename()
{ {
// If a game is already selected, just return the filename // If a game is already selected, just return the filename
if (m_game_tracker->SelectedGame() != nullptr) if (m_game_tracker->SelectedGame() != nullptr)
return m_game_tracker->SelectedGame()->GetFileName(); return m_game_tracker->SelectedGame()->GetFileName();
return ShowFileDialog(); return ShowFileDialog();
} }
@ -196,8 +215,7 @@ QString DMainWindow::ShowFileDialog()
QString DMainWindow::ShowFolderDialog() QString DMainWindow::ShowFolderDialog()
{ {
return QFileDialog::getExistingDirectory(this, tr("Browse for a directory to add"), return QFileDialog::getExistingDirectory(this, tr("Browse for a directory to add"),
QDir::homePath(), QDir::homePath(), QFileDialog::ShowDirsOnly);
QFileDialog::ShowDirsOnly);
} }
void DMainWindow::DoStartPause() void DMainWindow::DoStartPause()
@ -233,14 +251,6 @@ void DMainWindow::OnBrowse()
m_game_tracker->ScanForGames(); m_game_tracker->ScanForGames();
} }
void DMainWindow::OnExit()
{
close();
if (Core::GetState() == Core::CORE_UNINITIALIZED || m_isStopping)
return;
Stop();
}
void DMainWindow::OnPlay() void DMainWindow::OnPlay()
{ {
if (Core::GetState() != Core::CORE_UNINITIALIZED) if (Core::GetState() != Core::CORE_UNINITIALIZED)
@ -264,9 +274,17 @@ bool DMainWindow::OnStop()
// Ask for confirmation in case the user accidentally clicked Stop / Escape // Ask for confirmation in case the user accidentally clicked Stop / Escape
if (SConfig::GetInstance().bConfirmStop) if (SConfig::GetInstance().bConfirmStop)
{ {
// Pause emulation // Pause emulation if it isn't already
Core::SetState(Core::CORE_PAUSE); bool wasPaused = false;
emit CoreStateChanged(Core::CORE_PAUSE); 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..."), QMessageBox::StandardButton ret = QMessageBox::question(m_render_widget.get(), tr("Please confirm..."),
tr("Do you want to stop the current emulation?"), tr("Do you want to stop the current emulation?"),
@ -274,7 +292,8 @@ bool DMainWindow::OnStop()
if (ret == QMessageBox::No) if (ret == QMessageBox::No)
{ {
DoStartPause(); if (!wasPaused)
DoStartPause();
return false; return false;
} }
} }
@ -339,13 +358,11 @@ void DMainWindow::OnCoreStateChanged(Core::EState state)
{ {
m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PAUSE)); m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PAUSE));
m_ui->actionPlay->setText(tr("Pause")); m_ui->actionPlay->setText(tr("Pause"));
m_ui->actionPlay_mnu->setText(tr("Pause"));
} }
else if (is_paused || is_not_initialized) else if (is_paused || is_not_initialized)
{ {
m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PLAY)); m_ui->actionPlay->setIcon(Resources::GetIcon(Resources::TOOLBAR_PLAY));
m_ui->actionPlay->setText(tr("Play")); m_ui->actionPlay->setText(tr("Play"));
m_ui->actionPlay_mnu->setText(tr("Play"));
} }
m_ui->actionStop->setEnabled(!is_not_initialized); m_ui->actionStop->setEnabled(!is_not_initialized);
@ -359,4 +376,5 @@ void DMainWindow::UpdateIcons()
{ {
// Play/Pause is handled in OnCoreStateChanged(). // Play/Pause is handled in OnCoreStateChanged().
m_ui->actionStop->setIcon(Resources::GetIcon(Resources::TOOLBAR_STOP)); m_ui->actionStop->setIcon(Resources::GetIcon(Resources::TOOLBAR_STOP));
m_ui->actionScreenshot->setIcon(Resources::GetIcon(Resources::TOOLBAR_SCREENSHOT));
} }

View file

@ -18,7 +18,7 @@ namespace Ui
class DMainWindow; class DMainWindow;
} }
class DMainWindow : public QMainWindow class DMainWindow final : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
@ -44,7 +44,6 @@ private slots:
// Main toolbar // Main toolbar
void OnBrowse(); void OnBrowse();
void OnExit();
void OnPlay(); void OnPlay();
void OnReset(); void OnReset();
@ -55,7 +54,8 @@ private slots:
void UpdateIcons(); void UpdateIcons();
private: private:
void closeEvent(QCloseEvent* ce); bool event(QEvent* e) override;
void closeEvent(QCloseEvent* ce) override;
std::unique_ptr<Ui::DMainWindow> m_ui; std::unique_ptr<Ui::DMainWindow> m_ui;
DGameTracker* m_game_tracker; DGameTracker* m_game_tracker;

View file

@ -19,9 +19,6 @@
<height>32</height> <height>32</height>
</size> </size>
</property> </property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<property name="unifiedTitleAndToolBarOnMac"> <property name="unifiedTitleAndToolBarOnMac">
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -32,9 +29,12 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>990</width> <width>990</width>
<height>19</height> <height>21</height>
</rect> </rect>
</property> </property>
<property name="nativeMenuBar">
<bool>true</bool>
</property>
<widget class="QMenu" name="mnuFile"> <widget class="QMenu" name="mnuFile">
<property name="title"> <property name="title">
<string>Fi&amp;le</string> <string>Fi&amp;le</string>
@ -49,9 +49,11 @@
<property name="title"> <property name="title">
<string>E&amp;mulation</string> <string>E&amp;mulation</string>
</property> </property>
<addaction name="actionPlay_mnu"/> <addaction name="actionPlay"/>
<addaction name="actionStop_mnu"/> <addaction name="actionStop"/>
<addaction name="actionReset"/> <addaction name="actionReset"/>
<addaction name="separator"/>
<addaction name="actionScreenshot"/>
</widget> </widget>
<widget class="QMenu" name="mnuOptions"> <widget class="QMenu" name="mnuOptions">
<property name="title"> <property name="title">
@ -108,6 +110,9 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Toolbar</string> <string>Toolbar</string>
</property> </property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<attribute name="toolBarArea"> <attribute name="toolBarArea">
<enum>TopToolBarArea</enum> <enum>TopToolBarArea</enum>
</attribute> </attribute>
@ -116,6 +121,7 @@
</attribute> </attribute>
<addaction name="actionPlay"/> <addaction name="actionPlay"/>
<addaction name="actionStop"/> <addaction name="actionStop"/>
<addaction name="actionScreenshot"/>
</widget> </widget>
<action name="actionWebsite"> <action name="actionWebsite">
<property name="text"> <property name="text">
@ -160,11 +166,23 @@
<property name="text"> <property name="text">
<string>Play</string> <string>Play</string>
</property> </property>
<property name="shortcut">
<string>F10</string>
</property>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action> </action>
<action name="actionStop"> <action name="actionStop">
<property name="text"> <property name="text">
<string>Stop</string> <string>Stop</string>
</property> </property>
<property name="shortcut">
<string>Esc</string>
</property>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action> </action>
<action name="actionAboutQt"> <action name="actionAboutQt">
<property name="text"> <property name="text">
@ -216,27 +234,19 @@
<string>Exit</string> <string>Exit</string>
</property> </property>
</action> </action>
<action name="actionPlay_mnu">
<property name="text">
<string>&amp;Play</string>
</property>
<property name="shortcut">
<string>F10</string>
</property>
</action>
<action name="actionStop_mnu">
<property name="text">
<string>&amp;Stop</string>
</property>
<property name="shortcut">
<string>Esc</string>
</property>
</action>
<action name="actionReset"> <action name="actionReset">
<property name="text"> <property name="text">
<string>&amp;Reset</string> <string>&amp;Reset</string>
</property> </property>
</action> </action>
<action name="actionScreenshot">
<property name="text">
<string>Screenshot</string>
</property>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>

View file

@ -46,7 +46,7 @@ void DSystemInfo::UpdateSystemInfo()
sysinfo += SL("System\n===========================\n"); sysinfo += SL("System\n===========================\n");
sysinfo += SL("OS: %1\n").arg(GetOS()); 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()); .arg(QThread::idealThreadCount());
sysinfo += SL("\nDolphin\n===========================\n"); sysinfo += SL("\nDolphin\n===========================\n");
@ -69,12 +69,16 @@ QString DSystemInfo::GetOS() const
case QSysInfo::WV_VISTA: ret += SL("Vista"); break; case QSysInfo::WV_VISTA: ret += SL("Vista"); break;
case QSysInfo::WV_WINDOWS7: ret += SL("7"); break; case QSysInfo::WV_WINDOWS7: ret += SL("7"); break;
case QSysInfo::WV_WINDOWS8: ret += SL("8"); 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; default: ret += SL("(unknown)"); break;
} }
#elif defined(Q_OS_MAC) #elif defined(Q_OS_MAC)
ret += SL("Mac OS X "); ret += SL("Mac OS X ");
switch (QSysInfo::MacintoshVersion) { switch (QSysInfo::MacintoshVersion) {
case QSysInfo::MV_10_9: ret += SL("10.9"); break; 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; default: ret += SL("(unknown)"); break;
} }
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)

View file

@ -12,7 +12,7 @@ namespace Ui
class DSystemInfo; class DSystemInfo;
} }
class DSystemInfo : public QDialog class DSystemInfo final : public QDialog
{ {
Q_OBJECT Q_OBJECT

View file

@ -6,7 +6,7 @@
#include <QWidget> #include <QWidget>
class DRenderWidget : public QWidget class DRenderWidget final : public QWidget
{ {
Q_OBJECT Q_OBJECT
@ -19,10 +19,7 @@ protected:
void mousePressEvent(QMouseEvent*) override {} void mousePressEvent(QMouseEvent*) override {}
void paintEvent(QPaintEvent*) override {} void paintEvent(QPaintEvent*) override {}
private slots: private:
void closeEvent(QCloseEvent* e) override; void closeEvent(QCloseEvent* e) override;
signals:
void Closed();
}; };