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> 45 class KAboutApplicationDialog::Private
53 void init(
const KAboutData *aboutData, Options opt );
55 void _k_showLicense(
const QString &number );
73 d->init( aboutData, opt );
76 void KAboutApplicationDialog::Private::init(
const KAboutData *ad, Options opt )
85 "The supplied KAboutData object does not exist.</qt>"), q);
87 errorLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
88 q->setMainWidget(errorLabel);
92 q->setPlainCaption(
i18n(
"About %1", aboutData->programName()));
101 if (!aboutData->programIconName().isEmpty()) {
102 windowIcon =
KIcon(aboutData->programIconName());
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>",
114 aboutData->programName(), aboutData->version()));
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>",
118 aboutData->programName(), aboutData->version(), QString(KDE_VERSION_STRING)));
122 tabWidget->setUsesScrollButtons(
false);
125 QString aboutPageText = aboutData->shortDescription() +
'\n';
127 if (!aboutData->otherText().isEmpty())
128 aboutPageText +=
'\n' + aboutData->otherText() +
'\n';
130 if (!aboutData->copyrightStatement().isEmpty())
131 aboutPageText +=
'\n' + aboutData->copyrightStatement() +
'\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 );
180 if (!aboutData->customAuthorTextEnabled() || !aboutData->customAuthorRichText().isEmpty()) {
182 bugsLabel->setContentsMargins( 4, 2, 0, 4 );
183 bugsLabel->setOpenExternalLinks(
true );
184 if (!aboutData->customAuthorTextEnabled()) {
185 if (aboutData->bugAddress().isEmpty() || aboutData->bugAddress() ==
"submit@bugs.kde.org")
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 ) &&
189 ( aboutData->authors().first().emailAddress() == aboutData->bugAddress() ) ) {
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",
196 aboutData->bugAddress(), aboutData->bugAddress()));
201 bugsLabel->setText( aboutData->customAuthorRichText() );
202 bugsLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
203 authorLayout->addWidget( bugsLabel );
206 KDEPrivate::KAboutApplicationPersonModel *authorModel =
207 new KDEPrivate::KAboutApplicationPersonModel( aboutData->authors(),
208 aboutData->ocsProviderUrl(),
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(),
235 aboutData->ocsProviderUrl(),
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(),
262 aboutData->ocsProviderUrl(),
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);
299 mainWidget->setLayout(mainLayout);
301 q->setMainWidget(mainWidget);
309 qDeleteAll(findChildren<KWidgetItemDelegate*>());
312 void 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"
static int marginHint()
Returns the number of pixels that should be used between a dialog edge and the outermost widget(s) ac...
QString i18n(const char *text)
const KAboutData * aboutData() const
void setInitialSize(const QSize &size)
Convenience method.
KDialog(QWidget *parent=0, Qt::WindowFlags flags=0)
Creates a dialog.
Standard "About Application" dialog box.
A dialog base class with standard buttons and predefined layouts.
virtual void setCaption(const QString &caption)
Make a KDE compliant caption.
QString i18nc(const char *ctxt, const char *text)
void setMainWidget(QWidget *widget)
Sets the main widget of the dialog.
Show Close-button. (this button closes the dialog)
No options, show the standard about dialog.
A wrapper around QIcon that provides KDE icon features.
void setButtons(ButtonCodes buttonMask)
Creates (or recreates) the button box and all the buttons in it.
Don't show the KDE version next to the application name and version.
void setDefaultButton(ButtonCode id)
Sets the button that will be activated when the Enter key is pressed.
virtual ~KAboutApplicationDialog()
virtual QSize sizeHint() const
Reimplemented from QDialog.
Don't show the translators tab.
KAboutApplicationDialog(const KAboutData *aboutData, Options opts, QWidget *parent=0)
Constructor.
static QString aboutTranslationTeam()
QString name(KAboutData::NameFormat formatName) const
const KComponentData & mainComponent()
static QFont fixedFont()
Returns the default fixed font.