Fix regressions
[kphotoalbum.git] / MainWindow / FeatureDialog.cpp
blob3c19401c42c00277bfbe1ea4f317b8d5c1bd83c4
1 /* Copyright (C) 2003-2006 Jesper K. Pedersen <blackie@kde.org>
3 This program is free software; you can redistribute it and/or
4 modify it under the terms of the GNU General Public
5 License as published by the Free Software Foundation; either
6 version 2 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with this program; see the file COPYING. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
18 #include "FeatureDialog.h"
19 #include <QDebug>
20 #include <config-kpa-kipi.h>
21 #include <config-kpa-exiv2.h>
22 #include <klocale.h>
23 #include <qlayout.h>
24 #include <QList>
25 #include <kapplication.h>
26 #include "Exif/Database.h"
27 #include <ImageManager/VideoManager.h>
28 #include <kparts/componentfactory.h>
29 #include <ktoolinvocation.h>
30 #include <Phonon/BackendCapabilities>
32 using namespace MainWindow;
34 FeatureDialog::FeatureDialog( QWidget* parent )
35 :KDialog( parent )
37 setWindowTitle( makeStandardCaption( i18n("Feature Status"), this ) );
39 HelpBrowser* edit = new HelpBrowser( this );
40 setMainWidget( edit );
42 QString text = i18n("<h1>Overview</h1>"
43 "<p>Below you may see the list of compile- and runtime features KPhotoAlbum has, and their status:</p>"
44 "%1", featureString() );
45 text += i18n( "<h1>What can I do if I miss a feature?</h1>"
47 "<p>If you compiled KPhotoAlbum yourself, then please review the sections below to learn what to install "
48 "to get the feature in question. If on the other hand you installed KPhotoAlbum from a binary package, please tell "
49 "whoever made the package about this defect, eventually including the information from the section below.<p>"
51 "<p>In case you are missing a feature and you did not compile KPhotoAlbum yourself, please do consider doing so. "
52 "It really isn't that hard. If you need help compiling KPhotoAlbum, feel free to ask on the "
53 "<a href=\"http://mail.kdab.net/mailman/listinfo/kphotoalbum\">KPhotoAlbum mailing list</a></p>"
55 "<p>The steps to compile KPhotoAlbum can be seen on <a href=\"http://www.kphotoalbum.org/download-source.html\">"
56 "the KPhotoAlbum home page</a>. If you have never compiled a KDE application, then please ensure that "
57 "you have the developer packages installed, in most distributions they go under names like kdelibs<i>-devel</i></p>" );
61 text += i18n( "<h1><a name=\"kipi\">Plug-ins Support</a></h1>"
62 "<p>KPhotoAlbum has a plug-in system with lots of extensions. You may among other things find plug-ins for:"
63 "<ul>"
64 "<li>Writing images to cds or dvd's"
65 "<li>Adjusting timestamps on your images"
66 "<li>Making a calendar featuring your images"
67 "<li>Uploading your images to flickr"
68 "<li>Upload your images to facebook"
69 "</ul></p>"
71 "<p>The plug-in library is called KIPI, and may be downloaded from the "
72 "<a href=\"http://www.kipi-plugins.org\">KIPI Home page</a></p>" );
74 text += i18n( "<h1><a name=\"exiv2\">EXIF support</a></h1>"
75 "<p>Images store information like the date the image was shot, the shooting angle, focal length, and shutter-speed "
76 "in what is known as EXIF information.</p>"
78 "<p>KPhotoAlbum uses the <a href=\"http://freshmeat.net/projects/exiv2/\">EXIV2 library</a> "
79 "to read EXIF information from images</p>" );
82 text += i18n( "<h1><a name=\"database\">SQL Database Support</a></h1>"
83 "<p>KPhotoAlbum allows you to search using a certain number of EXIF tags. For this KPhotoAlbum "
84 "needs an Sqlite database. "
85 "In addition the qt package for sqlite (e.g.qt-sql-sqlite) must be installed.</p>");
87 text += i18n("<h1><a name=\"thumbnails\">Video Thumbnails Support</a></h1>"
88 "<p>KPhotoAlbum asks the KDE plug-in system for help when it needs to generate a thumbnail for videos. "
89 "<p>Unfortunately KDE4 does currently not come with any plug-ins for this, you therefore need manually to install "
90 "<a href=\"http://www.kde-apps.org/content/show.php?content=41180\">MPlayerThumbs</a>.</p>");
92 text += i18n("<h1><a name=\"video\">Video Support</a></h1>"
93 "<p>KPhotoAlbum relies on Qt's Phonon architecture for displaying videos; this in turn relies on GStreamer. "
94 "If this feature is not enabled for you, have a look at the "
95 "<a href=\"http://wiki.kde.org/tiki-index.php?page=KPhotoAlbum+Video+Support\">KPhotoAlbum wiki article on video support</a>.</p>");
97 QStringList mimeTypes = supportedVideoMimeTypes();
98 mimeTypes.sort();
99 if ( mimeTypes.isEmpty() )
100 text += i18n( "<p>No video mime types found, which indicates that either Qt was compiled without phonon support, or there were missing codecs</p>");
101 else
102 text += i18n("<p>Phonon is capable of playing movies of these mime types:<ul><li>%1</ul></p>", mimeTypes.join(QString::fromLatin1( "<li>" ) ) );
104 edit->setText( text );
106 resize( 800, 600 );
109 HelpBrowser::HelpBrowser( QWidget* parent, const char* name )
110 :QTextBrowser( parent )
112 setObjectName(QString::fromLatin1(name));
115 void HelpBrowser::setSource( const QUrl& url )
117 const QString name = url.toString();
119 if ( name.startsWith( QString::fromLatin1( "#" ) ) )
120 QTextBrowser::setSource( name );
121 else
122 KToolInvocation::invokeBrowser( name );
125 bool MainWindow::FeatureDialog::hasKIPISupport()
127 #ifdef HASKIPI
128 return true;
129 #else
130 return false;
131 #endif
134 bool MainWindow::FeatureDialog::hasSQLDBSupport()
136 #ifdef QT_NO_SQL
137 return false;
138 #else
139 return true;
140 #endif
144 bool MainWindow::FeatureDialog::hasEXIV2Support()
146 #ifdef HAVE_EXIV2
147 return true;
148 #else
149 return false;
150 #endif
153 bool MainWindow::FeatureDialog::hasEXIV2DBSupport()
155 #ifdef HAVE_EXIV2
156 return Exif::Database::isAvailable();
157 #else
158 return false;
159 #endif
162 bool MainWindow::FeatureDialog::hasAllFeaturesAvailable()
164 // Only answer those that are compile time tests, otherwise we will pay a penalty each time we start up.
165 return hasKIPISupport() && hasSQLDBSupport() && hasEXIV2Support() && hasEXIV2DBSupport();
168 struct Data
170 Data() {}
171 Data( const QString& title, const QString tag, bool featureFound )
172 : title( title ), tag( tag ), featureFound( featureFound ) {}
173 QString title;
174 QString tag;
175 bool featureFound;
178 QString MainWindow::FeatureDialog::featureString()
180 QList<Data> features;
181 features << Data( i18n("Plug-ins available"), QString::fromLatin1("#kipi"), hasKIPISupport() );
182 features << Data( i18n("EXIF info supported"), QString::fromLatin1("#exiv2"), hasEXIV2Support() );
183 features << Data( i18n("SQL Database Support"), QString::fromLatin1("#database"), hasSQLDBSupport() );
184 features << Data( i18n( "Sqlite Database Support (used for EXIF searches)" ), QString::fromLatin1("#database"),
185 hasEXIV2Support() && hasEXIV2DBSupport() );
186 features << Data( i18n( "Video Thumbnail support" ), QString::fromLatin1("#thumbnails"),
187 ImageManager::VideoManager::instance().hasVideoThumbnailSupport() );
188 features << Data( i18n( "Video support" ), QString::fromLatin1("#video"), !supportedVideoMimeTypes().isEmpty() );
190 QString result = QString::fromLatin1("<p><table>");
191 const QString yes = i18n("Yes");
192 const QString no = QString::fromLatin1("<font color=\"red\">%1</font>").arg( i18n("No") );
193 for( QList<Data>::ConstIterator featureIt = features.constBegin(); featureIt != features.constEnd(); ++featureIt ) {
194 result += QString::fromLatin1( "<tr><td><a href=\"%1\">%2</a></td><td><b>%3</b></td></tr>" )
195 .arg( (*featureIt).tag ).arg( (*featureIt).title ).arg( (*featureIt).featureFound ? yes : no );
197 result += QString::fromLatin1( "</table></p>" );
199 return result;
202 QStringList MainWindow::FeatureDialog::supportedVideoMimeTypes()
204 return Phonon::BackendCapabilities::availableMimeTypes();
207 #include "FeatureDialog.moc"