dont wait for dock to show for activate shortcuts

--when the application launcher is not a popup then
we do not have to wait for the dock show we can execute
the activation code immediately
--when Latte activates an entry can now understand
if a popup is going to be shown in order to delay
the execution. If a popup is NOT going to show either
for a latte task or an applet then the code is executed
immediately

BUG:415417
FIXED-IN:0.9.6
pull/10/head
Michail Vourlakos
parent 111254e509
commit d31d7afb9d

@ -223,7 +223,7 @@ void GlobalShortcuts::activateLauncherMenu()
for (const auto view : sortedViews) {
if (view->interface()->containsApplicationLauncher()) {
if (view->visibility()->isHidden()) {
if (view->visibility()->isHidden() && view->interface()->applicationLauncherInPopup()) {
if (!m_hideViews.contains(view)) {
m_hideViews.append(view);
}
@ -247,7 +247,7 @@ void GlobalShortcuts::activateLauncherMenu()
}
}
bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier)
bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution)
{
bool activation{modifier == static_cast<Qt::Key>(Qt::META)};
bool newInstance{!activation};
@ -262,18 +262,25 @@ bool GlobalShortcuts::activatePlasmaTaskManager(const Latte::View *view, int ind
}
});
*delayedExecution = true;
return true;
} else {
*delayedExecution = false;
return (activation ? view->interface()->activatePlasmaTask(index) : view->interface()->newInstanceForPlasmaTask(index));
}
}
bool GlobalShortcuts::activateLatteEntry(const Latte::View *view, int index, Qt::Key modifier)
bool GlobalShortcuts::activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution)
{
bool activation{modifier == static_cast<Qt::Key>(Qt::META)};
bool newInstance{!activation};
if (view->visibility()->isHidden()) {
int appletId = view->interface()->appletIdForIndex(index);
bool hasPopUp {(appletId>-1 && view->appletIsExpandable(appletId))};
if (view->visibility()->isHidden() && hasPopUp) {
//! delay the execution in order to show first the view
QTimer::singleShot(APPLETEXECUTIONDELAY, [this, view, index, activation]() {
if (activation) {
@ -283,8 +290,12 @@ bool GlobalShortcuts::activateLatteEntry(const Latte::View *view, int index, Qt:
}
});
*delayedExecution = true;
return true;
} else {
*delayedExecution = false;
return (activation ? view->interface()->activateEntry(index) : view->interface()->newInstanceForEntry(index));
}
}
@ -307,16 +318,21 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
continue;
}
bool delayed{false};
if ((!view->latteTasksArePresent() && view->tasksPresent() &&
activatePlasmaTaskManager(view, index, modifier))
|| activateLatteEntry(view, index, modifier)) {
activatePlasmaTaskManager(view, index, modifier, &delayed))
|| activateLatteEntry(view, index, modifier, &delayed)) {
if (!m_hideViews.contains(view)) {
m_hideViews.append(view);
}
view->visibility()->setBlockHiding(true);
m_hideViewsTimer.start();
if (delayed) {
view->visibility()->setBlockHiding(true);
m_hideViewsTimer.start();
}
return;
}
}

@ -73,8 +73,8 @@ private:
void showViews();
void showSettings();
bool activateLatteEntry(const Latte::View *view, int index, Qt::Key modifier);
bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier);
bool activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution);
bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution);
bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base);
bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base);
bool viewsToHideAreValid();

@ -73,12 +73,34 @@ void ContainmentInterface::identifyMethods()
int aeIndex = m_mainItem->metaObject()->indexOfMethod("activateEntryAtIndex(QVariant)");
int niIndex = m_mainItem->metaObject()->indexOfMethod("newInstanceForEntryAtIndex(QVariant)");
int sbIndex = m_mainItem->metaObject()->indexOfMethod("setShowAppletShortcutBadges(QVariant,QVariant,QVariant,QVariant)");
int afiIndex = m_mainItem->metaObject()->indexOfMethod("appletIdForIndex(QVariant)");
m_activateEntryMethod = m_mainItem->metaObject()->method(aeIndex);
m_appletIdForIndexMethod = m_mainItem->metaObject()->method(afiIndex);
m_newInstanceMethod = m_mainItem->metaObject()->method(niIndex);
m_showShortcutsMethod = m_mainItem->metaObject()->method(sbIndex);
}
bool ContainmentInterface::applicationLauncherInPopup() const
{
if (!containsApplicationLauncher()) {
return false;
}
int launcherAppletId = applicationLauncherId();
QString launcherPluginId;
const auto applets = m_view->containment()->applets();
for (auto applet : applets) {
if (applet->id() == launcherAppletId) {
launcherPluginId = applet->kPackage().metadata().pluginId();
}
}
return launcherPluginId != "org.kde.plasma.kickerdash";
}
bool ContainmentInterface::containsApplicationLauncher() const
{
return applicationLauncherId() == -1 ? false : true;
@ -304,5 +326,21 @@ bool ContainmentInterface::showShortcutBadges(const bool showLatteShortcuts, con
return m_showShortcutsMethod.invoke(m_mainItem, Q_ARG(QVariant, showLatteShortcuts), Q_ARG(QVariant, true), Q_ARG(QVariant, showMeta), Q_ARG(QVariant, appLauncherId));
}
int ContainmentInterface::appletIdForIndex(const int index)
{
identifyMainItem();
if (!m_appletIdForIndexMethod.isValid()) {
return false;
}
QVariant appletId{-1};
m_appletIdForIndexMethod.invoke(m_mainItem, Q_RETURN_ARG(QVariant, appletId), Q_ARG(QVariant, index));
return appletId.toInt();
}
}
}

@ -42,6 +42,7 @@ public:
ContainmentInterface(Latte::View *parent);
virtual ~ContainmentInterface();
bool applicationLauncherInPopup() const;
bool containsApplicationLauncher() const;
bool isCapableToShowShortcutBadges() const;
@ -59,6 +60,7 @@ public:
bool updateBadgeForLatteTask(const QString identifier, const QString value);
int applicationLauncherId() const;
int appletIdForIndex(const int index);
private slots:
void identifyMainItem();
@ -66,6 +68,7 @@ private slots:
private:
QMetaMethod m_activateEntryMethod;
QMetaMethod m_appletIdForIndexMethod;
QMetaMethod m_newInstanceMethod;
QMetaMethod m_showShortcutsMethod;

@ -1270,6 +1270,25 @@ void View::deactivateApplets()
}
}
bool View::appletIsExpandable(const int id)
{
if (!containment()) {
return false;
}
for (const auto applet : containment()->applets()) {
if (applet->id() == id) {
PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
if (ai) {
return (ai->preferredRepresentation() != ai->fullRepresentation());
}
}
}
return false;
}
void View::toggleAppletExpanded(const int id)
{
if (!containment()) {

@ -229,6 +229,7 @@ public slots:
Q_INVOKABLE void setBlockHiding(bool block);
Q_INVOKABLE void toggleAppletExpanded(const int id);
Q_INVOKABLE bool appletIsExpandable(const int id);
Q_INVOKABLE bool mimeContainsPlasmoid(QMimeData *mimeData, QString name);
Q_INVOKABLE bool tasksPresent();

@ -426,6 +426,11 @@ Item {
return false;
}
function refersEntryIndex(entryIndex) {
return (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index));
}
///END functions
//BEGIN connections
@ -589,7 +594,7 @@ Item {
onSignalActivateEntryAtIndex: {
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) {
latteApplet.activateTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex);
} else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index))) {
} else if (root.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) {
latteView.toggleAppletExpanded(applet.id);
}
}
@ -597,7 +602,7 @@ Item {
onSignalNewInstanceForEntryAtIndex: {
if (parabolicManager.pseudoIndexBelongsToLatteApplet(entryIndex) && appletItem.isLattePlasmoid) {
latteApplet.newInstanceForTaskAtIndex(entryIndex - latteApplet.tasksBaseIndex);
} else if (root.unifiedGlobalShortcuts && (entryIndex === parabolicManager.pseudoAppletIndex(appletItem.index))) {
} else if (root.unifiedGlobalShortcuts && refersEntryIndex(entryIndex)) {
latteView.toggleAppletExpanded(applet.id);
}
}

@ -1197,7 +1197,7 @@ Item {
}
}
// This is called by dockcorona in response to a Meta+number shortcut.
//! this is called from Latte::View::ContainmentInterface
function activateEntryAtIndex(index) {
if (typeof index !== "number") {
return;
@ -1212,7 +1212,7 @@ Item {
signalActivateEntryAtIndex(index);
}
// This is called by dockcorona in response to a Meta+Alt+number shortcut.
//! this is called from Latte::View::ContainmentInterface
function newInstanceForEntryAtIndex(index) {
if (typeof index !== "number") {
return;
@ -1227,6 +1227,39 @@ Item {
signalNewInstanceForEntryAtIndex(index);
}
//! this is called from Latte::View::ContainmentInterface
function appletIdForIndex(index) {
if (!root.unifiedGlobalShortcuts || parabolicManager.pseudoIndexBelongsToLatteApplet(index)) {
return -1;
}
for (var i=0; i<layoutsContainer.startLayout.children.length; ++i){
var appletItem = layoutsContainer.startLayout.children[i];
if (appletItem && appletItem.refersEntryIndex(index)) {
return appletItem.applet.id;
}
}
for (var j=0; j<layoutsContainer.mainLayout.children.length; ++j){
var appletItem2 = layoutsContainer.mainLayout.children[j];
if (appletItem2 && appletItem2.refersEntryIndex(index)) {
return appletItem2.applet.id;
}
}
for (var k=0; j<layoutsContainer.endLayout.children.length; ++k){
var appletItem3 = layoutsContainer.endLayout.children[k];
if (appletItem3 && appletItem3.refersEntryIndex(index)) {
return appletItem3.applet.id;
}
}
return -1;
}
function showTooltipLabel(taskItem, text){
titleTooltipDialog.show(taskItem, text);

Loading…
Cancel
Save