[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kwin/Plasma/5.8] kcmkwin/kwinrules: [kwinrules] Properly setting the value of the activity combo bo
From:       Ivan Čukić <ivan.cukic () kde ! org>
Date:       2016-09-24 17:17:25
Message-ID: E1bnqZp-00026l-SR () code ! kde ! org
[Download RAW message or body]

Git commit 5f4a91e8d72e907b6aadf406dceb334682ed8317 by Ivan Čukić.
Committed on 24/09/2016 at 17:17.
Pushed by ivan into branch 'Plasma/5.8'.

[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

M  +13   -0    kcmkwin/kwinrules/ruleswidget.cpp
M  +1    -0    kcmkwin/kwinrules/ruleswidget.h

http://commits.kde.org/kwin/5f4a91e8d72e907b6aadf406dceb334682ed8317

diff --git a/kcmkwin/kwinrules/ruleswidget.cpp b/kcmkwin/kwinrules/ruleswidget.cpp
index 8d8b8f8..ca0ea3b 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 a95428e..7a4e3f2 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; }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic