mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 18:32:50 +00:00
plasma: create batterymonitor applet widget and keyboard applet layout from constructors
Plasma::Applet::init() and Plasma::Applet::constraintsEvent() may be called in order such that the members were not created yet Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
388eeea355
commit
7c6d3bcb45
4 changed files with 8 additions and 20 deletions
|
@ -365,6 +365,8 @@ BatteryMonitor::BatteryMonitor(QObject *parent, const QVariantList &args)
|
|||
{
|
||||
KGlobal::locale()->insertCatalog("plasma_applet_battery");
|
||||
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
||||
m_batterywidget = new BatteryMonitorWidget(this);
|
||||
setPopupIcon(m_batterywidget->batteryUnavailableIcon());
|
||||
}
|
||||
|
||||
BatteryMonitor::~BatteryMonitor()
|
||||
|
@ -374,9 +376,8 @@ BatteryMonitor::~BatteryMonitor()
|
|||
|
||||
void BatteryMonitor::init()
|
||||
{
|
||||
m_batterywidget = new BatteryMonitorWidget(this);
|
||||
setPopupIcon(m_batterywidget->batteryUnavailableIcon());
|
||||
configChanged();
|
||||
QTimer::singleShot(500, m_batterywidget, SLOT(slotUpdateLayout()));
|
||||
}
|
||||
|
||||
QGraphicsWidget* BatteryMonitor::graphicsWidget()
|
||||
|
@ -399,12 +400,5 @@ void BatteryMonitor::saveState(KConfigGroup &group) const
|
|||
Plasma::PopupApplet::saveState(group);
|
||||
}
|
||||
|
||||
void BatteryMonitor::constraintsEvent(Plasma::Constraints constraints)
|
||||
{
|
||||
if (constraints & Plasma::StartupCompletedConstraint) {
|
||||
QTimer::singleShot(1500, m_batterywidget, SLOT(slotUpdateLayout()));
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_batterymonitor.cpp"
|
||||
#include "batterymonitor.moc"
|
||||
|
|
|
@ -40,7 +40,6 @@ public Q_SLOTS:
|
|||
void configChanged();
|
||||
protected:
|
||||
void saveState(KConfigGroup &group) const final;
|
||||
void constraintsEvent(Plasma::Constraints constraints) final;
|
||||
|
||||
private:
|
||||
friend BatteryMonitorWidget;
|
||||
|
|
|
@ -38,10 +38,12 @@ KeyboardApplet::KeyboardApplet(QObject *parent, const QVariantList &args)
|
|||
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
||||
setHasConfigurationInterface(true);
|
||||
setStatus(Plasma::ItemStatus::PassiveStatus);
|
||||
}
|
||||
|
||||
KeyboardApplet::~KeyboardApplet()
|
||||
{
|
||||
m_keyboardlayout = new KKeyboardLayout(this);
|
||||
connect(
|
||||
m_keyboardlayout, SIGNAL(layoutChanged()),
|
||||
this, SLOT(slotLayoutChanged())
|
||||
);
|
||||
}
|
||||
|
||||
void KeyboardApplet::init()
|
||||
|
@ -50,12 +52,6 @@ void KeyboardApplet::init()
|
|||
m_showflag = configgroup.readEntry("showFlag", false);
|
||||
m_showtext = configgroup.readEntry("showText", true);
|
||||
|
||||
m_keyboardlayout = new KKeyboardLayout(this);
|
||||
connect(
|
||||
m_keyboardlayout, SIGNAL(layoutChanged()),
|
||||
this, SLOT(slotLayoutChanged())
|
||||
);
|
||||
|
||||
setGlobalShortcut(KShortcut(Qt::ALT+Qt::CTRL+Qt::Key_K));
|
||||
connect(
|
||||
this, SIGNAL(activate()),
|
||||
|
|
|
@ -31,7 +31,6 @@ class KeyboardApplet : public Plasma::Applet
|
|||
Q_OBJECT
|
||||
public:
|
||||
KeyboardApplet(QObject *parent, const QVariantList &args);
|
||||
~KeyboardApplet();
|
||||
|
||||
// Plasma::Applet reimplementations
|
||||
void init() final;
|
||||
|
|
Loading…
Add table
Reference in a new issue