From b5989a764f73a0885303be38c3acd54d2f275946 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 4 Mar 2017 16:30:35 +0000 Subject: improved ui loader git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@7065 90c681e8-e032-0410-971d-27865f9a5e38 --- src/qmmpui/uiloader.cpp | 31 ++++++++++++++++++++++++++----- src/qmmpui/uiloader.h | 16 +++++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/qmmpui/uiloader.cpp b/src/qmmpui/uiloader.cpp index f009927e7..51b1c6456 100644 --- a/src/qmmpui/uiloader.cpp +++ b/src/qmmpui/uiloader.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011-2014 by Ilya Kotov * + * Copyright (C) 2011-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -60,6 +60,17 @@ QList UiLoader::factories() return list; } +QStringList UiLoader::names() const +{ + QStringList out; + loadPlugins(); + foreach(QmmpUiPluginCache *item, *m_cache) + { + out << item->shortName(); + } + return out; +} + QString UiLoader::file(UiFactory *factory) { loadPlugins(); @@ -72,12 +83,22 @@ QString UiLoader::file(UiFactory *factory) } void UiLoader::select(UiFactory* factory) +{ + select(factory->properties().shortName); +} + +void UiLoader::select(const QString &name) { loadPlugins(); - if (!factories().contains(factory)) - return; - QSettings settings (Qmmp::configFile(), QSettings::IniFormat); - settings.setValue ("Ui/current_plugin", factory->properties().shortName); + foreach(QmmpUiPluginCache *item, *m_cache) + { + if(item->shortName() == name) + { + QSettings settings (Qmmp::configFile(), QSettings::IniFormat); + settings.setValue ("Ui/current_plugin", name); + break; + } + } } UiFactory *UiLoader::selected() diff --git a/src/qmmpui/uiloader.h b/src/qmmpui/uiloader.h index 207e6e792..0f7e66c98 100644 --- a/src/qmmpui/uiloader.h +++ b/src/qmmpui/uiloader.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2011-2013 by Ilya Kotov * + * Copyright (C) 2011-2017 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -21,13 +21,14 @@ #define UILOADER_H #include +#include #include #include #include "uifactory.h" class QmmpUiPluginCache; -/*! @brief The UiLoader provides user interface plugins access +/*! @brief The UiLoader provides user interface plugins access. * @author Ilya Kotov */ class UiLoader @@ -37,6 +38,10 @@ public: * Returns a list of the loaded ui plugin factories. */ static QList factories(); + /*! + * Returns a list of the ui plugin short names. + */ + QStringList names() const; /*! * Returns plugin file path. * @param factory User interface plugin factory. @@ -48,7 +53,12 @@ public: */ static void select(UiFactory* factory); /*! - * Returns \b true if general plugin is enabled, otherwise returns \b false + * Selects active user interface. + * @param name Ui plugin factory short name. + */ + static void select(const QString &name); + /*! + * Returns \b true if general plugin is enabled, otherwise returns \b false.- */ static UiFactory *selected(); -- cgit v1.2.3-13-gbd6f