Skip to content

Commit 8710b12

Browse files
committed
Add AboutDlg.
1 parent 505500e commit 8710b12

File tree

7 files changed

+127
-5
lines changed

7 files changed

+127
-5
lines changed

snm.pro

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@ DEFINES += USE_QT5
1212
QT += gui
1313
}
1414

15+
DEFINES += VERSION=\\\"0.1.1\\\"
16+
1517
# Input
1618
HEADERS += \
19+
src/AboutDlg.hpp \
1720
src/Config.hpp \
1821
src/ControlToolBar.hpp \
1922
src/Editor.hpp \
@@ -26,6 +29,7 @@ HEADERS += \
2629
src/Settings.hpp
2730

2831
SOURCES += \
32+
src/AboutDlg.cpp \
2933
src/Config.cpp \
3034
src/ControlToolBar.cpp \
3135
src/Editor.cpp \

src/AboutDlg.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// This file is part of Simple Normal Mapper.
2+
// Copyright (c) 2013 Simple Normal Mapper developers.
3+
//
4+
// Simple Normal Mapper is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
// Simple Normal Mapper is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Simple Normal Mapper. If not, see <http://www.gnu.org/licenses/>.
15+
16+
#include "AboutDlg.hpp"
17+
#include "Config.hpp"
18+
19+
#include <QHBoxLayout>
20+
#include <QLabel>
21+
#include <QPixmap>
22+
#include <QPushButton>
23+
#include <QVBoxLayout>
24+
25+
AboutDlg::AboutDlg(QWidget * parent)
26+
: QDialog(parent)
27+
{
28+
setWindowTitle(tr("About") + " " + Config::name());
29+
initWidgets();
30+
}
31+
32+
void AboutDlg::initWidgets()
33+
{
34+
QVBoxLayout * vLayout = new QVBoxLayout(this);
35+
QHBoxLayout * hLayout = new QHBoxLayout();
36+
QLabel * pixmapLabel = new QLabel(this);
37+
38+
pixmapLabel->setPixmap(QPixmap(":/about.png").scaledToWidth(256));
39+
hLayout->addWidget(pixmapLabel);
40+
41+
QLabel * infoLabel = new QLabel(this);
42+
infoLabel->setText(QString("<h2>") + Config::name() + " v" + Config::version() + "</h2>"
43+
+ "<p>" + Config::name() + " is licenced under GNU GPLv3.</p>"
44+
+ "<p>Copyright (c) 2013 " + Config::name() + " developers.</p>"
45+
+ "<a href='http://sourceforge.net/projects/simplenormalmapper'>"
46+
+ "http://sourceforge.net/projects/simplenormalmapper</a>");
47+
48+
hLayout->addWidget(infoLabel);
49+
vLayout->addLayout(hLayout);
50+
QHBoxLayout * buttonLayout = new QHBoxLayout();
51+
QPushButton * button = new QPushButton("&Ok", this);
52+
connect(button, SIGNAL(clicked()), this, SLOT(accept()));
53+
buttonLayout->addWidget(button);
54+
buttonLayout->insertStretch(0);
55+
vLayout->addLayout(buttonLayout);
56+
}

src/AboutDlg.hpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// This file is part of Simple Normal Mapper.
2+
// Copyright (c) 2013 Simple Normal Mapper developers.
3+
//
4+
// Simple Normal Mapper is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
// Simple Normal Mapper is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Simple Normal Mapper. If not, see <http://www.gnu.org/licenses/>.
15+
16+
#ifndef ABOUTDLG_HPP
17+
#define ABOUTDLG_HPP
18+
19+
#include <QDialog>
20+
21+
//! The about dialog.
22+
class AboutDlg : public QDialog
23+
{
24+
Q_OBJECT
25+
26+
public:
27+
28+
//! Constructor.
29+
explicit AboutDlg(QWidget * parent = 0);
30+
31+
private:
32+
33+
void initWidgets();
34+
};
35+
36+
#endif // ABOUTDLG_HPP

src/Config.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515

1616
#include "Config.hpp"
1717

18-
Config::Config()
18+
static const QString nameStr = "Simple Normal Mapper";
19+
static const QString verStr = VERSION;
20+
21+
QString Config::name()
22+
{
23+
return nameStr;
24+
}
25+
26+
QString Config::version()
1927
{
28+
return verStr;
2029
}

src/Config.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@
1616
#ifndef CONFIG_HPP
1717
#define CONFIG_HPP
1818

19+
#include <QString>
20+
1921
class Config
2022
{
2123
public:
22-
Config();
24+
25+
static QString name();
26+
static QString version();
2327
};
2428

2529
#endif // CONFIG_HPP

src/MainWindow.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
// along with Simple Normal Mapper. If not, see <http://www.gnu.org/licenses/>.
1515

1616
#include "MainWindow.hpp"
17+
18+
#include "AboutDlg.hpp"
19+
#include "Config.hpp"
1720
#include "ControlToolBar.hpp"
1821
#include "Editor.hpp"
1922
#include "EditorView.hpp"
@@ -45,8 +48,6 @@
4548

4649
namespace
4750
{
48-
const char * SOFTWARE_NAME = "Simple Normal Mapper";
49-
const char * SOFTWARE_VERSION = "0.1.1";
5051
const int MARGIN = 0;
5152
const unsigned int MIN_ZOOM = 0;
5253
const unsigned int MAX_ZOOM = 400;
@@ -63,7 +64,7 @@ MainWindow::MainWindow(Editor & editor, Renderer & renderer)
6364
, m_scaleSlider(new QSlider(Qt::Horizontal, this))
6465
, m_console(new QTextEdit(this))
6566
{
66-
setWindowTitle(QString(SOFTWARE_NAME) + " " + SOFTWARE_VERSION);
67+
setWindowTitle(Config::name() + " v" + Config::version());
6768
setWindowIcon(QIcon(":/snm.png"));
6869

6970
QStatusBar * statusBar = new QStatusBar(this);
@@ -109,6 +110,10 @@ void MainWindow::initMenuBar()
109110
QMenu * helpMenu = new QMenu(tr("&Help"), this);
110111
menuBar->addMenu(helpMenu);
111112

113+
QAction * about = new QAction(tr("About"), this);
114+
helpMenu->addAction(about);
115+
connect(about, SIGNAL(triggered()), this, SLOT(showAboutDlg()));
116+
112117
// Add "about Qt"-action
113118
QAction * aboutQtAct = new QAction(tr("About &Qt"), this);
114119
helpMenu->addAction(aboutQtAct);
@@ -120,6 +125,12 @@ void MainWindow::showAboutQt()
120125
QMessageBox::aboutQt(this, tr("About Qt"));
121126
}
122127

128+
void MainWindow::showAboutDlg()
129+
{
130+
AboutDlg aboutDlg;
131+
aboutDlg.exec();
132+
}
133+
123134
void MainWindow::initLayout()
124135
{
125136
// Create layouts for slider, view and toolbar

src/MainWindow.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ private slots:
4747

4848
void showAboutQt();
4949

50+
void showAboutDlg();
51+
5052
void updateScale(int value);
5153

5254
private:

0 commit comments

Comments
 (0)