Pin elements to the shortcut bar

The bar's customising window gets an element search next to the command
list. Type part of a name, then drag a hit onto the bar, double-click
it, or press Enter to pin the best one. A pinned element shows as its
icon among the commands, and clicking it places the element, as the
picker does.

Pinned elements are saved in the same list as the commands, by
collection path (common://, custom://, company://), so the row keeps
the user's order. Elements embedded in a project are not offered: their
path names the project as loaded now. Elements are offered for the
empty-folio bar only; with something selected the bar is for acting on
it. Once any element is pinned there, the palette folder grid under the
bar is hidden, and comes back while typing a search.

Dragging a pinned element off the bar onto the commands, or a double
click, removes it. The Preferences page shows pinned elements by name
and icon, and removing one there drops it instead of listing it as a
command. The customising window is now kept on screen, since it is
taller than before.

Discussion #1033.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-27 03:05:54 +13:00
parent 57905a5789
commit 5bd55801e9
5 changed files with 246 additions and 48 deletions
+20
View File
@@ -22,6 +22,8 @@
#include <QCoreApplication>
#include <QSettings>
#include <algorithm>
namespace {
QString settingsKey(ShortcutBarSettings::Context context)
{
@@ -140,3 +142,21 @@ QStringList ShortcutBarSettings::availableIds()
}
return ids;
}
/**
@return true if @a id is a pinned element's collection path rather than
a command id. Command ids never contain "://".
*/
bool ShortcutBarSettings::isElement(const QString &id)
{
return id.contains(QLatin1String("://"));
}
/**
@return true if the row for @a context holds at least one element
*/
bool ShortcutBarSettings::hasElements(Context context)
{
const QStringList list = ids(context);
return std::any_of(list.cbegin(), list.cend(), &ShortcutBarSettings::isElement);
}