mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-28 04:54:13 +02:00
Show the selection's commands beside the cursor after a click
After a click that selects something on a folio, a small row of commands appears just above and to the right of the cursor, as the SolidWorks context toolbar does. It fades as the mouse moves away and is gone past 200 pixels; a click elsewhere, the wheel, a key press or an emptied selection hide it too. Clicking a command leaves it up, so rotate can be clicked again. The commands are the shortcut bar's for that selection -- elements or conductors -- at most eight, so customising the bar customises this as well. It is a child of the view's viewport, never a window, and never takes the focus. It is not shown after a drag (moving items, a rubber band), while placing or drawing (Diagram::eventInterfaceIsRunning()), on a read-only folio, or when switched off with the new General option "Afficher les commandes près de la sélection" (diagrameditor/ context_toolbar, on by default). ShortcutBarSettings::contextFor() now decides the context for both the bar and this toolbar. Discussion #1033. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01G2d2Zi8BfrYRPX88zhaoFG (cherry picked from commit 78f3c1a2bc5c3cf1f7beae4bd60aefec20847d6d)
This commit is contained in:
@@ -17,9 +17,11 @@
|
||||
*/
|
||||
#include "shortcutbarsettings.h"
|
||||
|
||||
#include "qetgraphicsitem/conductor.h"
|
||||
#include "shortcutmanager.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <algorithm>
|
||||
#include <QSettings>
|
||||
|
||||
namespace {
|
||||
@@ -46,6 +48,22 @@ QList<ShortcutBarSettings::Context> ShortcutBarSettings::contexts()
|
||||
return {Canvas, Selection, Conductor};
|
||||
}
|
||||
|
||||
/**
|
||||
@return the context for @a selection: Canvas when empty, Conductor when
|
||||
it holds only conductors, Selection otherwise
|
||||
*/
|
||||
ShortcutBarSettings::Context ShortcutBarSettings::contextFor(
|
||||
const QList<QGraphicsItem *> &selection)
|
||||
{
|
||||
if (selection.isEmpty()) {
|
||||
return Canvas;
|
||||
}
|
||||
const bool only_conductors = std::all_of(
|
||||
selection.cbegin(), selection.cend(),
|
||||
[](QGraphicsItem *item) { return item->type() == Conductor::Type; });
|
||||
return only_conductors ? Conductor : Selection;
|
||||
}
|
||||
|
||||
/**
|
||||
@return the name of @a context, for the configuration page
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user