File indexing completed on 2025-01-19 03:50:50

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-07-30
0007  * Description : digiKam components info dialog.
0008  *
0009  * SPDX-FileCopyrightText: 2008-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #include "componentsinfodlg.h"
0016 
0017 // Qt includes
0018 
0019 #include <QApplication>
0020 #include <QString>
0021 #include <QMap>
0022 
0023 // KDE includes
0024 
0025 #include <klocalizedstring.h>
0026 
0027 // Local includes
0028 
0029 #include "applicationsettings.h"
0030 #include "digikam_config.h"
0031 #include "libsinfodlg.h"
0032 #include "dbstatdlg.h"
0033 #include "digikam_opencv.h"
0034 
0035 // LibGphoto2 includes
0036 
0037 #ifdef HAVE_GPHOTO2
0038 
0039 extern "C"
0040 {
0041 #   include <gphoto2-version.h>
0042 }
0043 
0044 #endif
0045 
0046 // Mediaplayer includes
0047 
0048 #ifdef HAVE_MEDIAPLAYER
0049 #   include "ffmpegconfighelper.h"
0050 
0051 extern "C"
0052 {
0053 #   include <libavformat/version.h>
0054 #   include <libavutil/version.h>
0055 #   include <libavcodec/version.h>
0056 }
0057 
0058 #endif
0059 
0060 namespace Digikam
0061 {
0062 
0063 class Q_DECL_HIDDEN ComponentsInfoDlg : public LibsInfoDlg
0064 {
0065     Q_OBJECT
0066 
0067 public:
0068 
0069     explicit ComponentsInfoDlg(QWidget* const parent)
0070         : LibsInfoDlg(parent)
0071     {
0072         // Set digiKam specific components info list.
0073 
0074 #ifdef HAVE_GPHOTO2
0075 
0076         const char** gpLibrary = gp_library_version(GP_VERSION_SHORT);
0077 
0078         QString gpVersion      = gpLibrary ? QLatin1String(gpLibrary[0])
0079                                            : i18nc("@item: component info", "Unknown");
0080 
0081         new QTreeWidgetItem(m_libraries, QStringList() <<
0082                             i18nc("@item: component info", "LibGphoto2") <<             gpVersion);
0083 
0084 #else
0085 
0086         new QTreeWidgetItem(m_features, QStringList() <<
0087                             i18nc("@item: component info", "LibGphoto2 support") <<     i18nc("@item: component info", "No"));
0088 
0089 #endif
0090 
0091 #ifdef HAVE_KFILEMETADATA
0092 
0093         new QTreeWidgetItem(m_features, QStringList() <<
0094                             i18nc("@item: component info", "Baloo support") <<          i18nc("@item: component info", "Yes"));
0095 
0096 #else
0097 
0098         new QTreeWidgetItem(m_features, QStringList() <<
0099                             i18nc("@item: component info", "Baloo support") <<          i18nc("@item: component info", "No"));
0100 
0101 #endif
0102 
0103 #ifdef HAVE_AKONADICONTACT
0104 
0105         new QTreeWidgetItem(m_features, QStringList() <<
0106                             i18nc("@item: component info", "AddressBook support") <<    i18nc("@item: component info", "Yes"));
0107 
0108 #else
0109 
0110         new QTreeWidgetItem(m_features, QStringList() <<
0111                             i18nc("@item: component info", "AddressBook support") <<    i18nc("@item: component info", "No"));
0112 
0113 #endif
0114 
0115 #ifdef HAVE_MEDIAPLAYER
0116 
0117         new QTreeWidgetItem(m_features, QStringList() <<
0118                             i18nc("@item: component info", "Media player support") <<   i18nc("@item: component info", "Yes"));
0119 
0120         new QTreeWidgetItem(m_libraries, QStringList() <<
0121                             i18nc("@item: component info", "LibAVFormat") <<            QString::fromLatin1("%1.%2.%3").arg(LIBAVFORMAT_VERSION_MAJOR).arg(LIBAVFORMAT_VERSION_MINOR).arg(LIBAVFORMAT_VERSION_MICRO));
0122 
0123         new QTreeWidgetItem(m_libraries, QStringList() <<
0124                             i18nc("@item: component info", "LibAVCodec") <<             QString::fromLatin1("%1.%2.%3").arg(LIBAVCODEC_VERSION_MAJOR).arg(LIBAVCODEC_VERSION_MINOR).arg(LIBAVCODEC_VERSION_MICRO));
0125 
0126         new QTreeWidgetItem(m_libraries, QStringList() <<
0127                             i18nc("@item: component info", "LibAVUtil") <<              QString::fromLatin1("%1.%2.%3").arg(LIBAVUTIL_VERSION_MAJOR).arg(LIBAVUTIL_VERSION_MINOR).arg(LIBAVUTIL_VERSION_MICRO));
0128 
0129 #else
0130 
0131         new QTreeWidgetItem(m_features, QStringList() <<
0132                             i18nc("@item: component info", "Media player support") <<   i18nc("@item: component info", "No"));
0133 
0134 #endif
0135 
0136 #ifdef HAVE_DBUS
0137 
0138         new QTreeWidgetItem(m_features, QStringList() <<
0139                             i18nc("@item: component info", "DBus support") <<           i18nc("@item: component info", "Yes"));
0140 
0141 #else
0142 
0143         new QTreeWidgetItem(m_features, QStringList() <<
0144                             i18nc("@item: component info", "DBus support") <<           i18nc("@item: component info", "No"));
0145 
0146 #endif
0147 
0148 #ifdef HAVE_PANORAMA
0149 
0150         new QTreeWidgetItem(m_features, QStringList() <<
0151                             i18nc("@item: component info", "Panorama support") <<       i18nc("@item: component info", "Yes"));
0152 
0153 #else
0154 
0155         new QTreeWidgetItem(m_features, QStringList() <<
0156                             i18nc("@item: component info", "Panorama support") <<       i18nc("@item: component info", "No"));
0157 
0158 #endif
0159 
0160 #ifdef HAVE_HTMLGALLERY
0161 
0162         new QTreeWidgetItem(m_features, QStringList() <<
0163                             i18nc("@item: component info", "HTML Gallery support") <<   i18nc("@item: component info", "Yes"));
0164 
0165 #else
0166 
0167         new QTreeWidgetItem(m_features, QStringList() <<
0168                             i18nc("@item: component info", "HTML Gallery support") <<   i18nc("@item: component info", "No"));
0169 
0170 #endif
0171 
0172 #ifdef HAVE_KCALENDAR
0173 
0174         new QTreeWidgetItem(m_features, QStringList() <<
0175                             i18nc("@item: component info", "Calendar support") <<       i18nc("@item: component info", "Yes"));
0176 
0177 #else
0178 
0179         new QTreeWidgetItem(m_features, QStringList() <<
0180                             i18nc("@item: component info", "Calendar support") <<       i18nc("@item: component info", "No"));
0181 
0182 #endif
0183 
0184         new QTreeWidgetItem(m_libraries, QStringList() <<
0185                             i18nc("@item: component info", "LibOpenCV") <<              QLatin1String(CV_VERSION));
0186 
0187         // Database Backend information
0188         // TODO: add sqlite versions here? Could be useful for debugging sqlite problems..
0189         // Use this sqlite request; https://www.sqlite.org/lang_corefunc.html#sqlite_version
0190 
0191         QString dbBe = ApplicationSettings::instance()->getDbEngineParameters().databaseType;
0192         new QTreeWidgetItem(m_features, QStringList() <<
0193                             i18nc("@item: component info", "Database backend") <<       dbBe);
0194 
0195         if (dbBe != QLatin1String("QSQLITE"))
0196         {
0197             QString internal = ApplicationSettings::instance()->getDbEngineParameters().internalServer ? i18nc("@item: component info", "Yes")
0198                                                                                                        : i18nc("@item: component info", "No");
0199             new QTreeWidgetItem(m_features, QStringList() <<
0200                                 i18nc("@item: component info", "Database internal server") << internal);
0201         }
0202 
0203 #ifdef HAVE_MEDIAPLAYER
0204 
0205         QTreeWidgetItem* const ffmpegEntry = new QTreeWidgetItem(listView(), QStringList() << i18nc("@item: component info", "FFmpeg Configuration"));
0206         listView()->addTopLevelItem(ffmpegEntry);
0207 
0208         // --- FFMPEG Video codecs ---
0209 
0210         FFMpegProperties propsVid     = FFMpegConfigHelper::getVideoCodecsProperties();
0211         QTreeWidgetItem* const vidDec = new QTreeWidgetItem(ffmpegEntry, QStringList() << i18nc("@item: component info", "Video Decoders"));
0212 
0213         for (FFMpegProperties::const_iterator it = propsVid.constBegin() ; it != propsVid.constEnd() ; ++it)
0214         {
0215             QStringList vals = it.value();
0216 
0217             if ((vals.size() > 1) && (vals[1] == QLatin1String("R")))
0218             {
0219                 new QTreeWidgetItem(vidDec, QStringList() << it.key() << vals[0]);
0220             }
0221         }
0222 
0223         QTreeWidgetItem* const vidEnc = new QTreeWidgetItem(ffmpegEntry, QStringList() << i18nc("@item: component info", "Video Encoders"));
0224 
0225         for (FFMpegProperties::const_iterator it = propsVid.constBegin() ; it != propsVid.constEnd() ; ++it)
0226         {
0227             QStringList vals = it.value();
0228 
0229             if ((vals.size() > 2) && (vals[2] == QLatin1String("W")))
0230             {
0231                 new QTreeWidgetItem(vidEnc, QStringList() << it.key() << vals[0]);
0232             }
0233         }
0234 
0235         // --- FFMPEG Audio codecs ---
0236 
0237         FFMpegProperties propsAud     = FFMpegConfigHelper::getAudioCodecsProperties();
0238         QTreeWidgetItem* const audDec = new QTreeWidgetItem(ffmpegEntry, QStringList() << i18nc("@item: component info", "Audio Decoders"));
0239 
0240         for (FFMpegProperties::const_iterator it = propsAud.constBegin() ; it != propsAud.constEnd() ; ++it)
0241         {
0242             QStringList vals = it.value();
0243 
0244             if ((vals.size() > 1) && (vals[1] == QLatin1String("R")))
0245             {
0246                 new QTreeWidgetItem(audDec, QStringList() << it.key() << vals[0]);
0247             }
0248         }
0249 
0250         QTreeWidgetItem* const audEnc = new QTreeWidgetItem(ffmpegEntry, QStringList() << i18nc("@item: component info", "Audio Encoders"));
0251 
0252         for (FFMpegProperties::const_iterator it = propsAud.constBegin() ; it != propsAud.constEnd() ; ++it)
0253         {
0254             QStringList vals = it.value();
0255 
0256             if ((vals.size() > 2) && (vals[2] == QLatin1String("W")))
0257             {
0258                 new QTreeWidgetItem(audEnc, QStringList() << it.key() << vals[0]);
0259             }
0260         }
0261 
0262         // --- FFMPEG supported extensions ---
0263 
0264         FFMpegProperties propsExt       = FFMpegConfigHelper::getExtensionsProperties();
0265         QTreeWidgetItem* const extEntry = new QTreeWidgetItem(ffmpegEntry, QStringList() << i18nc("@item: component info", "Supported Extensions"));
0266 
0267         for (FFMpegProperties::const_iterator it = propsExt.constBegin() ; it != propsExt.constEnd() ; ++it)
0268         {
0269             if (!it.value().isEmpty())
0270             {
0271                 new QTreeWidgetItem(extEntry, QStringList() << it.key() << it.value()[0]);
0272             }
0273         }
0274 
0275 #endif
0276 
0277     }
0278 
0279     ~ComponentsInfoDlg()
0280     {
0281     }
0282 };
0283 
0284 // --------------------------------------------------------
0285 
0286 void showDigikamComponentsInfo()
0287 {
0288     ComponentsInfoDlg* const dlg = new ComponentsInfoDlg(qApp->activeWindow());
0289     dlg->show();
0290 }
0291 
0292 void showDigikamDatabaseStat()
0293 {
0294     DBStatDlg* const dlg = new DBStatDlg(qApp->activeWindow());
0295     dlg->show();
0296 }
0297 
0298 } // namespace Digikam
0299 
0300 #include "componentsinfodlg.moc"