mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-28 19:21:50 +03:00
updates and improvements at applets glob.shortcuts
This commit is contained in:
parent
103b901125
commit
1ff161a030
@ -106,6 +106,12 @@ DockView::DockView(Plasma::Corona *corona, QScreen *targetScreen, bool dockWindo
|
|||||||
|
|
||||||
if (!m_visibility) {
|
if (!m_visibility) {
|
||||||
m_visibility = new VisibilityManager(this);
|
m_visibility = new VisibilityManager(this);
|
||||||
|
|
||||||
|
connect(m_visibility, &VisibilityManager::isHiddenChanged, this, [&]() {
|
||||||
|
if (m_visibility->isHidden()) {
|
||||||
|
deactivateApplets();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(this->containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), SLOT(statusChanged(Plasma::Types::ItemStatus)));
|
connect(this->containment(), SIGNAL(statusChanged(Plasma::Types::ItemStatus)), SLOT(statusChanged(Plasma::Types::ItemStatus)));
|
||||||
|
@ -220,7 +220,7 @@ void GlobalShortcuts::init()
|
|||||||
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + key));
|
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + key));
|
||||||
connect(action, &QAction::triggered, this, [this, i] {
|
connect(action, &QAction::triggered, this, [this, i] {
|
||||||
// qDebug() << "meta action...";
|
// qDebug() << "meta action...";
|
||||||
activateTaskManagerEntry(i, static_cast<Qt::Key>(Qt::META));
|
activateEntry(i, static_cast<Qt::Key>(Qt::META));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +234,7 @@ void GlobalShortcuts::init()
|
|||||||
action->setShortcut(QKeySequence(Qt::META + keysAboveTen[i - 10]));
|
action->setShortcut(QKeySequence(Qt::META + keysAboveTen[i - 10]));
|
||||||
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + keysAboveTen[i - 10]));
|
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + keysAboveTen[i - 10]));
|
||||||
connect(action, &QAction::triggered, this, [this, i] {
|
connect(action, &QAction::triggered, this, [this, i] {
|
||||||
activateTaskManagerEntry(i, static_cast<Qt::Key>(Qt::META));
|
activateEntry(i, static_cast<Qt::Key>(Qt::META));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +248,7 @@ void GlobalShortcuts::init()
|
|||||||
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + Qt::CTRL + key));
|
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + Qt::CTRL + key));
|
||||||
connect(action, &QAction::triggered, this, [this, i] {
|
connect(action, &QAction::triggered, this, [this, i] {
|
||||||
// qDebug() << "meta + ctrl + action...";
|
// qDebug() << "meta + ctrl + action...";
|
||||||
activateTaskManagerEntry(i, static_cast<Qt::Key>(Qt::CTRL));
|
activateEntry(i, static_cast<Qt::Key>(Qt::CTRL));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +258,7 @@ void GlobalShortcuts::init()
|
|||||||
action->setText(i18n("New Instance for Task Manager Entry %1", i));
|
action->setText(i18n("New Instance for Task Manager Entry %1", i));
|
||||||
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + Qt::CTRL + keysAboveTen[i - 10]));
|
KGlobalAccel::setGlobalShortcut(action, QKeySequence(Qt::META + Qt::CTRL + keysAboveTen[i - 10]));
|
||||||
connect(action, &QAction::triggered, this, [this, i] {
|
connect(action, &QAction::triggered, this, [this, i] {
|
||||||
activateTaskManagerEntry(i, static_cast<Qt::Key>(Qt::CTRL));
|
activateEntry(i, static_cast<Qt::Key>(Qt::CTRL));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,11 +285,11 @@ void GlobalShortcuts::activateLauncherMenu()
|
|||||||
|
|
||||||
|
|
||||||
//! Activate task manager entry
|
//! Activate task manager entry
|
||||||
void GlobalShortcuts::activateTaskManagerEntry(int index, Qt::Key modifier)
|
void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
|
||||||
{
|
{
|
||||||
m_lastInvokedAction = dynamic_cast<QAction *>(sender());
|
m_lastInvokedAction = dynamic_cast<QAction *>(sender());
|
||||||
|
|
||||||
auto activateTaskManagerEntryOnContainment = [this](const Plasma::Containment * c, int index, Qt::Key modifier) {
|
auto activatePlasmaTaskManagerEntryOnContainment = [this](const Plasma::Containment * c, int index, Qt::Key modifier) {
|
||||||
const auto &applets = c->applets();
|
const auto &applets = c->applets();
|
||||||
|
|
||||||
for (auto *applet : applets) {
|
for (auto *applet : applets) {
|
||||||
@ -344,6 +344,46 @@ void GlobalShortcuts::activateTaskManagerEntry(int index, Qt::Key modifier)
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
auto activateLatteEntryOnContainment = [this](const Plasma::Containment * c, int index, Qt::Key modifier) {
|
||||||
|
if (QQuickItem *containmentInterface = c->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||||
|
const auto &childItems = containmentInterface->childItems();
|
||||||
|
|
||||||
|
for (QQuickItem *item : childItems) {
|
||||||
|
if (auto *metaObject = item->metaObject()) {
|
||||||
|
// not using QMetaObject::invokeMethod to avoid warnings when calling
|
||||||
|
// this on applets that don't have it or other child items since this
|
||||||
|
// is pretty much trial and error.
|
||||||
|
|
||||||
|
// Also, "var" arguments are treated as QVariant in QMetaObject
|
||||||
|
int methodIndex = modifier == static_cast<Qt::Key>(Qt::META) ?
|
||||||
|
metaObject->indexOfMethod("activateEntryAtIndex(QVariant)") :
|
||||||
|
metaObject->indexOfMethod("newInstanceForEntryAtIndex(QVariant)");
|
||||||
|
|
||||||
|
int methodIndex2 = metaObject->indexOfMethod("setShowAppletsNumbers(QVariant)");
|
||||||
|
|
||||||
|
if (methodIndex == -1 || (methodIndex2 == -1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_calledItem = item;
|
||||||
|
m_numbersMethodIndex = methodIndex2;
|
||||||
|
m_methodShowNumbers = metaObject->method(m_numbersMethodIndex);
|
||||||
|
|
||||||
|
QMetaMethod method = metaObject->method(methodIndex);
|
||||||
|
|
||||||
|
if (method.invoke(item, Q_ARG(QVariant, index))) {
|
||||||
|
m_methodShowNumbers.invoke(item, Q_ARG(QVariant, true));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
QHash<const Plasma::Containment *, DockView *> *views = m_corona->layoutManager()->currentDockViews();
|
QHash<const Plasma::Containment *, DockView *> *views = m_corona->layoutManager()->currentDockViews();
|
||||||
|
|
||||||
// To avoid overly complex configuration, we'll try to get the 90% usecase to work
|
// To avoid overly complex configuration, we'll try to get the 90% usecase to work
|
||||||
@ -353,7 +393,9 @@ void GlobalShortcuts::activateTaskManagerEntry(int index, Qt::Key modifier)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activateTaskManagerEntryOnContainment(it.key(), index, modifier)) {
|
if ((it.value()->latteTasksPresent() && activateLatteEntryOnContainment(it.key(), index, modifier))
|
||||||
|
|| (!it.value()->latteTasksPresent() && it.value()->tasksPresent() &&
|
||||||
|
activatePlasmaTaskManagerEntryOnContainment(it.key(), index, modifier))) {
|
||||||
m_hideDock = it.value();
|
m_hideDock = it.value();
|
||||||
m_hideDock->visibility()->setBlockHiding(true);
|
m_hideDock->visibility()->setBlockHiding(true);
|
||||||
m_hideDockTimer.start();
|
m_hideDockTimer.start();
|
||||||
@ -363,7 +405,9 @@ void GlobalShortcuts::activateTaskManagerEntry(int index, Qt::Key modifier)
|
|||||||
|
|
||||||
// we didn't find anything on primary, try all the panels
|
// we didn't find anything on primary, try all the panels
|
||||||
for (auto it = views->constBegin(), end = views->constEnd(); it != end; ++it) {
|
for (auto it = views->constBegin(), end = views->constEnd(); it != end; ++it) {
|
||||||
if (activateTaskManagerEntryOnContainment(it.key(), index, modifier)) {
|
if ((it.value()->latteTasksPresent() && activateLatteEntryOnContainment(it.key(), index, modifier))
|
||||||
|
|| (!it.value()->latteTasksPresent() && it.value()->tasksPresent() &&
|
||||||
|
activatePlasmaTaskManagerEntryOnContainment(it.key(), index, modifier))) {
|
||||||
m_hideDock = it.value();
|
m_hideDock = it.value();
|
||||||
m_hideDock->visibility()->setBlockHiding(true);
|
m_hideDock->visibility()->setBlockHiding(true);
|
||||||
m_hideDockTimer.start();
|
m_hideDockTimer.start();
|
||||||
@ -430,20 +474,10 @@ void GlobalShortcuts::showDock()
|
|||||||
{
|
{
|
||||||
m_lastInvokedAction = dynamic_cast<QAction *>(sender());
|
m_lastInvokedAction = dynamic_cast<QAction *>(sender());
|
||||||
|
|
||||||
auto containsLattePlasmoid = [this](const Plasma::Containment * c) {
|
auto invokeShowNumbers = [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") {
|
|
||||||
if (QQuickItem *containmentInterface = c->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
if (QQuickItem *containmentInterface = c->property("_plasma_graphicObject").value<QQuickItem *>()) {
|
||||||
const auto &childItems = containmentInterface->childItems();
|
const auto &childItems = containmentInterface->childItems();
|
||||||
|
|
||||||
if (childItems.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (QQuickItem *item : childItems) {
|
for (QQuickItem *item : childItems) {
|
||||||
if (auto *metaObject = item->metaObject()) {
|
if (auto *metaObject = item->metaObject()) {
|
||||||
// not using QMetaObject::invokeMethod to avoid warnings when calling
|
// not using QMetaObject::invokeMethod to avoid warnings when calling
|
||||||
@ -467,8 +501,6 @@ void GlobalShortcuts::showDock()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
@ -482,7 +514,7 @@ void GlobalShortcuts::showDock()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (containsLattePlasmoid(it.key())) {
|
if (it.value()->latteTasksPresent() && invokeShowNumbers(it.key())) {
|
||||||
m_hideDock = it.value();
|
m_hideDock = it.value();
|
||||||
m_hideDock->visibility()->setBlockHiding(true);
|
m_hideDock->visibility()->setBlockHiding(true);
|
||||||
m_hideDockTimer.start();
|
m_hideDockTimer.start();
|
||||||
@ -492,7 +524,7 @@ void GlobalShortcuts::showDock()
|
|||||||
|
|
||||||
// we didn't find anything on primary, try all the panels
|
// we didn't find anything on primary, try all the panels
|
||||||
for (auto it = views->constBegin(), end = views->constEnd(); it != end; ++it) {
|
for (auto it = views->constBegin(), end = views->constEnd(); it != end; ++it) {
|
||||||
if (containsLattePlasmoid(it.key())) {
|
if (it.value()->latteTasksPresent() && invokeShowNumbers(it.key())) {
|
||||||
m_hideDock = it.value();
|
m_hideDock = it.value();
|
||||||
m_hideDock->visibility()->setBlockHiding(true);
|
m_hideDock->visibility()->setBlockHiding(true);
|
||||||
m_hideDockTimer.start();
|
m_hideDockTimer.start();
|
||||||
@ -671,7 +703,6 @@ void GlobalShortcuts::hideDockTimerSlot()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "moc_globalshortcuts.cpp"
|
#include "moc_globalshortcuts.cpp"
|
||||||
|
@ -49,7 +49,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void activateTaskManagerEntry(int index, Qt::Key modifier);
|
void activateEntry(int index, Qt::Key modifier);
|
||||||
void showDock();
|
void showDock();
|
||||||
void hideDock();
|
void hideDock();
|
||||||
void showSettings();
|
void showSettings();
|
||||||
|
@ -394,4 +394,14 @@ Item {
|
|||||||
|
|
||||||
return counter + 1;
|
return counter + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pseudoIndexBelongsToLatteApplet(index) {
|
||||||
|
if (root.latteApplet) {
|
||||||
|
var lastTaskIndex = root.latteApplet.tasksNumbersBase + root.latteApplet.parabolicManager.countRealTasks;
|
||||||
|
return (index>root.latteApplet.tasksNumbersBase && index<=lastTaskIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -414,6 +414,22 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onSignalActivateEntryAtIndex: {
|
||||||
|
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && container.isLattePlasmoid) {
|
||||||
|
latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksNumbersBase);
|
||||||
|
} else if (entryIndex === parabolicManager.pseudoAppletIndex(container.index)) {
|
||||||
|
dock.toggleAppletExpanded(applet.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onSignalNewInstanceForEntryAtIndex: {
|
||||||
|
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && container.isLattePlasmoid) {
|
||||||
|
latteApplet.newInstanceForTaskAtIndex(entryIndex - latteApplet.tasksNumbersBase);
|
||||||
|
} else if (entryIndex === parabolicManager.pseudoAppletIndex(container.index)) {
|
||||||
|
dock.toggleAppletExpanded(applet.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections{
|
Connections{
|
||||||
|
@ -44,6 +44,8 @@ DragDrop.DropArea {
|
|||||||
//// BEGIN SIGNALS
|
//// BEGIN SIGNALS
|
||||||
signal clearZoomSignal();
|
signal clearZoomSignal();
|
||||||
signal separatorsUpdated();
|
signal separatorsUpdated();
|
||||||
|
signal signalActivateEntryAtIndex(int entryIndex);
|
||||||
|
signal signalNewInstanceForEntryAtIndex(int entryIndex);
|
||||||
signal updateEffectsArea();
|
signal updateEffectsArea();
|
||||||
signal updateIndexes();
|
signal updateIndexes();
|
||||||
signal updateScale(int delegateIndex, real newScale, real step);
|
signal updateScale(int delegateIndex, real newScale, real step);
|
||||||
@ -1055,6 +1057,35 @@ DragDrop.DropArea {
|
|||||||
showAppletsNumbers = showNumbers;
|
showAppletsNumbers = showNumbers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is called by dockcorona in response to a Meta+number shortcut.
|
||||||
|
function activateEntryAtIndex(index) {
|
||||||
|
if (typeof index !== "number") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (latteApplet) {
|
||||||
|
var base = parabolicManager.pseudoAppletIndex(latteAppletPos);
|
||||||
|
latteApplet.setTasksNumbersBase(base - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
signalActivateEntryAtIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is called by dockcorona in response to a Meta+Alt+number shortcut.
|
||||||
|
function newInstanceForEntryAtIndex(index) {
|
||||||
|
if (typeof index !== "number") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (latteApplet) {
|
||||||
|
var base = parabolicManager.pseudoAppletIndex(latteAppletPos);
|
||||||
|
latteApplet.setTasksNumbersBase(base - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
signalNewInstanceForEntryAtIndex(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function showTooltipLabel(taskItem, text){
|
function showTooltipLabel(taskItem, text){
|
||||||
titleTooltipDialog.show(taskItem, text);
|
titleTooltipDialog.show(taskItem, text);
|
||||||
}
|
}
|
||||||
|
@ -1304,7 +1304,6 @@ Item {
|
|||||||
//! this is used to bypass the internal separators if they exist
|
//! this is used to bypass the internal separators if they exist
|
||||||
var confirmedIndex = parabolicManager.realTaskIndex(index - 1);
|
var confirmedIndex = parabolicManager.realTaskIndex(index - 1);
|
||||||
|
|
||||||
|
|
||||||
for(var i=0; i<tasks.length; ++i){
|
for(var i=0; i<tasks.length; ++i){
|
||||||
var task = tasks[i];
|
var task = tasks[i];
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user