mirror of
https://github.com/KDE/latte-dock.git
synced 2025-03-09 00:58:15 +03:00
identify highest priority application launcher
--provide a new way to identify which application launcher has the highest priority in order to be triggered. When an application launcher applet has a global shortcut assigned to it then that application launcher applet has the highest priority in order to be triggered through "Super" global key.
This commit is contained in:
parent
411017c0f6
commit
34d6c2cd78
@ -207,6 +207,33 @@ ShortcutsPart::ShortcutsTracker *GlobalShortcuts::shortcutsTracker() const
|
||||
return m_shortcutsTracker;
|
||||
}
|
||||
|
||||
Latte::View *GlobalShortcuts::highestApplicationLauncherView(const QList<Latte::View *> &views) const
|
||||
{
|
||||
if (views.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Latte::View *highestPriorityView{nullptr};
|
||||
|
||||
for (const auto view : views) {
|
||||
if (view->interface()->applicationLauncherHasGlobalShortcut()) {
|
||||
highestPriorityView = view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!highestPriorityView) {
|
||||
for (const auto view : views) {
|
||||
if (view->interface()->containsApplicationLauncher()) {
|
||||
highestPriorityView = view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return highestPriorityView;
|
||||
}
|
||||
|
||||
//! Activate launcher menu through dbus interface
|
||||
void GlobalShortcuts::activateLauncherMenu()
|
||||
{
|
||||
@ -221,28 +248,26 @@ void GlobalShortcuts::activateLauncherMenu()
|
||||
sortedViews = currentLayout->sortedLatteViews();
|
||||
}
|
||||
|
||||
for (const auto view : sortedViews) {
|
||||
if (view->interface()->containsApplicationLauncher()) {
|
||||
if (view->visibility()->isHidden() && view->interface()->applicationLauncherInPopup()) {
|
||||
if (!m_hideViews.contains(view)) {
|
||||
m_hideViews.append(view);
|
||||
}
|
||||
Latte::View *highestPriorityView = highestApplicationLauncherView(sortedViews);
|
||||
|
||||
m_lastInvokedAction = m_singleMetaAction;
|
||||
|
||||
view->visibility()->setBlockHiding(true);
|
||||
|
||||
//! delay the execution in order to show first the view
|
||||
QTimer::singleShot(APPLETEXECUTIONDELAY, [this, view]() {
|
||||
view->toggleAppletExpanded(view->interface()->applicationLauncherId());
|
||||
});
|
||||
|
||||
m_hideViewsTimer.start();
|
||||
} else {
|
||||
view->toggleAppletExpanded(view->interface()->applicationLauncherId());
|
||||
if (highestPriorityView) {
|
||||
if (highestPriorityView->visibility()->isHidden() && highestPriorityView->interface()->applicationLauncherInPopup()) {
|
||||
if (!m_hideViews.contains(highestPriorityView)) {
|
||||
m_hideViews.append(highestPriorityView);
|
||||
}
|
||||
|
||||
return;
|
||||
m_lastInvokedAction = m_singleMetaAction;
|
||||
|
||||
highestPriorityView->visibility()->setBlockHiding(true);
|
||||
|
||||
//! delay the execution in order to show first the view
|
||||
QTimer::singleShot(APPLETEXECUTIONDELAY, [this, highestPriorityView]() {
|
||||
highestPriorityView->toggleAppletExpanded(highestPriorityView->interface()->applicationLauncherId());
|
||||
});
|
||||
|
||||
m_hideViewsTimer.start();
|
||||
} else {
|
||||
highestPriorityView->toggleAppletExpanded(highestPriorityView->interface()->applicationLauncherId());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,14 +407,8 @@ void GlobalShortcuts::showViews()
|
||||
}
|
||||
}
|
||||
|
||||
//! show Meta if it is not already shown for Tasks Latte View
|
||||
if (!viewWithTasks || !viewWithTasks->interface()->containsApplicationLauncher()) {
|
||||
for(const auto view : sortedViews) {
|
||||
if (!viewWithMeta && m_corona->universalSettings()->kwin_metaForwardedToLatte() && view->interface()->containsApplicationLauncher()) {
|
||||
viewWithMeta = view;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_corona->universalSettings()->kwin_metaForwardedToLatte()) {
|
||||
viewWithMeta = highestApplicationLauncherView(sortedViews);
|
||||
}
|
||||
|
||||
bool viewFound{false};
|
||||
@ -399,9 +418,13 @@ void GlobalShortcuts::showViews()
|
||||
}
|
||||
|
||||
//! show view that contains tasks plasmoid
|
||||
if (viewWithTasks && viewWithTasks->interface()->showShortcutBadges(true, true)) {
|
||||
if (viewWithTasks) {
|
||||
viewFound = true;
|
||||
|
||||
bool showMeta = (viewWithMeta && (viewWithMeta == viewWithTasks));
|
||||
|
||||
viewWithTasks->interface()->showShortcutBadges(true, showMeta);
|
||||
|
||||
if (!m_hideViewsTimer.isActive()) {
|
||||
m_hideViews.append(viewWithTasks);
|
||||
viewWithTasks->visibility()->setBlockHiding(true);
|
||||
@ -510,7 +533,7 @@ void GlobalShortcuts::hideViewsTimerSlot()
|
||||
for(const auto latteView : m_hideViews) {
|
||||
latteView->visibility()->setBlockHiding(false);
|
||||
latteView->interface()->hideShortcutBadges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_hideViews.clear();
|
||||
|
@ -79,6 +79,9 @@ private:
|
||||
bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base);
|
||||
bool viewsToHideAreValid();
|
||||
|
||||
//! highest priority application launcher view
|
||||
Latte::View *highestApplicationLauncherView(const QList<Latte::View *> &views) const;
|
||||
|
||||
QList<Latte::View *> sortedViewsList(QHash<const Plasma::Containment *, Latte::View *> *views);
|
||||
|
||||
private:
|
||||
|
@ -81,6 +81,25 @@ void ContainmentInterface::identifyMethods()
|
||||
m_showShortcutsMethod = m_mainItem->metaObject()->method(sbIndex);
|
||||
}
|
||||
|
||||
bool ContainmentInterface::applicationLauncherHasGlobalShortcut() const
|
||||
{
|
||||
if (!containsApplicationLauncher()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int launcherAppletId = applicationLauncherId();
|
||||
|
||||
const auto applets = m_view->containment()->applets();
|
||||
|
||||
for (auto applet : applets) {
|
||||
if (applet->id() == launcherAppletId) {
|
||||
return !applet->globalShortcut().isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContainmentInterface::applicationLauncherInPopup() const
|
||||
{
|
||||
if (!containsApplicationLauncher()) {
|
||||
@ -103,11 +122,13 @@ bool ContainmentInterface::applicationLauncherInPopup() const
|
||||
|
||||
bool ContainmentInterface::containsApplicationLauncher() const
|
||||
{
|
||||
return applicationLauncherId() == -1 ? false : true;
|
||||
return (applicationLauncherId() >= 0);
|
||||
}
|
||||
|
||||
bool ContainmentInterface::isCapableToShowShortcutBadges() const
|
||||
bool ContainmentInterface::isCapableToShowShortcutBadges()
|
||||
{
|
||||
identifyMainItem();
|
||||
|
||||
if (!m_view->latteTasksArePresent() && m_view->tasksPresent()) {
|
||||
return false;
|
||||
}
|
||||
@ -119,15 +140,21 @@ int ContainmentInterface::applicationLauncherId() const
|
||||
{
|
||||
const auto applets = m_view->containment()->applets();
|
||||
|
||||
auto launcherId{-1};
|
||||
|
||||
for (auto applet : applets) {
|
||||
const auto provides = applet->kPackage().metadata().value(QStringLiteral("X-Plasma-Provides"));
|
||||
|
||||
if (provides.contains(QLatin1String("org.kde.plasma.launchermenu"))) {
|
||||
return applet->id();
|
||||
if (!applet->globalShortcut().isEmpty()) {
|
||||
return applet->id();
|
||||
} else if (launcherId == -1) {
|
||||
launcherId = applet->id();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return launcherId;
|
||||
}
|
||||
|
||||
bool ContainmentInterface::updateBadgeForLatteTask(const QString identifier, const QString value)
|
||||
|
@ -43,8 +43,9 @@ public:
|
||||
virtual ~ContainmentInterface();
|
||||
|
||||
bool applicationLauncherInPopup() const;
|
||||
bool applicationLauncherHasGlobalShortcut() const;
|
||||
bool containsApplicationLauncher() const;
|
||||
bool isCapableToShowShortcutBadges() const;
|
||||
bool isCapableToShowShortcutBadges();
|
||||
|
||||
bool activateEntry(const int index);
|
||||
bool newInstanceForEntry(const int index);
|
||||
|
@ -62,6 +62,10 @@ Loader{
|
||||
return;
|
||||
}
|
||||
|
||||
if (root.showMetaBadge && applet && applet.id === applicationLauncherId) {
|
||||
return '\u2318';
|
||||
}
|
||||
|
||||
if (root.showAppletShortcutBadges) {
|
||||
var plasmaShortcut = applet ? shortcutsEngine.appletShortcutBadge(applet.id) : "";
|
||||
|
||||
@ -70,9 +74,7 @@ Loader{
|
||||
}
|
||||
}
|
||||
|
||||
if (root.showMetaBadge && applet && applet.id === applicationLauncherId) {
|
||||
return '\u2318';
|
||||
} else if (appletNumberLoader.fixedIndex>=1 && appletNumberLoader.fixedIndex<20) {
|
||||
if (appletNumberLoader.fixedIndex>=1 && appletNumberLoader.fixedIndex<20) {
|
||||
return root.badgesForActivate[appletNumberLoader.fixedIndex-1];
|
||||
} else {
|
||||
return "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user