When compiled in debug mode, this PR adds code to check for conflicting
accelerator keys when a command is created. This can help developers
ensure that their default accelerator key selections don't conflict.
Replace partial match algorithm
Co-authored-by: 0penBrain <48731257+0penBrain@users.noreply.github.com>
When the shortcut/accelerator key is changed, the tooltip should be
recalculated using the same code that calculated the original. Also
ensure this happens when the accelerator preferences are loaded.
Fixes#4664.
Improved tooltips showing:
- the command name as an <h3> title,
- the tooltip text,
- the (What's this).
the title is build from translated getMenuText() and can contain a "&" character. This commit search and remove the "&" characters. It should be better not to use the "&" character in the command name, but if it is necessary it has to be done with "&&".
ref forum discussion: https://forum.freecadweb.org/viewtopic.php?f=34&t=58747
.
QAction defaults menu role to TextHeuristicRole, which causes qt to
guess the menu role based on action title. And titles start with
'Config', 'Options', 'Settings', etc. will be considered as preference
menu. It seems some non-english translation causes the wrong action be
chosen as preference, such as 'Treeview actions'.
This commit just applied a temporary fix to default to QAction::NoRole
for GroupCommand. If there is ever some GroupCommand need to be a
system menu item on macos, we could add some command bit flag for that
purpose.
'QString& QString::vsprintf(const char*, __va_list_tag*)' is deprecated: Use vasprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
'QString& QString::sprintf(const char*, ...)' is deprecated: Use asprintf(), arg() or QTextStream instead [-Wdeprecated-declarations]
Found via `codespell -q 3 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,currenty,dof,doubleclick,dum,eiter,elemente,feld,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,orgin,orginx,orginy,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml`
Each command will create an App::AutoTransaction to auto create and
commit a transaction for proper undo/redo. But if the command starts
editing, the current transaction may be required to out live the current
command.
Note that the command can only detect editing if the code calls
Gui::Document::setEdit(). There are objects that starts editing by
calling its own ViewProvider::setEdit(), e.g. various TechDraw
ViewProviders. In this case, to avoid auto committing, one can call
App::Application::setActiveTransaction() with the second argument set to
true, or call App::AutoTransaction::setEnable(false).
* invoke(), distinguish between command triggering source. Also add
support of auto transaction using App::AutoTransaction. Now all
command will support undo/redo by default.
* setupCheckable(), a helper function to Improve support of
PythonGroupCommand
* getObjectCmd(), helper function to output Python command to refer to
an object without ambiguity. Because with introduction of external
linking, an object can no longer be safely referred through the
current active document.
* Support auto MacroManager command logger. For commands that does not
log any output to MacroManager, a log entry of 'Gui.runCommand()' will
be auto generated.
* Support linked object in copyVisual()
* Modified do/runCommand() to print calling file and line number.
* Add various helper macros for run command involving a document or
object.