Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DolphinQt updates #2359

Merged
merged 4 commits into from
May 8, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
53 changes: 52 additions & 1 deletion Source/Core/DolphinQt/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include "Core/BootManager.h"
#include "Core/ConfigManager.h"
#include "Core/HW/ProcessorInterface.h"

#include "DolphinQt/AboutDialog.h"
#include "DolphinQt/MainWindow.h"
Expand Down Expand Up @@ -57,15 +58,20 @@ DMainWindow::DMainWindow(QWidget* parent_widget)
connect(this, SIGNAL(CoreStateChanged(Core::EState)), this, SLOT(OnCoreStateChanged(Core::EState)));

connect(m_ui->actionOpen, SIGNAL(triggered()), this, SLOT(OnOpen()));
connect(m_ui->actionBrowse, SIGNAL(triggered()), this, SLOT(OnBrowse()));
connect(m_ui->actionExit, SIGNAL(triggered()), this, SLOT(OnExit()));

connect(m_ui->actionListView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
connect(m_ui->actionTreeView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
connect(m_ui->actionGridView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));
connect(m_ui->actionIconView, SIGNAL(triggered()), this, SLOT(OnGameListStyleChanged()));

connect(m_ui->actionPlay, SIGNAL(triggered()), this, SLOT(OnPlay()));
connect(m_ui->actionPlay_mnu, SIGNAL(triggered()), this, SLOT(OnPlay()));
connect(m_game_tracker, SIGNAL(StartGame()), this, SLOT(OnPlay()));
connect(m_ui->actionStop, SIGNAL(triggered()), this, SLOT(OnStop()));
connect(m_ui->actionStop_mnu, SIGNAL(triggered()), this, SLOT(OnStop()));
connect(m_ui->actionReset, SIGNAL(triggered()), this, SLOT(OnReset()));

connect(m_ui->actionWebsite, SIGNAL(triggered()), this, SLOT(OnOpenWebsite()));
connect(m_ui->actionOnlineDocs, SIGNAL(triggered()), this, SLOT(OnOpenDocs()));
Expand Down Expand Up @@ -142,6 +148,13 @@ QString DMainWindow::ShowFileDialog()
.arg(SL("*.gcm *.iso *.ciso *.gcz *.wbfs *.elf *.dol *.dff *.tmd *.wad")));
}

QString DMainWindow::ShowFolderDialog()
{
return QFileDialog::getExistingDirectory(this, tr("Browse for a directory to add"),
QDir::homePath(),
QFileDialog::ShowDirsOnly);
}

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.


void DMainWindow::DoStartPause()
{
if (Core::GetState() == Core::CORE_RUN)
Expand All @@ -165,6 +178,31 @@ void DMainWindow::OnOpen()
StartGame(filename);
}

void DMainWindow::OnBrowse()
{
std::string path = ShowFolderDialog().toStdString();
std::vector<std::string>& iso_folder = SConfig::GetInstance().m_ISOFolder;
if (!path.empty())
{
auto itResult = std::find(iso_folder.begin(), iso_folder.end(), path);

if (itResult == iso_folder.end())
{
iso_folder.push_back(path);
SConfig::GetInstance().SaveSettings();
}
}
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)
Expand All @@ -183,7 +221,7 @@ void DMainWindow::OnPlay()
bool DMainWindow::OnStop()
{
if (Core::GetState() == Core::CORE_UNINITIALIZED || m_isStopping)
return true; // We're already stopped/stopping
return true;

// Ask for confirmation in case the user accidentally clicked Stop / Escape
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bConfirmStop)
Expand All @@ -203,6 +241,11 @@ bool DMainWindow::OnStop()
}
}

return Stop();
}

bool DMainWindow::Stop()
{
m_isStopping = true;

// TODO: Movie stuff
Expand All @@ -229,6 +272,12 @@ bool DMainWindow::OnStop()
return true;
}

void DMainWindow::OnReset()
{
// TODO: Movie needs to be reset here
ProcessorInterface::ResetButton_Tap();
}

void DMainWindow::OnGameListStyleChanged()
{
if (m_ui->actionListView->isChecked())
Expand All @@ -253,11 +302,13 @@ 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);
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/DolphinQt/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ private slots:

// Main toolbar
void OnOpen();
void OnBrowse();
void OnExit();
void OnPlay();
void OnReset();

// View menu
void OnGameListStyleChanged();
Expand All @@ -66,7 +69,9 @@ private slots:
// Emulation
QString RequestBootFilename();
QString ShowFileDialog();
QString ShowFolderDialog();
void DoStartPause();
bool Stop();

std::unique_ptr<DRenderWidget> m_render_widget;
bool m_isStopping = false;
Expand Down
32 changes: 32 additions & 0 deletions Source/Core/DolphinQt/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@
<string>Fi&amp;le</string>
</property>
<addaction name="actionOpen"/>
<addaction name="separator"/>
<addaction name="actionBrowse"/>
<addaction name="separator"/>
<addaction name="actionExit"/>
</widget>
<widget class="QMenu" name="mnuEmulation">
<property name="title">
<string>E&amp;mulation</string>
</property>
<addaction name="actionPlay_mnu"/>
<addaction name="actionStop_mnu"/>
<addaction name="actionReset"/>
</widget>
<widget class="QMenu" name="mnuOptions">
<property name="title">
Expand Down Expand Up @@ -199,6 +206,31 @@
<string>&amp;Icon view</string>
</property>
</action>
<action name="actionBrowse">
<property name="text">
<string>&amp;Browse for ISOs...</string>
</property>
</action>
<action name="actionExit">
<property name="text">
<string>Exit</string>
</property>
</action>
<action name="actionPlay_mnu">
<property name="text">
<string>Play</string>
</property>
</action>
<action name="actionStop_mnu">
<property name="text">
<string>Stop</string>
</property>
</action>
<action name="actionReset">
<property name="text">
<string>Reset</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down