[kwinrules] Properly setting the value of the activity combo box

Summary:
The activities combobox content is loaded asynchronously,
we are storing the configured value for the window rule
until the activity list is loaded into the combo box.
And then, we set that item as the current one in the combo.

Reviewers: #kwin, mart

Reviewed By: mart

Subscribers: luebking, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2851
This commit is contained in:
Ivan Čukić 2016-09-24 10:36:49 +02:00
parent 2ba66b3fc2
commit 89eea1170e
2 changed files with 14 additions and 0 deletions

View file

@ -298,6 +298,7 @@ int RulesWidget::comboToDesktop(int val) const
return NET::OnAllDesktops; return NET::OnAllDesktops;
return val + 1; return val + 1;
} }
#ifdef KWIN_BUILD_ACTIVITIES #ifdef KWIN_BUILD_ACTIVITIES
int RulesWidget::activityToCombo(QString d) const int RulesWidget::activityToCombo(QString d) const
{ {
@ -335,8 +336,19 @@ void RulesWidget::updateActivitiesList()
activity->addItem(info.name(), activityId); activity->addItem(info.name(), activityId);
} }
} }
auto rules = this->rules();
if (rules->activityrule == Rules::UnusedSetRule) {
enable_activity->setChecked(false);
Ui::RulesWidgetBase::activity->setCurrentIndex(0);
} else {
enable_activity->setChecked(true);
Ui::RulesWidgetBase::activity->setCurrentIndex(activityToCombo(m_selectedActivityId));
}
updateEnableactivity();
} }
#endif #endif
static int placementToCombo(Placement::Policy placement) static int placementToCombo(Placement::Policy placement)
{ {
static const int conv[] = { static const int conv[] = {
@ -472,6 +484,7 @@ void RulesWidget::setRules(Rules* rules)
COMBOBOX_SET_RULE(desktop, desktopToCombo); COMBOBOX_SET_RULE(desktop, desktopToCombo);
SPINBOX_SET_RULE(screen, inc); SPINBOX_SET_RULE(screen, inc);
#ifdef KWIN_BUILD_ACTIVITIES #ifdef KWIN_BUILD_ACTIVITIES
m_selectedActivityId = rules->activity;
COMBOBOX_SET_RULE(activity, activityToCombo); COMBOBOX_SET_RULE(activity, activityToCombo);
#endif #endif
CHECKBOX_SET_RULE(maximizehoriz,); CHECKBOX_SET_RULE(maximizehoriz,);

View file

@ -111,6 +111,7 @@ private:
QString comboToActivity(int val) const; QString comboToActivity(int val) const;
void updateActivitiesList(); void updateActivitiesList();
KActivities::Consumer *m_activities; KActivities::Consumer *m_activities;
QString m_selectedActivityId; // we need this for async activity loading
#endif #endif
int comboToTiling(int val) const; int comboToTiling(int val) const;
int inc(int i) const { return i+1; } int inc(int i) const { return i+1; }