Adding a screen menu to the Client's useraction menu

New "Move To Screen" menu is shown after the "Move To Desktop"
menu if there are multiple screens and the window can be moved
to another screen. Menu contains one radio button for each
screen.

Selecting an entry sends the Client to the selected screen.

BUG: 269207
FIXED-IN: 4.10
REVIEW: 106065
This commit is contained in:
Martin Gräßlin 2012-08-17 22:32:06 +02:00
parent e8e6345290
commit 5042ca2bdc
3 changed files with 74 additions and 0 deletions

View file

@ -214,6 +214,7 @@ void Workspace::discardPopup()
delete popup;
popup = NULL;
desk_popup = NULL;
screen_popup = NULL;
activity_popup = NULL;
switch_to_tab_popup = NULL;
add_tabs_popup = NULL;
@ -251,6 +252,12 @@ void Workspace::clientPopupAboutToShow()
} else {
initDesktopPopup();
}
if (numScreens() == 1 || (!active_popup_client->isMovable() && !active_popup_client->isMovableAcrossScreens())) {
delete screen_popup;
screen_popup = NULL;
} else {
initScreenPopup();
}
#ifdef KWIN_BUILD_ACTIVITIES
updateActivityList(true, false, "showHideActivityMenu");
#endif
@ -407,6 +414,23 @@ void Workspace::initDesktopPopup()
action->setText(i18n("Move To &Desktop"));
}
void Workspace::initScreenPopup()
{
if (screen_popup) {
return;
}
screen_popup = new QMenu(popup);
screen_popup->setFont(KGlobalSettings::menuFont());
connect(screen_popup, SIGNAL(triggered(QAction*)), SLOT(slotSendToScreen(QAction*)));
connect(screen_popup, SIGNAL(aboutToShow()), SLOT(screenPopupAboutToShow()));
QAction *action = screen_popup->menuAction();
// set it as the first item after desktop
popup->insertAction(activity_popup ? activity_popup->menuAction() : mMinimizeOpAction, action);
action->setText(i18n("Move To &Screen"));
}
/*!
Creates activity popup.
I'm going with checkable ones instead of "copy to" and "move to" menus; I *think* it's an easier way.
@ -474,6 +498,33 @@ void Workspace::desktopPopupAboutToShow()
action->setEnabled(false);
}
/*!
Adjusts the screen popup to the current values and the location of
the popup client.
*/
void Workspace::screenPopupAboutToShow()
{
if (!screen_popup) {
return;
}
screen_popup->clear();
QActionGroup *group = new QActionGroup(screen_popup);
for (int i = 0; i<numScreens(); ++i) {
// TODO: retrieve the screen name?
// assumption: there are not more than 9 screens attached.
QAction *action = screen_popup->addAction(i18nc("@item:inmenu List of all Screens to send a window to",
"Screen &%1", (i+1)));
action->setData(i);
action->setCheckable(true);
if (active_popup_client && i == active_popup_client->screen()) {
action->setChecked(true);
}
group->addAction(action);
}
}
/*!
Adjusts the activity popup to the current values and the location of
the popup client.
@ -1403,6 +1454,24 @@ void Workspace::slotSendToDesktop(QAction *action)
}
/*!
Sends the popup client to screen \a screen
Internal slot for the window operation menu
*/
void Workspace::slotSendToScreen(QAction *action)
{
const int screen = action->data().toInt();
if (!active_popup_client) {
return;
}
if (screen >= numScreens()) {
return;
}
sendClientToScreen(active_popup_client, screen);
}
/*!
Toggles whether the popup client is on the \a activity

View file

@ -131,6 +131,7 @@ Workspace::Workspace(bool restore)
, popup(0)
, advanced_popup(0)
, desk_popup(0)
, screen_popup(NULL)
, activity_popup(0)
, add_tabs_popup(0)
, switch_to_tab_popup(0)

View file

@ -633,9 +633,11 @@ private slots:
void entabPopupClient(QAction*);
void selectPopupClientTab(QAction*);
void desktopPopupAboutToShow();
void screenPopupAboutToShow();
void activityPopupAboutToShow();
void clientPopupAboutToShow();
void slotSendToDesktop(QAction*);
void slotSendToScreen(QAction*);
void slotToggleOnActivity(QAction*);
void clientPopupActivated(QAction*);
void configureWM();
@ -716,6 +718,7 @@ private:
void init();
void initShortcuts();
void initDesktopPopup();
void initScreenPopup();
void initActivityPopup();
void initTabbingPopups();
void restartKWin(const QString &reason);
@ -843,6 +846,7 @@ private:
QMenu* popup;
QMenu* advanced_popup;
QMenu* desk_popup;
QMenu* screen_popup;
QMenu* activity_popup;
QMenu* add_tabs_popup; // Menu to add the group to other group
QMenu* switch_to_tab_popup; // Menu to change tab