Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / workspace / kcontrol / kxkb / kxkb_part.cpp
blob09e10ed0bb455a0d04523f4629ed58da78c85395
1 /*
2 * Copyright (C) 2007 Andriy Rysin (rysin@kde.org)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #include <QHBoxLayout>
21 #include <KDialog>
22 #include <KPluginFactory>
23 #include <KPluginLoader>
24 #include <KDebug>
26 #include "kxkb_part.h"
27 #include "kxkbwidget.h"
28 #include "kxkbcore.h"
31 K_PLUGIN_FACTORY(KxkbPartFactory, registerPlugin<KxkbPart>();)
32 K_EXPORT_PLUGIN(KxkbPartFactory("kxkb_part"))
34 KxkbPart::KxkbPart( QWidget* parent,
35 const QList<QVariant>& args )
36 : QWidget(parent)
38 int controlType = KxkbWidget::NO_MENU;
39 /* if( args.count() > 0 && args[0].type() == QVariant::Int ) { //TODO: replace with string?
40 controlType = args[0].toInt();
41 kDebug() << "controlType" << controlType << "(" << args[0] << ")";
42 if( controlType <= 0 ) {
43 kError() << "Wrong type for KxkbPart control";
44 return;
48 m_kxkbCore = new KxkbCore( KxkbCore::KXKB_COMPONENT );
49 if( m_kxkbCore->newInstance() == 0 ) {
50 KxkbLabel* kxkbWidget = new KxkbLabel(controlType, this);
51 m_kxkbCore->setWidget(kxkbWidget);
53 QHBoxLayout *layout = new QHBoxLayout(this);
54 layout->setSpacing( KDialog::spacingHint() );
55 layout->setMargin( 0 );
56 layout->addWidget( kxkbWidget->widget(), 0, Qt::AlignCenter );
58 else {
59 setVisible(false);
63 KxkbPart::~KxkbPart()
65 delete m_kxkbCore;
68 bool
69 KxkbPart::setLayout(const QString& layoutPair)
71 return m_kxkbCore->setLayout(layoutPair);
74 QString
75 KxkbPart::getCurrentLayout()
77 return m_kxkbCore->getCurrentLayout();
80 QStringList
81 KxkbPart::getLayoutsList()
83 return m_kxkbCore->getLayoutsList();