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 : public QDialog
class DAboutDialog final : public QDialog
{
Q_OBJECT

View File

@ -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" />

View File

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

View File

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

View File

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

View File

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

View File

@ -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()

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();
delete g_main_window;
Core::Shutdown();
UICommon::Shutdown();
return retcode;
}

View File

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

View File

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

View File

@ -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&amp;le</string>
@ -49,9 +49,11 @@
<property name="title">
<string>E&amp;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,27 +234,19 @@
<string>Exit</string>
</property>
</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">
<property name="text">
<string>&amp;Reset</string>
</property>
</action>
<action name="actionScreenshot">
<property name="text">
<string>Screenshot</string>
</property>
<property name="iconVisibleInMenu">
<bool>false</bool>
</property>
</action>
</widget>
<resources/>
<connections/>

View File

@ -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)

View File

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

View File

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