diff -r 94f10f69fe76 -r bf0ec13a21ea QTfrontend/ui/widget/about.cpp
--- a/QTfrontend/ui/widget/about.cpp Thu Dec 13 10:51:07 2018 -0500
+++ b/QTfrontend/ui/widget/about.cpp Thu Dec 13 17:28:53 2018 +0100
@@ -53,6 +53,143 @@
#include "about.h"
+QString About::getCreditsHtml()
+{
+ // Open the credits file
+
+ /* *** FILE FORMAT OF CREDITS FILE ***
+ The credits file is an RFC-4180-compliant CSV file with 3 columns:
+ * Task/contribution
+ * Contributor name
+ * Contributor e-mail
+
+ The first and last columns are optional.
+
+ There are special rows, which are marked by putting a "!__" in the
+ beginning of the first. The following special rows are supported:
+
+ !__SECTION: Section. Column 1 is the section name
+ !__SUBSECTION: Subsection. Column 1 is the subsection name
+ !__MISC: Placeholder for other or unknown authors
+ */
+ QFile creditsFile(":/res/credits.csv");
+ if (!creditsFile.open(QIODevice::ReadOnly))
+ {
+ qWarning("ERROR: Credits file could not be opened!");
+ return "
ERROR: Credits file could not be opened!
";
+ }
+ QString creditsString = creditsFile.readAll();
+ QString out = QString("" + tr("Credits") + "
\n");
+ QStringList cells = QStringList() << QString("") << QString("") << QString("");
+ bool firstSection = true;
+ unsigned long int column = 0;
+ unsigned long int charInCell = 0;
+ bool isInQuote = false;
+ bool ignoreChar = false;
+ bool lineComplete = false;
+ QChar currChar;
+ QChar prevChar;
+ for(long long int i = 0; i 0 && prevChar == '"' && (currChar == '\r' || currChar == ','))
+ {
+ isInQuote = false;
+ ignoreChar = true;
+ }
+
+ charInCell++;
+ if(!isInQuote && currChar == ',')
+ {
+ column++;
+ charInCell = 0;
+ }
+ else if(!isInQuote && currChar == '\n' && prevChar == '\r')
+ {
+ lineComplete = true;
+ }
+ if(!isInQuote && (currChar == '\r' || currChar == '\n' || currChar == ','))
+ {
+ ignoreChar = true;
+ }
+
+
+ if(!ignoreChar)
+ {
+ cells[column].append(currChar);
+ }
+ ignoreChar = false;
+
+ if(lineComplete)
+ {
+ task = cells[0];
+ name = cells[1];
+ mail = cells[2];
+
+ if(task == "!__SECTION")
+ {
+ if (!firstSection)
+ out = out + "\n";
+ out = out + "" + name + "
\n\n";
+ firstSection = false;
+ }
+ else if(task == "!__SUBSECTION")
+ {
+ out = out + "
\n";
+ out = out + "" + name + "
\n\n";
+ }
+ else if(task == "!__MISC")
+ {
+ out = out + "- " + tr("Other people") + "
" + "\n";
+ }
+ else
+ {
+ QString mailLink = QString("%1").arg(mail);
+ if(task.isEmpty() && mail.isEmpty())
+ {
+ out = out + "- " + name + "
\n";
+ }
+ else if(task.isEmpty())
+ {
+ out = out + "- " + tr("%1 <%2>").arg(name).arg(mailLink) + "
\n";
+ }
+ else if(mail.isEmpty())
+ {
+ out = out + "- " + tr("%1: %2").arg(task).arg(name) + "
\n";
+ }
+ else
+ {
+ out = out + "- " + tr("%1: %2 <%3>").arg(task).arg(name).arg(mailLink) + "
\n";
+ }
+ }
+ lineComplete = false;
+ column = 0;
+ cells[0] = "";
+ cells[1] = "";
+ cells[2] = "";
+ charInCell = 0;
+ }
+
+ prevChar = currChar;
+ }
+ creditsFile.close();
+ out = out + "
";
+ return out;
+}
+
About::About(QWidget * parent) :
QWidget(parent)
{
@@ -89,11 +226,32 @@
lbl1->setWordWrap(true);
mainLayout->addWidget(lbl1, 0, 1);
- lbl2 = new QTextBrowser(this);
- lbl2->setOpenExternalLinks(true);
- QUrl localpage = QUrl::fromLocalFile(":/res/html/about.html");
- lbl2->setSource(localpage); //sets the source of the label from the file above
- mainLayout->addWidget(lbl2, 1, 1);
+ /* Credits */
+ creditsBrowser = new QTextBrowser(this);
+ creditsBrowser->setOpenExternalLinks(true);
+ QString credits = getCreditsHtml();
+
+ QString header =
+ ""
+ ""
+ ""
+ "Hedgewars Credits"
+ ""
+ ""
+ ""
+ ""
+ "";
+ QString footer =
+ ""
+ "";
+
+ creditsBrowser->setHtml(header + credits + footer);
+ mainLayout->addWidget(creditsBrowser, 1, 1);
/* Library information */