File indexing completed on 2025-01-05 03:53:17
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2019-04-02 0007 * Description : plugin to export image as wallpaper. 0008 * 0009 * SPDX-FileCopyrightText: 2019 by Igor Antropov <antropovi at yahoo dot com> 0010 * SPDX-FileCopyrightText: 2019-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "wallpaperplugin.h" 0017 0018 // Qt includes 0019 0020 #include <QPointer> 0021 0022 // KDE includes 0023 0024 #include <klocalizedstring.h> 0025 0026 // Local includes 0027 0028 #include "digikam_debug.h" 0029 #include "wallpaperplugindlg.h" 0030 0031 namespace DigikamGenericWallpaperPlugin 0032 { 0033 0034 WallpaperPlugin::WallpaperPlugin(QObject* const parent) 0035 : DPluginGeneric(parent) 0036 { 0037 } 0038 0039 WallpaperPlugin::~WallpaperPlugin() 0040 { 0041 } 0042 0043 QString WallpaperPlugin::name() const 0044 { 0045 return i18n("Export as wallpaper"); 0046 } 0047 0048 QString WallpaperPlugin::iid() const 0049 { 0050 return QLatin1String(DPLUGIN_IID); 0051 } 0052 0053 QIcon WallpaperPlugin::icon() const 0054 { 0055 return QIcon::fromTheme(QLatin1String("preferences-desktop-wallpaper")); 0056 } 0057 0058 QString WallpaperPlugin::description() const 0059 { 0060 return i18n("A tool to set image as wallpaper"); 0061 } 0062 0063 QString WallpaperPlugin::details() const 0064 { 0065 return i18n("<p>This tool changes background wallpaper to selected image for all desktops.</p>" 0066 "<p>If many images are selected, the first one will be used.</p>" 0067 "<p>If no image is selected, the first one from current album will be used.</p>"); 0068 } 0069 0070 QString WallpaperPlugin::handbookSection() const 0071 { 0072 return QLatin1String("post_processing"); 0073 } 0074 0075 QString WallpaperPlugin::handbookChapter() const 0076 { 0077 return QLatin1String("wall_paper"); 0078 } 0079 0080 QList<DPluginAuthor> WallpaperPlugin::authors() const 0081 { 0082 return QList<DPluginAuthor>() 0083 << DPluginAuthor(QString::fromUtf8("Igor Antropov"), 0084 QString::fromUtf8("antropovi at yahoo dot com"), 0085 QString::fromUtf8("(C) 2019")) 0086 << DPluginAuthor(QString::fromUtf8("Gilles Caulier"), 0087 QString::fromUtf8("caulier dot gilles at gmail dot com"), 0088 QString::fromUtf8("(C) 2019-2021"), 0089 i18n("Author and Maintainer")); 0090 } 0091 0092 void WallpaperPlugin::setup(QObject* const parent) 0093 { 0094 DPluginAction* const ac = new DPluginAction(parent); 0095 ac->setIcon(icon()); 0096 ac->setText(i18nc("@action", "Set as wallpaper")); 0097 ac->setObjectName(QLatin1String("Wallpaper")); 0098 ac->setActionCategory(DPluginAction::GenericTool); 0099 0100 connect(ac, SIGNAL(triggered(bool)), 0101 this, SLOT(slotWallpaper())); 0102 0103 addAction(ac); 0104 } 0105 0106 void WallpaperPlugin::slotWallpaper() 0107 { 0108 DInfoInterface* const iface = infoIface(sender()); 0109 QList<QUrl> images = iface->currentSelectedItems(); 0110 0111 if (images.isEmpty()) 0112 { 0113 images = iface->currentAlbumItems(); 0114 } 0115 0116 if (!images.isEmpty()) 0117 { 0118 0119 #ifndef Q_OS_MACOS 0120 0121 QPointer<WallpaperPluginDlg> dlg = new WallpaperPluginDlg(this); 0122 0123 if (dlg->exec() == QDialog::Accepted) 0124 { 0125 setWallpaper(images[0].toString(), dlg->wallpaperLayout()); 0126 } 0127 0128 #else 0129 0130 setWallpaper(images[0].toString()); 0131 0132 #endif 0133 0134 } 0135 } 0136 0137 } // namespace DigikamGenericWallpaperPlugin 0138 0139 #include "moc_wallpaperplugin.cpp"