KDE/kdebase/workspace/plasma/applets/battery
Sebastian Kügler
sebas at kde.org
Thu Sep 18 03:11:37 CEST 2008
SVN commit 862081 by sebas:
Use an extender.
I'm still not getting the popup to pop up, out of ideas for now.
Maybe someone else can have a look, I'm kind of stuck.
CCMAIL:plasma-devel at kde.org
M +25 -3 battery.cpp
M +2 -0 battery.h
--- trunk/KDE/kdebase/workspace/plasma/applets/battery/battery.cpp #862080:862081
@@ -40,6 +40,8 @@
#include <plasma/svg.h>
#include <plasma/theme.h>
#include <plasma/animator.h>
+#include <plasma/extender.h>
+#include <plasma/extenderitem.h>
#include <plasma/popupapplet.h>
#include <plasma/widgets/label.h>
#include <plasma/widgets/slider.h>
@@ -61,7 +63,7 @@
m_numOfBattery(0)
{
kDebug() << "Loading applet battery";
- setAcceptsHoverEvents(true);
+ //setAcceptsHoverEvents(true);
setHasConfigurationInterface(true);
setPopupIcon(QIcon());
resize(128, 128);
@@ -72,6 +74,10 @@
void Battery::init()
{
+ new Plasma::Extender(this);
+ extender()->setEmptyExtenderMessage(i18n("no running jobs..."));
+ extender()->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
+
KConfigGroup cg = config();
m_showBatteryString = cg.readEntry("showBatteryString", false);
m_showMultipleBatteries = cg.readEntry("showMultipleBatteries", true);
@@ -109,6 +115,12 @@
dataUpdated(I18N_NOOP("AC Adapter"), dataEngine("powermanagement")->query(I18N_NOOP("AC Adapter")));
m_numOfBattery = battery_sources.size();
kDebug() << battery_sources.size();
+
+ if (!extender()->item("powermanagement")) {
+ Plasma::ExtenderItem *eItem = new Plasma::ExtenderItem(extender());
+ eItem->setName("powermanagement");
+ initExtenderItem(eItem);
+ }
}
void Battery::constraintsEvent(Plasma::Constraints constraints)
@@ -271,7 +283,14 @@
QGraphicsWidget *Battery::graphicsWidget()
{
- QGraphicsWidget *controls= new QGraphicsWidget(this);
+ kDebug();
+ return extender();
+}
+
+void Battery::initExtenderItem(Plasma::ExtenderItem *item)
+{
+ kDebug();
+ QGraphicsWidget *controls = new QGraphicsWidget(item);
QGraphicsLinearLayout *controlsLayout = new QGraphicsLinearLayout(controls);
controlsLayout->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -292,7 +311,10 @@
controls->setLayout(controlsLayout);
- return controls;
+ item->setWidget(controls);
+ item->setTitle(i18n("Power Management"));
+
+
}
void Battery::showLabel(bool show)
--- trunk/KDE/kdebase/workspace/plasma/applets/battery/battery.h #862080:862081
@@ -34,6 +34,7 @@
namespace Plasma
{
class Svg;
+ class ExtenderItem;
}
class Battery : public Plasma::PopupApplet
@@ -64,6 +65,7 @@
protected:
void createConfigurationInterface(KConfigDialog *parent);
QGraphicsWidget *graphicsWidget();
+ void initExtenderItem(Plasma::ExtenderItem *item);
private slots:
void animationUpdate(qreal progress);
More information about the Plasma-devel
mailing list