mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-12 15:14:12 +02:00
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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user