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>
22 #include <KPluginFactory>
23 #include <KPluginLoader>
26 #include <kshortcut.h>
28 #include "kxkb_part.h"
29 #include "kxkbwidget.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
)
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";
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
);
71 KxkbPart::setLayout(const QString
& layoutPair
)
73 return m_kxkbCore
->setLayout(layoutPair
);
77 KxkbPart::getCurrentLayout()
79 return m_kxkbCore
->getCurrentLayout();
83 KxkbPart::getLayoutsList()
85 return m_kxkbCore
->getLayoutsList();
91 m_kxkbCore
->toggled();
95 KxkbPart::getKDEShortcut()
97 return m_kxkbCore
->getKDEShortcut();