-
-
Notifications
You must be signed in to change notification settings - Fork 104
Expand file tree
/
Copy pathAboutDialog.cpp
More file actions
184 lines (152 loc) · 6.3 KB
/
Copy pathAboutDialog.cpp
File metadata and controls
184 lines (152 loc) · 6.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
* AboutDialog.cpp
*
* (c) 2016 Dame Diongue -- baydamd(@)gmail(.)com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AboutDialog.h"
#include <QtWidgets>
namespace mmp {
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent)
{
// Defines fixed size
resize(ABOUT_WINDOW_WIDTH, ABOUT_WINDOW_HEIGHT);
setMinimumSize(ABOUT_WINDOW_WIDTH, ABOUT_WINDOW_HEIGHT);
// Set title
setWindowTitle(tr("About %1").arg(MM::APPLICATION_NAME));
// Set Layout
QGridLayout *mainLayout = new QGridLayout;
setLayout(mainLayout);
// Set icon label
QLabel *iconLabel = new QLabel;
iconLabel->setPixmap(QPixmap(":/mapmap-logo").scaled(64, 64, Qt::KeepAspectRatio, Qt::SmoothTransformation));
iconLabel->setContentsMargins(0, 20, 0, 20);
mainLayout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignRight);
// Set title label
QLabel *textLabel = new QLabel;
textLabel->setPixmap(QPixmap(":/mapmap-title-light").scaled(200, 40, Qt::KeepAspectRatio, Qt::SmoothTransformation));
mainLayout->addWidget(textLabel, 0, 2);
// Set version label
QLabel *versionLabel = new QLabel;
versionLabel->setText(QString("<h2> %1 </h2>").arg(MM::VERSION));
versionLabel->setContentsMargins(7, 20, 0, 0);
mainLayout->addWidget(versionLabel, 0, 3);
// Add tab widget
_tabWidget = new QTabWidget;
mainLayout->addWidget(_tabWidget, 1, 0, 1, 4);
// Close button
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close);
connect(buttonBox, SIGNAL(rejected()), this, SLOT(close()));
mainLayout->addWidget(buttonBox, 2, 0, 1, 4);
// Create and fill different tabs
createAboutTab();
// Changelog Tab
createChangelogTab();
// Libraries
// createLibrariesTab();
// Contributors
createContributorsTab();
// License
createLicenseTab();
createOscTab();
}
void AboutDialog::createAboutTab()
{
QWidget *aboutWidget = new QWidget;
QVBoxLayout *aboutLayout = new QVBoxLayout(aboutWidget);
// Add splash image at the top.
QLabel *splashLabel = new QLabel;
QPixmap splashPixmap(":/mapmap-splash");
int targetWidth = qMin(splashPixmap.width(), ABOUT_WINDOW_WIDTH - 40);
splashLabel->setPixmap(splashPixmap.scaledToWidth(targetWidth, Qt::SmoothTransformation));
splashLabel->setAlignment(Qt::AlignCenter);
aboutLayout->addWidget(splashLabel);
QTextBrowser *aboutTextBrowser = new QTextBrowser;
aboutTextBrowser->setOpenExternalLinks(true);
// Software description
QString aboutSoftwareText = "<p>" + tr("MapMap is a free/open source video mapping software.") + "</p>";
// Copyright and software owners
QString copyrightText = "<p>" + tr("Copyright © 2013 %1.").arg(MM::COPYRIGHT_OWNERS) + "</p>";
// License short notice
QFile licenseShortFile(":/license-short");
licenseShortFile.open(QIODevice::ReadOnly | QIODevice::Text);
QString licenseNoticeText = Qt::convertFromPlainText(QString::fromUtf8(licenseShortFile.readAll()), Qt::WhiteSpaceNormal);
// About projection mapping
QFile aboutMappingFile(":/projection-mapping");
aboutMappingFile.open(QIODevice::ReadOnly | QIODevice::Text);
QString aboutMappingText = QString::fromUtf8(aboutMappingFile.readAll());
// Visit our website for more information
QString projectWebsiteText = "<p>" + tr("See the ") + QString("<a href=\"http://%1\">").arg(MM::ORGANIZATION_DOMAIN) +
tr("%1 website").arg(MM::APPLICATION_NAME) + "</a> for more information on this software.</p>";
// Append texts
QString aboutText;
aboutText.append(aboutSoftwareText);
aboutText.append(copyrightText);
aboutText.append(licenseNoticeText);
aboutText.append(aboutMappingText);
aboutText.append(projectWebsiteText);
// Set about text
aboutTextBrowser->setText(aboutText);
aboutLayout->addWidget(aboutTextBrowser);
_tabWidget->addTab(aboutWidget, tr("About"));
}
void AboutDialog::createChangelogTab()
{
QTextBrowser *changelogTextBrowser = new QTextBrowser;
changelogTextBrowser->setOpenExternalLinks(true);
QFile changelogFile(":/changelog_md");
changelogFile.open(QIODevice::ReadOnly | QIODevice::Text);
changelogTextBrowser->setMarkdown(QString::fromUtf8(changelogFile.readAll()));
_tabWidget->addTab(changelogTextBrowser, tr("Changelog"));
}
void AboutDialog::createLibrariesTab()
{
QTextBrowser *librariesTextBrowser = new QTextBrowser;
librariesTextBrowser->setOpenExternalLinks(true);
QString qtVersionText = QString("<h4>Qt %1</h4>").arg(QT_VERSION_STR);
QString librairiesText;
librairiesText.append(qtVersionText);
// Set librairies main text
librariesTextBrowser->setText(librairiesText);
_tabWidget->addTab(librariesTextBrowser, tr("Libraries"));
}
void AboutDialog::createContributorsTab()
{
QTextBrowser *contributorsTextBrowser = new QTextBrowser;
contributorsTextBrowser->setOpenExternalLinks(true);
QFile contributorsFile(":/contributors_md");
contributorsFile.open(QIODevice::ReadOnly | QIODevice::Text);
contributorsTextBrowser->setMarkdown(QString::fromUtf8(contributorsFile.readAll()));
_tabWidget->addTab(contributorsTextBrowser, tr("Contributors"));
}
void AboutDialog::createLicenseTab()
{
QTextBrowser *licenseTextBrowser = new QTextBrowser;
licenseTextBrowser->setOpenExternalLinks(true);
QFile licenseFile(":/license");
licenseFile.open(QIODevice::ReadOnly | QIODevice::Text);
licenseTextBrowser->setText(QString::fromUtf8(licenseFile.readAll()));
_tabWidget->addTab(licenseTextBrowser, tr("License"));
}
void AboutDialog::createOscTab()
{
QTextBrowser *oscBrowser = new QTextBrowser;
oscBrowser->setOpenExternalLinks(true);
QFile oscFile(":/osc-documentation_md");
oscFile.open(QIODevice::ReadOnly | QIODevice::Text);
oscBrowser->setMarkdown(QString::fromUtf8(oscFile.readAll()));
_tabWidget->addTab(oscBrowser, tr("OSC Commands"));
}
}