Warning, file /office/calligra/libs/flake/KoDockRegistry.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  *
0004  * This library is free software; you can redistribute it and/or
0005  * modify it under the terms of the GNU Library General Public
0006  * License as published by the Free Software Foundation; either
0007  * version 2 of the License, or (at your option) any later version.
0008  *
0009  * This library is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * Library General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU Library General Public License
0015  * along with this library; see the file COPYING.LIB.  If not, write to
0016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017  * Boston, MA 02110-1301, USA.
0018  */
0019 
0020 #include "KoDockRegistry.h"
0021 
0022 #include <QGlobalStatic>
0023 #include <QFontDatabase>
0024 #include <QDebug>
0025 
0026 #include <ksharedconfig.h>
0027 #include <kconfiggroup.h>
0028 
0029 #include "KoPluginLoader.h"
0030 
0031 Q_GLOBAL_STATIC(KoDockRegistry, s_instance)
0032 
0033 KoDockRegistry::KoDockRegistry()
0034   : d(0)
0035 {
0036 }
0037 
0038 void KoDockRegistry::init()
0039 {
0040     KoPluginLoader::PluginsConfig config;
0041     config.whiteList = "DockerPlugins";
0042     config.blacklist = "DockerPluginsDisabled";
0043     config.group = "calligra";
0044     KoPluginLoader::load(QStringLiteral("calligra/dockers"), config);
0045 }
0046 
0047 KoDockRegistry::~KoDockRegistry()
0048 {
0049     qDeleteAll(doubleEntries());
0050     qDeleteAll(values());
0051 }
0052 
0053 KoDockRegistry* KoDockRegistry::instance()
0054 {
0055 
0056     if (!s_instance.exists()) {
0057         s_instance->init();
0058     }
0059     return s_instance;
0060 }
0061 
0062 QFont KoDockRegistry::dockFont()
0063 {
0064     KConfigGroup group( KSharedConfig::openConfig(), "GUI");
0065     QFont dockWidgetFont = QFontDatabase::systemFont(QFontDatabase::GeneralFont);
0066     QFont smallFont = QFontDatabase::systemFont(QFontDatabase::SmallestReadableFont);
0067 
0068     int pointSize = group.readEntry("palettefontsize", dockWidgetFont.pointSize());
0069 
0070     // Not set by the user
0071     if (pointSize == dockWidgetFont.pointSize()) {
0072         // and there is no setting for the smallest readable font, calculate something small
0073         if (smallFont.pointSize() >= pointSize) {
0074             smallFont.setPointSizeF(pointSize * 0.9);
0075         }
0076     }
0077     else {
0078         // paletteFontSize was set, use that
0079         smallFont.setPointSize(pointSize);
0080     }
0081     return smallFont;
0082 }