Fixing activities list in the rulewidget
KActivities API is not synchronous anymore. If we want to retrieve the activities, we should do it when we actually get the data. We are listening to the service status changes and activity list changes. REVIEW: 123869 BUG: 347732
This commit is contained in:
parent
1e16ab2567
commit
e44bffa097
2 changed files with 31 additions and 9 deletions
|
@ -149,15 +149,12 @@ RulesWidget::RulesWidget(QWidget* parent)
|
|||
desktop->addItem(i18n("All Desktops"));
|
||||
|
||||
#ifdef KWIN_BUILD_ACTIVITIES
|
||||
static KActivities::Consumer activities;
|
||||
foreach (const QString & activityId, activities.activities()) {
|
||||
const KActivities::Info info(activityId);
|
||||
activity->addItem(info.name(), activityId);
|
||||
}
|
||||
// cloned from kactivities/src/lib/core/consumer.cpp
|
||||
#define NULL_UUID "00000000-0000-0000-0000-000000000000"
|
||||
activity->addItem(i18n("All Activities"), QString::fromLatin1(NULL_UUID));
|
||||
#undef NULL_UUID
|
||||
m_activities = new KActivities::Consumer(this);
|
||||
connect(m_activities, &KActivities::Consumer::activitiesChanged,
|
||||
this, [this] { updateActivitiesList(); });
|
||||
connect(m_activities, &KActivities::Consumer::serviceStatusChanged,
|
||||
this, [this] { updateActivitiesList(); });
|
||||
updateActivitiesList();
|
||||
#endif
|
||||
|
||||
KColorSchemeManager *schemes = new KColorSchemeManager(this);
|
||||
|
@ -320,6 +317,23 @@ QString RulesWidget::comboToActivity(int val) const
|
|||
|
||||
return activity->itemData(val).toString();
|
||||
}
|
||||
|
||||
void RulesWidget::updateActivitiesList()
|
||||
{
|
||||
activity->clear();
|
||||
|
||||
// cloned from kactivities/src/lib/core/consumer.cpp
|
||||
#define NULL_UUID "00000000-0000-0000-0000-000000000000"
|
||||
activity->addItem(i18n("All Activities"), QString::fromLatin1(NULL_UUID));
|
||||
#undef NULL_UUID
|
||||
|
||||
if (m_activities->serviceStatus() == KActivities::Consumer::Running) {
|
||||
foreach (const QString & activityId, m_activities->activities(KActivities::Info::Running)) {
|
||||
const KActivities::Info info(activityId);
|
||||
activity->addItem(info.name(), activityId);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
static int placementToCombo(Placement::Policy placement)
|
||||
{
|
||||
|
|
|
@ -29,6 +29,12 @@
|
|||
#include "ui_ruleswidgetbase.h"
|
||||
#include "ui_editshortcut.h"
|
||||
|
||||
#ifdef KWIN_BUILD_ACTIVITIES
|
||||
namespace KActivities {
|
||||
class Consumer;
|
||||
} // namespace KActivities
|
||||
#endif
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -102,6 +108,8 @@ private:
|
|||
#ifdef KWIN_BUILD_ACTIVITIES
|
||||
int activityToCombo(QString d) const;
|
||||
QString comboToActivity(int val) const;
|
||||
void updateActivitiesList();
|
||||
KActivities::Consumer *m_activities;
|
||||
#endif
|
||||
int comboToTiling(int val) const;
|
||||
int inc(int i) const { return i+1; }
|
||||
|
|
Loading…
Reference in a new issue