mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-03 20:58:25 +03:00
add Meta+` shortcut and fix animation behavior
--the isHidden flag shouldnt be set from visibilitymanager, it is only the qml responsibility
This commit is contained in:
parent
4de9ea1e7e
commit
d54fc5b436
@ -24,6 +24,15 @@ GlobalShortcuts::GlobalShortcuts(QObject *parent)
|
||||
if (m_corona) {
|
||||
init();
|
||||
}
|
||||
|
||||
m_hideDockTimer.setSingleShot(true);
|
||||
m_hideDockTimer.setInterval(3000);
|
||||
connect(&m_hideDockTimer, &QTimer::timeout, this, [this]() {
|
||||
if (m_hideDock) {
|
||||
m_hideDock->visibility()->setBlockHiding(false);
|
||||
m_hideDock = nullptr;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
GlobalShortcuts::~GlobalShortcuts()
|
||||
@ -62,6 +71,14 @@ void GlobalShortcuts::init()
|
||||
});
|
||||
}
|
||||
|
||||
//show-hide the main dock in the primary screen
|
||||
QAction *showAction = taskbarActions->addAction(QStringLiteral("show latte dock"));
|
||||
showAction->setText(i18n("Show Latte Dock"));
|
||||
KGlobalAccel::setGlobalShortcut(showAction, QKeySequence(Qt::META + '`'));
|
||||
connect(showAction, &QAction::triggered, this, [this]() {
|
||||
showDock();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//! Activate launcher menu through dbus interface
|
||||
@ -148,7 +165,6 @@ void GlobalShortcuts::activateTaskManagerEntry(int index, Qt::Key modifier)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//! update badge for specific dock item
|
||||
void GlobalShortcuts::updateDockItemBadge(QString identifier, QString value)
|
||||
{
|
||||
@ -201,6 +217,48 @@ void GlobalShortcuts::updateDockItemBadge(QString identifier, QString value)
|
||||
}
|
||||
}
|
||||
|
||||
void GlobalShortcuts::showDock()
|
||||
{
|
||||
//qDebug() << "DBUS CALL ::: " << identifier << " - " << value;
|
||||
auto containsLattePlasmoid = [this](const Plasma::Containment * c) {
|
||||
const auto &applets = c->applets();
|
||||
|
||||
for (auto *applet : applets) {
|
||||
KPluginMetaData meta = applet->kPackage().metadata();
|
||||
|
||||
if (meta.pluginId() == "org.kde.latte.plasmoid") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
// To avoid overly complex configuration, we'll try to get the 90% usecase to work
|
||||
// which is activating a task on the task manager on a panel on the primary screen.
|
||||
for (auto it = m_corona->m_dockViews.constBegin(), end = m_corona->m_dockViews.constEnd(); it != end; ++it) {
|
||||
if (it.value()->screen() != qGuiApp->primaryScreen()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (containsLattePlasmoid(it.key())) {
|
||||
m_hideDock = it.value();
|
||||
m_hideDock->visibility()->setBlockHiding(true);
|
||||
m_hideDockTimer.start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// we didn't find anything on primary, try all the panels
|
||||
for (auto it = m_corona->m_dockViews.constBegin(), end = m_corona->m_dockViews.constEnd(); it != end; ++it) {
|
||||
if (containsLattePlasmoid(it.key())) {
|
||||
m_hideDock = it.value();
|
||||
m_hideDock->visibility()->setBlockHiding(true);
|
||||
m_hideDockTimer.start();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,11 @@
|
||||
#define GLOBALSHORTCUTS_H
|
||||
|
||||
#include "dockcorona.h"
|
||||
#include "dockview.h"
|
||||
#include "../liblattedock/dock.h"
|
||||
|
||||
class DockCorona;
|
||||
class DockView;
|
||||
|
||||
namespace Latte {
|
||||
|
||||
@ -39,11 +41,15 @@ public:
|
||||
void updateDockItemBadge(QString identifier, QString value);
|
||||
|
||||
private:
|
||||
void activateTaskManagerEntry(int index, Qt::Key modifier);
|
||||
void init();
|
||||
void activateTaskManagerEntry(int index, Qt::Key modifier);
|
||||
void showDock();
|
||||
void hideDock();
|
||||
|
||||
QTimer m_hideDockTimer;
|
||||
DockView *m_hideDock;
|
||||
|
||||
DockCorona *m_corona{nullptr};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -170,6 +170,7 @@ inline void VisibilityManagerPrivate::setMode(Dock::Visibility mode)
|
||||
timerCheckWindows.start();
|
||||
}
|
||||
break;
|
||||
|
||||
case Dock::WindowsGoBelow: {
|
||||
//
|
||||
}
|
||||
@ -203,7 +204,7 @@ inline void VisibilityManagerPrivate::setIsHidden(bool isHidden)
|
||||
if (this->isHidden == isHidden)
|
||||
return;
|
||||
|
||||
if (blockHiding) {
|
||||
if (blockHiding && isHidden) {
|
||||
qWarning() << "isHidden property is blocked, ignoring update";
|
||||
return;
|
||||
}
|
||||
@ -224,8 +225,6 @@ void VisibilityManagerPrivate::setBlockHiding(bool blockHiding)
|
||||
timerHide.stop();
|
||||
|
||||
if (isHidden) {
|
||||
isHidden = false;
|
||||
emit q->isHiddenChanged();
|
||||
emit q->mustBeShown(VisibilityManager::QPrivateSignal{});
|
||||
}
|
||||
} else {
|
||||
@ -364,17 +363,17 @@ void VisibilityManagerPrivate::dodgeMaximized(WId wid)
|
||||
|
||||
auto isMaxVert = [&]() noexcept -> bool {
|
||||
return winfo.isMaxVert()
|
||||
|| (view->screen() && view->screen()->size().height() <= winfo.geometry().height());
|
||||
|| (view->screen() && view->screen()->size().height() <= winfo.geometry().height());
|
||||
};
|
||||
|
||||
auto isMaxHoriz = [&]() noexcept -> bool {
|
||||
return winfo.isMaxHoriz()
|
||||
|| (view->screen() && view->screen()->size().width() <= winfo.geometry().width());
|
||||
|| (view->screen() && view->screen()->size().width() <= winfo.geometry().width());
|
||||
};
|
||||
|
||||
if (wm->isOnCurrentDesktop(wid) && !winfo.isMinimized())
|
||||
raiseDock(view->formFactor() == Plasma::Types::Vertical
|
||||
? !isMaxHoriz() : !isMaxVert());
|
||||
? !isMaxHoriz() : !isMaxVert());
|
||||
}
|
||||
|
||||
void VisibilityManagerPrivate::dodgeWindows(WId wid)
|
||||
@ -457,18 +456,18 @@ inline void VisibilityManagerPrivate::restoreConfig()
|
||||
setRaiseOnActivity(config.readEntry("raiseOnActivityChange", false));
|
||||
|
||||
auto mode = [&]() {
|
||||
return static_cast<Dock::Visibility>(view->containment()->config()
|
||||
.readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
|
||||
return static_cast<Dock::Visibility>(view->containment()->config()
|
||||
.readEntry("visibility", static_cast<int>(Dock::DodgeActive)));
|
||||
};
|
||||
|
||||
if (mode() == Dock::AlwaysVisible) {
|
||||
setMode(Dock::AlwaysVisible);
|
||||
} else {
|
||||
connect(&timerStartUp, &QTimer::timeout, this, [&, mode]() {
|
||||
connect(&timerStartUp, &QTimer::timeout, this, [ &, mode]() {
|
||||
setMode(mode());
|
||||
});
|
||||
connect(view->containment(), &Plasma::Containment::userConfiguringChanged
|
||||
,this, [&](bool configuring) {
|
||||
, this, [&](bool configuring) {
|
||||
if (configuring && timerStartUp.isActive())
|
||||
timerStartUp.start(100);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user