aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qmmpui/uiloader.cpp31
-rw-r--r--src/qmmpui/uiloader.h16
2 files changed, 39 insertions, 8 deletions
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<UiFactory *> 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();
@@ -73,11 +84,21 @@ 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 <QString>
+#include <QStringList>
#include <QList>
#include <QObject>
#include "uifactory.h"
class QmmpUiPluginCache;
-/*! @brief The UiLoader provides user interface plugins access
+/*! @brief The UiLoader provides user interface plugins access.
* @author Ilya Kotov <forkotov02@hotmail.ru>
*/
class UiLoader
@@ -38,6 +39,10 @@ public:
*/
static QList<UiFactory*> 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();