Commit a99455be authored by Elvis Angelaccio's avatar Elvis Angelaccio

Use custom part factory and honour KParts::ReadOnlyPart requests

If we are asked to create an ArkPart of type `KParts::ReadOnlyPart`, we
should honour the request and set the part to read-only. To do so, we
need to use a custom KPluginFactory instead of the default one created
by the `K_PLUGIN_FACTORY` macro.
parent cf5e04c7
set(arkpart_PART_SRCS
part.cpp
infopanel.cpp
arkviewer.cpp
archivemodel.cpp
archivesortfiltermodel.cpp
archiveview.cpp
jobtracker.cpp
overwritedialog.cpp
factory.cpp
part.cpp
infopanel.cpp
arkviewer.cpp
archivemodel.cpp
archivesortfiltermodel.cpp
archiveview.cpp
jobtracker.cpp
overwritedialog.cpp
)
ecm_qt_declare_logging_category(arkpart_PART_SRCS
......
/*
* ark -- archiver for the KDE project
*
* Copyright (c) 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "factory.h"
#include "part.h"
QObject *Factory::create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
{
Q_UNUSED(keyword)
auto part = new Ark::Part(parentWidget, parent, args);
part->setReadWrite(QByteArray(iface) == QByteArray(KParts::ReadWritePart::staticMetaObject.className()));
return part;
}
/*
* ark -- archiver for the KDE project
*
* Copyright (c) 2017 Elvis Angelaccio <elvis.angelaccio@kde.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef FACTORY_H
#define FACTORY_H
#include <KPluginFactory>
class Factory: public KPluginFactory
{
Q_OBJECT
Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE "ark_part.json")
Q_INTERFACES(KPluginFactory)
protected:
QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword) override;
};
#endif
......@@ -81,8 +81,6 @@
using namespace Kerfuffle;
K_PLUGIN_FACTORY_WITH_JSON(Factory, "ark_part.json", registerPlugin<Ark::Part>();)
namespace Ark
{
......
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