Git commit ce15c154eb7f641c3ce6a273660edb11a2bdcab1 by Andrzej J. R. Hunt. Committed on 03/04/2012 at 20:46. Pushed by andrzejhunt into branch 'master'.
Diagnostics Dialog for Amarok. FEATURE: 296415 REVIEW: 104449 GUI: M +1 -0 src/CMakeLists.txt M +14 -0 src/MainWindow.cpp M +1 -0 src/MainWindow.h M +1 -1 src/PluginManager.cpp M +1 -1 src/PluginManager.h A +123 -0 src/dialogs/DiagnosticDialog.cpp [License: GPL (v2+)] A +45 -0 src/dialogs/DiagnosticDialog.h [License: GPL (v2+)] http://commits.kde.org/amarok/ce15c154eb7f641c3ce6a273660edb11a2bdcab1 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 956b3da..43bda90 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -680,6 +680,7 @@ set(amaroklib_LIB_SRCS databaseimporter/sqlbatch/SqlBatchImporterConfig.cpp dialogs/CollectionSetup.cpp dialogs/DatabaseImporterDialog.cpp + dialogs/DiagnosticDialog.cpp dialogs/EditFilterDialog.cpp dialogs/EqualizerDialog.cpp dialogs/FilenameLayoutDialog.cpp diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 98b1c77..773f9b0 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -42,6 +42,7 @@ #include "context/ContextDock.h" #include "core-impl/collections/support/CollectionManager.h" #include "covermanager/CoverManager.h" // for actions +#include "dialogs/DiagnosticDialog.h" #include "dialogs/EqualizerDialog.h" #include "likeback/LikeBack.h" #include "moodbar/MoodbarManager.h" @@ -533,6 +534,13 @@ MainWindow::slotShowCoverManager() const //SLOT CoverManager::showOnce(); } +void +MainWindow::slotShowDiagnosticsDialog() const +{ + DiagnosticDialog dialog( KGlobal::mainComponent().aboutData() ); + dialog.exec(); +} + void MainWindow::slotShowBookmarkManager() const { The::bookmarkManager()->showOnce(); @@ -938,6 +946,10 @@ MainWindow::createActions() ac->addAction( "extendedAbout", action ); connect( action, SIGNAL( triggered() ), SLOT( showAbout() ) ); + action = new KAction ( KIcon( "info-amarok" ), i18n( "&Diagnostics" ), this ); + ac->addAction( "diagnosticDialog", action ); + connect( action, SIGNAL( triggered() ), SLOT( slotShowDiagnosticsDialog() ) ); + action = new KAction( KIcon( "tools-report-bug" ), i18n("&Report Bug..."), this ); ac->addAction( "reportBug", action ); connect( action, SIGNAL( triggered() ), SLOT( showReportBug() ) ); @@ -1089,6 +1101,8 @@ MainWindow::createMenus() Amarok::actionCollection()->action( "reportBug" ) ); helpMenu->insertAction( helpMenu->actions().last(), Amarok::actionCollection()->action( "extendedAbout" ) ); + helpMenu->insertAction( helpMenu->actions().last(), + Amarok::actionCollection()->action( "diagnosticDialog" ) ); helpMenu->insertAction( helpMenu->actions().at( 4 ), Amarok::actionCollection()->action( "likeBackSendComment" ) ); helpMenu->insertAction( helpMenu->actions().at( 5 ), diff --git a/src/MainWindow.h b/src/MainWindow.h index b149cb9..d497764 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -140,6 +140,7 @@ class AMAROK_EXPORT MainWindow : public KMainWindow void slotShowBookmarkManager() const; void slotShowEqualizer() const; void slotShowCoverManager() const; + void slotShowDiagnosticsDialog() const; void slotShowMenuBar(); void slotPlayMedia(); void slotAddLocation( bool directPlay = false ); diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index c46b12f..9b34565 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -141,7 +141,7 @@ Plugins::PluginManager::checkPluginEnabledStates() } KPluginInfo::List -Plugins::PluginManager::plugins( const QString &category ) +Plugins::PluginManager::plugins( const QString &category ) const { return m_pluginInfos.value( category ); } diff --git a/src/PluginManager.h b/src/PluginManager.h index 6b9f3ca..242409e 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -46,7 +46,7 @@ class AMAROK_EXPORT PluginManager : public QObject QList<PluginFactory*> factories( const QString &category ) const; - KPluginInfo::List plugins( const QString &category ); + KPluginInfo::List plugins( const QString &category ) const; ServicePluginManager *servicePluginManager(); diff --git a/src/dialogs/DiagnosticDialog.cpp b/src/dialogs/DiagnosticDialog.cpp new file mode 100644 index 0000000..fc0c9da --- /dev/null +++ b/src/dialogs/DiagnosticDialog.cpp @@ -0,0 +1,123 @@ +/**************************************************************************************** + * Copyright (c) 2012 Andrzej J. R. Hunt <andrzej at ahunt.org> * + * * + * This program is free software; you can redistribute it and/or modify it under * + * the terms of the GNU General Public License as published by the Free Software * + * Foundation; either version 2 of the License, or (at your option) any later * + * version. * + * * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY * + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along with * + * this program. If not, see <http://www.gnu.org/licenses/>. * + ****************************************************************************************/ + +#include "DiagnosticDialog.h" + +#include "PluginManager.h" +#include "ScriptManager.h" + +#include <kapplication.h> +#include <KDE/KService> +#include <KDE/KServiceTypeTrader> +#include <kglobal.h> +#include "kplugininfo.h" +#include <Phonon/Global> + +#include <QClipboard> + + +DiagnosticDialog::DiagnosticDialog( const KAboutData *aboutData, QWidget *parent ) + : KDialog( parent ) +{ + if ( aboutData == 0 ) + aboutData = KGlobal::mainComponent().aboutData(); + + + m_textBox = new QPlainTextEdit( generateReport( aboutData ), this ); + + setPlainCaption( i18n( "%1 Diagnostics", aboutData->programName() ) ); + + setButtons( Close | User1 ); + setButtonText( User1, i18n( "Copy to Clipboard" ) ); + + m_textBox->setReadOnly( true ); + + setMainWidget( m_textBox ); + setInitialSize( QSize( 480, 460 ) ); + + connect( this, SIGNAL( user1Clicked() ), SLOT( slotCopyToClipboard() ) ); +} + +DiagnosticDialog::~DiagnosticDialog() +{ + delete m_textBox; +} + +const QString +DiagnosticDialog::generateReport( const KAboutData *aboutData ) +{ + + // Get scripts -- we have to assemble 3 lists into one + KPluginInfo::List aScripts; + const ScriptManager *aScriptManager = ScriptManager::instance(); + aScripts.append( aScriptManager->scripts( QLatin1String( "Generic" ) ) ); + aScripts.append( aScriptManager->scripts( QLatin1String( "Lyrics" ) ) ); + aScripts.append( aScriptManager->scripts( QLatin1String( "Scriptable Service" ) ) ); + + // Format the data to be readable + QString aScriptString; + foreach( KPluginInfo aInfo, aScripts ) + { + aScriptString = aScriptString % aInfo.name() % " " % aInfo.version() % + ( aInfo.isPluginEnabled() ? " (running)" : " (stopped)" ) % "\n "; + } + + + // Get plugins -- we have to assemble a list again. + KPluginInfo::List aPlugins; + const Plugins::PluginManager *aPluginManager = Plugins::PluginManager::instance(); + aPlugins.append( aPluginManager->plugins( QLatin1String( "Collection" ) ) ); + aPlugins.append( aPluginManager->plugins( QLatin1String( "Service" ) ) ); + aPlugins.append( aPluginManager->plugins( QLatin1String( "Device" ) ) ); + + QString aPluginString; + foreach( KPluginInfo aInfo, aPlugins ) + { + aPluginString = aPluginString % aInfo.name() % // " " % aInfo.version() % + ( aInfo.isPluginEnabled() ? " (enabled)" : " (disabled)" ) % "\n "; + } + + + const KService::Ptr aPhononBackend = + KServiceTypeTrader::self()->preferredService( "PhononBackend" ); + + return i18n( + "%1-Diagnostics\n\n%1 Version: %2\n" + "KDE Version: %3\n" + "Qt Version: %4\n" + "Phonon Version: %5\n" + "Phonon Backend: %6 (%7)\n\n" + "Amarok Scripts:\n %8\n" + "Amarok Plugins:\n %9\n", + + aboutData->programName(), aboutData->version(), // Amarok + KDE::versionString(), // KDE + qVersion(), // QT + Phonon::phononVersion(), // Phonon + aPhononBackend.data()->name(), + aPhononBackend.data()->property( "X-KDE-PhononBackendInfo-Version", + QVariant::String).toString(), // & Backend + aScriptString, aPluginString + ); + +} + +void +DiagnosticDialog::slotCopyToClipboard() const +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setText( m_textBox->toPlainText() ); +} diff --git a/src/dialogs/DiagnosticDialog.h b/src/dialogs/DiagnosticDialog.h new file mode 100644 index 0000000..d32b00b --- /dev/null +++ b/src/dialogs/DiagnosticDialog.h @@ -0,0 +1,45 @@ +/**************************************************************************************** + * Copyright (c) 2012 Andrzej J. R. Hunt <andrzej at ahunt.org> * + * * + * This program is free software; you can redistribute it and/or modify it under * + * the terms of the GNU General Public License as published by the Free Software * + * Foundation; either version 2 of the License, or (at your option) any later * + * version. * + * * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY * + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License along with * + * this program. If not, see <http://www.gnu.org/licenses/>. * + ****************************************************************************************/ +#ifndef AMAROK_DIAGNOSTICDIALOG_H +#define AMAROK_DIAGNOSTICDIALOG_H + +#include "amarok_export.h" + +#include <KAboutData> +#include <kdialog.h> +#include <QPlainTextEdit> +#include <QWeakPointer> + +class AMAROK_EXPORT DiagnosticDialog : public KDialog +{ + Q_OBJECT +public: + explicit DiagnosticDialog( const KAboutData *aboutData, QWidget *parent = 0 ); + virtual ~DiagnosticDialog(); + +private: + QPlainTextEdit *m_textBox; + + const QString generateReport( const KAboutData *aboutData ); + +private slots: + void slotCopyToClipboard() const; +}; + + + + +#endif //AMAROK_DIAGNOSTICDIALOG_H \ No newline at end of file
