Qt: Add about screen

This commit is contained in:
Jeffrey Pfau 2015-07-29 22:13:40 -07:00
parent 4036294593
commit 9b66243e37
7 changed files with 263 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 KiB

After

Width:  |  Height:  |  Size: 518 KiB

View File

@ -0,0 +1,36 @@
/* Copyright (c) 2013-2015 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AboutScreen.h"
#include "util/version.h"
#include <QPixmap>
using namespace QGBA;
AboutScreen::AboutScreen(QWidget* parent)
: QDialog(parent)
{
m_ui.setupUi(this);
QPixmap logo(":/res/mgba-1024.png");
logo = logo.scaled(m_ui.logo->minimumSize() * devicePixelRatio(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
logo.setDevicePixelRatio(devicePixelRatio());
m_ui.logo->setPixmap(logo);
m_ui.projectName->setText(QLatin1String(projectName));
m_ui.projectVersion->setText(QLatin1String(projectVersion));
QString gitInfo = m_ui.gitInfo->text();
gitInfo.replace("{gitBranch}", QLatin1String(gitBranch));
gitInfo.replace("{gitCommit}", QLatin1String(gitCommit));
m_ui.gitInfo->setText(gitInfo);
QString description = m_ui.description->text();
description.replace("{projectName}", QLatin1String(projectName));
m_ui.description->setText(description);
QString extraLinks = m_ui.extraLinks->text();
extraLinks.replace("{gitBranch}", QLatin1String(gitBranch));
m_ui.extraLinks->setText(extraLinks);
}

View File

@ -0,0 +1,27 @@
/* Copyright (c) 2013-2014 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef QGBA_ABOUT_SCREEN
#define QGBA_ABOUT_SCREEN
#include <QDialog>
#include "ui_AboutScreen.h"
namespace QGBA {
class AboutScreen : public QDialog {
Q_OBJECT
public:
AboutScreen(QWidget* parent = nullptr);
private:
Ui::AboutScreen m_ui;
};
}
#endif

View File

@ -0,0 +1,177 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutScreen</class>
<widget class="QWidget" name="AboutScreen">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>565</width>
<height>268</height>
</rect>
</property>
<property name="windowTitle">
<string>About</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="0" column="1">
<widget class="QLabel" name="projectName">
<property name="font">
<font>
<pointsize>36</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>{projectName}</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<widget class="QLabel" name="copyright">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>© 2013 2015 Jeffrey Pfau — Game Boy Advance is a registered trademark of Nintendo Co., Ltd.</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="projectVersion">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>{projectVersion}</string>
</property>
<property name="alignment">
<set>Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft</set>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="6">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>8</number>
</property>
<property name="rightMargin">
<number>16</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="logo">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>256</width>
<height>192</height>
</size>
</property>
<property name="text">
<string>{logo}</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="3" column="1">
<widget class="QLabel" name="description">
<property name="text">
<string>{projectName} is an open-source Game Boy Advance emulator</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="extraLinks">
<property name="text">
<string>&lt;a href=&quot;http://mgba.io/&quot;&gt;Website&lt;/a&gt; • &lt;a href=&quot;https://forumsmgba.io/&quot;&gt;Forums / Support&lt;/a&gt; • &lt;a href=&quot;https://github.com/mgba-emu/mgba/tree/{gitBranch}&quot;&gt;Source&lt;/a&gt; • &lt;a href=&quot;https://github.com/mgba-emu/mgba/blob/{gitBranch}/LICENSE&quot;&gt;License&lt;/a&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="gitInfo">
<property name="font">
<font>
<pointsize>10</pointsize>
</font>
</property>
<property name="text">
<string>Branch: &lt;tt&gt;{gitBranch}&lt;/tt&gt;&lt;br/&gt;Revision: &lt;tt&gt;{gitCommit}&lt;/tt&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -47,6 +47,7 @@ if(QT_TYPE STREQUAL STATIC_LIBRARY)
endif()
set(SOURCE_FILES
AboutScreen.cpp
AudioProcessor.cpp
CheatsModel.cpp
CheatsView.cpp
@ -83,6 +84,7 @@ set(SOURCE_FILES
VideoView.cpp)
qt5_wrap_ui(UI_FILES
AboutScreen.ui
CheatsView.ui
GIFView.ui
LoadSaveState.ui

View File

@ -13,6 +13,7 @@
#include <QPainter>
#include <QStackedLayout>
#include "AboutScreen.h"
#include "CheatsView.h"
#include "ConfigController.h"
#include "Display.h"
@ -346,6 +347,11 @@ void Window::openMemoryWindow() {
openView(memoryWindow);
}
void Window::openAboutScreen() {
AboutScreen* about = new AboutScreen();
openView(about);
}
#ifdef BUILD_SDL
void Window::openGamepadWindow() {
const char* profile = m_inputController.profileForType(SDL_BINDING_BUTTON);
@ -754,6 +760,14 @@ void Window::setupMenu(QMenuBar* menubar) {
});
addControlledAction(fileMenu, multiWindow, "multiWindow");
#ifndef Q_OS_MAC
fileMenu->addSeparator();
#endif
QAction* about = new QAction(tr("About"), fileMenu);
connect(about, SIGNAL(triggered()), this, SLOT(openAboutScreen()));
fileMenu->addAction(about);
#ifndef Q_OS_MAC
addControlledAction(fileMenu, fileMenu->addAction(tr("E&xit"), this, SLOT(close()), QKeySequence::Quit), "quit");
#endif
@ -1216,11 +1230,11 @@ void WindowBackground::paintEvent(QPaintEvent*) {
painter.setRenderHint(QPainter::SmoothPixmapTransform);
painter.fillRect(QRect(QPoint(), size()), Qt::black);
QSize s = size();
QSize ds = s;
if (s.width() * m_aspectHeight > s.height() * m_aspectWidth) {
ds.setWidth(s.height() * m_aspectWidth / m_aspectHeight);
} else if (s.width() * m_aspectHeight < s.height() * m_aspectWidth) {
ds.setHeight(s.width() * m_aspectHeight / m_aspectWidth);
QSize ds = s * 0.8;
if (ds.width() * m_aspectHeight > ds.height() * m_aspectWidth) {
ds.setWidth(ds.height() * m_aspectWidth / m_aspectHeight);
} else if (ds.width() * m_aspectHeight < ds.height() * m_aspectWidth) {
ds.setHeight(ds.width() * m_aspectHeight / m_aspectWidth);
}
QPoint origin = QPoint((s.width() - ds.width()) / 2, (s.height() - ds.height()) / 2);
QRect full(origin, ds);

View File

@ -82,6 +82,8 @@ public slots:
void openPaletteWindow();
void openMemoryWindow();
void openAboutScreen();
#ifdef BUILD_SDL
void openGamepadWindow();
#endif