From fbfe3ed4d4943eb58635c1c5bf87e4ff01966de8 Mon Sep 17 00:00:00 2001 From: Jacopo De Simoi Date: Sun, 21 Feb 2021 22:06:37 -0500 Subject: [PATCH] Add shortcut to hide panel fix bogus lines typo --- shell/shellcorona.cpp | 30 ++++++++++++++++++++++++++++-- shell/shellcorona.h | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp index 21b3e4c54..f1f4d2bd5 100644 --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -153,6 +153,8 @@ void ShellCorona::init() connect(this, &ShellCorona::containmentAdded, this, &ShellCorona::handleContainmentAdded); + + QAction *dashboardAction = actions()->addAction(QStringLiteral("show dashboard")); QObject::connect(dashboardAction, &QAction::triggered, this, &ShellCorona::setDashboardShown); dashboardAction->setText(i18n("Show Desktop")); @@ -167,6 +169,21 @@ void ShellCorona::init() dashboardAction->setData(Plasma::Types::ControlAction); KGlobalAccel::self()->setGlobalShortcut(dashboardAction, Qt::CTRL | Qt::Key_F12); + QAction *panelAction = actions()->addAction(QStringLiteral("show panel")); + QObject::connect(panelAction, &QAction::triggered, + this, &ShellCorona::togglePanelVisibility); + panelAction->setText(i18n("Toggle Panel")); + // connect(KWindowSystem::self(), &KWindowSystem::showingDesktopChanged, [panelAction](bool showing) { + // panelAction->setText(showing ? i18n("Hide Desktop") : i18n("Show Desktop")); + // panelAction->setChecked(showing); + // }); + + // panelAction->setAutoRepeat(true); + // panelAction->setCheckable(true); + // panelAction->setIcon(QIcon::fromTheme(QStringLiteral("panel-show"))); + // panelAction->setData(Plasma::Types::ControlAction); + KGlobalAccel::self()->setGlobalShortcut(panelAction, Qt::CTRL + Qt::Key_F11); + checkAddPanelAction(); connect(KSycoca::self(), SIGNAL(databaseChanged(QStringList)), this, SLOT(checkAddPanelAction(QStringList))); @@ -1108,7 +1125,17 @@ QList ShellCorona::panelsForScreen(QScreen *screen) const return ret; } -DesktopView *ShellCorona::desktopForScreen(QScreen *screen) const +void ShellCorona::togglePanelVisibility() +{ + for (auto it = m_panelViews.constBegin(), end = m_panelViews.constEnd(); it != end; ++it) { + if (it.value()->screen() != qGuiApp->primaryScreen()) { + continue; + } + it.value()->setVisible(!it.value()->isVisible()); + } +} + +DesktopView *ShellCorona::desktopForScreen(QScreen* screen) const { return m_desktopViewforId.value(m_screenPool->id(screen->name())); } @@ -2208,5 +2235,4 @@ void ShellCorona::activateTaskManagerEntry(int index) // Desktop corona handler -#include "moc_shellcorona.cpp" #include "shellcorona.moc" diff --git a/shell/shellcorona.h b/shell/shellcorona.h index 169f6fddd..aba2c1f15 100644 --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -202,6 +202,7 @@ protected Q_SLOTS: void showAlternativesForApplet(Plasma::Applet *applet); + void togglePanelVisibility(); private Q_SLOTS: void createWaitingPanels(); void handleContainmentAdded(Plasma::Containment *c);