Skip to content

Commit

Permalink
add About dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
stoneface86 committed Jun 15, 2021
1 parent febd2ef commit abbf43e
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Trackerboy](/.github/logo.png)
![Trackerboy](/ui/resources/images/logo.png)
---

[![build-lib][build-lib-badge]][build-lib-link]
Expand Down
1 change: 1 addition & 0 deletions ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ set(UI_SRC
"core/SyncWorker.cpp"
"core/WavExporter.cpp"

"forms/AboutDialog.cpp"
"forms/AudioDiagDialog.cpp"
"forms/ConfigDialog.cpp"
"forms/ExportWavDialog.cpp"
Expand Down
61 changes: 61 additions & 0 deletions ui/forms/AboutDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

#include "forms/AboutDialog.hpp"

#include "trackerboy/version.hpp"

AboutDialog::AboutDialog(QWidget *parent) :
QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint),
mLayout(),
mLogo(),
mLine(),
mBodyLayout(),
mIcon(),
mBody(),
mButtons()
{
setModal(true);
setWindowTitle(tr("About"));

mBodyLayout.addWidget(&mIcon);
mBodyLayout.addWidget(&mBody, 1);

mLayout.addWidget(&mLogo);
mLayout.addWidget(&mLine);
mLayout.addLayout(&mBodyLayout, 1);
mLayout.addWidget(&mButtons);
mLayout.setSizeConstraint(QLayout::SizeConstraint::SetFixedSize);
setLayout(&mLayout);

mLogo.setPixmap(QPixmap(QStringLiteral(":/images/logo.png")));
mIcon.setPixmap(QPixmap(QStringLiteral(":/icons/app/appicon-48.png")));

mLine.setFrameShape(QFrame::HLine);
mLine.setFrameShadow(QFrame::Sunken);

mIcon.setAlignment(Qt::AlignTop | Qt::AlignHCenter);

mBody.setTextFormat(Qt::RichText);
mBody.setTextInteractionFlags(Qt::TextBrowserInteraction);
mBody.setOpenExternalLinks(true);
mBody.setText(QStringLiteral(
R"bodystr(
<html><head/>
<body>
<h1>Trackerboy v%1.%2.%3</h1>
<h3> A Gameboy/Gameboy Color music tracker</h3>
<h3>Copyright (C) 2019-2021 stoneface86</h3>
<br/>
<br/>
<span>Repo - <a href="https://github.com/stoneface86/trackerboy">https://github.com/stoneface86/trackerboy</a></span>
<br/>
<p>This software is licensed under the MIT License.</p>
</body>
</html>
)bodystr").arg(trackerboy::VERSION.major)
.arg(trackerboy::VERSION.minor)
.arg(trackerboy::VERSION.patch));

mButtons.addButton(QDialogButtonBox::Close);

connect(&mButtons, &QDialogButtonBox::rejected, this, &AboutDialog::reject);
}
32 changes: 32 additions & 0 deletions ui/forms/AboutDialog.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

#pragma once


#include <QDialog>
#include <QDialogButtonBox>
#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>


class AboutDialog : public QDialog {

Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = nullptr);


private:

QVBoxLayout mLayout;
QLabel mLogo;
QFrame mLine;
QHBoxLayout mBodyLayout;
QLabel mIcon;
QLabel mBody;
QDialogButtonBox mButtons;


};
9 changes: 9 additions & 0 deletions ui/forms/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ MainWindow::MainWindow(Miniaudio &miniaudio) :
mConfig(miniaudio),
mDocumentCounter(0),
mErrorSinceLastConfig(false),
mAboutDialog(nullptr),
mAudioDiag(nullptr),
mConfigDialog(nullptr),
mToolbarFile(),
Expand Down Expand Up @@ -313,6 +314,13 @@ void MainWindow::onConfigApplied(Config::Categories categories) {
mConfig.writeSettings();
}

void MainWindow::showAboutDialog() {
if (mAboutDialog == nullptr) {
mAboutDialog = new AboutDialog(this);
}
mAboutDialog->show();
}

void MainWindow::showAudioDiag() {
if (mAudioDiag == nullptr) {
mAudioDiag = new AudioDiagDialog(*mRenderer, this);
Expand Down Expand Up @@ -855,6 +863,7 @@ void MainWindow::setupUi() {

// help
connectActionToThis(mActionAudioDiag, showAudioDiag);
connectActionToThis(mActionHelpAbout, showAboutDialog);
QApplication::connect(&mActionHelpAboutQt, &QAction::triggered, &QApplication::aboutQt);

// editors
Expand Down
3 changes: 3 additions & 0 deletions ui/forms/MainWindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/SyncWorker.hpp"
#include "core/model/ModuleDocument.hpp"
#include "core/model/ModuleModel.hpp"
#include "forms/AboutDialog.hpp"
#include "forms/AudioDiagDialog.hpp"
#include "forms/ConfigDialog.hpp"
#include "widgets/docks/ModuleSettingsWidget.hpp"
Expand Down Expand Up @@ -66,6 +67,7 @@ private slots:
void onConfigApplied(Config::Categories categories);

// dialog show slots (lazy loading)
void showAboutDialog();
void showAudioDiag();
void showConfigDialog();
void showExportWavDialog();
Expand Down Expand Up @@ -125,6 +127,7 @@ private slots:
bool mErrorSinceLastConfig;

// dialogs
AboutDialog *mAboutDialog;
AudioDiagDialog *mAudioDiag;
ConfigDialog *mConfigDialog;

Expand Down
7 changes: 4 additions & 3 deletions ui/resources/images.qrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>images/gridHeaderFont.bmp</file>
<file>images/whitekey_down.png</file>
<file>images/blackkey_down.png</file>
<file>images/piano_whitekeys.png</file>
<file>images/gridHeaderFont.bmp</file>
<file>images/logo.png</file>
<file>images/piano_blackkeys.png</file>
<file>images/piano_whitekeys.png</file>
<file>images/whitekey_down.png</file>
</qresource>
</RCC>
File renamed without changes

0 comments on commit abbf43e

Please sign in to comment.