File indexing completed on 2025-01-19 03:51:07
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2018-07-30 0007 * Description : image editor plugin to insert text 0008 * 0009 * SPDX-FileCopyrightText: 2018-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 "inserttexttoolplugin.h" 0016 0017 // Qt includes 0018 0019 #include <QPointer> 0020 0021 // KDE includes 0022 0023 #include <klocalizedstring.h> 0024 0025 // Local includes 0026 0027 #include "editorwindow.h" 0028 #include "inserttexttool.h" 0029 0030 namespace DigikamEditorInsertTextToolPlugin 0031 { 0032 0033 InsertTextToolPlugin::InsertTextToolPlugin(QObject* const parent) 0034 : DPluginEditor(parent) 0035 { 0036 } 0037 0038 InsertTextToolPlugin::~InsertTextToolPlugin() 0039 { 0040 } 0041 0042 QString InsertTextToolPlugin::name() const 0043 { 0044 return i18nc("@title", "Insert Text"); 0045 } 0046 0047 QString InsertTextToolPlugin::iid() const 0048 { 0049 return QLatin1String(DPLUGIN_IID); 0050 } 0051 0052 QIcon InsertTextToolPlugin::icon() const 0053 { 0054 return QIcon::fromTheme(QLatin1String("insert-text")); 0055 } 0056 0057 QString InsertTextToolPlugin::description() const 0058 { 0059 return i18nc("@info", "A tool to insert text over an image"); 0060 } 0061 0062 QString InsertTextToolPlugin::details() const 0063 { 0064 return i18nc("@info", "This Image Editor tool can insert text over an image."); 0065 } 0066 0067 QString InsertTextToolPlugin::handbookSection() const 0068 { 0069 return QLatin1String("image_editor"); 0070 } 0071 0072 QString InsertTextToolPlugin::handbookChapter() const 0073 { 0074 return QLatin1String("decorate_tools"); 0075 } 0076 0077 QString InsertTextToolPlugin::handbookReference() const 0078 { 0079 return QLatin1String("decorate-inserttext"); 0080 } 0081 0082 QList<DPluginAuthor> InsertTextToolPlugin::authors() const 0083 { 0084 return QList<DPluginAuthor>() 0085 << DPluginAuthor(QString::fromUtf8("Marcel Wiesweg"), 0086 QString::fromUtf8("marcel dot wiesweg at gmx dot de"), 0087 QString::fromUtf8("(C) 2006-2012")) 0088 << DPluginAuthor(QString::fromUtf8("Gilles Caulier"), 0089 QString::fromUtf8("caulier dot gilles at gmail dot com"), 0090 QString::fromUtf8("(C) 2005-2021")) 0091 ; 0092 } 0093 0094 void InsertTextToolPlugin::setup(QObject* const parent) 0095 { 0096 DPluginAction* const ac = new DPluginAction(parent); 0097 ac->setIcon(icon()); 0098 ac->setText(i18nc("@action", "Insert Text...")); 0099 ac->setObjectName(QLatin1String("editorwindow_decorate_inserttext")); 0100 ac->setShortcut(Qt::CTRL | Qt::SHIFT | Qt::Key_T); 0101 ac->setActionCategory(DPluginAction::EditorDecorate); 0102 0103 connect(ac, SIGNAL(triggered(bool)), 0104 this, SLOT(slotInsertText())); 0105 0106 addAction(ac); 0107 } 0108 0109 void InsertTextToolPlugin::slotInsertText() 0110 { 0111 EditorWindow* const editor = dynamic_cast<EditorWindow*>(sender()->parent()); 0112 0113 if (editor) 0114 { 0115 InsertTextTool* const tool = new InsertTextTool(editor); 0116 tool->setPlugin(this); 0117 editor->loadTool(tool); 0118 } 0119 } 0120 0121 } // namespace DigikamEditorInsertTextToolPlugin 0122 0123 #include "moc_inserttexttoolplugin.cpp"