26#include "kaboutapplicationpersonmodel_p.h"
27#include "kaboutapplicationpersonlistview_p.h"
28#include "kaboutapplicationpersonlistdelegate_p.h"
39#include <QtGui/QLabel>
40#include <QtGui/QLayout>
41#include <QtGui/QPushButton>
42#include <QtGui/QScrollBar>
43#include <QtGui/QTabWidget>
45class KAboutApplicationDialog::Private
53 void init(
const KAboutData *aboutData, Options opt );
55 void _k_showLicense(
const QString &number );
73 d->init( aboutData, opt );
76void KAboutApplicationDialog::Private::init(
const KAboutData *ad, Options opt )
85 "The supplied KAboutData object does not exist.</qt>"), q);
87 errorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
104 windowIcon = qApp->windowIcon();
107 if (aboutData->
programLogo().canConvert<QPixmap>())
109 else if (aboutData->
programLogo().canConvert<QImage>())
113 titleWidget->
setText(
i18n(
"<html><font size=\"5\">%1</font><br /><b>Version %2</b><br /> </html>",
116 titleWidget->
setText(
i18nc(
"Program name, version and KDE platform version; do not translate 'Development Platform'",
117 "<html><font size=\"5\">%1</font><br /><b>Version %2</b><br />Using KDE Development Platform %3</html>",
122 tabWidget->setUsesScrollButtons(
false);
128 aboutPageText +=
'\n' + aboutData->
otherText() +
'\n';
133 if (!aboutData->
homepage().isEmpty())
134 aboutPageText +=
'\n' + QString(
"<a href=\"%1\">%1</a>").arg(aboutData->
homepage()) +
'\n';
135 aboutPageText = aboutPageText.trimmed();
138 aboutLabel->setWordWrap(
true);
139 aboutLabel->setOpenExternalLinks(
true);
140 aboutLabel->setText(aboutPageText.replace(
'\n',
"<br />"));
141 aboutLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
143 QVBoxLayout *aboutLayout =
new QVBoxLayout;
144 aboutLayout->addStretch();
145 aboutLayout->addWidget(aboutLabel);
147 const int licenseCount = aboutData->
licenses().count();
148 for (
int i = 0; i < licenseCount; ++i) {
152 showLicenseLabel->setText(QString(
"<a href=\"%1\">%2</a>").arg(QString::number(i),
155 showLicenseLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
156 connect(showLicenseLabel, SIGNAL(linkActivated(QString)), q, SLOT(_k_showLicense(QString)));
158 aboutLayout->addWidget(showLicenseLabel);
161 aboutLayout->addStretch();
164 aboutWidget->setLayout(aboutLayout);
166 tabWidget->addTab(aboutWidget,
i18n(
"&About"));
169 QPalette transparentBackgroundPalette;
170 transparentBackgroundPalette.setColor(QPalette::Base, Qt::transparent);
171 transparentBackgroundPalette.setColor(QPalette::Text, transparentBackgroundPalette.color(QPalette::WindowText));
174 const int authorCount = aboutData->
authors().count();
177 QVBoxLayout *authorLayout =
new QVBoxLayout( authorWidget );
178 authorLayout->setMargin( 0 );
182 bugsLabel->setContentsMargins( 4, 2, 0, 4 );
183 bugsLabel->setOpenExternalLinks(
true );
186 bugsLabel->setText(
i18n(
"Please use <a href=\"http://bugs.kde.org\">http://bugs.kde.org</a> to report bugs.\n") );
188 if( ( aboutData->
authors().count() == 1 ) &&
190 bugsLabel->setText(
i18n(
"Please report bugs to <a href=\"mailto:%1\">%2</a>.\n",
191 aboutData->
authors().first().emailAddress(),
192 aboutData->
authors().first().emailAddress() ) );
195 bugsLabel->setText(
i18n(
"Please report bugs to <a href=\"mailto:%1\">%2</a>.\n",
202 bugsLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
203 authorLayout->addWidget( bugsLabel );
206 KDEPrivate::KAboutApplicationPersonModel *authorModel =
207 new KDEPrivate::KAboutApplicationPersonModel( aboutData->
authors(),
211 KDEPrivate::KAboutApplicationPersonListView *authorView =
212 new KDEPrivate::KAboutApplicationPersonListView( authorWidget );
214 KDEPrivate::KAboutApplicationPersonListDelegate *authorDelegate =
215 new KDEPrivate::KAboutApplicationPersonListDelegate( authorView, authorView );
217 authorView->setModel( authorModel );
218 authorView->setItemDelegate( authorDelegate );
219 authorView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
220 authorLayout->addWidget( authorView );
222 QString authorPageTitle = QString( ( authorCount == 1 ) ?
i18n(
"A&uthor") :
i18n(
"A&uthors") );
223 tabWidget->addTab( authorWidget, authorPageTitle );
227 const int creditsCount = aboutData->
credits().count();
230 QVBoxLayout *creditLayout =
new QVBoxLayout( creditWidget );
231 creditLayout->setMargin( 0 );
233 KDEPrivate::KAboutApplicationPersonModel *creditModel =
234 new KDEPrivate::KAboutApplicationPersonModel( aboutData->
credits(),
238 KDEPrivate::KAboutApplicationPersonListView *creditView =
239 new KDEPrivate::KAboutApplicationPersonListView( creditWidget );
241 KDEPrivate::KAboutApplicationPersonListDelegate *creditDelegate =
242 new KDEPrivate::KAboutApplicationPersonListDelegate( creditView, creditView );
244 creditView->setModel( creditModel );
245 creditView->setItemDelegate( creditDelegate );
246 creditView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
247 creditLayout->addWidget( creditView );
249 tabWidget->addTab( creditWidget,
i18n(
"&Thanks To"));
254 const int translatorsCount = aboutData->
translators().count();
255 if( translatorsCount ) {
257 QVBoxLayout *translatorLayout =
new QVBoxLayout( translatorWidget );
258 translatorLayout->setMargin( 0 );
260 KDEPrivate::KAboutApplicationPersonModel *translatorModel =
261 new KDEPrivate::KAboutApplicationPersonModel( aboutData->
translators(),
265 KDEPrivate::KAboutApplicationPersonListView *translatorView =
266 new KDEPrivate::KAboutApplicationPersonListView( translatorWidget );
268 KDEPrivate::KAboutApplicationPersonListDelegate *translatorDelegate =
269 new KDEPrivate::KAboutApplicationPersonListDelegate( translatorView, translatorView );
271 translatorView->setModel( translatorModel );
272 translatorView->setItemDelegate( translatorDelegate );
273 translatorView->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
274 translatorLayout->addWidget( translatorView );
277 if( !aboutTranslationTeam.isEmpty() ) {
278 QLabel *translationTeamLabel =
new QLabel( translatorWidget );
279 translationTeamLabel->setContentsMargins( 4, 2, 4, 4 );
280 translationTeamLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
281 translationTeamLabel->setWordWrap(
true );
282 translationTeamLabel->setText( aboutTranslationTeam );
283 translationTeamLabel->setOpenExternalLinks(
true );
284 translatorLayout->addWidget( translationTeamLabel );
288 tabWidget->addTab( translatorWidget,
i18n(
"T&ranslation"));
293 QVBoxLayout *mainLayout =
new QVBoxLayout;
294 mainLayout->addWidget(titleWidget);
295 mainLayout->addWidget(tabWidget);
296 mainLayout->setMargin(0);
309 qDeleteAll(findChildren<KWidgetItemDelegate*>());
312void KAboutApplicationDialog::Private::_k_showLicense(
const QString &number )
315 dialog->setAttribute( Qt::WA_DeleteOnClose );
322 QFontMetrics metrics(font);
324 const QString licenseText = aboutData->licenses().at(number.toInt()).text();
326 licenseBrowser->setFont(font);
327 licenseBrowser->setLineWrapMode(QTextEdit::NoWrap);
328 licenseBrowser->setText(licenseText);
334 const qreal idealWidth = licenseBrowser->document()->idealWidth() + (2 * dialog->
marginHint())
335 + licenseBrowser->verticalScrollBar()->width() * 2;
338 const int idealHeight = metrics.height() * 30;
344#include "kaboutapplicationdialog.moc"
Standard "About Application" dialog box.
@ HideTranslators
Don't show the translators tab.
@ NoOptions
No options, show the standard about dialog.
@ HideKdeVersion
Don't show the KDE version next to the application name and version.
KAboutApplicationDialog(const KAboutData *aboutData, Options opts, QWidget *parent=0)
Constructor.
virtual ~KAboutApplicationDialog()
QVariant programLogo() const
QString ocsProviderUrl() const
static QString aboutTranslationTeam()
QString customAuthorRichText() const
QList< KAboutPerson > credits() const
QString programName() const
QString programIconName() const
bool customAuthorTextEnabled() const
QList< KAboutPerson > authors() const
QString shortDescription() const
QString copyrightStatement() const
QList< KAboutPerson > translators() const
QString bugAddress() const
QString otherText() const
QList< KAboutLicense > licenses() const
QString name(KAboutData::NameFormat formatName) const
const KAboutData * aboutData() const
A dialog base class with standard buttons and predefined layouts.
static int marginHint()
Returns the number of pixels that should be used between a dialog edge and the outermost widget(s) ac...
void setMainWidget(QWidget *widget)
Sets the main widget of the dialog.
void setInitialSize(const QSize &size)
Convenience method.
virtual void setPlainCaption(const QString &caption)
Make a plain caption without any modifications.
virtual QSize sizeHint() const
Reimplemented from QDialog.
void setButtons(ButtonCodes buttonMask)
Creates (or recreates) the button box and all the buttons in it.
@ Close
Show Close-button. (this button closes the dialog)
void setDefaultButton(ButtonCode id)
Sets the button that will be activated when the Enter key is pressed.
virtual void setCaption(const QString &caption)
Make a KDE compliant caption.
static QFont fixedFont()
Returns the default fixed font.
A wrapper around QIcon that provides KDE icon features.
QString i18n(const char *text)
QString i18nc(const char *ctxt, const char *text)
const KComponentData & mainComponent()