CVS commit by faure: Show the error message in the message box when a part can't be loaded. Fixed wrong "wait cursor" in that msgbox, and don't select the plugin in the sidepane until successfully loaded, otherwise it looks out of sync. M +32 -5 interfaces/core.cpp 1.20 M +2 -0 interfaces/core.h 1.24 M +6 -5 src/mainwindow.cpp 1.133 --- kdepim/kontact/interfaces/core.cpp #1.19:1.20 @@ -28,10 +28,18 @@ #include #include +#include using namespace Kontact; +class Core::Private +{ +public: + QString lastErrorMessage; +}; + Core::Core( QWidget *parent, const char *name ) : KParts::MainWindow( parent, name ) { + d = new Private; QTimer* timer = new QTimer( this ); mLastDate = QDate::currentDate(); @@ -42,4 +50,5 @@ Core::Core( QWidget *parent, const char Core::~Core() { + delete d; } @@ -66,10 +75,23 @@ KParts::ReadOnlyPart *Core::createPart( SLOT( slotPartDestroyed( QObject * ) ) ); } else { - if ( error == KParts::ComponentFactory::ErrNoLibrary ) { - // ### how to pass it to kontact for displaying together with the "Cannot load Part" box? - kdWarning(5601) << KLibLoader::self()->lastErrorMessage() << endl; - } else { - kdWarning(5601) << "KParts::ComponentFactory::createInstanceFromFactory returned error code " << error << " for " << libname << endl; + // TODO move to KParts::ComponentFactory + switch( error ) { + case KParts::ComponentFactory::ErrNoServiceFound: + d->lastErrorMessage = i18n( "No service found" ); + break; + case KParts::ComponentFactory::ErrServiceProvidesNoLibrary: + d->lastErrorMessage = i18n( "Program error: the .desktop file for the service does not have a Library key." ); + break; + case KParts::ComponentFactory::ErrNoLibrary: + d->lastErrorMessage = KLibLoader::self()->lastErrorMessage(); + break; + case KParts::ComponentFactory::ErrNoFactory: + d->lastErrorMessage = i18n( "Program error: the library %1 does not provide a factory." ).arg( libname ); + break; + case KParts::ComponentFactory::ErrNoComponent: + d->lastErrorMessage = i18n( "Program error: the library %1 does not support creating components of the specified type" ).arg( libname ); + break; } + kdWarning(5601) << d->lastErrorMessage << endl; } @@ -99,4 +121,9 @@ void Core::checkNewDay() } +QString Core::lastErrorMessage() const +{ + return d->lastErrorMessage; +} + #include "core.moc" // vim: sw=2 sts=2 et tw=80 --- kdepim/kontact/interfaces/core.h #1.23:1.24 @@ -82,4 +82,6 @@ class Core : public KParts::MainWindow Core( QWidget *parentWidget = 0, const char *name = 0 ); + QString lastErrorMessage() const; + private slots: void slotPartDestroyed( QObject * ); --- kdepim/kontact/src/mainwindow.cpp #1.132:1.133 @@ -533,16 +533,17 @@ void MainWindow::selectPlugin( Kontact:: KApplication::setOverrideCursor( QCursor( Qt::WaitCursor ) ); - if ( mSidePane ) - mSidePane->selectPlugin( plugin ); - KParts::Part *part = plugin->part(); if ( !part ) { - KMessageBox::error( this, i18n( "Cannot load part for %1." ) - .arg( plugin->title() ) ); KApplication::restoreOverrideCursor(); + KMessageBox::error( this, i18n( "Cannot load part for %1." ) + .arg( plugin->title() ) + + "\n" + lastErrorMessage() ); return; } + if ( mSidePane ) + mSidePane->selectPlugin( plugin ); + plugin->select();