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

@@ -31,7 +31,6 @@
#include "Application.h"
#include "Command.h"
#include "MainWindow.h"
#include "UserSettings.h"
using namespace Gui;
@@ -288,8 +287,6 @@ void MenuManager::setup(MenuItem* menuItems) const
}
}
setupMenuBarCornerWidgets();
// hide all menus which we don't need for the moment
for (QList<QAction*>::Iterator it = actions.begin(); it != actions.end(); ++it) {
(*it)->setVisible(false);
@@ -366,41 +363,6 @@ void MenuManager::setup(MenuItem* item, QMenu* menu) const
}
}
void MenuManager::setupMenuBarCornerWidgets() const
{
/*Note: currently only workbench selector uses corner widget.*/
QMenuBar* menuBar = getMainWindow()->menuBar();
std::string pos = WorkbenchSwitcher::getValue();
bool showLeftWidget = false;
bool showRightWidget = false;
//Right corner widget
if (WorkbenchSwitcher::isRightCorner(pos)) {
//add workbench selector to menubar right corner widget.
if (!menuBar->cornerWidget(Qt::TopRightCorner)) {
Application::Instance->commandManager().addTo("Std_Workbench", menuBar);
}
showRightWidget = true;
}
//Left corner widget
else if (WorkbenchSwitcher::isLeftCorner(pos)) {
//add workbench selector to menubar left corner widget.
if (!menuBar->cornerWidget(Qt::TopLeftCorner)) {
Application::Instance->commandManager().addTo("Std_Workbench", menuBar);
}
showLeftWidget = true;
}
// Set visibility of corner widget
if (QWidget* right = menuBar->cornerWidget(Qt::TopRightCorner)) {
right->setVisible(showRightWidget);
}
if (QWidget* left = menuBar->cornerWidget(Qt::TopLeftCorner)) {
left->setVisible(showLeftWidget);
}
}
void MenuManager::retranslate() const
{
QMenuBar* menuBar = getMainWindow()->menuBar();