not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / kxkb / kxkb_applet.cpp
blob87bee39bcd4d831ed65de0911276e0c486c5d3c8
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 <QWidget>
20 #include <QSizeF>
21 #include <QMenu>
23 #include <kglobal.h>
24 #include <klocale.h>
26 #include <plasma/widgets/boxlayout.h>
28 #include "kxkbwidget.h"
29 #include "kxkbcore.h"
30 #include "kxkb_applet.h"
33 // Plasma widget
35 KxkbPlasmaWidget::KxkbPlasmaWidget(QGraphicsItem* parent, int controlType) :
36 KxkbWidget(controlType),
37 m_displayMode(ICON)
39 // if( controlType == ICON )
40 m_indicatorWidget = new Plasma::Icon(parent);
41 m_indicatorWidget->setIconSize(32,32);
42 connect(m_indicatorWidget, SIGNAL(clicked()), this, SIGNAL(iconToggled()));
43 // else
44 // m_indicatorWidget = new Plasma::PushButton(parent);
45 m_menu = new QMenu(NULL); // TODO: proper parent
49 // Plasma applet
51 KxkbApplet::KxkbApplet(QObject *parent, const QVariantList &args)
52 : Plasma::Applet(parent, args)
54 m_kxkbCore = new KxkbCore(KxkbCore::KXKB_COMPONENT);
55 if( m_kxkbCore->newInstance() < 0 ) {
56 setFailedToLaunch(true);
58 else {
59 new Plasma::HBoxLayout(this);
60 setDrawStandardBackground(true);
61 KxkbWidget* kxkbWidget = new KxkbPlasmaWidget(this, KxkbWidget::MENU_FULL);
62 m_kxkbCore->setWidget(kxkbWidget);
63 // m_kxkbWidget = kxkbWidget;
65 //setCustomMenu(widget->history()->popup());
66 //centerWidget();
67 //kxkbWidget->show();
70 KxkbApplet::~KxkbApplet()
72 if (failedToLaunch()) {
73 delete m_kxkbCore;
74 // Do some cleanup here
75 } else {
76 // Save settings
80 QSizeF KxkbApplet::contentSizeHint() const
82 // return QSizeF(m_kxkbCore->size());
83 return QSizeF(32,32);
86 void KxkbApplet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *option,
87 const QRect& contentsRect)
89 // Q_UNUSED(option);
91 ((KxkbPlasmaWidget*)m_kxkbWidget)->widget()->paint(painter, option, NULL);
95 #include "kxkb_applet.moc"