Files
qelectrotech-source-mirror/sources/shortcutbarsettings.h
T
ispyisail 6d42556d9f Customise the shortcut bar in place
Right-click the shortcut bar, or click the "…" button at its end, and it
turns into a small window holding two lists: the bar's commands, left
to right, and every other command. Drag a command onto the bar, off
it, or to another place on it; a double click moves it to the other
list. Terminé saves and shows the bar again where it was, with the
result; Annuler, Esc or closing the window leaves it as it was.
"Valeurs par défaut" puts back the defaults for this context.

A Qt::Popup closes on a press outside it and holds the mouse grab, so
the bar is re-shown as a Qt::Tool window for the time of the edit.
Only QSettings is written, through ShortcutBarSettings, never the
project's undo stack.

The popup now looks the commands up itself (popUpShortcutBar(pos,
context)) instead of being handed actions, since it has to rebuild
them after an edit. ShortcutBarSettings::availableIds() lists what can
go on the bar, shared with the configuration page. An empty bar still
shows its "…" button, so it can be filled again.

Discussion #1033.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG
(cherry picked from commit 4145d4bec1d403126b2a6587105aea47092db8a2)
2026-09-26 21:40:19 +12:00

52 lines
1.7 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHORTCUTBARSETTINGS_H
#define SHORTCUTBARSETTINGS_H
#include <QList>
#include <QString>
#include <QStringList>
/**
@brief The commands shown on the diagram editor's shortcut bar.
The bar opens at the cursor and shows a different row of commands
depending on what is selected. Each row is a list of ShortcutManager ids,
so any registered command can go on it and the bar needs no command list
of its own. Stored in QSettings, one key per context; a context the user
never changed uses the defaults below.
*/
class ShortcutBarSettings
{
public:
enum Context {
Canvas, ///< nothing selected
Selection, ///< elements, texts or shapes selected
Conductor ///< only conductors selected
};
static QList<Context> contexts();
static QString title(Context context);
static QStringList ids(Context context);
static QStringList defaultIds(Context context);
static void setIds(Context context, const QStringList &ids);
static QStringList availableIds();
};
#endif // SHORTCUTBARSETTINGS_H