Changeset View
Changeset View
Standalone View
Standalone View
plugins/sourceformatter/sourceformatterplugin.cpp
Show All 15 Lines | |||||
16 | * License along with this library; if not, write to the Free Software | 16 | * License along with this library; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "sourceformatterplugin.h" | 20 | #include "sourceformatterplugin.h" | ||
21 | 21 | | |||
22 | #include "config/projectconfigpage.h" | 22 | #include "config/projectconfigpage.h" | ||
23 | 23 | | |||
24 | #include <interfaces/icore.h> | ||||
25 | #include <interfaces/isourceformattercontroller.h> | ||||
24 | #include <project/projectconfigpage.h> | 26 | #include <project/projectconfigpage.h> | ||
25 | 27 | | |||
26 | #include <KPluginFactory> | 28 | #include <KPluginFactory> | ||
27 | 29 | | |||
28 | K_PLUGIN_FACTORY_WITH_JSON(SourceFormatterPluginFactory, "kdevsourceformatter.json", registerPlugin<SourceFormatterPlugin>();) | 30 | K_PLUGIN_FACTORY_WITH_JSON(SourceFormatterPluginFactory, "kdevsourceformatter.json", registerPlugin<SourceFormatterPlugin>();) | ||
29 | 31 | | |||
30 | SourceFormatterPlugin::SourceFormatterPlugin(QObject* parent, const QVariantList& args) | 32 | SourceFormatterPlugin::SourceFormatterPlugin(QObject* parent, const QVariantList& args) | ||
31 | : KDevelop::IPlugin(QStringLiteral("kdevsourceformatter"), parent) | 33 | : KDevelop::IPlugin(QStringLiteral("kdevsourceformatter"), parent) | ||
32 | { | 34 | { | ||
33 | Q_UNUSED(args); | 35 | Q_UNUSED(args); | ||
34 | 36 | | |||
35 | } | 37 | } | ||
36 | 38 | | |||
37 | SourceFormatterPlugin::~SourceFormatterPlugin() = default; | 39 | SourceFormatterPlugin::~SourceFormatterPlugin() = default; | ||
38 | 40 | | |||
39 | int SourceFormatterPlugin::perProjectConfigPages() const | 41 | int SourceFormatterPlugin::perProjectConfigPages() const | ||
40 | { | 42 | { | ||
41 | return 1; | 43 | const auto hasFormatters = KDevelop::ICore::self()->sourceFormatterController()->hasFormatters(); | ||
44 | return hasFormatters ? 1 : 0; | ||||
mwolff: why not simply make hasFormatters public, i.e. add it to the sourceFormatterController API? | |||||
I did not dare to also propose changes to the abstract interface yet. But followed your suggestion, added together with signal. kossebau: I did not dare to also propose changes to the abstract interface yet. But followed your… | |||||
42 | } | 45 | } | ||
43 | 46 | | |||
44 | KDevelop::ConfigPage* SourceFormatterPlugin::perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent) | 47 | KDevelop::ConfigPage* SourceFormatterPlugin::perProjectConfigPage(int number, const KDevelop::ProjectConfigOptions& options, QWidget* parent) | ||
45 | { | 48 | { | ||
46 | if (number != 0) { | 49 | if (number != 0) { | ||
47 | return nullptr; | 50 | return nullptr; | ||
48 | } | 51 | } | ||
49 | 52 | | |||
50 | return new SourceFormatter::ProjectConfigPage(this, options.project, parent); | 53 | return new SourceFormatter::ProjectConfigPage(this, options.project, parent); | ||
51 | } | 54 | } | ||
52 | 55 | | |||
53 | // needed for QObject class created from K_PLUGIN_FACTORY_WITH_JSON | 56 | // needed for QObject class created from K_PLUGIN_FACTORY_WITH_JSON | ||
54 | #include "sourceformatterplugin.moc" | 57 | #include "sourceformatterplugin.moc" |
why not simply make hasFormatters public, i.e. add it to the sourceFormatterController API?