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

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2006-12-20
0007  * Description : a widget to display a welcome page
0008  *               on root album.
0009  *
0010  * SPDX-FileCopyrightText: 2006-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  * SPDX-FileCopyrightText: 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com>
0012  * SPDX-FileCopyrightText: 2015      by Mohamed_Anwer <m_dot_anwer at gmx dot com>
0013  *
0014  * SPDX-License-Identifier: GPL-2.0-or-later
0015  *
0016  * ============================================================ */
0017 
0018 #include "welcomepageview.h"
0019 
0020 // Qt includes
0021 
0022 #include <QFile>
0023 #include <QFileInfo>
0024 #include <QTimer>
0025 #include <QApplication>
0026 #include <QStandardPaths>
0027 
0028 #ifdef HAVE_QWEBENGINE
0029 #   include <QtWebEngineWidgetsVersion>
0030 #endif
0031 
0032 // KDE includes
0033 
0034 #include <klocalizedstring.h>
0035 
0036 // Local includes
0037 
0038 #include "digikam_debug.h"
0039 #include "digikam_version.h"
0040 #include "daboutdata.h"
0041 #include "thememanager.h"
0042 #include "webbrowserdlg.h"
0043 
0044 namespace Digikam
0045 {
0046 
0047 #ifdef HAVE_QWEBENGINE
0048 
0049 WelcomePageViewPage::WelcomePageViewPage(QObject* const parent)
0050     : QWebEnginePage(parent)
0051 {
0052 }
0053 
0054 WelcomePageViewPage::~WelcomePageViewPage()
0055 {
0056 }
0057 
0058 bool WelcomePageViewPage::acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool)
0059 {
0060     if (type == QWebEnginePage::NavigationTypeLinkClicked)
0061     {
0062         Q_EMIT linkClicked(url);
0063 
0064         return false;
0065     }
0066 
0067     return true;
0068 }
0069 
0070 // ----------------------------------------------------------------------------
0071 
0072 WelcomePageView::WelcomePageView(QWidget* const parent)
0073     : QWebEngineView(parent)
0074 
0075 #else
0076 
0077 WelcomePageView::WelcomePageView(QWidget* const parent)
0078     : QWebView(parent)
0079 
0080 #endif
0081 
0082 {
0083     setFocusPolicy(Qt::WheelFocus);
0084 
0085 #ifndef HAVE_QWEBENGINE
0086 
0087     page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
0088     setRenderHint(QPainter::TextAntialiasing);
0089 
0090 #endif
0091 
0092     setContextMenuPolicy(Qt::NoContextMenu);
0093     setContentsMargins(QMargins());
0094 
0095 #ifdef HAVE_QWEBENGINE
0096 
0097     WelcomePageViewPage* const wpage = new WelcomePageViewPage(this);
0098     setPage(wpage);
0099 
0100     settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false);
0101     settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false);
0102 
0103 #endif
0104 
0105     // ------------------------------------------------------------
0106 
0107 #ifdef HAVE_QWEBENGINE
0108 
0109     connect(wpage, SIGNAL(linkClicked(QUrl)),
0110             this, SLOT(slotUrlOpen(QUrl)));
0111 
0112 #else
0113 
0114     connect(this, SIGNAL(linkClicked(QUrl)),
0115             this, SLOT(slotUrlOpen(QUrl)));
0116 
0117 #endif
0118 
0119     connect(ThemeManager::instance(), SIGNAL(signalThemeChanged()),
0120             this, SLOT(slotThemeChanged()));
0121 
0122     QTimer::singleShot(0, this, SLOT(slotThemeChanged()));
0123 }
0124 
0125 WelcomePageView::~WelcomePageView()
0126 {
0127 }
0128 
0129 void WelcomePageView::slotUrlOpen(const QUrl& url)
0130 {
0131     WebBrowserDlg* const browser = new WebBrowserDlg(url, qApp->activeWindow());
0132     browser->show();
0133 }
0134 
0135 QStringList WelcomePageView::featuresTabContent() const
0136 {
0137     QStringList newFeatures;
0138     newFeatures << i18n("More than 650 user-reports closed on bugzilla.");
0139     newFeatures << i18n("Port code to Qt6 framework (code still compatible with Qt5 API).");
0140     newFeatures << i18n("Windows Installer is now compiled natively with Microsoft VCPKG tool-chain and use Qt6 and KF6 frameworks.");
0141     newFeatures << i18n("Add JPEG-XL, WEBP, and AVIF export settings everywhere.");
0142     newFeatures << i18n("Add convert to lossless JPEG-XL, WEBP, and AVIF while importing from camera.");
0143     newFeatures << i18n("Add JPEG-XL; WEBP, and AVIF converters in Batch Queue Manager.");
0144     newFeatures << i18n("Versionning: add support of JPEG-XL, HEIF, WEBP, and AVIF as lossless image format to store versionned images in editor.");
0145     newFeatures << i18n("Usability: add hamburger menu to tool-bar if main menu is hidden.");
0146     newFeatures << i18n("Metadata: add new option to write metadata to files with ExifTool backend.");
0147     newFeatures << i18n("Metadata: optional write metadata operations to DNG and RAW files are now always delegated to ExifTool Backend.");
0148     newFeatures << i18n("Metadata: optimize layout of Metadata Edit plugin for a better usability.");
0149     newFeatures << i18n("Metadata: add new options to save and load configuration profiles in Advanced Metadata Settings Panel.");
0150     newFeatures << i18n("Advanced Rename: add increment file counter to sequence numbering from with option [c] or [c,step].");
0151     newFeatures << i18n("Advanced Rename: add random text sequence numbering with option [r].");
0152     newFeatures << i18n("Advanced Rename: add configurable first character for the unique modifier with {unique:n,c}.");
0153     newFeatures << i18n("Advanced Search: add search for items by number of face regions.");
0154     newFeatures << i18n("Advanced Search: add search for items without face regions.");
0155     newFeatures << i18n("Collections: add support for cross-platform network paths.");
0156     newFeatures << i18n("Database: add support for SQLite WAL (Write-Ahead-Logging) mode.");
0157     newFeatures << i18n("Add spell-checking support in caption text widget using KF5::Sonnet component.");
0158     newFeatures << i18n("Add Spellcheck config panel in Settings/Miscellaneous for digiKam and Showfoto.");
0159     newFeatures << i18n("Add online translations support to Alternative Language text editor widget.");
0160     newFeatures << i18n("Add Localize config panel in Settings/Miscellaneous for digiKam and Showfoto.");
0161     newFeatures << i18n("Add settings to list preferred alternative/translated languages in text edit widget.");
0162     newFeatures << i18n("Allow to use Global or Customized Image Quality Sorting settings everywhere.");
0163     newFeatures << i18n("Add Icon-View settings to customize Labels visibility over thumbnails.");
0164     newFeatures << i18n("Add support for float16 (half float) images in the TIFF Loader.");
0165     newFeatures << i18n("Add new maintenance tool to perform <a href=\"https://community.kde.org/GSoc/2022/StatusReports/PhuocKhanhLe\">Aesthetic Detection to classify images using deep learning model</a>.");
0166     newFeatures << i18n("Add new tool <a href=\"https://community.kde.org/GSoC/2022/StatusReports/QuocHungTran\">to perform OCR over scanned text</a>.");
0167     newFeatures << i18n("Queue Manager: add new tool to assign pick label automatically by parsing image quality.");
0168     newFeatures << i18n("Queue Manager: add new tool to assign rating, pick, and color labels in batch.");
0169     newFeatures << i18n("Queue Manager: add new tool to assign titles and captions in batch.");
0170     newFeatures << i18n("Documentation: <a href=\" https://docs.digikam.org/en/index.html\">Rewrite handbook</a> from DocBook to Sphinx/ReStructuredText framework.");
0171     newFeatures << i18n("Update G'MIC-Qt tool to last version 3.2.2 and finalize MacOS port and improve stability of plugin.");
0172     newFeatures << i18n("Update internal RAW engine to last Libraw snapshot 2023-11-21.");
0173     newFeatures << i18n("New RAW features: "
0174                         "Phase One/Leaf IIQ-S v2 support "
0175                         "Canon CR3 filmrolls/RawBurst "
0176                         "Canon CRM (movie) files "
0177                         "Tiled bit-packed (and 16-bit unpacked) DNGs "
0178                         "(non-standard) Deflate-compressed integer DNG files are allowed "
0179                         "Canon EOS R3, R7 and R10 "
0180                         "Fujifilm X-H2S, X-T30 II "
0181                         "OM System OM-1 "
0182                         "Leica M11 "
0183                         "Sony A7-IV (ILCE-7M4) "
0184                         "DJI Mavic 3");
0185 
0186     // Add new features here...
0187 
0188     newFeatures << i18n("...and much more.");
0189 
0190     QString featureItems;
0191 
0192     for (int i = 0 ; i < newFeatures.count() ; ++i)
0193     {
0194         featureItems += i18n("<li>%1</li>\n", newFeatures.at(i));
0195     }
0196 
0197     QString tabHeader  = i18n("New Features");
0198     QString tabContent =
0199         i18n("<h3>%1</h3><ul>%2</ul>",
0200              i18n("Some of the new features in this release of digiKam include (compared to digiKam 7):"),
0201              featureItems);
0202 
0203     return QStringList() << tabHeader << tabContent;
0204 }
0205 
0206 QStringList WelcomePageView::aboutTabContent() const
0207 {
0208     QString tabHeader  = i18n("About");
0209     QString tabContent =
0210         i18n("<h3>%1</h3><h3>%2</h3><ul>%3</ul>",
0211              i18n("digiKam is an open source photo management program designed to import, organize, enhance, search and export your digital images to and from your computer."),
0212              i18n("Currently, you are in the Album view mode of digiKam. Albums are the places where your files are stored, and are identical to the folders on your hard disk."),
0213              i18n("<li>%1</li><li>%2</li>",
0214                   i18n("digiKam has many powerful features which are described in the <a href=\"https://docs.digikam.org/en/index.html\">documentation</a>"),
0215                   i18n("The <a href=\"https://www.digikam.org\">digiKam homepage</a> provides information about new versions of digiKam.")));
0216 
0217     return QStringList() << tabHeader << tabContent;
0218 }
0219 
0220 QByteArray WelcomePageView::fileToString(const QString& aFileName) const
0221 {
0222     QByteArray   result;
0223     QFileInfo    info(aFileName);
0224     unsigned int readLen;
0225     unsigned int len = info.size();
0226     QFile        file(aFileName);
0227 
0228     if (aFileName.isEmpty() || (len == 0)   ||
0229         !info.exists()      || info.isDir() || !info.isReadable() ||
0230         !file.open(QIODevice::Unbuffered|QIODevice::ReadOnly))
0231     {
0232         return QByteArray();
0233     }
0234 
0235     result.resize(len + 2);
0236     readLen = file.read(result.data(), len);
0237     file.close();
0238 
0239     if (result[len-1] != '\n')
0240     {
0241         result[len++] = '\n';
0242         ++readLen;
0243     }
0244 
0245     result[len] = '\0';
0246 
0247     if (readLen < len)
0248     {
0249         return QByteArray();
0250     }
0251 
0252     return result;
0253 }
0254 
0255 void WelcomePageView::slotThemeChanged()
0256 {
0257     QString appTitle         = i18n("digiKam");
0258     QString slogan           = DAboutData::digiKamSlogan();
0259     QString locationHtml     = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("digikam/about/main.html"));
0260     QString content          = QString::fromUtf8(fileToString(locationHtml));
0261 
0262     content                  = content.arg((layoutDirection() == Qt::RightToLeft) ? QLatin1String("rtl") : QLatin1String("ltr")) // For RTL issue. See bug #376438
0263                                       .arg(appTitle)
0264                                       .arg(slogan)
0265                                       .arg(i18n("Welcome to digiKam %1", QLatin1String(digikam_version)))
0266                                       .arg(featuresTabContent().value(0))
0267                                       .arg(aboutTabContent().value(0))
0268                                       .arg(i18n("Background Image Credits"))
0269                                       .arg(featuresTabContent().value(1))
0270                                       .arg(aboutTabContent().value(1))
0271                                       .arg(i18n("Author:"))
0272                                       .arg(i18n("Location:"))
0273                                       .arg(i18n("Date:"))
0274                                       .arg(i18n("Camera:"))
0275                                       .arg(i18n("Lens:"))
0276     ;
0277 
0278     //qCDebug(DIGIKAM_GENERAL_LOG) << content;
0279 
0280     setHtml(content, QUrl::fromLocalFile(locationHtml));
0281 }
0282 
0283 } // namespace Digikam
0284 
0285 #include "moc_welcomepageview.cpp"