Changeset View
Changeset View
Standalone View
Standalone View
src/aboutdialog/ExtendedAboutDialog.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include "ExtendedAboutDialog.h" | 22 | #include "ExtendedAboutDialog.h" | ||
23 | 23 | | |||
24 | #include "core/support/Amarok.h" | 24 | #include "core/support/Amarok.h" | ||
25 | #include "core/support/Debug.h" | 25 | #include "core/support/Debug.h" | ||
26 | #include "OcsPersonItem.h" | 26 | #include "OcsPersonItem.h" | ||
27 | #include "libattica-ocsclient/providerinitjob.h" | 27 | #include "libattica-ocsclient/providerinitjob.h" | ||
28 | 28 | | |||
29 | #include <QApplication> | ||||
30 | #include <QDialogButtonBox> | ||||
31 | #include <QFontDatabase> | ||||
29 | #include <QLabel> | 32 | #include <QLabel> | ||
30 | #include <QLayout> | 33 | #include <QLayout> | ||
34 | #include <QNetworkConfigurationManager> | ||||
31 | #include <QPushButton> | 35 | #include <QPushButton> | ||
32 | #include <QScrollBar> | 36 | #include <QScrollBar> | ||
37 | #include <QStandardPaths> | ||||
33 | #include <QTabWidget> | 38 | #include <QTabWidget> | ||
39 | #include <QTextBrowser> | ||||
40 | #include <QVBoxLayout> | ||||
34 | 41 | | |||
35 | #include <qapplication.h> | | |||
36 | #include <KCoreAddons> | | |||
37 | #include <kglobal.h> | | |||
38 | #include <kglobalsettings.h> | | |||
39 | #include <kiconloader.h> | | |||
40 | #include <klocale.h> | | |||
41 | #include <kmessagebox.h> | | |||
42 | #include <kstandarddirs.h> | | |||
43 | #include <ktextbrowser.h> | | |||
44 | #include <ktitlewidget.h> | | |||
45 | #include <solid/networking.h> | | |||
46 | #include <KConfigGroup> | 42 | #include <KConfigGroup> | ||
47 | #include <QDialogButtonBox> | 43 | #include <KCoreAddons> | ||
48 | #include <QVBoxLayout> | 44 | #include <KIconLoader> | ||
45 | #include <KMessageBox> | ||||
46 | #include <KTitleWidget> | ||||
49 | 47 | | |||
50 | void ExtendedAboutDialog::Private::_k_showLicense( const QString &number ) | 48 | void ExtendedAboutDialog::Private::_k_showLicense( const QString &number ) | ||
51 | { | 49 | { | ||
52 | QDialog *dialog = new QDialog(q); | 50 | QDialog *dialog = new QDialog(q); | ||
53 | QWidget *mainWidget = new QWidget; | 51 | QWidget *mainWidget = new QWidget; | ||
54 | 52 | | |||
55 | dialog->setWindowTitle(i18n("License Agreement")); | 53 | dialog->setWindowTitle(i18n("License Agreement")); | ||
56 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); | 54 | QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); | ||
57 | dialog->connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); | 55 | dialog->connect(buttonBox, &QDialogButtonBox::accepted, dialog, &QDialog::accept); | ||
58 | dialog->connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); | 56 | dialog->connect(buttonBox, &QDialogButtonBox::rejected, dialog, &QDialog::reject); | ||
59 | buttonBox->button(QDialogButtonBox::Close)->setDefault(true); | 57 | buttonBox->button(QDialogButtonBox::Close)->setDefault(true); | ||
60 | 58 | | |||
61 | const QFont font = KGlobalSettings::fixedFont(); | 59 | const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont); | ||
62 | QFontMetrics metrics(font); | 60 | QFontMetrics metrics(font); | ||
63 | 61 | | |||
64 | const QString licenseText = aboutData->licenses().at(number.toInt()).text(); | 62 | const QString licenseText = aboutData->licenses().at(number.toInt()).text(); | ||
65 | KTextBrowser *licenseBrowser = new KTextBrowser; | 63 | QTextBrowser *licenseBrowser = new QTextBrowser; | ||
66 | licenseBrowser->setFont(font); | 64 | licenseBrowser->setFont(font); | ||
67 | licenseBrowser->setLineWrapMode(QTextEdit::NoWrap); | 65 | licenseBrowser->setLineWrapMode(QTextEdit::NoWrap); | ||
68 | licenseBrowser->setText(licenseText); | 66 | licenseBrowser->setText(licenseText); | ||
69 | 67 | | |||
70 | QVBoxLayout *mainLayout = new QVBoxLayout; | 68 | QVBoxLayout *mainLayout = new QVBoxLayout; | ||
71 | dialog->setLayout(mainLayout); | 69 | dialog->setLayout(mainLayout); | ||
72 | mainLayout->addWidget(licenseBrowser); | 70 | mainLayout->addWidget(licenseBrowser); | ||
73 | mainLayout->addWidget(mainWidget); | 71 | mainLayout->addWidget(mainWidget); | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 91 | { | |||
146 | if (aboutData->programLogo().canConvert<QPixmap>()) | 144 | if (aboutData->programLogo().canConvert<QPixmap>()) | ||
147 | titleWidget->setPixmap(aboutData->programLogo().value<QPixmap>(), KTitleWidget::ImageLeft); | 145 | titleWidget->setPixmap(aboutData->programLogo().value<QPixmap>(), KTitleWidget::ImageLeft); | ||
148 | else if (aboutData->programLogo().canConvert<QImage>()) | 146 | else if (aboutData->programLogo().canConvert<QImage>()) | ||
149 | titleWidget->setPixmap(QPixmap::fromImage(aboutData->programLogo().value<QImage>()), KTitleWidget::ImageLeft); | 147 | titleWidget->setPixmap(QPixmap::fromImage(aboutData->programLogo().value<QImage>()), KTitleWidget::ImageLeft); | ||
150 | 148 | | |||
151 | titleWidget->setText(i18n("<html><font size=\"5\">%1</font><br /><b>Version %2</b><br />Using KDE Frameworks %3</html>", | 149 | titleWidget->setText(i18n("<html><font size=\"5\">%1</font><br /><b>Version %2</b><br />Using KDE Frameworks %3</html>", | ||
152 | aboutData->displayName(), aboutData->version(), KCoreAddons::versionString())); | 150 | aboutData->displayName(), aboutData->version(), KCoreAddons::versionString())); | ||
153 | 151 | | |||
154 | | ||||
155 | //Now let's add the tab bar... | 152 | //Now let's add the tab bar... | ||
156 | QTabWidget *tabWidget = new QTabWidget; | 153 | QTabWidget *tabWidget = new QTabWidget; | ||
157 | tabWidget->setUsesScrollButtons(false); | 154 | tabWidget->setUsesScrollButtons(false); | ||
158 | 155 | | |||
159 | 156 | | |||
160 | //Set up the first page... | 157 | //Set up the first page... | ||
161 | QString aboutPageText = aboutData->shortDescription() + '\n'; | 158 | QString aboutPageText = aboutData->shortDescription() + '\n'; | ||
162 | 159 | | |||
Show All 38 Lines | |||||
201 | 198 | | |||
202 | QWidget *aboutWidget = new QWidget(this); | 199 | QWidget *aboutWidget = new QWidget(this); | ||
203 | aboutWidget->setLayout(aboutLayout); | 200 | aboutWidget->setLayout(aboutLayout); | ||
204 | 201 | | |||
205 | tabWidget->addTab(aboutWidget, i18n("&About")); | 202 | tabWidget->addTab(aboutWidget, i18n("&About")); | ||
206 | 203 | | |||
207 | 204 | | |||
208 | //Stuff needed by both Authors and Credits pages: | 205 | //Stuff needed by both Authors and Credits pages: | ||
209 | QPixmap openDesktopPixmap = QPixmap( KStandardDirs::locate( "data", "amarok/images/opendesktop-22.png" ) ); | 206 | QPixmap openDesktopPixmap = QPixmap( QStandardPaths::locate( QStandardPaths::GenericDataLocation, "amarok/images/opendesktop-22.png" ) ); | ||
210 | QIcon openDesktopIcon = QIcon( openDesktopPixmap ); | 207 | QIcon openDesktopIcon = QIcon( openDesktopPixmap ); | ||
211 | 208 | | |||
212 | 209 | | |||
213 | //And now, the Authors page: | 210 | //And now, the Authors page: | ||
214 | const int authorCount = d->aboutData->authors().count(); | 211 | const int authorCount = d->aboutData->authors().count(); | ||
215 | 212 | | |||
216 | if (authorCount) | 213 | if (authorCount) | ||
217 | { | 214 | { | ||
Show All 38 Lines | |||||
256 | connect( m_authorListWidget.data(), &OcsPersonListWidget::switchedToOcs, | 253 | connect( m_authorListWidget.data(), &OcsPersonListWidget::switchedToOcs, | ||
257 | m_showOcsAuthorButton.data(), &AnimatedBarWidget::stop ); | 254 | m_showOcsAuthorButton.data(), &AnimatedBarWidget::stop ); | ||
258 | connect( m_authorListWidget.data(), &OcsPersonListWidget::switchedToOcs, | 255 | connect( m_authorListWidget.data(), &OcsPersonListWidget::switchedToOcs, | ||
259 | m_showOcsAuthorButton.data(), &AnimatedBarWidget::fold ); | 256 | m_showOcsAuthorButton.data(), &AnimatedBarWidget::fold ); | ||
260 | 257 | | |||
261 | authorLayout->addWidget( m_authorListWidget.data() ); | 258 | authorLayout->addWidget( m_authorListWidget.data() ); | ||
262 | authorLayout->setMargin( 0 ); | 259 | authorLayout->setMargin( 0 ); | ||
263 | authorLayout->setSpacing( 2 ); | 260 | authorLayout->setSpacing( 2 ); | ||
264 | m_authorWidget.data()->setLayout( authorLayout ); | 261 | m_authorWidget->setLayout( authorLayout ); | ||
265 | 262 | | |||
266 | m_authorPageTitle = ( authorCount == 1 ) ? i18n("A&uthor") : i18n("A&uthors"); | 263 | m_authorPageTitle = ( authorCount == 1 ) ? i18n("A&uthor") : i18n("A&uthors"); | ||
267 | tabWidget->addTab(m_authorWidget.data(), m_authorPageTitle); | 264 | tabWidget->addTab(m_authorWidget.data(), m_authorPageTitle); | ||
268 | m_isOfflineAuthorWidget = true; //is this still used? | 265 | m_isOfflineAuthorWidget = true; //is this still used? | ||
269 | } | 266 | } | ||
270 | 267 | | |||
271 | //Then the Credits page: | 268 | //Then the Credits page: | ||
272 | const int creditCount = aboutData->credits().count(); | 269 | const int creditCount = aboutData->credits().count(); | ||
Show All 13 Lines | 272 | { | |||
286 | connect( m_creditListWidget.data(), &OcsPersonListWidget::switchedToOcs, | 283 | connect( m_creditListWidget.data(), &OcsPersonListWidget::switchedToOcs, | ||
287 | m_showOcsCreditButton.data(), &AnimatedBarWidget::stop ); | 284 | m_showOcsCreditButton.data(), &AnimatedBarWidget::stop ); | ||
288 | connect( m_creditListWidget.data(), &OcsPersonListWidget::switchedToOcs, | 285 | connect( m_creditListWidget.data(), &OcsPersonListWidget::switchedToOcs, | ||
289 | m_showOcsCreditButton.data(), &AnimatedBarWidget::fold ); | 286 | m_showOcsCreditButton.data(), &AnimatedBarWidget::fold ); | ||
290 | 287 | | |||
291 | creditLayout->addWidget( m_creditListWidget.data() ); | 288 | creditLayout->addWidget( m_creditListWidget.data() ); | ||
292 | creditLayout->setMargin( 0 ); | 289 | creditLayout->setMargin( 0 ); | ||
293 | creditLayout->setSpacing( 2 ); | 290 | creditLayout->setSpacing( 2 ); | ||
294 | m_creditWidget.data()->setLayout( creditLayout ); | 291 | m_creditWidget->setLayout( creditLayout ); | ||
295 | 292 | | |||
296 | tabWidget->addTab( m_creditWidget.data(), i18n("&Contributors")); | 293 | tabWidget->addTab( m_creditWidget.data(), i18n("&Contributors")); | ||
297 | m_isOfflineCreditWidget = true; //is this still used? | 294 | m_isOfflineCreditWidget = true; //is this still used? | ||
298 | } | 295 | } | ||
299 | 296 | | |||
300 | //Finally, the Donors page: | 297 | //Finally, the Donors page: | ||
301 | const int donorCount = ocsData->donors()->count(); | 298 | const int donorCount = ocsData->donors()->count(); | ||
302 | 299 | | |||
Show All 24 Lines | 301 | { | |||
327 | QLabel *roktoberLabel = | 324 | QLabel *roktoberLabel = | ||
328 | new QLabel(i18n("<p>Each year in October the Amarok team organizes a funding " | 325 | new QLabel(i18n("<p>Each year in October the Amarok team organizes a funding " | ||
329 | "drive called <b>Roktober</b>.</p>" | 326 | "drive called <b>Roktober</b>.</p>" | ||
330 | "<p>If you want your name mentioned on this list " | 327 | "<p>If you want your name mentioned on this list " | ||
331 | "<a href=\"http://amarok.kde.org/donations\"> donate " | 328 | "<a href=\"http://amarok.kde.org/donations\"> donate " | ||
332 | "during Roktober</a> and opt-in.</p>")); | 329 | "during Roktober</a> and opt-in.</p>")); | ||
333 | roktoberLabel->setOpenExternalLinks(true); | 330 | roktoberLabel->setOpenExternalLinks(true); | ||
334 | donorLayout->addWidget(roktoberLabel); | 331 | donorLayout->addWidget(roktoberLabel); | ||
335 | m_donorWidget.data()->setLayout( donorLayout ); | 332 | m_donorWidget->setLayout( donorLayout ); | ||
336 | 333 | | |||
337 | tabWidget->addTab( m_donorWidget.data(), i18n("&Donors")); | 334 | tabWidget->addTab( m_donorWidget.data(), i18n("&Donors")); | ||
338 | m_isOfflineDonorWidget = true; | 335 | m_isOfflineDonorWidget = true; | ||
339 | } | 336 | } | ||
340 | 337 | | |||
341 | 338 | | |||
342 | //And the translators: | 339 | //And the translators: | ||
343 | QPalette transparentBackgroundPalette; | 340 | QPalette transparentBackgroundPalette; | ||
Show All 11 Lines | 351 | for(it = translatorList.begin(); it != translatorList.end(); ++it) { | |||
355 | translatorPageText += QString("<p style=\"margin: 0px;\">%1</p>").arg((*it).name()); | 352 | translatorPageText += QString("<p style=\"margin: 0px;\">%1</p>").arg((*it).name()); | ||
356 | if (!(*it).emailAddress().isEmpty()) | 353 | if (!(*it).emailAddress().isEmpty()) | ||
357 | translatorPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"mailto:%1\">%1</a></p>").arg((*it).emailAddress()); | 354 | translatorPageText += QString("<p style=\"margin: 0px; margin-left: 15px;\"><a href=\"mailto:%1\">%1</a></p>").arg((*it).emailAddress()); | ||
358 | translatorPageText += "<p style=\"margin: 0px;\"> </p>"; | 355 | translatorPageText += "<p style=\"margin: 0px;\"> </p>"; | ||
359 | } | 356 | } | ||
360 | 357 | | |||
361 | translatorPageText += KAboutData::aboutTranslationTeam(); | 358 | translatorPageText += KAboutData::aboutTranslationTeam(); | ||
362 | 359 | | |||
363 | KTextBrowser *translatorTextBrowser = new KTextBrowser; | 360 | QTextBrowser *translatorTextBrowser = new QTextBrowser; | ||
364 | translatorTextBrowser->setFrameStyle(QFrame::NoFrame); | 361 | translatorTextBrowser->setFrameStyle(QFrame::NoFrame); | ||
365 | translatorTextBrowser->setPalette(transparentBackgroundPalette); | 362 | translatorTextBrowser->setPalette(transparentBackgroundPalette); | ||
366 | translatorTextBrowser->setHtml(translatorPageText); | 363 | translatorTextBrowser->setHtml(translatorPageText); | ||
367 | tabWidget->addTab(translatorTextBrowser, i18n("T&ranslation")); | 364 | tabWidget->addTab(translatorTextBrowser, i18n("T&ranslation")); | ||
368 | } | 365 | } | ||
369 | 366 | | |||
370 | //Jam everything together in a layout: | 367 | //Jam everything together in a layout: | ||
371 | mainLayout->addWidget(titleWidget); | 368 | mainLayout->addWidget(titleWidget); | ||
372 | mainLayout->addWidget(tabWidget); | 369 | mainLayout->addWidget(tabWidget); | ||
373 | mainLayout->setMargin(0); | 370 | mainLayout->setMargin(0); | ||
374 | 371 | | |||
375 | mainLayout->addWidget(buttonBox); | 372 | mainLayout->addWidget(buttonBox); | ||
376 | 373 | | |||
377 | resize( QSize( 480, 460 ) ); | 374 | resize( QSize( 480, 460 ) ); | ||
378 | } | 375 | } | ||
379 | 376 | | |||
380 | ExtendedAboutDialog::~ExtendedAboutDialog() | 377 | ExtendedAboutDialog::~ExtendedAboutDialog() | ||
381 | { | 378 | { | ||
382 | delete d; | 379 | delete d; | ||
383 | } | 380 | } | ||
384 | 381 | | |||
385 | void | 382 | void | ||
386 | ExtendedAboutDialog::switchToOcsWidgets() | 383 | ExtendedAboutDialog::switchToOcsWidgets() | ||
387 | { | 384 | { | ||
388 | if( !( Solid::Networking::status() == Solid::Networking::Connected || | 385 | if( !QNetworkConfigurationManager().isOnline() ) | ||
389 | Solid::Networking::status() == Solid::Networking::Unknown ) ) | | |||
390 | { | 386 | { | ||
391 | KMessageBox::error( this, i18n( "Internet connection not available" ), i18n( "Network error" ) ); | 387 | KMessageBox::error( this, i18n( "Internet connection not available" ), i18n( "Network error" ) ); | ||
392 | return; | 388 | return; | ||
393 | } | 389 | } | ||
394 | 390 | | |||
395 | if( m_showOcsAuthorButton ) | 391 | if( m_showOcsAuthorButton ) | ||
396 | m_showOcsAuthorButton.data()->animate(); | 392 | m_showOcsAuthorButton->animate(); | ||
397 | if( m_showOcsCreditButton ) | 393 | if( m_showOcsCreditButton ) | ||
398 | m_showOcsCreditButton.data()->animate(); | 394 | m_showOcsCreditButton->animate(); | ||
399 | if( m_showOcsDonorButton ) | 395 | if( m_showOcsDonorButton ) | ||
400 | m_showOcsDonorButton.data()->animate(); | 396 | m_showOcsDonorButton->animate(); | ||
401 | AmarokAttica::ProviderInitJob *providerJob = AmarokAttica::Provider::byId( m_ocsData.providerId() ); | 397 | AmarokAttica::ProviderInitJob *providerJob = AmarokAttica::Provider::byId( m_ocsData.providerId() ); | ||
402 | connect( providerJob, &AmarokAttica::ProviderInitJob::result, this, &ExtendedAboutDialog::onProviderFetched ); | 398 | connect( providerJob, &AmarokAttica::ProviderInitJob::result, this, &ExtendedAboutDialog::onProviderFetched ); | ||
403 | } | 399 | } | ||
404 | 400 | | |||
405 | void | 401 | void | ||
406 | ExtendedAboutDialog::onProviderFetched( KJob *job ) | 402 | ExtendedAboutDialog::onProviderFetched( KJob *job ) | ||
407 | { | 403 | { | ||
408 | AmarokAttica::ProviderInitJob *providerJob = qobject_cast< AmarokAttica::ProviderInitJob * >( job ); | 404 | AmarokAttica::ProviderInitJob *providerJob = qobject_cast< AmarokAttica::ProviderInitJob * >( job ); | ||
409 | if( providerJob->error() == 0 ) | 405 | if( providerJob->error() == 0 ) | ||
410 | { | 406 | { | ||
411 | debug()<<"Successfully fetched OCS provider"<< providerJob->provider().name(); | 407 | debug()<<"Successfully fetched OCS provider"<< providerJob->provider().name(); | ||
412 | debug()<<"About to request OCS data"; | 408 | debug()<<"About to request OCS data"; | ||
413 | if( m_authorListWidget ) | 409 | if( m_authorListWidget ) | ||
414 | m_authorListWidget.data()->switchToOcs( providerJob->provider() ); | 410 | m_authorListWidget->switchToOcs( providerJob->provider() ); | ||
415 | if( m_creditListWidget ) | 411 | if( m_creditListWidget ) | ||
416 | m_creditListWidget.data()->switchToOcs( providerJob->provider() ); | 412 | m_creditListWidget->switchToOcs( providerJob->provider() ); | ||
417 | if( m_donorListWidget ) | 413 | if( m_donorListWidget ) | ||
418 | m_donorListWidget.data()->switchToOcs( providerJob->provider() ); | 414 | m_donorListWidget->switchToOcs( providerJob->provider() ); | ||
419 | } | 415 | } | ||
420 | else | 416 | else | ||
421 | warning() << "OCS provider fetch failed"; | 417 | warning() << "OCS provider fetch failed"; | ||
422 | } | 418 | } | ||
423 | 419 | | |||
424 | void | 420 | void | ||
425 | ExtendedAboutDialog::showLicense(const QString& number) | 421 | ExtendedAboutDialog::showLicense(const QString& number) | ||
426 | { | 422 | { | ||
427 | d->_k_showLicense(number); | 423 | d->_k_showLicense(number); | ||
428 | } | 424 | } | ||
429 | 425 | |