[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 val + 1;
}
#ifdef KWIN_BUILD_ACTIVITIES
int RulesWidget::activityToCombo(QString d) const
{
@ -335,8 +336,19 @@ void RulesWidget::updateActivitiesList()
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
static int placementToCombo(Placement::Policy placement)
{
static const int conv[] = {
@ -472,6 +484,7 @@ void RulesWidget::setRules(Rules* rules)
COMBOBOX_SET_RULE(desktop, desktopToCombo);
SPINBOX_SET_RULE(screen, inc);
#ifdef KWIN_BUILD_ACTIVITIES
m_selectedActivityId = rules->activity;
COMBOBOX_SET_RULE(activity, activityToCombo);
#endif
CHECKBOX_SET_RULE(maximizehoriz,);

View file

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