From 27e7860fd95f2af8beda0ce3584babc96126ac4e Mon Sep 17 00:00:00 2001 From: 0xd34df00d <0xd34df00d@gmail.com> Date: Wed, 21 May 2014 00:08:13 +0400 Subject: [PATCH] ColorSchemeManager::loadCustomColorScheme(const QString& path). --- lib/ColorScheme.cpp | 11 +++++++++++ lib/ColorScheme.h | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/ColorScheme.cpp b/lib/ColorScheme.cpp index 756aa55..fc17cad 100644 --- a/lib/ColorScheme.cpp +++ b/lib/ColorScheme.cpp @@ -639,6 +639,17 @@ void ColorSchemeManager::addColorScheme(ColorScheme* scheme) scheme->write(config); } #endif + +bool ColorSchemeManager::loadCustomColorScheme(const QString& path) +{ + if (path.endsWith(QLatin1String(".colorscheme"))) + return loadColorScheme(path); + else if (path.endsWith(QLatin1String(".schema"))) + return loadKDE3ColorScheme(path); + else + return false; +} + bool ColorSchemeManager::loadColorScheme(const QString& filePath) { if ( !filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath) ) diff --git a/lib/ColorScheme.h b/lib/ColorScheme.h index dd1830f..3b5c211 100644 --- a/lib/ColorScheme.h +++ b/lib/ColorScheme.h @@ -314,6 +314,19 @@ public: /** Returns the global color scheme manager instance. */ static ColorSchemeManager* instance(); + /** @brief Loads a custom color scheme under given \em path. + * + * The \em path may refer to either KDE 4 .colorscheme or KDE 3 + * .schema file + * + * The loaded color scheme is available under the name equal to + * the base name of the \em path via the allColorSchemes() and + * findColorScheme() methods after this call if loaded successfully. + * + * @param[in] path The path to KDE 4 .colorscheme or KDE 3 .schema. + * @return Whether the color scheme is loaded successfully. + */ + bool loadCustomColorScheme(const QString& path); private: // loads a color scheme from a KDE 4+ .colorscheme file bool loadColorScheme(const QString& path);