Merge pull request #1060 from ispyisail/feature/shortcut-bar-symbols

Add pinned elements to the shortcut bar, with a width you can set
This commit is contained in:
Laurent Trinques
2026-09-27 09:09:44 +02:00
committed by GitHub
5 changed files with 423 additions and 54 deletions
+48
View File
@@ -24,6 +24,8 @@
#include <algorithm>
#include <QSettings>
#include <algorithm>
namespace {
QString settingsKey(ShortcutBarSettings::Context context)
{
@@ -158,3 +160,49 @@ 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);
}
/**
@return the width the user gave the bar with its size grip, or 0 when
they never did: the tiles then stay on one row
*/
int ShortcutBarSettings::barWidth()
{
return QSettings().value(QStringLiteral("diagrameditor/shortcut_bar/width"), 0).toInt();
}
void ShortcutBarSettings::setBarWidth(int width)
{
QSettings().setValue(QStringLiteral("diagrameditor/shortcut_bar/width"), width);
}
/**
@return the size the user left the customising window at, or an invalid
size when it was never opened
*/
QSize ShortcutBarSettings::editorSize()
{
return QSettings().value(QStringLiteral("diagrameditor/shortcut_bar/editor_size")).toSize();
}
void ShortcutBarSettings::setEditorSize(const QSize &size)
{
QSettings().setValue(QStringLiteral("diagrameditor/shortcut_bar/editor_size"), size);
}