KisAboutApplication::KisAboutApplication(QWidget *parent)
    : QDialog(parent)
{
    setWindowTitle(i18n("About Krita"));

    QVBoxLayout *vlayout = new QVBoxLayout(this);
    vlayout->setMargin(0);
    QTabWidget *wdg = new QTabWidget;
    vlayout->addWidget(wdg);

    KisSplashScreen *splash = new KisSplashScreen(qApp->applicationVersion(), QPixmap(splash_screen_xpm), true);
    splash->setWindowFlags(Qt::Widget);
    splash->setFixedSize(splash->sizeHint());
    wdg->addTab(splash, i18n("About"));
    setMinimumSize(wdg->sizeHint());

    QTextEdit *lblAuthors = new QTextEdit();
    lblAuthors->setReadOnly(true);

    QString authors = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Created By</h1></p>"
                          "<p>");

    QFile fileDevelopers(":/developers.txt");
    Q_ASSERT(fileDevelopers.exists());
    fileDevelopers.open(QIODevice::ReadOnly);

    foreach(const QByteArray &author, fileDevelopers.readAll().split('\n')) {
        authors.append(QString::fromUtf8(author));
        authors.append(", ");
    }
    authors.chop(2);
    authors.append(".</p></body></html>");
    lblAuthors->setText(authors);
    wdg->addTab(lblAuthors, i18n("Authors"));

    QTextEdit *lblKickstarter = new QTextEdit();
    lblKickstarter->setReadOnly(true);

    QString backers = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Backed By</h1>"
                          "<p>");

    QFile fileBackers(":/backers.txt");
    Q_ASSERT(fileBackers.exists());
    fileBackers.open(QIODevice::ReadOnly);
    foreach(const QByteArray &backer, fileBackers.readAll().split('\n')) {
        backers.append(QString::fromUtf8(backer));
        backers.append(", ");
    }
    backers.chop(2);
    backers.append(i18n(".</p><p><i>Thanks! You were all <b>awesome</b>!</i></p></body></html>"));
    lblKickstarter->setText(backers);
    wdg->addTab(lblKickstarter, i18n("Backers"));



    QTextEdit *lblCredits = new QTextEdit();
    lblCredits->setReadOnly(true);
    QString credits = i18n("<html>"
                          "<head/>"
                          "<body>"
                          "<h1 align=\"center\">Thanks To</h1>"
                          "<p>");

    QFile fileCredits(":/credits.txt");
    Q_ASSERT(fileCredits.exists());
    fileCredits.open(QIODevice::ReadOnly);

    foreach(const QByteArray &credit, fileCredits.readAll().split('\n')) {
        if (!credit.isEmpty()) {
            QList<QByteArray> creditSplit = credit.split(':');
            Q_ASSERT(creditSplit.size() == 2);
            credits.append(QString::fromUtf8(creditSplit.at(0)));
            credits.append(" (<i>" + QString::fromUtf8(creditSplit.at(1)) + "</i>)");
            credits.append(", ");
        }
    }
    credits.chop(2);
    credits.append(i18n(".</p><p><i>For supporting Krita development with advice, icons, brush sets and more.</i></p></body></html>"));

    lblCredits->setText(credits);
    wdg->addTab(lblCredits, i18n("Also Thanks To"));

    QTextEdit *lblLicense = new QTextEdit();
    lblLicense->setReadOnly(true);
    QString license = i18n("<html>"
                           "<head/>"
                           "<body>"
                           "<h1 align=\"center\"><b>Your Rights</h1>"
                           "<p>Krita is released under the GNU General Public License (version 2 or any later version).</p>"
                           "<p>This license grants people a number of freedoms:</p>"
                           "<ul>"
                           "<li>You are free to use Krita, for any purpose</li>"
                           "<li>You are free to distribute Krita</li>"
                           "<li>You can study how Krita works and change it</li>"
                           "<li>You can distribute changed versions of Krita</li>"
                           "</ul>"
                           "<p>The Krita Foundation and its projects on krita.org are <b>committed</b> to preserving Krita as free software.</p>"
                           "<h1 align=\"center\">Your artwork</h1>"
                           "<p>What you create with Krita is your sole property. All your artwork is free for you to use as you like.</p>"
                           "<p>That means that Krita can be used commercially, for any purpose. There are no restrictions whatsoever.</p>"
                           "<p>Krita’s GNU GPL license guarantees you this freedom. Nobody is ever permitted to take it away, in contrast "
                           "to trial or educational versions of commercial software that will forbid your work in commercial situations.</p>"
                           "<br/><hr/><pre>");

    QFile licenseFile(":/LICENSE");
    Q_ASSERT(licenseFile.exists());
    licenseFile.open(QIODevice::ReadOnly);
    QByteArray ba = licenseFile.readAll();
    license.append(QString::fromUtf8(ba));
    license.append("</pre></body></html>");
    lblLicense->setText(license);

    wdg->addTab(lblLicense, i18n("License"));

    QPushButton *bnClose = new QPushButton(i18n("Close"));
    connect(bnClose, SIGNAL(clicked()), SLOT(close()));

    QHBoxLayout *hlayout = new QHBoxLayout;
    hlayout->setMargin(0);
    hlayout->addStretch(10);
    hlayout->addWidget(bnClose);

    vlayout->addLayout(hlayout);
}