"fix" activity assignemt by popup menu

problem is that toggleOnActivity interprets "all" as "none" and
subsequent setting of any activity will move the window to that
activity *only* - what's not suggested by the GUI
-> force the user to "hold it correctly" by unchecking all
   individual activities when setting on all - this also matches
   the display when the popup is opened w/ "on all" preselected

CCBUG: 330838

Forward port of 31f9e4cf053f59b7013ff006c86290f86adfcdb5 from kde-workspace
This commit is contained in:
Thomas Lübking 2014-02-06 18:39:07 +01:00 committed by Martin Gräßlin
parent d8dd369f9e
commit d8c9da0cc7

View file

@ -676,6 +676,11 @@ void UserActionsMenu::activityPopupAboutToShow()
QAction *action = m_activityMenu->addAction(i18n("&All Activities")); QAction *action = m_activityMenu->addAction(i18n("&All Activities"));
action->setData(QString()); action->setData(QString());
action->setCheckable(true); action->setCheckable(true);
static QActionGroup *allActivitiesGroup = NULL;
if (!allActivitiesGroup) {
allActivitiesGroup = new QActionGroup(m_activityMenu);
}
allActivitiesGroup->addAction(action);
if (!m_client.isNull() && m_client.data()->isOnAllActivities()) if (!m_client.isNull() && m_client.data()->isOnAllActivities())
action->setChecked(true); action->setChecked(true);
@ -787,7 +792,20 @@ void UserActionsMenu::slotToggleOnActivity(QAction *action)
Activities::self()->toggleClientOnActivity(m_client.data(), activity, false); Activities::self()->toggleClientOnActivity(m_client.data(), activity, false);
if (m_activityMenu && m_activityMenu->isVisible() && m_activityMenu->actions().count()) { if (m_activityMenu && m_activityMenu->isVisible() && m_activityMenu->actions().count()) {
m_activityMenu->actions().at(0)->setChecked(m_client.data()->isOnAllActivities()); const bool isOnAll = m_client.data()->isOnAllActivities();
m_activityMenu->actions().at(0)->setChecked(isOnAll);
if (isOnAll) {
// toggleClientOnActivity interprets "on all" as "on none" and
// susequent toggling ("off") would move the client to only that activity.
// bug #330838 -> set all but "on all" off to "force proper usage"
for (int i = 1; i < m_activityMenu->actions().count(); ++i) {
if (QWidgetAction *qwa = qobject_cast<QWidgetAction*>(m_activityMenu->actions().at(i))) {
if (QCheckBox *qcb = qobject_cast<QCheckBox*>(qwa->defaultWidget())) {
qcb->setChecked(false);
}
}
}
}
} }
#endif #endif
} }