00001 #include "aboutdialog.h"
00002 #include <QLabel>
00003 #include <QFile>
00004 #include <QTextStream>
00005 #include <QScrollBar>
00006 #include <QDialogButtonBox>
00007 #include <QStyle>
00008
00009 AboutDialog::AboutDialog(AboutData *data, QWidget *parent) : QDialog(parent)
00010 {
00011 setupUi(this);
00012 setAttribute(Qt::WA_DeleteOnClose);
00013
00014 aboutData = data;
00015 titleWidget->setPixmap(":/allevo/Allevo", ATitleWidget::ImageLeft);
00016
00017 QString text = "<html><font size=\"5\">";
00018 text += "Allevo II";
00019 text += "</font><br /><b>Version: ";
00020 text += QCoreApplication::applicationVersion();
00021 text += "</b><br /></html>";
00022 titleWidget->setText(text);
00023
00024 setupTabs();
00025 connect(buttonClose, SIGNAL(clicked()), this, SLOT(close()));
00026 }
00027
00028 void AboutDialog::setupTabs()
00029 {
00030 QString aboutPageText = aboutData->shortDescription() + '\n';
00031
00032 if(!aboutData->otherText().isEmpty())
00033 {
00034 aboutPageText += '\n' + aboutData->otherText() + '\n';
00035 }
00036
00037 if(!aboutData->copyrightStatement().isEmpty())
00038 {
00039 aboutPageText += '\n' + aboutData->copyrightStatement() + '\n';
00040 }
00041
00042 if(!aboutData->homepage().isEmpty())
00043 {
00044 aboutPageText += '\n' + QString("<a href=\"%1\">%1</a>").arg(aboutData->homepage()) + '\n';
00045 }
00046 aboutPageText = aboutPageText.trimmed();
00047
00048 QLabel *aboutLabel = new QLabel;
00049 aboutLabel->setWordWrap(true);
00050 aboutLabel->setOpenExternalLinks(true);
00051 aboutLabel->setText(aboutPageText.replace('\n', "<br />"));
00052 aboutLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
00053
00054 QVBoxLayout *aboutLayout = new QVBoxLayout;
00055 aboutLayout->addStretch();
00056 aboutLayout->addWidget(aboutLabel);
00057
00058 QLabel *showLicenseLabel = new QLabel;
00059
00060 QString licenseInfo = "<a href=\"";
00061 licenseInfo += "GPL_V2";
00062 licenseInfo += "\">";
00063 licenseInfo += "Lizenz: ";
00064 licenseInfo += "GNU General Public License Version 2";
00065 licenseInfo += "</a>";
00066
00067 showLicenseLabel->setText(licenseInfo);
00068 showLicenseLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
00069 connect(showLicenseLabel, SIGNAL(linkActivated(QString)), this, SLOT(showLicense(const QString&)));
00070
00071 aboutLayout->addWidget(showLicenseLabel);
00072
00073 aboutLayout->addStretch();
00074
00075 QWidget *aboutWidget = new QWidget(this);
00076 aboutWidget->setLayout(aboutLayout);
00077
00078 tabWidget->insertTab(0, aboutWidget, tr("Ü&ber"));
00079
00080 QPalette transparentBacktroundPalette;
00081 transparentBacktroundPalette.setColor(QPalette::Base, Qt::transparent);
00082 transparentBacktroundPalette.setColor(QPalette::Text, transparentBacktroundPalette.color(QPalette::WindowText));
00083
00084 const int authorCount = aboutData->authors().count();
00085 if(authorCount)
00086 {
00087 QString authorPageText;
00088 QString authorPageTitle = authorCount == 1 ? tr("&Mitwirkender") : tr("&Mitwirkende");
00089
00090 if(!aboutData->customAuthorTextEnabled() || !aboutData->customAuthorRichText().isEmpty())
00091 {
00092 if(!aboutData->customAuthorTextEnabled())
00093 {
00094 if(aboutData->bugAddress().isEmpty() || aboutData->bugAddress() == "allevo.bugs@gmx.at")
00095 {
00096 authorPageText = tr("Bitte benützen Sie <a href=\"mailto:allevo.bugs@gmx.at\">allevo.bugs@gmx.at</a>, oder den eingebauten Fehler Meldungsdialog zum Berichten von Fehlern.\n");
00097 }
00098 else
00099 {
00100 if(aboutData->authors().count() == 1 &&(aboutData->authors().first().emailAddress() == aboutData->bugAddress()))
00101 {
00102 authorPageText = "Please report bugs to <a href=\"mailto:";
00103 authorPageText += aboutData->authors().first().emailAddress();
00104 authorPageText += "\">";
00105 authorPageText += aboutData->authors().first().emailAddress();
00106 authorPageText += "</a>.\n";
00107 }
00108 else
00109 {
00110 authorPageText = "Bitte melden Sie Fehler hier oder im eingebauten Dialog: <a href=\"mailto:" + aboutData->bugAddress() + "\">" + aboutData->bugAddress() + "</a>.\n";
00111 }
00112 }
00113 }
00114 else
00115 authorPageText = aboutData->customAuthorRichText();
00116 }
00117
00118 authorPageText += "<br />";
00119
00120 const QList<AboutPerson> lst = aboutData->authors();
00121 for(int i = 0; i < lst.size(); ++i)
00122 {
00123 authorPageText += QString("<p style=\"margin: 0px;\">%1</p>").arg(lst.at(i).name());
00124 if(!lst.at(i).emailAddress().isEmpty())
00125 {
00126 authorPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"mailto:%1\">%1</a></p>").arg(lst.at(i).emailAddress());
00127 }
00128 if(!lst.at(i).webAddress().isEmpty())
00129 {
00130 authorPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"%3\">%3</a></p>").arg(lst.at(i).webAddress());
00131 }
00132 if(!lst.at(i).task().isEmpty())
00133 {
00134 authorPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\">%4</p>").arg(lst.at(i).task());
00135 }
00136 if(i < lst.size() - 1)
00137 {
00138 authorPageText += "<p style=\"margin: 0px;\"> </p>";
00139 }
00140 }
00141
00142 textAuthors->setFrameStyle(QFrame::NoFrame);
00143 textAuthors->setPalette(transparentBacktroundPalette);
00144 textAuthors->setHtml(authorPageText);
00145 }
00146
00147 const int creditsCount = aboutData->credits().count();
00148 if(creditsCount)
00149 {
00150 QString creditsPageText;
00151
00152 const QList<AboutPerson> lst = aboutData->credits();
00153 for(int i = 0; i < lst.size(); ++i)
00154 {
00155 creditsPageText += QString("<p style=\"margin: 0px;\">%1</p>").arg(lst.at(i).name());
00156 if(!lst.at(i).emailAddress().isEmpty())
00157 {
00158 creditsPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"mailto:%1\">%1</a></p>").arg(lst.at(i).emailAddress());
00159 }
00160 if(!lst.at(i).webAddress().isEmpty())
00161 {
00162 creditsPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"%3\">%3</a></p>").arg(lst.at(i).webAddress());
00163 }
00164 if(!lst.at(i).task().isEmpty())
00165 {
00166 creditsPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\">%4</p>").arg(lst.at(i).task());
00167 }
00168 if(i < lst.size() - 1)
00169 {
00170 creditsPageText += "<p style=\"margin: 0px;\"> </p>";
00171 }
00172 }
00173
00174 textThanksTo->setFrameStyle(QFrame::NoFrame);
00175 textThanksTo->setPalette(transparentBacktroundPalette);
00176 textThanksTo->setHtml(creditsPageText);
00177 }
00178
00179 tabWidget->setCurrentIndex(0);
00180 }
00181
00182 void AboutDialog::showLicense(const QString &shortName)
00183 {
00184 QDialog *dialog = new QDialog(this);
00185 dialog->setMinimumSize(500,500);
00186 dialog->setWindowModality(Qt::ApplicationModal);
00187 QVBoxLayout *vbox = new QVBoxLayout();
00188 dialog->setWindowTitle(tr("Lizenz Abkommen"));
00189
00190 const QFont font = QFont();
00191 QFontMetrics metrics(font);
00192
00193 QString licenseText = "";
00194 QFile file(":/about/GPL_V2");
00195 if(file.open(QIODevice::ReadOnly))
00196 {
00197 QTextStream str(&file);
00198 licenseText += str.readAll();
00199 }
00200
00201 QTextBrowser *licenseBrowser = new QTextBrowser;
00202 licenseBrowser->setFont(font);
00203 licenseBrowser->setLineWrapMode(QTextEdit::WidgetWidth);
00204 licenseBrowser->setText(licenseText);
00205
00206 QPushButton *button = new QPushButton("Schließen", this);
00207 connect(button, SIGNAL(clicked()), dialog, SLOT(close()));
00208
00209 vbox->addWidget(licenseBrowser);
00210 vbox->addWidget(button);
00211 dialog->setLayout(vbox);
00212
00213
00214
00215 int marginHint = QApplication::style()->pixelMetric(QStyle::PM_DefaultChildMargin);
00216 const qreal idealWidth = licenseBrowser->document()->idealWidth() + (2 * marginHint) + licenseBrowser->verticalScrollBar()->width() * 2;
00217
00218
00219 const int idealHeight = metrics.height() * 30;
00220
00221 dialog->setMinimumSize(dialog->sizeHint().expandedTo(QSize((int)idealWidth, idealHeight)));
00222 dialog->show();
00223 }