Changeset View
Changeset View
Standalone View
Standalone View
useractions.cpp
Show All 22 Lines | |||||
23 | 23 | | |||
24 | This file contains things relevant to direct user actions, such as | 24 | This file contains things relevant to direct user actions, such as | ||
25 | responses to global keyboard shortcuts, or selecting actions | 25 | responses to global keyboard shortcuts, or selecting actions | ||
26 | from the window operations menu. | 26 | from the window operations menu. | ||
27 | 27 | | |||
28 | */ | 28 | */ | ||
29 | 29 | | |||
30 | /////////////////////////////////////////////////////////////////////////////// | 30 | /////////////////////////////////////////////////////////////////////////////// | ||
31 | // NOTE: if you change the menu, keep kde-workspace/libs/taskmanager/taskactions.cpp in sync | 31 | // NOTE: if you change the menu, keep | ||
32 | // plasma-desktop/applets/taskmanager/package/contents/ui/ContextMenu.qml | ||||
33 | // in sync | ||||
32 | ////////////////////////////////////////////////////////////////////////////// | 34 | ////////////////////////////////////////////////////////////////////////////// | ||
33 | 35 | | |||
34 | #include "useractions.h" | 36 | #include "useractions.h" | ||
35 | #include "cursor.h" | 37 | #include "cursor.h" | ||
36 | #include "client.h" | 38 | #include "client.h" | ||
37 | #include "colorcorrection/manager.h" | 39 | #include "colorcorrection/manager.h" | ||
38 | #include "composite.h" | 40 | #include "composite.h" | ||
39 | #include "input.h" | 41 | #include "input.h" | ||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Line(s) | 234 | { | |||
252 | }; | 254 | }; | ||
253 | 255 | | |||
254 | m_moveOperation = advancedMenu->addAction(i18n("&Move")); | 256 | m_moveOperation = advancedMenu->addAction(i18n("&Move")); | ||
255 | m_moveOperation->setIcon(QIcon::fromTheme(QStringLiteral("transform-move"))); | 257 | m_moveOperation->setIcon(QIcon::fromTheme(QStringLiteral("transform-move"))); | ||
256 | setShortcut(m_moveOperation, QStringLiteral("Window Move")); | 258 | setShortcut(m_moveOperation, QStringLiteral("Window Move")); | ||
257 | m_moveOperation->setData(Options::UnrestrictedMoveOp); | 259 | m_moveOperation->setData(Options::UnrestrictedMoveOp); | ||
258 | 260 | | |||
259 | m_resizeOperation = advancedMenu->addAction(i18n("&Resize")); | 261 | m_resizeOperation = advancedMenu->addAction(i18n("&Resize")); | ||
262 | m_resizeOperation->setIcon(QIcon::fromTheme(QStringLiteral("transform-scale"))); | ||||
260 | setShortcut(m_resizeOperation, QStringLiteral("Window Resize")); | 263 | setShortcut(m_resizeOperation, QStringLiteral("Window Resize")); | ||
261 | m_resizeOperation->setData(Options::ResizeOp); | 264 | m_resizeOperation->setData(Options::ResizeOp); | ||
262 | 265 | | |||
263 | m_keepAboveOperation = advancedMenu->addAction(i18n("Keep &Above Others")); | 266 | m_keepAboveOperation = advancedMenu->addAction(i18n("Keep &Above Others")); | ||
264 | m_keepAboveOperation->setIcon(QIcon::fromTheme(QStringLiteral("go-up"))); | 267 | m_keepAboveOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-keep-above"))); | ||
265 | setShortcut(m_keepAboveOperation, QStringLiteral("Window Above Other Windows")); | 268 | setShortcut(m_keepAboveOperation, QStringLiteral("Window Above Other Windows")); | ||
266 | m_keepAboveOperation->setCheckable(true); | 269 | m_keepAboveOperation->setCheckable(true); | ||
267 | m_keepAboveOperation->setData(Options::KeepAboveOp); | 270 | m_keepAboveOperation->setData(Options::KeepAboveOp); | ||
268 | 271 | | |||
269 | m_keepBelowOperation = advancedMenu->addAction(i18n("Keep &Below Others")); | 272 | m_keepBelowOperation = advancedMenu->addAction(i18n("Keep &Below Others")); | ||
270 | m_keepBelowOperation->setIcon(QIcon::fromTheme(QStringLiteral("go-down"))); | 273 | m_keepBelowOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-keep-below"))); | ||
271 | setShortcut(m_keepBelowOperation, QStringLiteral("Window Below Other Windows")); | 274 | setShortcut(m_keepBelowOperation, QStringLiteral("Window Below Other Windows")); | ||
272 | m_keepBelowOperation->setCheckable(true); | 275 | m_keepBelowOperation->setCheckable(true); | ||
273 | m_keepBelowOperation->setData(Options::KeepBelowOp); | 276 | m_keepBelowOperation->setData(Options::KeepBelowOp); | ||
274 | 277 | | |||
275 | m_fullScreenOperation = advancedMenu->addAction(i18n("&Fullscreen")); | 278 | m_fullScreenOperation = advancedMenu->addAction(i18n("&Fullscreen")); | ||
276 | m_fullScreenOperation->setIcon(QIcon::fromTheme(QStringLiteral("view-fullscreen"))); | 279 | m_fullScreenOperation->setIcon(QIcon::fromTheme(QStringLiteral("view-fullscreen"))); | ||
277 | setShortcut(m_fullScreenOperation, QStringLiteral("Window Fullscreen")); | 280 | setShortcut(m_fullScreenOperation, QStringLiteral("Window Fullscreen")); | ||
278 | m_fullScreenOperation->setCheckable(true); | 281 | m_fullScreenOperation->setCheckable(true); | ||
279 | m_fullScreenOperation->setData(Options::FullScreenOp); | 282 | m_fullScreenOperation->setData(Options::FullScreenOp); | ||
280 | 283 | | |||
281 | m_shadeOperation = advancedMenu->addAction(i18n("&Shade")); | 284 | m_shadeOperation = advancedMenu->addAction(i18n("&Shade")); | ||
285 | m_shadeOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-shade"))); | ||||
282 | setShortcut(m_shadeOperation, QStringLiteral("Window Shade")); | 286 | setShortcut(m_shadeOperation, QStringLiteral("Window Shade")); | ||
283 | m_shadeOperation->setCheckable(true); | 287 | m_shadeOperation->setCheckable(true); | ||
284 | m_shadeOperation->setData(Options::ShadeOp); | 288 | m_shadeOperation->setData(Options::ShadeOp); | ||
285 | 289 | | |||
286 | m_noBorderOperation = advancedMenu->addAction(i18n("&No Border")); | 290 | m_noBorderOperation = advancedMenu->addAction(i18n("&No Border")); | ||
291 | m_noBorderOperation->setIcon(QIcon::fromTheme(QStringLiteral("edit-none-border"))); | ||||
trickyricky26: If I'm not mistaken, this icon is currently not in the Breeze icon theme and is added in D23782. | |||||
It currently falls back to edit-none thanks to the name. If an entirely different icon should be used I can make a new commit or patch. GB_2: It currently falls back to `edit-none` thanks to the name. If an entirely different icon should… | |||||
287 | setShortcut(m_noBorderOperation, QStringLiteral("Window No Border")); | 292 | setShortcut(m_noBorderOperation, QStringLiteral("Window No Border")); | ||
288 | m_noBorderOperation->setCheckable(true); | 293 | m_noBorderOperation->setCheckable(true); | ||
289 | m_noBorderOperation->setData(Options::NoBorderOp); | 294 | m_noBorderOperation->setData(Options::NoBorderOp); | ||
290 | 295 | | |||
291 | advancedMenu->addSeparator(); | 296 | advancedMenu->addSeparator(); | ||
292 | 297 | | |||
293 | m_shortcutOperation = advancedMenu->addAction(i18n("Window Short&cut...")); | 298 | m_shortcutOperation = advancedMenu->addAction(i18n("Set Window Short&cut...")); | ||
294 | m_shortcutOperation->setIcon(QIcon::fromTheme(QStringLiteral("configure-shortcuts"))); | 299 | m_shortcutOperation->setIcon(QIcon::fromTheme(QStringLiteral("configure-shortcuts"))); | ||
295 | setShortcut(m_shortcutOperation, QStringLiteral("Setup Window Shortcut")); | 300 | setShortcut(m_shortcutOperation, QStringLiteral("Setup Window Shortcut")); | ||
296 | m_shortcutOperation->setData(Options::SetupWindowShortcutOp); | 301 | m_shortcutOperation->setData(Options::SetupWindowShortcutOp); | ||
297 | 302 | | |||
298 | QAction *action = advancedMenu->addAction(i18n("Special &Window Settings...")); | 303 | QAction *action = advancedMenu->addAction(i18n("Configure Special &Window Settings...")); | ||
299 | action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions"))); | 304 | action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions"))); | ||
300 | action->setData(Options::WindowRulesOp); | 305 | action->setData(Options::WindowRulesOp); | ||
301 | m_rulesOperation = action; | 306 | m_rulesOperation = action; | ||
302 | 307 | | |||
303 | action = advancedMenu->addAction(i18n("S&pecial Application Settings...")); | 308 | action = advancedMenu->addAction(i18n("Configure S&pecial Application Settings...")); | ||
304 | action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions"))); | 309 | action->setIcon(QIcon::fromTheme(QStringLiteral("preferences-system-windows-actions"))); | ||
305 | action->setData(Options::ApplicationRulesOp); | 310 | action->setData(Options::ApplicationRulesOp); | ||
306 | m_applicationRulesOperation = action; | 311 | m_applicationRulesOperation = action; | ||
307 | if (!kwinApp()->config()->isImmutable() && | 312 | if (!kwinApp()->config()->isImmutable() && | ||
308 | !KAuthorized::authorizeControlModules(configModules(true)).isEmpty()) { | 313 | !KAuthorized::authorizeControlModules(configModules(true)).isEmpty()) { | ||
309 | advancedMenu->addSeparator(); | 314 | advancedMenu->addSeparator(); | ||
310 | action = advancedMenu->addAction(i18nc("Entry in context menu of window decoration to open the configuration module of KWin", | 315 | action = advancedMenu->addAction(i18nc("Entry in context menu of window decoration to open the configuration module of KWin", | ||
311 | "Window Manager S&ettings...")); | 316 | "Configure W&indow Manager...")); | ||
312 | action->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | 317 | action->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); | ||
313 | connect(action, &QAction::triggered, this, | 318 | connect(action, &QAction::triggered, this, | ||
314 | [this]() { | 319 | [this]() { | ||
315 | // opens the KWin configuration | 320 | // opens the KWin configuration | ||
316 | QStringList args; | 321 | QStringList args; | ||
317 | args << QStringLiteral("--icon") << QStringLiteral("preferences-system-windows"); | 322 | args << QStringLiteral("--icon") << QStringLiteral("preferences-system-windows"); | ||
318 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | 323 | const QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, | ||
319 | QStringLiteral("kservices5/kwinfocus.desktop")); | 324 | QStringLiteral("kservices5/kwinfocus.desktop")); | ||
Show All 13 Lines | 335 | [p] (QProcess::ProcessError e) { | |||
333 | } | 338 | } | ||
334 | } | 339 | } | ||
335 | ); | 340 | ); | ||
336 | p->start(); | 341 | p->start(); | ||
337 | } | 342 | } | ||
338 | ); | 343 | ); | ||
339 | } | 344 | } | ||
340 | 345 | | |||
341 | m_minimizeOperation = m_menu->addAction(i18n("Mi&nimize")); | | |||
342 | setShortcut(m_minimizeOperation, QStringLiteral("Window Minimize")); | | |||
343 | m_minimizeOperation->setData(Options::MinimizeOp); | | |||
344 | | ||||
345 | m_maximizeOperation = m_menu->addAction(i18n("Ma&ximize")); | 346 | m_maximizeOperation = m_menu->addAction(i18n("Ma&ximize")); | ||
347 | m_maximizeOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-maximize"))); | ||||
346 | setShortcut(m_maximizeOperation, QStringLiteral("Window Maximize")); | 348 | setShortcut(m_maximizeOperation, QStringLiteral("Window Maximize")); | ||
347 | m_maximizeOperation->setCheckable(true); | 349 | m_maximizeOperation->setCheckable(true); | ||
348 | m_maximizeOperation->setData(Options::MaximizeOp); | 350 | m_maximizeOperation->setData(Options::MaximizeOp); | ||
349 | 351 | | |||
350 | m_menu->addSeparator(); | 352 | m_minimizeOperation = m_menu->addAction(i18n("Mi&nimize")); | ||
353 | m_minimizeOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-minimize"))); | ||||
354 | setShortcut(m_minimizeOperation, QStringLiteral("Window Minimize")); | ||||
355 | m_minimizeOperation->setData(Options::MinimizeOp); | ||||
351 | 356 | | |||
352 | // Actions for window tabbing | 357 | // Actions for window tabbing | ||
353 | if (false) { | 358 | if (false) { | ||
354 | m_removeFromTabGroup = m_menu->addAction(i18n("&Untab")); | 359 | m_removeFromTabGroup = m_menu->addAction(i18n("&Untab")); | ||
355 | setShortcut(m_removeFromTabGroup, QStringLiteral("Untab")); | 360 | setShortcut(m_removeFromTabGroup, QStringLiteral("Untab")); | ||
356 | m_removeFromTabGroup->setData(Options::RemoveTabFromGroupOp); | 361 | m_removeFromTabGroup->setData(Options::RemoveTabFromGroupOp); | ||
357 | 362 | | |||
358 | m_closeTabGroup = m_menu->addAction(i18n("Close Entire &Group")); | 363 | m_closeTabGroup = m_menu->addAction(i18n("Close Entire &Group")); | ||
359 | m_closeTabGroup->setIcon(QIcon::fromTheme(QStringLiteral("window-close"))); | 364 | m_closeTabGroup->setIcon(QIcon::fromTheme(QStringLiteral("window-close"))); | ||
360 | setShortcut(m_closeTabGroup, QStringLiteral("Close TabGroup")); | 365 | setShortcut(m_closeTabGroup, QStringLiteral("Close TabGroup")); | ||
361 | m_closeTabGroup->setData(Options::CloseTabGroupOp); | 366 | m_closeTabGroup->setData(Options::CloseTabGroupOp); | ||
362 | 367 | | |||
363 | m_menu->addSeparator(); | 368 | m_menu->addSeparator(); | ||
364 | } | 369 | } | ||
365 | 370 | | |||
366 | m_menu->addSeparator(); | | |||
367 | | ||||
368 | action = m_menu->addMenu(advancedMenu); | 371 | action = m_menu->addMenu(advancedMenu); | ||
369 | action->setText(i18n("&More Actions")); | 372 | action->setText(i18n("&More Actions")); | ||
370 | 373 | action->setIcon(QIcon::fromTheme(QStringLiteral("view-more-symbolic"))); | |||
371 | m_menu->addSeparator(); | | |||
372 | 374 | | |||
373 | m_closeOperation = m_menu->addAction(i18n("&Close")); | 375 | m_closeOperation = m_menu->addAction(i18n("&Close")); | ||
374 | m_closeOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-close"))); | 376 | m_closeOperation->setIcon(QIcon::fromTheme(QStringLiteral("window-close"))); | ||
375 | setShortcut(m_closeOperation, QStringLiteral("Window Close")); | 377 | setShortcut(m_closeOperation, QStringLiteral("Window Close")); | ||
376 | m_closeOperation->setData(Options::CloseOp); | 378 | m_closeOperation->setData(Options::CloseOp); | ||
377 | } | 379 | } | ||
378 | 380 | | |||
379 | void UserActionsMenu::discard() | 381 | void UserActionsMenu::discard() | ||
▲ Show 20 Lines • Show All 214 Lines • ▼ Show 20 Line(s) | 592 | if (kwinApp()->operationMode() == Application::OperationModeWaylandOnly || | |||
594 | } | 596 | } | ||
595 | 597 | | |||
596 | m_multipleDesktopsMenu = new QMenu(m_menu); | 598 | m_multipleDesktopsMenu = new QMenu(m_menu); | ||
597 | connect(m_multipleDesktopsMenu, &QMenu::triggered, this, &UserActionsMenu::slotToggleOnVirtualDesktop); | 599 | connect(m_multipleDesktopsMenu, &QMenu::triggered, this, &UserActionsMenu::slotToggleOnVirtualDesktop); | ||
598 | connect(m_multipleDesktopsMenu, &QMenu::aboutToShow, this, &UserActionsMenu::multipleDesktopsPopupAboutToShow); | 600 | connect(m_multipleDesktopsMenu, &QMenu::aboutToShow, this, &UserActionsMenu::multipleDesktopsPopupAboutToShow); | ||
599 | 601 | | |||
600 | QAction *action = m_multipleDesktopsMenu->menuAction(); | 602 | QAction *action = m_multipleDesktopsMenu->menuAction(); | ||
601 | // set it as the first item | 603 | // set it as the first item | ||
602 | m_menu->insertAction(m_minimizeOperation, action); | 604 | m_menu->insertAction(m_maximizeOperation, action); | ||
603 | action->setText(i18n("&Desktops")); | 605 | action->setText(i18n("&Desktops")); | ||
606 | action->setIcon(QIcon::fromTheme(QStringLiteral("virtual-desktops"))); | ||||
604 | 607 | | |||
605 | } else { | 608 | } else { | ||
606 | if (m_desktopMenu) | 609 | if (m_desktopMenu) | ||
607 | return; | 610 | return; | ||
608 | 611 | | |||
609 | m_desktopMenu = new QMenu(m_menu); | 612 | m_desktopMenu = new QMenu(m_menu); | ||
610 | connect(m_desktopMenu, &QMenu::triggered, this, &UserActionsMenu::slotSendToDesktop); | 613 | connect(m_desktopMenu, &QMenu::triggered, this, &UserActionsMenu::slotSendToDesktop); | ||
611 | connect(m_desktopMenu, &QMenu::aboutToShow, this, &UserActionsMenu::desktopPopupAboutToShow); | 614 | connect(m_desktopMenu, &QMenu::aboutToShow, this, &UserActionsMenu::desktopPopupAboutToShow); | ||
612 | 615 | | |||
613 | QAction *action = m_desktopMenu->menuAction(); | 616 | QAction *action = m_desktopMenu->menuAction(); | ||
614 | // set it as the first item | 617 | // set it as the first item | ||
615 | m_menu->insertAction(m_minimizeOperation, action); | 618 | m_menu->insertAction(m_maximizeOperation, action); | ||
616 | action->setText(i18n("Move To &Desktop")); | 619 | action->setText(i18n("Move to &Desktop")); | ||
620 | action->setIcon(QIcon::fromTheme(QStringLiteral("virtual-desktops"))); | ||||
617 | } | 621 | } | ||
618 | } | 622 | } | ||
619 | 623 | | |||
620 | void UserActionsMenu::initScreenPopup() | 624 | void UserActionsMenu::initScreenPopup() | ||
621 | { | 625 | { | ||
622 | if (m_screenMenu) { | 626 | if (m_screenMenu) { | ||
623 | return; | 627 | return; | ||
624 | } | 628 | } | ||
625 | 629 | | |||
626 | m_screenMenu = new QMenu(m_menu); | 630 | m_screenMenu = new QMenu(m_menu); | ||
627 | connect(m_screenMenu, &QMenu::triggered, this, &UserActionsMenu::slotSendToScreen); | 631 | connect(m_screenMenu, &QMenu::triggered, this, &UserActionsMenu::slotSendToScreen); | ||
628 | connect(m_screenMenu, &QMenu::aboutToShow, this, &UserActionsMenu::screenPopupAboutToShow); | 632 | connect(m_screenMenu, &QMenu::aboutToShow, this, &UserActionsMenu::screenPopupAboutToShow); | ||
629 | 633 | | |||
630 | QAction *action = m_screenMenu->menuAction(); | 634 | QAction *action = m_screenMenu->menuAction(); | ||
631 | // set it as the first item after desktop | 635 | // set it as the first item after desktop | ||
632 | m_menu->insertAction(m_activityMenu ? m_activityMenu->menuAction() : m_minimizeOperation, action); | 636 | m_menu->insertAction(m_activityMenu ? m_activityMenu->menuAction() : m_minimizeOperation, action); | ||
633 | action->setText(i18n("Move To &Screen")); | 637 | action->setText(i18n("Move to &Screen")); | ||
638 | action->setIcon(QIcon::fromTheme(QStringLiteral("computer"))); | ||||
634 | } | 639 | } | ||
635 | 640 | | |||
636 | void UserActionsMenu::initActivityPopup() | 641 | void UserActionsMenu::initActivityPopup() | ||
637 | { | 642 | { | ||
638 | if (m_activityMenu) | 643 | if (m_activityMenu) | ||
639 | return; | 644 | return; | ||
640 | 645 | | |||
641 | m_activityMenu = new QMenu(m_menu); | 646 | m_activityMenu = new QMenu(m_menu); | ||
642 | connect(m_activityMenu, &QMenu::triggered, this, &UserActionsMenu::slotToggleOnActivity); | 647 | connect(m_activityMenu, &QMenu::triggered, this, &UserActionsMenu::slotToggleOnActivity); | ||
643 | connect(m_activityMenu, &QMenu::aboutToShow, this, &UserActionsMenu::activityPopupAboutToShow); | 648 | connect(m_activityMenu, &QMenu::aboutToShow, this, &UserActionsMenu::activityPopupAboutToShow); | ||
644 | 649 | | |||
645 | QAction *action = m_activityMenu->menuAction(); | 650 | QAction *action = m_activityMenu->menuAction(); | ||
646 | // set it as the first item | 651 | // set it as the first item | ||
647 | m_menu->insertAction(m_minimizeOperation, action); | 652 | m_menu->insertAction(m_maximizeOperation, action); | ||
648 | action->setText(i18n("Ac&tivities")); //FIXME is that a good string? | 653 | action->setText(i18n("Show in &Activities")); | ||
davidedmundson: I don't like this one as the behaviour doesn't "move" the window. | |||||
GB_2: Yeah, "Show in Activities" is more accurate. I'll change it to that. | |||||
654 | action->setIcon(QIcon::fromTheme(QStringLiteral("activities"))); | ||||
649 | } | 655 | } | ||
650 | 656 | | |||
651 | void UserActionsMenu::desktopPopupAboutToShow() | 657 | void UserActionsMenu::desktopPopupAboutToShow() | ||
652 | { | 658 | { | ||
653 | if (!m_desktopMenu) | 659 | if (!m_desktopMenu) | ||
654 | return; | 660 | return; | ||
655 | const VirtualDesktopManager *vds = VirtualDesktopManager::self(); | 661 | const VirtualDesktopManager *vds = VirtualDesktopManager::self(); | ||
656 | 662 | | |||
▲ Show 20 Lines • Show All 1267 Lines • Show Last 20 Lines |
If I'm not mistaken, this icon is currently not in the Breeze icon theme and is added in D23782. Not sure if this should have been used here already, but adding this comment for reference in D23782.