Skip to content

Commit

Permalink
DolphinQt2: Experimental GUI Warning Prompt.
Browse files Browse the repository at this point in the history
Add a GUI prompt to tell users not to use DolphinQt by accident.
  • Loading branch information
EmptyChaos committed Jul 13, 2016
1 parent 3e4cea7 commit 80b6e84
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 6 deletions.
1 change: 1 addition & 0 deletions Source/Core/DolphinQt2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(CMAKE_AUTOMOC ON)
set(SRCS
AboutDialog.cpp
Host.cpp
InDevelopmentWarning.cpp
Main.cpp
MainWindow.cpp
MenuBar.cpp
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/DolphinQt2/DolphinQt2.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
Expand Down Expand Up @@ -90,6 +90,7 @@
<QtMoc Include="GameList\ListProxyModel.h" />
<QtMoc Include="GameList\TableDelegate.h" />
<QtMoc Include="Host.h" />
<QtMoc Include="InDevelopmentWarning.h" />
<QtMoc Include="MainWindow.h" />
<QtMoc Include="MenuBar.h" />
<QtMoc Include="RenderWidget.h" />
Expand All @@ -105,6 +106,7 @@
<ClCompile Include="$(QtMocOutPrefix)GameListModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)GameTracker.cpp" />
<ClCompile Include="$(QtMocOutPrefix)Host.cpp" />
<ClCompile Include="$(QtMocOutPrefix)InDevelopmentWarning.cpp" />
<ClCompile Include="$(QtMocOutPrefix)InfoWidget.cpp" />
<ClCompile Include="$(QtMocOutPrefix)ListProxyModel.cpp" />
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
Expand All @@ -129,6 +131,7 @@
<ClCompile Include="GameList\ListProxyModel.cpp" />
<ClCompile Include="GameList\TableDelegate.cpp" />
<ClCompile Include="Host.cpp" />
<ClCompile Include="InDevelopmentWarning.cpp" />
<ClCompile Include="Main.cpp" />
<ClCompile Include="MainWindow.cpp" />
<ClCompile Include="MenuBar.cpp" />
Expand Down Expand Up @@ -230,4 +233,4 @@
<Message Text="Copy: @(BinaryFiles) -&gt; $(BinaryOutputDir)" Importance="High" />
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
</Target>
</Project>
</Project>
7 changes: 6 additions & 1 deletion Source/Core/DolphinQt2/DolphinQt2.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="Main.cpp" />
Expand Down Expand Up @@ -87,6 +87,10 @@
<ClCompile Include="$(QtMocOutPrefix)FilesystemWidget.cpp">
<Filter>Generated Files</Filter>
</ClCompile>
<ClCompile Include="InDevelopmentWarning.cpp" />
<ClCompile Include="$(QtMocOutPrefix)InDevelopmentWarning.cpp">
<Filter>Generated Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="MainWindow.h" />
Expand Down Expand Up @@ -119,6 +123,7 @@
<QtMoc Include="Config\PropertiesDialog.h" />
<QtMoc Include="Config\FilesystemWidget.h" />
<QtMoc Include="Config\InfoWidget.h" />
<QtMoc Include="InDevelopmentWarning.h" />
</ItemGroup>
<ItemGroup>
<QtUi Include="*.ui" />
Expand Down
148 changes: 148 additions & 0 deletions Source/Core/DolphinQt2/InDevelopmentWarning.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <QApplication>
#include <QBoxLayout>
#include <QBrush>
#include <QCommandLinkButton>
#include <QFileInfo>
#include <QLabel>
#include <QLinearGradient>
#include <QMessageBox>
#include <QProcess>

#include "DolphinQt2/InDevelopmentWarning.h"
#include "DolphinQt2/Resources.h"

static QBrush MakeConstructionBrush()
{
QLinearGradient gradient;
gradient.setSpread(QGradient::RepeatSpread);
gradient.setStart(0, 16);
gradient.setFinalStop(16, 0);
gradient.setColorAt(0, Qt::yellow);
gradient.setColorAt(0.25, Qt::yellow);
gradient.setColorAt(0.251, Qt::black);
gradient.setColorAt(0.75, Qt::black);
gradient.setColorAt(0.751, Qt::yellow);
gradient.setColorAt(1.0, Qt::yellow);

return QBrush(gradient);
}

static bool LaunchDolphinWX()
{
QFileInfo file_info;
for (auto path : {"/Dolphin.exe", "/dolphin-emu", "/Dolphin"})
{
file_info.setFile(qApp->applicationDirPath() + QString::fromUtf8(path));
if (file_info.isExecutable())
return QProcess::startDetached(file_info.absoluteFilePath(), {});
}
return false;
}

InDevelopmentWarning::InDevelopmentWarning(QWidget* parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
{
QWidget* strip_container = new QWidget(this);
QLabel* strip = new QLabel(tr("DolphinQt Experimental GUI"), strip_container);
QLabel* body = new QLabel(this);

QCommandLinkButton* btn_dolphinwx =
new QCommandLinkButton(tr("Run DolphinWX Instead"), tr("Recommended for normal users"), this);
QCommandLinkButton* btn_run = new QCommandLinkButton(tr("Use DolphinQt Anyway"), this);
QCommandLinkButton* btn_close = new QCommandLinkButton(tr("Exit Dolphin"), this);

QPalette yellow_tape_palette{palette()};
yellow_tape_palette.setBrush(QPalette::Window, MakeConstructionBrush());
yellow_tape_palette.setColor(QPalette::WindowText, Qt::black);

QPalette yellow_text_palette{palette()};
yellow_text_palette.setColor(QPalette::Window, Qt::yellow);
yellow_text_palette.setColor(QPalette::WindowText, Qt::black);

QFont heading_font{strip->font()};
heading_font.setPointSizeF(heading_font.pointSizeF() * 2);
heading_font.setBold(true);
strip->setFont(heading_font);
strip->setPalette(yellow_text_palette);
strip->setAutoFillBackground(true);
strip->setContentsMargins(15, 5, 15, 5);
strip->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);

strip_container->setPalette(yellow_tape_palette);
strip_container->setAutoFillBackground(true);
strip_container->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);

QHBoxLayout* strip_layout = new QHBoxLayout(strip_container);
strip_layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
strip_layout->addWidget(strip);
strip_layout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding));
strip_layout->setMargin(10);
strip_layout->setSpacing(0);

QString body_text = tr(
"<p>DolphinQt is a new experimental GUI that is eventually intended to replace "
"the current GUI based on wxWidgets. The implementation is <b>very "
"incomplete</b>, even basic functionality like changing settings and "
"attaching gamepads may be missing or not work at all.</p>\n"
"<p>Only developers working on the DolphinQt implementation should use it at "
"the present time; normal users are recommended to continue using the "
"older DolphinWX GUI for the time being.</p>\n"
"<p><big><b>Bug Reports:</b></big> At the current time there is no point making bug reports "
"about the DolphinQt GUI as the list of what is broken is much longer "
"than the list of things that work.</p>\n");
body->setText(body_text);
body->setWordWrap(true);
body->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);

connect(btn_dolphinwx, &QCommandLinkButton::clicked, [this](bool) {
if (!LaunchDolphinWX())
QMessageBox::critical(
this, tr("Failed to launch"),
tr("Could not start DolphinWX. Check for dolphin.exe in the installation directory."));
reject();
});
connect(btn_run, &QCommandLinkButton::clicked, this, [this](bool) { accept(); });
connect(btn_close, &QCommandLinkButton::clicked, this, [this](bool) { reject(); });

QVBoxLayout* button_column = new QVBoxLayout();
button_column->addWidget(btn_dolphinwx);
button_column->addWidget(btn_run);
button_column->addWidget(btn_close);
button_column->setMargin(0);
button_column->setSpacing(10);

QHBoxLayout* button_padding = new QHBoxLayout();
button_padding->addSpacerItem(new QSpacerItem(10, 20, QSizePolicy::Expanding));
button_padding->addLayout(button_column);
button_padding->addSpacerItem(new QSpacerItem(10, 20, QSizePolicy::Expanding));
button_padding->setStretch(0, 1);
button_padding->setStretch(1, 2);
button_padding->setStretch(2, 1);
button_padding->setMargin(0);
button_padding->setSpacing(0);

QVBoxLayout* body_column = new QVBoxLayout();
body_column->addWidget(body);
body_column->addSpacerItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
body_column->addLayout(button_padding);
body_column->addSpacerItem(new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Expanding));
body_column->setMargin(10);

QVBoxLayout* top_level_layout = new QVBoxLayout(this);
top_level_layout->addWidget(strip_container);
top_level_layout->addLayout(body_column);
top_level_layout->setSpacing(0);
top_level_layout->setMargin(0);

setWindowIcon(Resources::GetMisc(Resources::LOGO_SMALL));
setWindowTitle(tr("DolphinQt2 Experimental GUI"));
setMinimumSize(480, 340);
}

InDevelopmentWarning::~InDevelopmentWarning()
{
}
16 changes: 16 additions & 0 deletions Source/Core/DolphinQt2/InDevelopmentWarning.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <QDialog>

class InDevelopmentWarning final : public QDialog
{
Q_OBJECT

public:
explicit InDevelopmentWarning(QWidget* parent = nullptr);
~InDevelopmentWarning();
};
17 changes: 14 additions & 3 deletions Source/Core/DolphinQt2/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include "Core/BootManager.h"
#include "Core/Core.h"
#include "DolphinQt2/Host.h"
#include "DolphinQt2/InDevelopmentWarning.h"
#include "DolphinQt2/MainWindow.h"
#include "DolphinQt2/Resources.h"
#include "DolphinQt2/Settings.h"
#include "UICommon/UICommon.h"

int main(int argc, char* argv[])
Expand All @@ -26,9 +28,18 @@ int main(int argc, char* argv[])
QObject::connect(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock,
&app, &Core::HostDispatchJobs);

MainWindow win;
win.show();
int retval = app.exec();
int retval = 0;
if (Settings().IsInDevelopmentWarningEnabled())
{
InDevelopmentWarning warning_box;
retval = warning_box.exec() == QDialog::Rejected;
}
if (!retval)
{
MainWindow win;
win.show();
retval = app.exec();
}

BootManager::Stop();
Core::Shutdown();
Expand Down
7 changes: 7 additions & 0 deletions Source/Core/DolphinQt2/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ QString Settings::GetThemeDir() const
return QString::fromStdString(File::GetThemeDir(theme_name.toStdString()));
}

bool Settings::IsInDevelopmentWarningEnabled() const
{
// There's intentionally no way to set this from the UI.
// Add it to your INI manually instead.
return value(QStringLiteral("ShowDevelopmentWarning"), true).toBool();
}

QString Settings::GetLastGame() const
{
return value(QStringLiteral("GameList/LastGame")).toString();
Expand Down
1 change: 1 addition & 0 deletions Source/Core/DolphinQt2/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Settings final : public QSettings

// UI
QString GetThemeDir() const;
bool IsInDevelopmentWarningEnabled() const;

// GameList
QString GetLastGame() const;
Expand Down

0 comments on commit 80b6e84

Please sign in to comment.