Entropy Piano Tuner  1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
aboutdialog.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2015 Haye Hinrichsen, Christoph Wick
3  *
4  * This file is part of Entropy Piano Tuner.
5  *
6  * Entropy Piano Tuner is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * Entropy Piano Tuner is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * Entropy Piano Tuner. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #include "aboutdialog.h"
21 #include <QHBoxLayout>
22 #include <QVBoxLayout>
23 #include <QLabel>
24 #include <QTextBrowser>
25 #include <QScroller>
26 #include <QPushButton>
27 #include <QDateTime>
28 #include <QThread>
29 #include <QMessageBox>
30 #include <QDesktopServices>
31 #include <QFile>
32 #include <QProcess>
33 
35 #include "core/system/version.h"
36 #include "core/system/log.h"
37 #include "core/system/serverinfo.h"
38 #include "qtconfig.h"
39 
40 
41 AboutDialog::AboutDialog(QWidget *parent, QString iconPostfix) :
42  QDialog(parent, Qt::Window)
43 {
44  EptAssert(parent, "Parent required for size");
45  setModal(true);
46 
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);
53 
54  QHBoxLayout *titleLayout = new QHBoxLayout;
55  mTitleBarLayout = titleLayout;
56  mainLayout->addLayout(titleLayout);
57 
58  titleLayout->addWidget(new QLabel(QString("<h1>%1 %2</h1>").arg(tr("Entropy Piano Tuner"), EPT_VERSION_STRING)));
59  titleLayout->addStretch();
60 
61  QLabel *webpage = new QLabel(QString::fromStdString("<a href=\"" + serverinfo::SERVER_ADDRESS + "\">" + serverinfo::SERVER_NAME + "</a> - <a href=\"mailto:.org\">Feedback</a>"));
62  QObject::connect(webpage, SIGNAL(linkActivated(QString)), this, SLOT(onOpenAboutLink(QString)));
63  mainLayout->addWidget(webpage);
64 
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);
72 
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.");
75 
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>");
79 #if defined(Q_OS_IOS)
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>");
83 #else
84  dependenciesText.append(", <a href=\"http://www.music.mcgill.ca/~gary/rtmidi\">RtMidi</a>");
85 #endif
86 
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>");
91 
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.");
93 
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";
96 
97  auto makeParagraphTags = [](const QString &t) {return "<p>" + t + "</p>";};
98  QString completeText;
99  completeText.append("<html><img src=\"" + iconPath + "\" style=\"float: left;\"/>");
100 
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));
108 
109  completeText.append("</html>");
110 
111  text->setHtml(completeText);
112 
113  QHBoxLayout *okButtonLayout = new QHBoxLayout;
114  okButtonLayout->setMargin(0);
115  mainLayout->addLayout(okButtonLayout);
116  okButtonLayout->addStretch();
117 
118  QPushButton *okButton = new QPushButton(tr("Ok"));
119  okButtonLayout->addWidget(okButton);
120 
121  QObject::connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
122 
123  QScroller::grabGesture(text);
124  text->setReadOnly(true);
125  text->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
126 
127  SHOW_DIALOG(this);
128 
129 }
130 
132  if (url.toString() == "Qt") {
133  QMessageBox::aboutQt(this);
134  } else {
135  QDesktopServices::openUrl(url);
136  }
137 }
138 
139 void AboutDialog::onOpenAboutLink(QString link) {
140  QDesktopServices::openUrl(QUrl::fromUserInput(link));
141 }
142 
void onOpenAboutUrl(QUrl url)
Slot called by the about dialog when clicked a url.
QHBoxLayout * mTitleBarLayout
Definition: aboutdialog.h:33
#define SHOW_DIALOG(d)
Definition: qtconfig.h:41
#define EPT_VERSION_STRING
Definition: version.h:28
void onOpenAboutLink(QString link)
AboutDialog(QWidget *parent, QString iconPostfix)
Definition: aboutdialog.cpp:41
#define EptAssert(a, b)
Definition: eptexception.h:47
static const std::string SERVER_NAME
Definition: serverinfo.h:30
static const std::string SERVER_ADDRESS
Definition: serverinfo.h:29