not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / kxkb / kxkb_part.cpp
blobdbaf4a1bfe9a995b8348e8fe2a00912fff950748
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 <kshortcut.h>
28 #include "kxkb_part.h"
29 #include "kxkbwidget.h"
30 #include "kxkbcore.h"
33 K_PLUGIN_FACTORY(KxkbPartFactory, registerPlugin<KxkbPart>();)
34 K_EXPORT_PLUGIN(KxkbPartFactory("kxkb_part"))
36 KxkbPart::KxkbPart( QWidget* parent,
37 const QList<QVariant>& args )
38 : QWidget(parent)
40 int controlType = KxkbWidget::NO_MENU;
41 /* if( args.count() > 0 && args[0].type() == QVariant::Int ) { //TODO: replace with string?
42 controlType = args[0].toInt();
43 kDebug() << "controlType" << controlType << "(" << args[0] << ")";
44 if( controlType <= 0 ) {
45 kError() << "Wrong type for KxkbPart control";
46 return;
50 m_kxkbCore = new KxkbCore( KxkbCore::KXKB_COMPONENT );
51 if( m_kxkbCore->newInstance() == 0 ) {
52 KxkbLabel* kxkbWidget = new KxkbLabel(controlType, this);
53 m_kxkbCore->setWidget(kxkbWidget);
55 QHBoxLayout *layout = new QHBoxLayout(this);
56 layout->setSpacing( KDialog::spacingHint() );
57 layout->setMargin( 0 );
58 layout->addWidget( kxkbWidget->widget(), 0, Qt::AlignCenter );
60 else {
61 setVisible(false);
65 KxkbPart::~KxkbPart()
67 delete m_kxkbCore;
70 bool
71 KxkbPart::setLayout(const QString& layoutPair)
73 return m_kxkbCore->setLayout(layoutPair);
76 QString
77 KxkbPart::getCurrentLayout()
79 return m_kxkbCore->getCurrentLayout();
82 QStringList
83 KxkbPart::getLayoutsList()
85 return m_kxkbCore->getLayoutsList();
88 void
89 KxkbPart::toggled()
91 m_kxkbCore->toggled();
94 const KShortcut*
95 KxkbPart::getKDEShortcut()
97 return m_kxkbCore->getKDEShortcut();