From 69cd8229d845cdab8acc29e73e98f3e4e8a83528 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 25 Oct 2014 09:21:05 -0400 Subject: [PATCH] Fixes to the About dialog & add the SystemInfo dialog. Also fix the build on Mac OS X. --- Source/Core/DolphinQt/AboutDialog.cpp | 30 +++-- Source/Core/DolphinQt/AboutDialog.h | 7 +- Source/Core/DolphinQt/AboutDialog.ui | 42 ++----- Source/Core/DolphinQt/CMakeLists.txt | 20 +++- Source/Core/DolphinQt/DolphinQt.vcxproj | 3 + .../Core/DolphinQt/DolphinQt.vcxproj.filters | 2 + Source/Core/DolphinQt/MainWindow.cpp | 21 +++- Source/Core/DolphinQt/MainWindow.h | 3 +- Source/Core/DolphinQt/MainWindow.ui | 21 +++- Source/Core/DolphinQt/SystemInfo.cpp | 106 ++++++++++++++++++ Source/Core/DolphinQt/SystemInfo.h | 31 +++++ Source/Core/DolphinQt/SystemInfo.ui | 71 ++++++++++++ Source/Core/DolphinQt/Utils/Utils.h | 6 +- 13 files changed, 296 insertions(+), 67 deletions(-) create mode 100644 Source/Core/DolphinQt/SystemInfo.cpp create mode 100644 Source/Core/DolphinQt/SystemInfo.h create mode 100644 Source/Core/DolphinQt/SystemInfo.ui diff --git a/Source/Core/DolphinQt/AboutDialog.cpp b/Source/Core/DolphinQt/AboutDialog.cpp index f76fe2decc..0e8f30d355 100644 --- a/Source/Core/DolphinQt/AboutDialog.cpp +++ b/Source/Core/DolphinQt/AboutDialog.cpp @@ -5,29 +5,27 @@ #include #include -#include "AboutDialog.h" #include "ui_AboutDialog.h" + #include "Common/Common.h" #include "Common/StdMakeUnique.h" -DAboutDialog::DAboutDialog(QWidget* p) - : QDialog(p) +#include "DolphinQt/AboutDialog.h" +#include "DolphinQt/Utils/Utils.h" + +DAboutDialog::DAboutDialog(QWidget* parent_widget) + : QDialog(parent_widget) { - ui = std::make_unique(); - ui->setupUi(this); - ui->label->setText(ui->label->text().arg(QLatin1String(scm_desc_str), - QStringLiteral("2014"), - QLatin1String(scm_branch_str), - QLatin1String(scm_rev_git_str), - QStringLiteral(__DATE__), - QStringLiteral(__TIME__))); + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose); + + m_ui = std::make_unique(); + m_ui->setupUi(this); + m_ui->label->setText(m_ui->label->text().arg(SC(scm_desc_str), + SL("2014"), SC(scm_branch_str), SC(scm_rev_git_str), + SL(__DATE__), SL(__TIME__))); } DAboutDialog::~DAboutDialog() { } - -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 index 74b13e0a0a..6f5988aad0 100644 --- a/Source/Core/DolphinQt/AboutDialog.h +++ b/Source/Core/DolphinQt/AboutDialog.h @@ -17,12 +17,9 @@ class DAboutDialog : public QDialog Q_OBJECT public: - explicit DAboutDialog(QWidget* p = nullptr); + explicit DAboutDialog(QWidget* parent_widget = nullptr); ~DAboutDialog(); -private slots: - void on_label_linkActivated(const QString& link); - private: - std::unique_ptr ui; + std::unique_ptr m_ui; }; diff --git a/Source/Core/DolphinQt/AboutDialog.ui b/Source/Core/DolphinQt/AboutDialog.ui index 339140d79c..df77fa4686 100644 --- a/Source/Core/DolphinQt/AboutDialog.ui +++ b/Source/Core/DolphinQt/AboutDialog.ui @@ -6,57 +6,39 @@ 0 0 - 375 - 534 + 504 + 458 - + 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> +Dolphin is a GameCube/Wii emulator, which was originally written by<br>F|RES and ector. Today Dolphin is an open source project with many<br> contributors, too many to list. If interested, just go check out <a href="https://github.com/dolphin-emu/dolphin">the project<br>page</a>.<br> <br> -Special thanks to Bushing, Costis, CrowTRobo, Marcan, Segher, Titanik, or9, and Hotquik for their reverse engineering and docs/demos.<br> +Special thanks to Bushing, Costis, CrowTRobo, Marcan, Segher, Titanik,<br>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> +Big thanks to Gilles Mouchard whose Microlib PPC emulator gave our<br> development a kickstart.<br> <br> -Thanks to Frank Wille for his PowerPC disassembler, which or9 and we modified to include Gekko specifics.<br> +Thanks to Frank Wille for his PowerPC disassembler, which or9 and we<br> 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. +We are not affiliated with Nintendo in any way. GameCube and Wii are<br> trademarks of Nintendo. This emulator should not be used to play games<br>you do not legally own. Qt::RichText @@ -64,12 +46,12 @@ We are not affiliated with Nintendo in any way. GameCube and Wii are trademarks Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + true - + Qt::Horizontal diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 8bbd09ed2f..c3be11d12e 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -7,21 +7,35 @@ set(CMAKE_AUTOMOC ON) set(SRCS AboutDialog.cpp AboutDialog.h + Host.cpp Main.cpp MainWindow.cpp MainWindow.h - Host.cpp + SystemInfo.cpp Utils/Resources.cpp Utils/Utils.cpp - VideoInterface/VideoInterface.cpp) + VideoInterface/VideoInterface.cpp + ) set(UIS AboutDialog.ui - MainWindow.ui) + MainWindow.ui + SystemInfo.ui + ) set(LIBS core uicommon) if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + # Link against OS X system frameworks. + list(APPEND LIBS + ${APPKIT_LIBRARY} + ${AU_LIBRARY} + ${COREAUDIO_LIBRARY} + ${COREFUND_LIBRARY} + ${CORESERV_LIBRARY} + ${IOK_LIBRARY} + ${FORCEFEEDBACK} + ) set(DOLPHINQT_BINARY DolphinQt) else() set(DOLPHINQT_BINARY dolphin-emu-qt) diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj b/Source/Core/DolphinQt/DolphinQt.vcxproj index 7399f17771..08b4484179 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj @@ -61,11 +61,14 @@ + + + diff --git a/Source/Core/DolphinQt/DolphinQt.vcxproj.filters b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters index d94c197d64..e81be15e09 100644 --- a/Source/Core/DolphinQt/DolphinQt.vcxproj.filters +++ b/Source/Core/DolphinQt/DolphinQt.vcxproj.filters @@ -14,10 +14,12 @@ Utils + + diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp index b67ec2198a..62382e10c5 100644 --- a/Source/Core/DolphinQt/MainWindow.cpp +++ b/Source/Core/DolphinQt/MainWindow.cpp @@ -11,17 +11,22 @@ #include "DolphinQt/AboutDialog.h" #include "DolphinQt/MainWindow.h" +#include "DolphinQt/SystemInfo.h" #include "DolphinQt/Utils/Resources.h" #include "DolphinQt/Utils/Utils.h" DMainWindow::DMainWindow(QWidget* parent_widget) : QMainWindow(parent_widget) { - ui = std::make_unique(); - ui->setupUi(this); + m_ui = std::make_unique(); + m_ui->setupUi(this); Resources::Init(); - ui->actOpen->setIcon(Resources::GetIcon(Resources::TOOLBAR_OPEN)); + m_ui->actOpen->setIcon(Resources::GetIcon(Resources::TOOLBAR_OPEN)); + +#ifdef Q_OS_MACX + m_ui->toolbar->setMovable(false); +#endif } DMainWindow::~DMainWindow() @@ -43,8 +48,14 @@ void DMainWindow::on_actGitHub_triggered() QDesktopServices::openUrl(QUrl(SL("https://github.com/dolphin-emu/dolphin/"))); } +void DMainWindow::on_actSystemInfo_triggered() +{ + DSystemInfo* dlg = new DSystemInfo(this); + dlg->open(); +} + void DMainWindow::on_actAbout_triggered() { - DAboutDialog dlg; - dlg.exec(); + DAboutDialog* dlg = new DAboutDialog(this); + dlg->open(); } diff --git a/Source/Core/DolphinQt/MainWindow.h b/Source/Core/DolphinQt/MainWindow.h index d7db3b6294..286dc4fae8 100644 --- a/Source/Core/DolphinQt/MainWindow.h +++ b/Source/Core/DolphinQt/MainWindow.h @@ -26,8 +26,9 @@ private slots: void on_actWebsite_triggered(); void on_actOnlineDocs_triggered(); void on_actGitHub_triggered(); + void on_actSystemInfo_triggered(); void on_actAbout_triggered(); private: - std::unique_ptr ui; + std::unique_ptr m_ui; }; diff --git a/Source/Core/DolphinQt/MainWindow.ui b/Source/Core/DolphinQt/MainWindow.ui index 7172fc4424..c63d5610c0 100644 --- a/Source/Core/DolphinQt/MainWindow.ui +++ b/Source/Core/DolphinQt/MainWindow.ui @@ -6,8 +6,8 @@ 0 0 - 996 - 596 + 992 + 592 @@ -31,8 +31,8 @@ 0 0 - 996 - 21 + 992 + 24 @@ -69,6 +69,7 @@ + @@ -87,7 +88,7 @@ - toolBar + Toolbar TopToolBarArea @@ -119,11 +120,19 @@ - Open + &Open Open file... + + Ctrl+O + + + + + &System Information + diff --git a/Source/Core/DolphinQt/SystemInfo.cpp b/Source/Core/DolphinQt/SystemInfo.cpp new file mode 100644 index 0000000000..ca9ff2e07f --- /dev/null +++ b/Source/Core/DolphinQt/SystemInfo.cpp @@ -0,0 +1,106 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include +#include +#include + +#include "ui_SystemInfo.h" + +#include "Common/Common.h" +#include "Common/CPUDetect.h" +#include "Common/StdMakeUnique.h" + +#include "DolphinQt/SystemInfo.h" +#include "DolphinQt/Utils/Utils.h" + +DSystemInfo::DSystemInfo(QWidget* parent_widget) : + QDialog(parent_widget) +{ + setWindowModality(Qt::WindowModal); + setAttribute(Qt::WA_DeleteOnClose); + + m_ui = std::make_unique(); + m_ui->setupUi(this); + + UpdateSystemInfo(); + + QPushButton* btn = m_ui->buttonBox->addButton(tr("Copy"), QDialogButtonBox::ActionRole); + connect(btn, SIGNAL(pressed()), this, SLOT(btnCopy_pressed())); +} + +DSystemInfo::~DSystemInfo() +{ +} + +void DSystemInfo::btnCopy_pressed() +{ + QClipboard* clipboard = QApplication::clipboard(); + clipboard->setText(m_ui->txtSysInfo->toPlainText()); +} + +void DSystemInfo::UpdateSystemInfo() +{ + QString sysinfo; + + 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())) + .arg(QThread::idealThreadCount()); + + sysinfo += SL("\nDolphin\n===========================\n"); + sysinfo += SL("SCM: branch %1, rev %2\n").arg(SC(scm_branch_str)).arg(SC(scm_rev_git_str)); + sysinfo += SL("Compiled: %1, %2\n").arg(SL(__DATE__)).arg(SL(__TIME__)); + + sysinfo += SL("\nGUI\n===========================\n"); + sysinfo += SL("Compiled for Qt: %1\n").arg(SL(QT_VERSION_STR)); + sysinfo += SL("Running on Qt: %1").arg(SC(qVersion())); + + m_ui->txtSysInfo->setPlainText(sysinfo); +} + +QString DSystemInfo::GetOS() +{ + QString ret; + /* DON'T REORDER WITHOUT READING Qt DOCS! */ +#if defined(Q_OS_WIN) + ret += SL("Windows "); + switch (QSysInfo::WindowsVersion) { + case QSysInfo::WV_VISTA: ret += SL("Vista"); break; + case QSysInfo::WV_WINDOWS7: ret += SL("7"); break; + case QSysInfo::WV_WINDOWS8: ret += SL("8"); break; + default: ret += SL("(unknown)"); break; + } +#elif defined(Q_OS_MAC) + ret += SL("Mac OS X "); + switch (QSysInfo::MacintoshVersion) { + case QSysInfo::MV_10_7: ret += SL("10.7"); break; + case QSysInfo::MV_10_8: ret += SL("10.8"); break; + case QSysInfo::MV_10_9: ret += SL("10.9"); break; + default: ret += SL("(unknown)"); break; + } +#elif defined(Q_OS_LINUX) + ret += SL("Linux"); +#elif defined(Q_OS_FREEBSD) + ret += SL("FreeBSD"); +#elif defined(Q_OS_OPENBSD) + ret += SL("OpenBSD"); +#elif defined(Q_OS_NETBSD) + ret += SL("NetBSD"); +#elif defined(Q_OS_BSD4) + ret += SL("Other BSD"); +#elif defined(Q_OS_UNIX) + ret += SL("Unix"); +#else + ret += SL("Unknown"); +#endif + +#if defined(Q_WS_X11) || defined(Q_OS_X11) + ret += SL(" X11"); +#elif defined(Q_WS_WAYLAND) + ret += SL(" Wayland"); +#endif + + return ret; +} diff --git a/Source/Core/DolphinQt/SystemInfo.h b/Source/Core/DolphinQt/SystemInfo.h new file mode 100644 index 0000000000..fc34ab7517 --- /dev/null +++ b/Source/Core/DolphinQt/SystemInfo.h @@ -0,0 +1,31 @@ +// Copyright 2014 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include +#include + +namespace Ui +{ +class DSystemInfo; +} + +class DSystemInfo : public QDialog +{ + Q_OBJECT + +public: + explicit DSystemInfo(QWidget* parent_widget = nullptr); + ~DSystemInfo(); + +private slots: + void btnCopy_pressed(); + +private: + std::unique_ptr m_ui; + + void UpdateSystemInfo(); + QString GetOS(); +}; diff --git a/Source/Core/DolphinQt/SystemInfo.ui b/Source/Core/DolphinQt/SystemInfo.ui new file mode 100644 index 0000000000..95506a9857 --- /dev/null +++ b/Source/Core/DolphinQt/SystemInfo.ui @@ -0,0 +1,71 @@ + + + DSystemInfo + + + + 0 + 0 + 446 + 298 + + + + System Information + + + + + + true + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Close + + + + + + + + + buttonBox + accepted() + DSystemInfo + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DSystemInfo + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/Source/Core/DolphinQt/Utils/Utils.h b/Source/Core/DolphinQt/Utils/Utils.h index 9591d4dd98..8b149c6fe8 100644 --- a/Source/Core/DolphinQt/Utils/Utils.h +++ b/Source/Core/DolphinQt/Utils/Utils.h @@ -8,7 +8,11 @@ #include "Common/CommonTypes.h" -// Shorter version of QStringLiteral(str) +// Use this to encapsulate ASCII string literals #define SL(str) QStringLiteral(str) +// Use this to encapsulate string constants and functions that +// return "char*"s +#define SC(str) QString::fromLatin1(str) + QString NiceSizeFormat(s64 size);