Use KPluginLoader to load the decoration config dialog
Straight forward update from KLibrary to KPluginLoader. REVIEW: 115931
This commit is contained in:
parent
b3d3c45149
commit
59d91b9fd3
3 changed files with 28 additions and 25 deletions
|
@ -28,7 +28,6 @@
|
|||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "oxygenconfig.h"
|
||||
#include "oxygenconfig.moc"
|
||||
|
||||
#include "oxygenanimationconfigwidget.h"
|
||||
#include "oxygenconfiguration.h"
|
||||
|
@ -41,19 +40,21 @@
|
|||
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
#include <KPluginFactory>
|
||||
|
||||
//_______________________________________________________________________
|
||||
extern "C"
|
||||
{
|
||||
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
|
||||
{ return ( new Oxygen::Config( conf, parent ) ); }
|
||||
}
|
||||
|
||||
K_PLUGIN_FACTORY(OxygenConfigPlugin, registerPlugin<Oxygen::Config>(QString(), &Oxygen::Config::create); )
|
||||
|
||||
namespace Oxygen
|
||||
{
|
||||
QObject *Config::create(QWidget *parentWidget, QObject *, const QList<QVariant> &)
|
||||
{
|
||||
return new Config(parentWidget);
|
||||
}
|
||||
|
||||
//_______________________________________________________________________
|
||||
Config::Config( KConfig*, QWidget* parent ):
|
||||
Config::Config(QWidget* parent ):
|
||||
QObject( parent )
|
||||
{
|
||||
|
||||
|
@ -174,3 +175,5 @@ namespace Oxygen
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
#include "oxygenconfig.moc"
|
||||
|
|
|
@ -50,11 +50,13 @@ namespace Oxygen {
|
|||
public:
|
||||
|
||||
//! constructor
|
||||
Config( KConfig* conf, QWidget* parent );
|
||||
Config( QWidget* parent );
|
||||
|
||||
//! destructor
|
||||
~Config();
|
||||
|
||||
static QObject *create(QWidget *parentWidget, QObject *parent, const QList<QVariant> &arguments);
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
//! emmited whenever configuration is changed
|
||||
|
|
|
@ -22,10 +22,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
|
||||
#include <KLibrary>
|
||||
#include <KSharedConfig>
|
||||
#include <KLocalizedString>
|
||||
#include <KConfigGroup>
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
|
@ -88,23 +89,20 @@ KWinDecorationConfigDialog::KWinDecorationConfigDialog(QString deco, const QList
|
|||
connect(m_buttons, SIGNAL(accepted()), SLOT(accept()));
|
||||
connect(m_buttons, SIGNAL(rejected()), SLOT(reject()));
|
||||
|
||||
KLibrary library(styleToConfigLib(deco));
|
||||
if (library.load()) {
|
||||
KLibrary::void_function_ptr alloc_ptr = library.resolveFunction("allocate_config");
|
||||
if (alloc_ptr != nullptr) {
|
||||
allocatePlugin = (QObject * (*)(KConfigGroup & conf, QWidget * parent))alloc_ptr;
|
||||
KConfigGroup config(m_kwinConfig, "Style");
|
||||
m_pluginConfigWidget = new QWidget(this);
|
||||
m_pluginConfigWidget->setLayout(new QVBoxLayout);
|
||||
m_pluginObject = (QObject*)(allocatePlugin(config, m_pluginConfigWidget));
|
||||
KPluginLoader loader(styleToConfigLib(deco));
|
||||
KPluginFactory *factory = loader.factory();
|
||||
if (factory) {
|
||||
m_pluginConfigWidget = new QWidget(this);
|
||||
m_pluginConfigWidget->setLayout(new QVBoxLayout);
|
||||
m_pluginObject = factory->create<QObject>(m_pluginConfigWidget, m_pluginConfigWidget, QString(),
|
||||
QVariantList() << QStringLiteral("kwinrc") << QStringLiteral("Style"));
|
||||
|
||||
// connect required signals and slots together...
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
|
||||
connect(m_pluginObject, SIGNAL(changed()), this, SLOT(slotSelectionChanged()));
|
||||
connect(this, SIGNAL(pluginSave(KConfigGroup&)), m_pluginObject, SLOT(save(KConfigGroup&)));
|
||||
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), m_pluginObject, SLOT(defaults()));
|
||||
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), SLOT(slotDefault()));
|
||||
}
|
||||
// connect required signals and slots together...
|
||||
connect(this, SIGNAL(accepted()), this, SLOT(slotAccepted()));
|
||||
connect(m_pluginObject, SIGNAL(changed()), this, SLOT(slotSelectionChanged()));
|
||||
connect(this, SIGNAL(pluginSave(KConfigGroup&)), m_pluginObject, SLOT(save(KConfigGroup&)));
|
||||
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), m_pluginObject, SLOT(defaults()));
|
||||
connect(m_buttons->button(QDialogButtonBox::RestoreDefaults), SIGNAL(clicked(bool)), SLOT(slotDefault()));
|
||||
}
|
||||
|
||||
if (m_pluginConfigWidget) {
|
||||
|
|
Loading…
Reference in a new issue