[KPhotoAlbum] New snapshot
Robert L Krawitz
rlk at alum.mit.edu
Tue Nov 7 13:05:49 GMT 2006
I finally solved my video display problem. It seems that I had a bad
service listed first for x-msvideo (there are also service entries for
"msvideo" and ".avi", and changing these didn't help anything).
I've submitted a patch to have KPA search the entire list of services
for the MIME type; this should help in this kind of case.
Try this:
Index: VideoDisplay.h
===================================================================
--- VideoDisplay.h (revision 602829)
+++ VideoDisplay.h (working copy)
@@ -52,7 +52,7 @@
void stateChanged( int );
protected:
- enum ErrorType { NoMimeType, NoKPart, NoLibrary, NoPartInstance,NoWidget };
+ enum ErrorType { NoError, NoMimeType, NoKPart, NoLibrary, NoPartInstance,NoWidget };
QString mimeTypeForFileName( const QString& fileName ) const;
void showError( ErrorType, const QString& fileName, const QString& mimeType );
void resize( float factor );
Index: VideoDisplay.cpp
===================================================================
--- VideoDisplay.cpp (revision 602829)
+++ VideoDisplay.cpp (working copy)
@@ -97,36 +97,48 @@
return false;
}
+ KServiceTypeProfile::OfferList services = KServiceTypeProfile::offers(mimeType, QString::fromLatin1("KParts/ReadOnlyPart"));
- // Ask for a part for this mime type
- KService::Ptr service = KServiceTypeProfile::preferredService(mimeType, QString::fromLatin1("KParts/ReadOnlyPart"));
- if (!service.data()) {
- showError( NoKPart, info->fileName(), mimeType );
- kdWarning() << "Couldn't find a KPart for " << mimeType << endl;
- return false;
- }
+ ErrorType etype = NoError;
+
+ for( KServiceTypeProfile::OfferList::Iterator it = services.begin(); it != services.end(); ++it ) {
- QString library=service->library();
- if ( library.isNull() ) {
- showError( NoLibrary, info->fileName(), mimeType );
- kdWarning() << "The library returned from the service was null, indicating we could not display videos." << endl;
- return false;
- }
+ // Ask for a part for this mime type
+ KService::Ptr service = (*it).service();
- _playerPart = KParts::ComponentFactory::createPartInstanceFromService<KParts::ReadOnlyPart>(service, this );
- if (!_playerPart) {
- showError( NoPartInstance, info->fileName(), mimeType );
- kdWarning() << "Failed to instantiate KPart from library " << library << endl;
- return false;
- }
+ if (!service.data()) {
+ etype = NoKPart;
+ kdWarning() << "Couldn't find a KPart for " << mimeType << endl;
+ continue;
+ }
- QWidget* widget = _playerPart->widget();
- if ( !widget ) {
- showError(NoWidget, info->fileName(), mimeType );
- return false;
+ QString library=service->library();
+ if ( library.isNull() ) {
+ etype = NoLibrary;
+ kdWarning() << "The library returned from the service was null, indicating we could not display videos." << endl;
+ continue;
+ }
+
+ _playerPart = KParts::ComponentFactory::createPartInstanceFromService<KParts::ReadOnlyPart>(service, this );
+ if (!_playerPart) {
+ etype = NoPartInstance;
+ kdWarning() << "Failed to instantiate KPart from library " << library << endl;
+ continue;
+ }
+
+ QWidget* widget = _playerPart->widget();
+ if ( !widget ) {
+ etype = NoWidget;
+ continue;
+ }
+ etype = NoError;
+ widget->show();
+ break;
}
- widget->show();
-
+ if (etype != NoError) {
+ showError(NoWidget, info->fileName(), mimeType );
+ return false;
+ }
_playerPart->openURL(info->fileName());
// If the part implements the KMediaPlayer::Player interface, start
More information about the Kphotoalbum
mailing list