Commit 02e1cd6a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Implement "KMailPluginCheckBeforeDeletingManagerInterface"

parent 2255a5d1
......@@ -65,7 +65,7 @@ option(KDEPIM_RUN_AKONADI_TEST "Enable autotest based on Akonadi." TRUE)
find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED DBus Network Test Widgets WebEngine WebEngineWidgets)
set(LIBGRAVATAR_VERSION "5.17.40")
set(MAILCOMMON_LIB_VERSION "5.17.40")
set(MESSAGELIB_LIB_VERSION "5.17.52")
set(MESSAGELIB_LIB_VERSION "5.17.56")
set(LIBKLEO_LIB_VERSION "5.17.40")
set(PIMCOMMON_LIB_VERSION "5.17.40")
set(LIBKDEPIM_LIB_VERSION "5.17.40")
......
......@@ -136,6 +136,7 @@ target_sources(kmailprivate PRIVATE
tag/tagselectdialog.cpp
tag/tagmonitormanager.cpp
plugininterface/kmailplugininterface.cpp
plugininterface/kmailplugincheckbeforedeletingmanagerinterface.cpp
editor/plugininterface/kmailplugineditormanagerinterface.cpp
editor/plugininterface/kmailplugineditorcheckbeforesendmanagerinterface.cpp
editor/plugininterface/kmailplugineditorinitmanagerinterface.cpp
......
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "kmailplugincheckbeforedeletingmanagerinterface.h"
#include "kmail_debug.h"
#include <MessageViewer/MessageViewerCheckBeforeDeletingInterface>
#include <MessageViewer/MessageViewerCheckBeforeDeletingPlugin>
#include <MessageViewer/MessageViewerCheckBeforeDeletingPluginManager>
KMailPluginCheckBeforeDeletingManagerInterface::KMailPluginCheckBeforeDeletingManagerInterface(QObject *parent)
: QObject(parent)
{
}
KMailPluginCheckBeforeDeletingManagerInterface::~KMailPluginCheckBeforeDeletingManagerInterface()
{
}
void KMailPluginCheckBeforeDeletingManagerInterface::initializePlugins()
{
if (mWasInitialized) {
qCDebug(KMAIL_LOG) << "KMailPluginCheckBeforeDeletingManagerInterface : Plugin was already initialized. This is a bug";
return;
}
if (!mParentWidget) {
qCDebug(KMAIL_LOG) << "KMailPluginCheckBeforeDeletingManagerInterface : Parent is null. This is a bug";
}
const QVector<MessageViewer::MessageViewerCheckBeforeDeletingPlugin *> lstPlugin =
MessageViewer::MessageViewerCheckBeforeDeletingPluginManager::self()->pluginsList();
for (MessageViewer::MessageViewerCheckBeforeDeletingPlugin *plugin : lstPlugin) {
if (plugin->isEnabled()) {
auto interface = static_cast<MessageViewer::MessageViewerCheckBeforeDeletingInterface *>(plugin->createInterface(this));
interface->setParentWidget(mParentWidget);
}
}
mWasInitialized = true;
}
QWidget *KMailPluginCheckBeforeDeletingManagerInterface::parentWidget() const
{
return mParentWidget;
}
void KMailPluginCheckBeforeDeletingManagerInterface::setParentWidget(QWidget *newParentWidget)
{
mParentWidget = newParentWidget;
}
/*
SPDX-FileCopyrightText: 2021 Laurent Montel <montel@kde.org>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include <QObject>
class KMailPluginCheckBeforeDeletingManagerInterface : public QObject
{
Q_OBJECT
public:
explicit KMailPluginCheckBeforeDeletingManagerInterface(QObject *parent = nullptr);
~KMailPluginCheckBeforeDeletingManagerInterface() override;
void initializePlugins();
Q_REQUIRED_RESULT QWidget *parentWidget() const;
void setParentWidget(QWidget *newParentWidget);
private:
QWidget *mParentWidget = nullptr;
bool mWasInitialized = false;
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment