Skip to content

Commit

Permalink
Merge pull request #2359 from darkengine-io/new-qt
Browse files Browse the repository at this point in the history
DolphinQt updates
  • Loading branch information
shuffle2 committed May 8, 2015
2 parents f775875 + 6c6fe8d commit 6fe2ab7
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 1 deletion.
53 changes: 52 additions & 1 deletion Source/Core/DolphinQt/MainWindow.cpp
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);
}

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

0 comments on commit 6fe2ab7

Please sign in to comment.