Warning, file /office/calligra/libs/flake/KoToolRegistry.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
0003  * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Library General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Library General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Library General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #include "KoToolRegistry.h"
0022 
0023 #include <FlakeDebug.h>
0024 #include <kconfiggroup.h>
0025 #include <ksharedconfig.h>
0026 
0027 #include "tools/KoCreateShapesToolFactory.h"
0028 #include "tools/KoCreateShapesTool.h"
0029 #include "tools/KoPathToolFactory.h"
0030 #include "tools/KoZoomTool.h"
0031 #include "tools/KoZoomToolFactory.h"
0032 #include "tools/KoPanTool.h"
0033 #include "tools/KoPanToolFactory.h"
0034 #include "KoToolManager.h"
0035 #include <KoPluginLoader.h>
0036 
0037 #include <QGlobalStatic>
0038 
0039 Q_GLOBAL_STATIC(KoToolRegistry, s_instance)
0040 
0041 KoToolRegistry::KoToolRegistry()
0042   : d(0)
0043 {
0044 }
0045 
0046 void KoToolRegistry::init()
0047 {
0048     KoPluginLoader::PluginsConfig config;
0049     config.group = "calligra";
0050     config.whiteList = "ToolPlugins";
0051     config.blacklist = "ToolPluginsDisabled";
0052     KoPluginLoader::load(QStringLiteral("calligra/tools"), config);
0053 
0054     // register generic tools
0055     add(new KoCreateShapesToolFactory());
0056     add(new KoPathToolFactory());
0057     add(new KoZoomToolFactory());
0058     add(new KoPanToolFactory());
0059 
0060     KConfigGroup cfg =  KSharedConfig::openConfig()->group("calligra");
0061     QStringList toolsBlacklist = cfg.readEntry("ToolsBlacklist", QStringList());
0062     foreach (const QString& toolID, toolsBlacklist) {
0063         delete value(toolID);
0064         remove(toolID);
0065     }
0066 }
0067 
0068 KoToolRegistry::~KoToolRegistry()
0069 {
0070     qDeleteAll(doubleEntries());
0071     qDeleteAll(values());
0072 }
0073 
0074 KoToolRegistry* KoToolRegistry::instance()
0075 {
0076     if (!s_instance.exists()) {
0077         s_instance->init();
0078     }
0079     return s_instance;
0080 }
0081 
0082 void KoToolRegistry::addDeferred(KoToolFactoryBase *toolFactory)
0083 {
0084     add(toolFactory);
0085     KoToolManager::instance()->addDeferredToolFactory(toolFactory);
0086 }