Gui: support toolbar drag and drop to status bar and menu bar (#13571)

* Gui: support toolbar drag and drop to status bar and menu bar

Closes FreeCAD/FreeCAD#12979

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Gui: improve toolbar handling in status and menu bar

* Gui: fix workbench tab bar orientation in status or menu bar

* Gui: remove workbench toolbar position settings

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Zheng Lei
2024-05-06 23:59:16 +08:00
committed by GitHub
parent 8f7424820c
commit b00a4384bf
15 changed files with 816 additions and 393 deletions

View File

@@ -36,7 +36,6 @@
# include <QToolBar>
# include <QToolButton>
# include <QToolTip>
# include <QMenuBar>
#endif
#include <Base/Exception.h>
@@ -55,7 +54,6 @@
#include "Macro.h"
#include "MainWindow.h"
#include "PythonEditor.h"
#include "UserSettings.h"
#include "WhatsThis.h"
#include "Widgets.h"
#include "Workbench.h"
@@ -631,7 +629,7 @@ WorkbenchGroup::WorkbenchGroup ( Command* pcCmd, QObject * parent )
void WorkbenchGroup::addTo(QWidget *widget)
{
if (widget->inherits("QToolBar") || widget->inherits("QMenuBar")) {
if (widget->inherits("QToolBar")) {
ParameterGrp::handle hGrp;
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Workbenches");
QWidget* wbSel;
@@ -642,13 +640,7 @@ void WorkbenchGroup::addTo(QWidget *widget)
wbSel = new WorkbenchTabWidget(this, widget);
}
if (widget->inherits("QToolBar")) {
qobject_cast<QToolBar*>(widget)->addWidget(wbSel);
}
else {
bool left = WorkbenchSwitcher::isLeftCorner(WorkbenchSwitcher::getValue());
qobject_cast<QMenuBar*>(widget)->setCornerWidget(wbSel, left ? Qt::TopLeftCorner : Qt::TopRightCorner);
}
static_cast<QToolBar*>(widget)->addWidget(wbSel);
}
else if (widget->inherits("QMenu")) {
auto menu = qobject_cast<QMenu*>(widget);