From 89eea1170e8338cd80bfae61c57739d47bd0d65c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Sat, 24 Sep 2016 10:36:49 +0200 Subject: [PATCH] [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 --- kcmkwin/kwinrules/ruleswidget.cpp | 13 +++++++++++++ kcmkwin/kwinrules/ruleswidget.h | 1 + 2 files changed, 14 insertions(+) diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp index 8d8b8f8f32..ca0ea3b2d0 100644 --- a/kcmkwin/kwinrules/ruleswidget.cpp +++ b/kcmkwin/kwinrules/ruleswidget.cpp @@ -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,); diff --git a/kcmkwin/kwinrules/ruleswidget.h b/kcmkwin/kwinrules/ruleswidget.h index a95428eb4f..7a4e3f27f7 100644 --- a/kcmkwin/kwinrules/ruleswidget.h +++ b/kcmkwin/kwinrules/ruleswidget.h @@ -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; }