File indexing completed on 2024-04-28 04:39:45

0001 /*
0002     SPDX-FileCopyrightText: 2017 Friedrich W. H. Kossebau <kossebau@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-or-later
0005 */
0006 
0007 #include "sourceformatterplugin.h"
0008 
0009 #include "config/projectconfigpage.h"
0010 
0011 #include <interfaces/icore.h>
0012 #include <interfaces/isourceformattercontroller.h>
0013 #include <project/projectconfigpage.h>
0014 
0015 #include <KPluginFactory>
0016 
0017 K_PLUGIN_FACTORY_WITH_JSON(SourceFormatterPluginFactory, "kdevsourceformatter.json", registerPlugin<SourceFormatterPlugin>();)
0018 
0019 SourceFormatterPlugin::SourceFormatterPlugin(QObject* parent, const QVariantList& args)
0020     : KDevelop::IPlugin(QStringLiteral("kdevsourceformatter"), parent)
0021 {
0022     Q_UNUSED(args);
0023 
0024 }
0025 
0026 SourceFormatterPlugin::~SourceFormatterPlugin() = default;
0027 
0028 int SourceFormatterPlugin::perProjectConfigPages() const
0029 {
0030     const auto hasFormatters = KDevelop::ICore::self()->sourceFormatterController()->hasFormatters();
0031     return hasFormatters ? 1 : 0;
0032 }
0033 
0034 KDevelop::ConfigPage* SourceFormatterPlugin::perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent)
0035 {
0036     if (number != 0) {
0037         return nullptr;
0038     }
0039 
0040     return new SourceFormatter::ProjectConfigPage(this, options.project, parent);
0041 }
0042 
0043 // needed for QObject class created from K_PLUGIN_FACTORY_WITH_JSON
0044 #include "sourceformatterplugin.moc"
0045 #include "moc_sourceformatterplugin.cpp"