Changeset View
Changeset View
Standalone View
Standalone View
virtualdesktops.cpp
Show First 20 Lines • Show All 528 Lines • ▼ Show 20 Line(s) | 509 | { | |||
---|---|---|---|---|---|
529 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | 529 | // TODO: why is there no call to m_rootInfo->setDesktopLayout? | ||
530 | emit layoutChanged(width, height); | 530 | emit layoutChanged(width, height); | ||
531 | } | 531 | } | ||
532 | 532 | | |||
533 | void VirtualDesktopManager::initShortcuts() | 533 | void VirtualDesktopManager::initShortcuts() | ||
534 | { | 534 | { | ||
535 | initSwitchToShortcuts(); | 535 | initSwitchToShortcuts(); | ||
536 | 536 | | |||
537 | addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), &VirtualDesktopManager::slotNext); | 537 | QAction *nextAction = addAction(QStringLiteral("Switch to Next Desktop"), i18n("Switch to Next Desktop"), &VirtualDesktopManager::slotNext); | ||
538 | addAction(QStringLiteral("Switch to Previous Desktop"), i18n("Switch to Previous Desktop"), &VirtualDesktopManager::slotPrevious); | 538 | input()->registerTouchpadSwipeShortcut(SwipeDirection::Right, nextAction); | ||
539 | QAction *previousAction = addAction(QStringLiteral("Switch to Previous Desktop"), i18n("Switch to Previous Desktop"), &VirtualDesktopManager::slotPrevious); | ||||
540 | input()->registerTouchpadSwipeShortcut(SwipeDirection::Left, previousAction); | ||||
539 | addAction(QStringLiteral("Switch One Desktop to the Right"), i18n("Switch One Desktop to the Right"), &VirtualDesktopManager::slotRight); | 541 | addAction(QStringLiteral("Switch One Desktop to the Right"), i18n("Switch One Desktop to the Right"), &VirtualDesktopManager::slotRight); | ||
540 | addAction(QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), &VirtualDesktopManager::slotLeft); | 542 | addAction(QStringLiteral("Switch One Desktop to the Left"), i18n("Switch One Desktop to the Left"), &VirtualDesktopManager::slotLeft); | ||
541 | addAction(QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), &VirtualDesktopManager::slotUp); | 543 | addAction(QStringLiteral("Switch One Desktop Up"), i18n("Switch One Desktop Up"), &VirtualDesktopManager::slotUp); | ||
542 | addAction(QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), &VirtualDesktopManager::slotDown); | 544 | addAction(QStringLiteral("Switch One Desktop Down"), i18n("Switch One Desktop Down"), &VirtualDesktopManager::slotDown); | ||
543 | 545 | | |||
544 | // axis events | 546 | // axis events | ||
545 | input()->registerAxisShortcut(Qt::ControlModifier | Qt::AltModifier, PointerAxisDown, | 547 | input()->registerAxisShortcut(Qt::ControlModifier | Qt::AltModifier, PointerAxisDown, | ||
546 | findChild<QAction*>(QStringLiteral("Switch to Next Desktop"))); | 548 | findChild<QAction*>(QStringLiteral("Switch to Next Desktop"))); | ||
Show All 10 Lines | 554 | { | |||
557 | addAction(toDesktop, toDesktopLabel, 3, QKeySequence(Qt::CTRL + Qt::Key_F3), &VirtualDesktopManager::slotSwitchTo); | 559 | addAction(toDesktop, toDesktopLabel, 3, QKeySequence(Qt::CTRL + Qt::Key_F3), &VirtualDesktopManager::slotSwitchTo); | ||
558 | addAction(toDesktop, toDesktopLabel, 4, QKeySequence(Qt::CTRL + Qt::Key_F4), &VirtualDesktopManager::slotSwitchTo); | 560 | addAction(toDesktop, toDesktopLabel, 4, QKeySequence(Qt::CTRL + Qt::Key_F4), &VirtualDesktopManager::slotSwitchTo); | ||
559 | 561 | | |||
560 | for (uint i = 5; i <= maximum(); ++i) { | 562 | for (uint i = 5; i <= maximum(); ++i) { | ||
561 | addAction(toDesktop, toDesktopLabel, i, QKeySequence(), &VirtualDesktopManager::slotSwitchTo); | 563 | addAction(toDesktop, toDesktopLabel, i, QKeySequence(), &VirtualDesktopManager::slotSwitchTo); | ||
562 | } | 564 | } | ||
563 | } | 565 | } | ||
564 | 566 | | |||
565 | void VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)()) | 567 | QAction *VirtualDesktopManager::addAction(const QString &name, const KLocalizedString &label, uint value, const QKeySequence &key, void (VirtualDesktopManager::*slot)()) | ||
566 | { | 568 | { | ||
567 | QAction *a = new QAction(this); | 569 | QAction *a = new QAction(this); | ||
568 | a->setProperty("componentName", QStringLiteral(KWIN_NAME)); | 570 | a->setProperty("componentName", QStringLiteral(KWIN_NAME)); | ||
569 | a->setObjectName(name.arg(value)); | 571 | a->setObjectName(name.arg(value)); | ||
570 | a->setText(label.subs(value).toString()); | 572 | a->setText(label.subs(value).toString()); | ||
571 | a->setData(value); | 573 | a->setData(value); | ||
572 | KGlobalAccel::setGlobalShortcut(a, key); | 574 | KGlobalAccel::setGlobalShortcut(a, key); | ||
573 | input()->registerShortcut(key, a, this, slot); | 575 | input()->registerShortcut(key, a, this, slot); | ||
576 | return a; | ||||
574 | } | 577 | } | ||
575 | 578 | | |||
576 | void VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()) | 579 | QAction *VirtualDesktopManager::addAction(const QString &name, const QString &label, void (VirtualDesktopManager::*slot)()) | ||
577 | { | 580 | { | ||
578 | QAction *a = new QAction(this); | 581 | QAction *a = new QAction(this); | ||
579 | a->setProperty("componentName", QStringLiteral(KWIN_NAME)); | 582 | a->setProperty("componentName", QStringLiteral(KWIN_NAME)); | ||
580 | a->setObjectName(name); | 583 | a->setObjectName(name); | ||
581 | a->setText(label); | 584 | a->setText(label); | ||
582 | KGlobalAccel::setGlobalShortcut(a, QKeySequence()); | 585 | KGlobalAccel::setGlobalShortcut(a, QKeySequence()); | ||
583 | input()->registerShortcut(QKeySequence(), a, this, slot); | 586 | input()->registerShortcut(QKeySequence(), a, this, slot); | ||
587 | return a; | ||||
584 | } | 588 | } | ||
585 | 589 | | |||
586 | void VirtualDesktopManager::slotSwitchTo() | 590 | void VirtualDesktopManager::slotSwitchTo() | ||
587 | { | 591 | { | ||
588 | QAction *act = qobject_cast<QAction*>(sender()); | 592 | QAction *act = qobject_cast<QAction*>(sender()); | ||
589 | if (!act) { | 593 | if (!act) { | ||
590 | return; | 594 | return; | ||
591 | } | 595 | } | ||
▲ Show 20 Lines • Show All 48 Lines • Show Last 20 Lines |