21 #include <QHBoxLayout>
22 #include <QVBoxLayout>
24 #include <QTextBrowser>
26 #include <QPushButton>
29 #include <QMessageBox>
30 #include <QDesktopServices>
42 QDialog(parent, Qt::Window)
44 EptAssert(parent,
"Parent required for size");
47 QRect r(parent->geometry());
48 setGeometry(r.left() + r.width() / 4, r.top() + r.height() / 4, r.width() / 2, r.height() / 2);
49 setWindowTitle(tr(
"About"));
50 QVBoxLayout *mainLayout =
new QVBoxLayout;
51 mainLayout->setSpacing(0);
52 setLayout(mainLayout);
54 QHBoxLayout *titleLayout =
new QHBoxLayout;
56 mainLayout->addLayout(titleLayout);
58 titleLayout->addWidget(
new QLabel(QString(
"<h1>%1 %2</h1>").arg(tr(
"Entropy Piano Tuner"),
EPT_VERSION_STRING)));
59 titleLayout->addStretch();
62 QObject::connect(webpage, SIGNAL(linkActivated(QString)),
this, SLOT(
onOpenAboutLink(QString)));
63 mainLayout->addWidget(webpage);
65 QString iconPath =
":/media/images/icon_256x256" + iconPostfix +
".png";
66 QTextBrowser *text =
new QTextBrowser;
67 text->setStyleSheet(
"background-color: transparent;");
68 text->setFrameShape(QFrame::NoFrame);
69 text->setOpenLinks(
false);
70 QObject::connect(text, SIGNAL(anchorClicked(QUrl)),
this, SLOT(
onOpenAboutUrl(QUrl)));
71 mainLayout->addWidget(text);
73 const QString buildText = tr(
"Built on %1").arg(QDateTime::fromString(__TIMESTAMP__).toString(Qt::DefaultLocaleLongDate));
74 const QString buildByText = tr(
"by %1 and %2").arg(
"Prof. Dr. Haye Hinrichsen",
"Christoph Wick M.Sc.");
76 QString dependenciesText = tr(
"Based on");
77 dependenciesText.append(
" <a href=\"Qt\">Qt</a>, <a href=\"http://qwt.sf.net\">Qwt</a>, <a href=\"http://fftw.org\">fftw3</a>");
78 dependenciesText.append(
", <a href=\"http://www.grinninglizard.com/tinyxml2\">tinyxml2</a>");
80 dependenciesText.append(
", <a href=\"https://github.com/petegoodliffe/PGMidi\">PgMidi</a>");
81 #elif defined(Q_OS_ANDROID)
82 dependenciesText.append(
", <a href=\"https://github.com/kshoji/USB-MIDI-Driver\">USB-Midi-Driver</a>");
84 dependenciesText.append(
", <a href=\"http://www.music.mcgill.ca/~gary/rtmidi\">RtMidi</a>");
87 const QString copyrightText = tr(
"Copyright 2015 Dept. of Theor. Phys. III, University of Würzburg. All rights reserved.");
88 const QString licenseText = tr(
"This software is licensed under the terms of the %1. The source code can be accessed at %2.").
89 arg(
"<a href=\"http://www.gnu.org/licenses/gpl-3.0-standalone.html\">GPLv3</a>",
90 "<a href=\"https://gitlab.com/entropytuner/Entropy-Piano-Tuner\">GitLab</a>");
92 const QString warrantyText = tr(
"The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.");
94 const QString acknowledgementsText = tr(
"We thank all those who have contributed to the project:") +
95 " Prof. Dr. S. R. Dahmen, A. Frick, A. Heilrath, M. Jiminez, Prof. Dr. W. Kinzel, M. Kohl, L. Kusmierz, Prof. Dr. A. C. Lehmann, B. Olbrich., Dr. J. Um, Zhou Ying, Xavier Monnin";
97 auto makeParagraphTags = [](
const QString &t) {
return "<p>" + t +
"</p>";};
99 completeText.append(
"<html><img src=\"" + iconPath +
"\" style=\"float: left;\"/>");
101 completeText.append(makeParagraphTags(buildText));
102 completeText.append(makeParagraphTags(buildByText));
103 completeText.append(makeParagraphTags(dependenciesText));
104 completeText.append(makeParagraphTags(copyrightText));
105 completeText.append(makeParagraphTags(licenseText));
106 completeText.append(makeParagraphTags(warrantyText));
107 completeText.append(makeParagraphTags(acknowledgementsText));
109 completeText.append(
"</html>");
111 text->setHtml(completeText);
113 QHBoxLayout *okButtonLayout =
new QHBoxLayout;
114 okButtonLayout->setMargin(0);
115 mainLayout->addLayout(okButtonLayout);
116 okButtonLayout->addStretch();
118 QPushButton *okButton =
new QPushButton(tr(
"Ok"));
119 okButtonLayout->addWidget(okButton);
121 QObject::connect(okButton, SIGNAL(clicked()),
this, SLOT(accept()));
123 QScroller::grabGesture(text);
124 text->setReadOnly(
true);
125 text->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
132 if (url.toString() ==
"Qt") {
133 QMessageBox::aboutQt(
this);
135 QDesktopServices::openUrl(url);
140 QDesktopServices::openUrl(QUrl::fromUserInput(link));
void onOpenAboutUrl(QUrl url)
Slot called by the about dialog when clicked a url.
QHBoxLayout * mTitleBarLayout
#define EPT_VERSION_STRING
void onOpenAboutLink(QString link)
AboutDialog(QWidget *parent, QString iconPostfix)
static const std::string SERVER_NAME
static const std::string SERVER_ADDRESS