From 16c6a191905f30022b93d555ee2eab1eacc9268e Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sun, 14 Sep 2014 15:03:07 -0400 Subject: [PATCH] DolphinQt: initial commit. This adds the beginning of the DolphinQt user interface. It doesn't do anything useful yet and only builds via CMake. --- CMakeLists.txt | 10 ++- Source/Core/CMakeLists.txt | 4 + Source/Core/DolphinQt/AboutDialog.cpp | 37 +++++++++ Source/Core/DolphinQt/AboutDialog.h | 27 ++++++ Source/Core/DolphinQt/AboutDialog.ui | 103 +++++++++++++++++++++++ Source/Core/DolphinQt/CMakeLists.txt | 21 +++++ Source/Core/DolphinQt/Main.cpp | 54 ++++++++++++ Source/Core/DolphinQt/MainWindow.cpp | 44 ++++++++++ Source/Core/DolphinQt/MainWindow.h | 32 +++++++ Source/Core/DolphinQt/MainWindow.ui | 115 ++++++++++++++++++++++++++ 10 files changed, 445 insertions(+), 2 deletions(-) create mode 100644 Source/Core/DolphinQt/AboutDialog.cpp create mode 100644 Source/Core/DolphinQt/AboutDialog.h create mode 100644 Source/Core/DolphinQt/AboutDialog.ui create mode 100644 Source/Core/DolphinQt/CMakeLists.txt create mode 100644 Source/Core/DolphinQt/Main.cpp create mode 100644 Source/Core/DolphinQt/MainWindow.cpp create mode 100644 Source/Core/DolphinQt/MainWindow.h create mode 100644 Source/Core/DolphinQt/MainWindow.ui diff --git a/CMakeLists.txt b/CMakeLists.txt index 25cac0851e..eb271feaf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,14 @@ ######################################## # General setup # -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.8) option(ANDROID "Enables a build for Android" OFF) option(USE_EGL "Enables EGL OpenGL Interface" OFF) option(TRY_X11 "Enables X11 Support" ON) option(USE_UPNP "Enables UPnP port mapping support" ON) -option(DISABLE_WX "Disable wxWidgets (use CLI interface)" OFF) +option(DISABLE_WX "Disable wxWidgets (use Qt or CLI interface)" OFF) +option(ENABLE_QT "Enable Qt (use the experimental Qt interface)" OFF) option(ENABLE_PCH "Use PCH to speed up compilation" ON) option(ENABLE_LTO "Enables Link Time Optimization" OFF) option(ENABLE_GENERIC "Enables generic build that should run on any little-endian host" OFF) @@ -640,6 +641,11 @@ if (ANDROID) add_subdirectory(Externals/libiconv-1.14) endif() +if(ENABLE_QT) + find_package(Qt5Widgets REQUIRED) + message("Found Qt version ${Qt5Core_VERSION}, enabling the Qt backend") +endif() + if(NOT DISABLE_WX AND NOT ANDROID) include(FindwxWidgets OPTIONAL) FIND_PACKAGE(wxWidgets COMPONENTS core aui adv) diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt index 7b4042b604..2563294778 100644 --- a/Source/Core/CMakeLists.txt +++ b/Source/Core/CMakeLists.txt @@ -6,3 +6,7 @@ add_subdirectory(DolphinWX) add_subdirectory(InputCommon) add_subdirectory(VideoCommon) add_subdirectory(VideoBackends) + +if(ENABLE_QT) + add_subdirectory(DolphinQt) +endif() diff --git a/Source/Core/DolphinQt/AboutDialog.cpp b/Source/Core/DolphinQt/AboutDialog.cpp new file mode 100644 index 0000000000..afb557cb31 --- /dev/null +++ b/Source/Core/DolphinQt/AboutDialog.cpp @@ -0,0 +1,37 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include + +#include "AboutDialog.h" +#include "ui_AboutDialog.h" + +// TODO +#define scm_desc_str "unknown" +#define scm_branch_str "unknown" +#define scm_rev_git_str "0000000" + +DAboutDialog::DAboutDialog(QWidget *p) : + QDialog(p), + ui(new Ui::DAboutDialog) +{ + ui->setupUi(this); + ui->label->setText(ui->label->text().arg(scm_desc_str, + "2014", + scm_branch_str, + scm_rev_git_str, + __DATE__, + __TIME__)); +} + +DAboutDialog::~DAboutDialog() +{ + delete ui; +} + +void DAboutDialog::on_label_linkActivated(const QString &link) +{ + QDesktopServices::openUrl(QUrl(link)); +} diff --git a/Source/Core/DolphinQt/AboutDialog.h b/Source/Core/DolphinQt/AboutDialog.h new file mode 100644 index 0000000000..c267530249 --- /dev/null +++ b/Source/Core/DolphinQt/AboutDialog.h @@ -0,0 +1,27 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include + +// Predefinitions +namespace Ui { +class DAboutDialog; +} + +class DAboutDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DAboutDialog(QWidget *p = 0); + ~DAboutDialog(); + +private slots: + void on_label_linkActivated(const QString &link); + +private: + Ui::DAboutDialog *ui; +}; diff --git a/Source/Core/DolphinQt/AboutDialog.ui b/Source/Core/DolphinQt/AboutDialog.ui new file mode 100644 index 0000000000..339140d79c --- /dev/null +++ b/Source/Core/DolphinQt/AboutDialog.ui @@ -0,0 +1,103 @@ + + + DAboutDialog + + + + 0 + 0 + 375 + 534 + + + + + 0 + 0 + + + + + 375 + 0 + + + + + 375 + 16777215 + + + + About Dolphin + + + + + + + 0 + 0 + + + + <big><b>Dolphin</b></big> %1<br> +© 2003-%2 Dolphin Team<br> +Branch: %3<br> +Revision: %4<br> +Compiled: %5 @ %6<br> +Dolphin is a GameCube/Wii emulator, which was originally written by F|RES and ector. Today Dolphin is an open source project with many contributors, too many to list. If interested, just go check out <a href="https://github.com/dolphin-emu/dolphin">the project page</a>.<br> +<br> +Special thanks to Bushing, Costis, CrowTRobo, Marcan, Segher, Titanik, or9, and Hotquik for their reverse engineering and docs/demos.<br> +<br> +Big thanks to Gilles Mouchard whose Microlib PPC emulator gave our development a kickstart.<br> +<br> +Thanks to Frank Wille for his PowerPC disassembler, which or9 and we modified to include Gekko specifics.<br> +<br> +Thanks to hcs/destop for their GC ADPCM decoder.<br> +<br> +We are not affiliated with Nintendo in any way. GameCube and Wii are trademarks of Nintendo. This emulator should not be used to play games you do not legally own. + + + Qt::RichText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DAboutDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt new file mode 100644 index 0000000000..f5d6930bba --- /dev/null +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -0,0 +1,21 @@ +include_directories(${CMAKE_CURRENT_BINARY_DIR}) # because of generated UI files +set(CMAKE_AUTOMOC ON) + +set(SRCS AboutDialog.cpp + AboutDialog.h + Main.cpp + MainWindow.cpp + MainWindow.h) + +set(UIS AboutDialog.ui + MainWindow.ui) + +if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(DOLPHINQT_BINARY DolphinQt) +else() + set(DOLPHINQT_BINARY dolphin-emu-qt) +endif() + +qt5_wrap_ui(UI_HEADERS ${UIS}) +add_executable(${DOLPHINQT_BINARY} ${SRCS} ${UI_HEADERS}) +qt5_use_modules(${DOLPHINQT_BINARY} Widgets) diff --git a/Source/Core/DolphinQt/Main.cpp b/Source/Core/DolphinQt/Main.cpp new file mode 100644 index 0000000000..ae72e34267 --- /dev/null +++ b/Source/Core/DolphinQt/Main.cpp @@ -0,0 +1,54 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include +#include +#include +#include +#include + +#include "MainWindow.h" + +static bool IsOsSupported() +{ +#ifdef Q_OS_OSX + return QSysInfo::MacVersion >= QSysInfo::MV_10_7; +#elif defined(Q_OS_WIN) + return (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) >= QSysInfo::WV_VISTA; +#else + return true; +#endif +} + +static QString LowestSupportedOsVersion() +{ +#ifdef Q_OS_OSX + return QStringLiteral("Mac OS X 10.7"); +#elif defined(Q_OS_WIN) + return QStringLiteral("Windows Vista SP2"); +#else + return QStringLiteral("Unknown"); +#endif +} + +int main(int argc, char* argv[]) +{ + QApplication app(argc, argv); + // TODO: Add command line options + + if (!IsOsSupported()) + { + QMessageBox::critical(nullptr, QObject::tr("Unsupported OS"), + QObject::tr("Dolphin requires %1 or greater.\n" + "Please upgrade to %1 or greater to use Dolphin.") + .arg(LowestSupportedOsVersion())); + return 1; + } + + DMainWindow w; + w.show(); + + return app.exec(); +} diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp new file mode 100644 index 0000000000..9a61e2a258 --- /dev/null +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -0,0 +1,44 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include + +#include "AboutDialog.h" + +#include "MainWindow.h" +#include "ui_MainWindow.h" + +DMainWindow::DMainWindow(QWidget *p) : + QMainWindow(p), + ui(new Ui::DMainWindow) +{ + ui->setupUi(this); +} + +DMainWindow::~DMainWindow() +{ + delete ui; +} + +void DMainWindow::on_actWebsite_triggered() +{ + QDesktopServices::openUrl(QUrl("https://dolphin-emu.org/")); +} + +void DMainWindow::on_actOnlineDocs_triggered() +{ + QDesktopServices::openUrl(QUrl("https://dolphin-emu.org/docs/guides/")); +} + +void DMainWindow::on_actGitHub_triggered() +{ + QDesktopServices::openUrl(QUrl("https://github.com/dolphin-emu/dolphin/")); +} + +void DMainWindow::on_actAbout_triggered() +{ + DAboutDialog dlg; + dlg.exec(); +} diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h new file mode 100644 index 0000000000..14240e59c4 --- /dev/null +++ b/Source/Core/DolphinQt/MainWindow.h @@ -0,0 +1,32 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include + +// Predefinitions +namespace Ui { +class DMainWindow; +} + +class DMainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit DMainWindow(QWidget *p = 0); + ~DMainWindow(); + +private slots: + + // Help menu + void on_actWebsite_triggered(); + void on_actOnlineDocs_triggered(); + void on_actGitHub_triggered(); + void on_actAbout_triggered(); + +private: + Ui::DMainWindow *ui; +}; diff --git a/Source/Core/DolphinQt/MainWindow.ui b/Source/Core/DolphinQt/MainWindow.ui new file mode 100644 index 0000000000..29200f44a5 --- /dev/null +++ b/Source/Core/DolphinQt/MainWindow.ui @@ -0,0 +1,115 @@ + + + DMainWindow + + + + 0 + 0 + 998 + 598 + + + + Dolphin + + + + 64 + 64 + + + + Qt::ToolButtonTextUnderIcon + + + true + + + + + + 0 + 0 + 998 + 24 + + + + + Fi&le + + + + + E&mulation + + + + + Optio&ns + + + + + Tools + + + + + &View + + + + + Help + + + + + + + + + + + + + + + + + + toolBar + + + TopToolBarArea + + + false + + + + + &Website + + + + + &Online Documentation + + + + + &Dolphin at GitHub + + + + + &About + + + + + +