File indexing completed on 2025-01-19 04:46:40
0001 /* 0002 SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "nonbreakingspaceplugineditorinterface.h" 0008 #include <KActionCollection> 0009 #include <KLocalizedString> 0010 #include <QAction> 0011 #include <TextCustomEditor/RichTextEditor> 0012 0013 NonBreakingSpacePluginEditorInterface::NonBreakingSpacePluginEditorInterface(QObject *parent) 0014 : MessageComposer::PluginEditorInterface(parent) 0015 { 0016 } 0017 0018 NonBreakingSpacePluginEditorInterface::~NonBreakingSpacePluginEditorInterface() = default; 0019 0020 void NonBreakingSpacePluginEditorInterface::createAction(KActionCollection *ac) 0021 { 0022 auto action = new QAction(i18n("Insert Non Breaking Space"), this); 0023 ac->addAction(QStringLiteral("insert_non_breaking_space"), action); 0024 ac->setDefaultShortcut(action, Qt::CTRL | Qt::Key_Space); 0025 connect(action, &QAction::triggered, this, &NonBreakingSpacePluginEditorInterface::slotActivated); 0026 MessageComposer::PluginActionType type(action, MessageComposer::PluginActionType::Insert); 0027 setActionType(type); 0028 } 0029 0030 void NonBreakingSpacePluginEditorInterface::slotActivated() 0031 { 0032 Q_EMIT emitPluginActivated(this); 0033 } 0034 0035 void NonBreakingSpacePluginEditorInterface::exec() 0036 { 0037 richTextEditor()->insertPlainText(QChar(0x000A0)); 0038 } 0039 0040 #include "moc_nonbreakingspaceplugineditorinterface.cpp"