| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | #include <QActionEvent>
|
| | #include <QActionGroup>
|
| | #include <QApplication>
|
| | #include <QEvent>
|
| | #include <QFileInfo>
|
| | #include <QMenu>
|
| | #include <QRegularExpression>
|
| | #include <QScreen>
|
| | #include <QTimer>
|
| | #include <QToolBar>
|
| | #include <QToolButton>
|
| | #include <QToolTip>
|
| |
|
| | #include <Base/Exception.h>
|
| | #include <Base/Interpreter.h>
|
| | #include <Base/Tools.h>
|
| | #include <App/Document.h>
|
| |
|
| | #include "Action.h"
|
| | #include "BitmapFactory.h"
|
| | #include "Command.h"
|
| | #include "Dialogs/DlgUndoRedo.h"
|
| | #include "PreferencePages/DlgSettingsWorkbenchesImp.h"
|
| | #include "Document.h"
|
| | #include "EditorView.h"
|
| | #include "Macro.h"
|
| | #include "ModuleIO.h"
|
| | #include "MainWindow.h"
|
| | #include "PythonEditor.h"
|
| | #include "WhatsThis.h"
|
| | #include "Widgets.h"
|
| | #include "Workbench.h"
|
| | #include "WorkbenchManager.h"
|
| | #include "WorkbenchSelector.h"
|
| | #include "ShortcutManager.h"
|
| | #include "Tools.h"
|
| |
|
| |
|
| | using namespace Gui;
|
| | using namespace Gui::Dialog;
|
| | namespace sp = std::placeholders;
|
| |
|
| | |
| | |
| | |
| |
|
| | Action::Action(Command* pcCmd, QObject* parent)
|
| | : QObject(parent)
|
| | , _action(new QAction(this))
|
| | , _pcCmd(pcCmd)
|
| | {
|
| | _action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
|
| | _connection = connect(_action, &QAction::triggered, this, &Action::onActivated);
|
| | }
|
| |
|
| | Action::Action(Command* pcCmd, QAction* action, QObject* parent)
|
| | : QObject(parent)
|
| | , _action(action)
|
| | , _pcCmd(pcCmd)
|
| | {
|
| | _action->setParent(this);
|
| | _action->setObjectName(QString::fromLatin1(_pcCmd->getName()));
|
| | _connection = connect(_action, &QAction::triggered, this, &Action::onActivated);
|
| | }
|
| |
|
| | Action::~Action()
|
| | {
|
| | delete _action;
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void Action::addTo(QWidget* widget)
|
| | {
|
| | widget->addAction(_action);
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void Action::onActivated()
|
| | {
|
| | command()->invoke(0, Command::TriggerAction);
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void Action::onToggled(bool toggle)
|
| | {
|
| | command()->invoke(toggle ? 1 : 0, Command::TriggerAction);
|
| | }
|
| |
|
| | void Action::setCheckable(bool check)
|
| | {
|
| | if (check == _action->isCheckable()) {
|
| | return;
|
| | }
|
| |
|
| | _action->setCheckable(check);
|
| |
|
| | if (check) {
|
| | disconnect(_connection);
|
| | _connection = connect(_action, &QAction::toggled, this, &Action::onToggled);
|
| | }
|
| | else {
|
| | disconnect(_connection);
|
| | _connection = connect(_action, &QAction::triggered, this, &Action::onActivated);
|
| | }
|
| | }
|
| |
|
| | void Action::setChecked(bool check)
|
| | {
|
| | _action->setChecked(check);
|
| | }
|
| |
|
| | |
| | |
| | |
| | |
| | |
| |
|
| | void Action::setBlockedChecked(bool check)
|
| | {
|
| | QSignalBlocker block(_action);
|
| | _action->setChecked(check);
|
| | }
|
| |
|
| | bool Action::isChecked() const
|
| | {
|
| | return _action->isChecked();
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void Action::setEnabled(bool enable)
|
| | {
|
| | _action->setEnabled(enable);
|
| | }
|
| |
|
| | bool Action::isEnabled() const
|
| | {
|
| | return _action->isEnabled();
|
| | }
|
| |
|
| | void Action::setVisible(bool visible)
|
| | {
|
| | _action->setVisible(visible);
|
| | }
|
| |
|
| | void Action::setShortcut(const QString& key)
|
| | {
|
| | _action->setShortcut(key);
|
| | setToolTip(_tooltip, _title);
|
| | }
|
| |
|
| | QKeySequence Action::shortcut() const
|
| | {
|
| | return _action->shortcut();
|
| | }
|
| |
|
| | void Action::setIcon(const QIcon& icon)
|
| | {
|
| | _action->setIcon(icon);
|
| | }
|
| |
|
| | QIcon Action::icon() const
|
| | {
|
| | return _action->icon();
|
| | }
|
| |
|
| | void Action::setStatusTip(const QString& text)
|
| | {
|
| | _action->setStatusTip(text);
|
| | }
|
| |
|
| | QString Action::statusTip() const
|
| | {
|
| | return _action->statusTip();
|
| | }
|
| |
|
| | void Action::setText(const QString& text)
|
| | {
|
| | _action->setText(text);
|
| | if (_title.isEmpty()) {
|
| | setToolTip(_tooltip);
|
| | }
|
| | }
|
| |
|
| | QString Action::text() const
|
| | {
|
| | return _action->text();
|
| | }
|
| |
|
| | void Action::setToolTip(const QString& text, const QString& title)
|
| | {
|
| | _tooltip = text;
|
| | _title = title;
|
| | _action->setToolTip(createToolTip(
|
| | text,
|
| | title.isEmpty() ? _action->text() : title,
|
| | _action->font(),
|
| | _action->shortcut().toString(QKeySequence::NativeText),
|
| | command()
|
| | ));
|
| | }
|
| |
|
| | QString Action::cleanTitle(const QString& title)
|
| | {
|
| | QString text(title);
|
| |
|
| | static QRegularExpression re(QStringLiteral("&(.)"));
|
| | text.replace(re, QStringLiteral("\\1"));
|
| |
|
| |
|
| | #if 0
|
| |
|
| | static QRegularExpression rePunct(QStringLiteral("[[:punct:]]+$"));
|
| | text.replace(rePunct, QString());
|
| | #endif
|
| | return text;
|
| | }
|
| |
|
| | QString Action::commandToolTip(const Command* cmd, bool richFormat)
|
| | {
|
| | if (!cmd) {
|
| | return {};
|
| | }
|
| |
|
| | if (richFormat) {
|
| | if (auto action = cmd->getAction()) {
|
| | return action->_action->toolTip();
|
| | }
|
| | }
|
| |
|
| | QString title, tooltip;
|
| | if (dynamic_cast<const MacroCommand*>(cmd)) {
|
| | if (auto txt = cmd->getMenuText()) {
|
| | title = QString::fromUtf8(txt);
|
| | }
|
| | if (auto txt = cmd->getToolTipText()) {
|
| | tooltip = QString::fromUtf8(txt);
|
| | }
|
| | }
|
| | else {
|
| | if (auto txt = cmd->getMenuText()) {
|
| | title = qApp->translate(cmd->className(), txt);
|
| | }
|
| | if (auto txt = cmd->getToolTipText()) {
|
| | tooltip = qApp->translate(cmd->className(), txt);
|
| | }
|
| | }
|
| |
|
| | if (!richFormat) {
|
| | return tooltip;
|
| | }
|
| | return createToolTip(tooltip, title, QFont(), cmd->getShortcut(), cmd);
|
| | }
|
| |
|
| | QString Action::commandMenuText(const Command* cmd)
|
| | {
|
| | if (!cmd) {
|
| | return {};
|
| | }
|
| |
|
| | QString title;
|
| | if (auto action = cmd->getAction()) {
|
| | title = action->text();
|
| | }
|
| | else if (dynamic_cast<const MacroCommand*>(cmd)) {
|
| | if (auto txt = cmd->getMenuText()) {
|
| | title = QString::fromUtf8(txt);
|
| | }
|
| | }
|
| | else {
|
| | if (auto txt = cmd->getMenuText()) {
|
| | title = qApp->translate(cmd->className(), txt);
|
| | }
|
| | }
|
| | if (title.isEmpty()) {
|
| | title = QString::fromUtf8(cmd->getName());
|
| | }
|
| | else {
|
| | title = cleanTitle(title);
|
| | }
|
| | return title;
|
| | }
|
| |
|
| | QString Action::createToolTip(
|
| | QString helpText,
|
| | const QString& title,
|
| | const QFont& font,
|
| | const QString& shortCut,
|
| | const Command* command
|
| | )
|
| | {
|
| | QString text = cleanTitle(title);
|
| |
|
| | if (text.isEmpty()) {
|
| | return helpText;
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | QString shortcut = shortCut;
|
| | if (!shortcut.isEmpty() && helpText.endsWith(shortcut)) {
|
| | helpText.resize(helpText.size() - shortcut.size());
|
| | }
|
| | if (!shortcut.isEmpty()) {
|
| | shortcut = QStringLiteral(" (%1)").arg(shortcut);
|
| | }
|
| |
|
| | QString tooltip = QStringLiteral("<p style='white-space:pre; margin-bottom:0.5em;'><b>%1</b>%2</p>")
|
| | .arg(text.toHtmlEscaped(), shortcut.toHtmlEscaped());
|
| |
|
| | QString cmdName;
|
| | if (command && command->getName()) {
|
| | cmdName = QString::fromLatin1(command->getName());
|
| | if (auto groupcmd = dynamic_cast<const GroupCommand*>(command)) {
|
| | if (auto act = command->getAction()) {
|
| | int idx = act->property("defaultAction").toInt();
|
| | auto cmd = groupcmd->getCommand(idx);
|
| | if (cmd && cmd->getName()) {
|
| | cmdName = QStringLiteral("%1 (%2:%3)")
|
| | .arg(QString::fromLatin1(cmd->getName()), cmdName)
|
| | .arg(idx);
|
| | }
|
| | }
|
| | }
|
| | cmdName = QStringLiteral("<p style='white-space:pre; margin-top:0.5em;'><i>%1</i></p>")
|
| | .arg(cmdName.toHtmlEscaped());
|
| | }
|
| |
|
| | if (!shortcut.isEmpty() && helpText.endsWith(shortcut)) {
|
| | helpText.resize(helpText.size() - shortcut.size());
|
| | }
|
| |
|
| | if (helpText.isEmpty() || helpText == text || helpText == title) {
|
| | return tooltip + cmdName;
|
| | }
|
| | if (Qt::mightBeRichText(helpText)) {
|
| |
|
| | return tooltip + helpText + cmdName;
|
| | }
|
| |
|
| | tooltip += QStringLiteral("<p style='white-space:pre; margin:0;'>");
|
| |
|
| |
|
| | if (helpText.indexOf(QLatin1Char('\n')) >= 0) {
|
| | tooltip += helpText.toHtmlEscaped() + QStringLiteral("</p>");
|
| | }
|
| | else {
|
| |
|
| |
|
| | float tipWidth = 400;
|
| | QFontMetrics fm(font);
|
| | int width = QtTools::horizontalAdvance(fm, helpText);
|
| | if (width <= tipWidth) {
|
| | tooltip += helpText.toHtmlEscaped() + QStringLiteral("</p>");
|
| | }
|
| | else {
|
| | int index = tipWidth / width * helpText.size();
|
| |
|
| | for (int i = 0; i < 50 && index < helpText.size(); ++i, ++index) {
|
| | if (helpText[index] == QLatin1Char(' ')) {
|
| | break;
|
| | }
|
| | }
|
| | tooltip += helpText.left(index).toHtmlEscaped() + QStringLiteral("</p>")
|
| | + helpText.right(helpText.size() - index).trimmed().toHtmlEscaped();
|
| | }
|
| | }
|
| | return tooltip + cmdName;
|
| | }
|
| |
|
| | QString Action::toolTip() const
|
| | {
|
| | return _tooltip;
|
| | }
|
| |
|
| | void Action::setWhatsThis(const QString& text)
|
| | {
|
| | _action->setWhatsThis(text);
|
| | }
|
| |
|
| | QString Action::whatsThis() const
|
| | {
|
| | return _action->whatsThis();
|
| | }
|
| |
|
| | void Action::setMenuRole(QAction::MenuRole menuRole)
|
| | {
|
| | _action->setMenuRole(menuRole);
|
| | }
|
| |
|
| |
|
| |
|
| | |
| | |
| | |
| |
|
| | ActionGroup::ActionGroup(Command* pcCmd, QObject* parent)
|
| | : Action(pcCmd, parent)
|
| | , _group(nullptr)
|
| | , _dropDown(false)
|
| | , _isMode(false)
|
| | , _rememberLast(true)
|
| | {
|
| | _group = new QActionGroup(this);
|
| | connect(_group, &QActionGroup::triggered, this, qOverload<QAction*>(&ActionGroup::onActivated));
|
| | connect(_group, &QActionGroup::hovered, this, &ActionGroup::onHovered);
|
| | }
|
| |
|
| | ActionGroup::~ActionGroup()
|
| | {
|
| | delete _group;
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void ActionGroup::addTo(QWidget* widget)
|
| | {
|
| |
|
| |
|
| |
|
| |
|
| | if (_dropDown) {
|
| | if (widget->inherits("QMenu")) {
|
| | auto menu = new QMenu(widget);
|
| | QAction* item = qobject_cast<QMenu*>(widget)->addMenu(menu);
|
| | item->setMenuRole(action()->menuRole());
|
| | menu->setTitle(action()->text());
|
| | menu->addActions(groupAction()->actions());
|
| |
|
| | QObject::connect(menu, &QMenu::aboutToShow, [this, menu]() { Q_EMIT aboutToShow(menu); });
|
| |
|
| | QObject::connect(menu, &QMenu::aboutToHide, [this, menu]() { Q_EMIT aboutToHide(menu); });
|
| | }
|
| | else if (widget->inherits("QToolBar")) {
|
| | widget->addAction(action());
|
| | QToolButton* tb = widget->findChildren<QToolButton*>().constLast();
|
| | tb->setPopupMode(QToolButton::MenuButtonPopup);
|
| | tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton"));
|
| | QList<QAction*> acts = groupAction()->actions();
|
| | auto menu = new QMenu(tb);
|
| | menu->addActions(acts);
|
| | tb->setMenu(menu);
|
| |
|
| | QObject::connect(menu, &QMenu::aboutToShow, [this, menu]() { Q_EMIT aboutToShow(menu); });
|
| |
|
| | QObject::connect(menu, &QMenu::aboutToHide, [this, menu]() { Q_EMIT aboutToHide(menu); });
|
| | }
|
| | else {
|
| | widget->addActions(groupAction()->actions());
|
| | }
|
| | }
|
| | else {
|
| | widget->addActions(groupAction()->actions());
|
| | }
|
| | }
|
| |
|
| | void ActionGroup::setEnabled(bool check)
|
| | {
|
| | Action::setEnabled(check);
|
| | groupAction()->setEnabled(check);
|
| | }
|
| |
|
| | void ActionGroup::setDisabled(bool check)
|
| | {
|
| | Action::setEnabled(!check);
|
| | groupAction()->setDisabled(check);
|
| | }
|
| |
|
| | void ActionGroup::setExclusive(bool check)
|
| | {
|
| | groupAction()->setExclusive(check);
|
| | }
|
| |
|
| | bool ActionGroup::isExclusive() const
|
| | {
|
| | return groupAction()->isExclusive();
|
| | }
|
| |
|
| | void ActionGroup::setVisible(bool check)
|
| | {
|
| | Action::setVisible(check);
|
| | groupAction()->setVisible(check);
|
| | }
|
| |
|
| | void ActionGroup::setRememberLast(bool remember)
|
| | {
|
| | _rememberLast = remember;
|
| | }
|
| |
|
| | bool ActionGroup::doesRememberLast() const
|
| | {
|
| | return _rememberLast;
|
| | }
|
| |
|
| | QAction* ActionGroup::addAction(QAction* action)
|
| | {
|
| | return groupAction()->addAction(action);
|
| | }
|
| |
|
| | QAction* ActionGroup::addAction(const QString& text)
|
| | {
|
| | return groupAction()->addAction(text);
|
| | }
|
| |
|
| | QList<QAction*> ActionGroup::actions() const
|
| | {
|
| | return groupAction()->actions();
|
| | }
|
| |
|
| | int ActionGroup::checkedAction() const
|
| | {
|
| | auto checked = groupAction()->checkedAction();
|
| |
|
| | return actions().indexOf(checked);
|
| | }
|
| |
|
| | void ActionGroup::setCheckedAction(int index)
|
| | {
|
| | auto acts = groupAction()->actions();
|
| | QAction* act = acts.at(index);
|
| | act->setChecked(true);
|
| | this->setIcon(act->icon());
|
| |
|
| | if (!this->_isMode) {
|
| | this->action()->setToolTip(act->toolTip());
|
| | }
|
| | this->setProperty("defaultAction", QVariant(index));
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void ActionGroup::onActivated()
|
| | {
|
| | command()->invoke(this->property("defaultAction").toInt(), Command::TriggerAction);
|
| | }
|
| |
|
| | void ActionGroup::onToggled(bool check)
|
| | {
|
| | Q_UNUSED(check)
|
| | onActivated();
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void ActionGroup::onActivated(QAction* act)
|
| | {
|
| | if (_rememberLast) {
|
| | int index = groupAction()->actions().indexOf(act);
|
| |
|
| | this->setIcon(act->icon());
|
| | if (!this->_isMode) {
|
| | this->action()->setToolTip(act->toolTip());
|
| | }
|
| | this->setProperty("defaultAction", QVariant(index));
|
| | command()->invoke(index, Command::TriggerChildAction);
|
| | }
|
| | }
|
| |
|
| | |
| | |
| |
|
| | void ActionGroup::onHovered(QAction* act)
|
| | {
|
| | const auto topLevelWidgets = QApplication::topLevelWidgets();
|
| | QMenu* foundMenu = nullptr;
|
| |
|
| | for (QWidget* widget : topLevelWidgets) {
|
| | QList<QMenu*> menus = widget->findChildren<QMenu*>();
|
| |
|
| | for (QMenu* menu : menus) {
|
| | if (menu->isVisible() && menu->actions().contains(act)) {
|
| | foundMenu = menu;
|
| | break;
|
| | }
|
| | }
|
| |
|
| | if (foundMenu) {
|
| | break;
|
| | }
|
| | }
|
| |
|
| | if (foundMenu) {
|
| | QRect actionRect = foundMenu->actionGeometry(act);
|
| | QPoint globalPos = foundMenu->mapToGlobal(actionRect.topRight());
|
| | QToolTip::showText(globalPos, act->toolTip(), foundMenu, actionRect);
|
| | }
|
| | else {
|
| | QToolTip::showText(QCursor::pos(), act->toolTip());
|
| | }
|
| | }
|
| |
|
| |
|
| |
|
| | WorkbenchGroup::WorkbenchGroup(Command* pcCmd, QObject* parent)
|
| | : ActionGroup(pcCmd, parent)
|
| | {
|
| | refreshWorkbenchList();
|
| |
|
| |
|
| | Application::Instance->signalRefreshWorkbenches.connect(
|
| | std::bind(&WorkbenchGroup::refreshWorkbenchList, this)
|
| | );
|
| |
|
| |
|
| | connect(getMainWindow(), &MainWindow::workbenchActivated, this, &WorkbenchGroup::onWorkbenchActivated);
|
| | }
|
| |
|
| | QAction* WorkbenchGroup::getOrCreateAction(const QString& wbName)
|
| | {
|
| | if (!actionByWorkbenchName.contains(wbName)) {
|
| | actionByWorkbenchName[wbName] = new QAction(QApplication::instance());
|
| | }
|
| |
|
| | return actionByWorkbenchName[wbName];
|
| | }
|
| |
|
| | void WorkbenchGroup::addTo(QWidget* widget)
|
| | {
|
| | if (widget->inherits("QToolBar")) {
|
| | ParameterGrp::handle hGrp;
|
| | hGrp = App::GetApplication().GetParameterGroupByPath(
|
| | "User parameter:BaseApp/Preferences/Workbenches"
|
| | );
|
| |
|
| | QWidget* workbenchSelectorWidget;
|
| | if (hGrp->GetInt("WorkbenchSelectorType", 0) == 0) {
|
| | workbenchSelectorWidget = new WorkbenchComboBox(this, widget);
|
| | }
|
| | else {
|
| | workbenchSelectorWidget = new WorkbenchTabWidget(this, widget);
|
| | }
|
| |
|
| | static_cast<QToolBar*>(widget)->addWidget(workbenchSelectorWidget);
|
| | }
|
| | else if (widget->inherits("QMenu")) {
|
| | auto menu = qobject_cast<QMenu*>(widget);
|
| | menu = menu->addMenu(action()->text());
|
| | menu->addActions(getEnabledWbActions());
|
| |
|
| | connect(this, &WorkbenchGroup::workbenchListRefreshed, this, [menu](QList<QAction*> actions) {
|
| | menu->clear();
|
| | menu->addActions(actions);
|
| | });
|
| | }
|
| | }
|
| |
|
| | void WorkbenchGroup::refreshWorkbenchList()
|
| | {
|
| | QStringList enabledWbNames = DlgSettingsWorkbenchesImp::getEnabledWorkbenches();
|
| |
|
| |
|
| | for (QAction* action : actions()) {
|
| | groupAction()->removeAction(action);
|
| | }
|
| |
|
| | enabledWbsActions.clear();
|
| | disabledWbsActions.clear();
|
| |
|
| | std::string activeWbName = WorkbenchManager::instance()->activeName();
|
| |
|
| |
|
| | int index = 0;
|
| | for (const auto& wbName : enabledWbNames) {
|
| | QString name = Application::Instance->workbenchMenuText(wbName);
|
| | QPixmap px = Application::Instance->workbenchIcon(wbName);
|
| | QString tip = Application::Instance->workbenchToolTip(wbName);
|
| |
|
| | QAction* action = getOrCreateAction(wbName);
|
| |
|
| | groupAction()->addAction(action);
|
| |
|
| | action->setText(name);
|
| | action->setCheckable(true);
|
| | action->setData(QVariant(index));
|
| | action->setObjectName(wbName);
|
| | action->setIcon(px);
|
| | action->setToolTip(tip);
|
| | action->setStatusTip(tr("Selects the '%1' workbench").arg(name));
|
| | if (index < 9) {
|
| | action->setShortcut(QKeySequence(QStringLiteral("W,%1").arg(index + 1)));
|
| | }
|
| | if (wbName.toStdString() == activeWbName) {
|
| | action->setChecked(true);
|
| | }
|
| | enabledWbsActions.push_back(action);
|
| | index++;
|
| | }
|
| |
|
| |
|
| | QStringList disabledWbNames = DlgSettingsWorkbenchesImp::getDisabledWorkbenches();
|
| | for (const auto& wbName : disabledWbNames) {
|
| | QString name = Application::Instance->workbenchMenuText(wbName);
|
| | QPixmap px = Application::Instance->workbenchIcon(wbName);
|
| | QString tip = Application::Instance->workbenchToolTip(wbName);
|
| |
|
| | QAction* action = getOrCreateAction(wbName);
|
| |
|
| | groupAction()->addAction(action);
|
| |
|
| | action->setText(name);
|
| | action->setCheckable(true);
|
| | action->setData(QVariant(index));
|
| | action->setObjectName(wbName);
|
| | action->setIcon(px);
|
| | action->setToolTip(tip);
|
| | action->setStatusTip(tr("Select the '%1' workbench").arg(name));
|
| | if (wbName.toStdString() == activeWbName) {
|
| | action->setChecked(true);
|
| | }
|
| | disabledWbsActions.push_back(action);
|
| | index++;
|
| | }
|
| |
|
| |
|
| | workbenchListRefreshed(enabledWbsActions);
|
| | }
|
| |
|
| | void WorkbenchGroup::onWorkbenchActivated(const QString& name)
|
| | {
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | for (QAction* action : actions()) {
|
| | if (action->objectName() == name) {
|
| | if (!action->isChecked()) {
|
| | action->trigger();
|
| | }
|
| | break;
|
| | }
|
| | }
|
| | }
|
| |
|
| | QList<QAction*> WorkbenchGroup::getEnabledWbActions() const
|
| | {
|
| | return enabledWbsActions;
|
| | }
|
| |
|
| | QList<QAction*> WorkbenchGroup::getDisabledWbActions() const
|
| | {
|
| | return disabledWbsActions;
|
| | }
|
| |
|
| |
|
| |
|
| | class RecentFilesAction::Private: public ParameterGrp::ObserverType
|
| | {
|
| | public:
|
| | Private(const Private&) = delete;
|
| | Private(Private&&) = delete;
|
| | void operator=(const Private&) = delete;
|
| | void operator=(Private&&) = delete;
|
| |
|
| | Private(RecentFilesAction* master, const char* path)
|
| | : master(master)
|
| | {
|
| | handle = App::GetApplication().GetParameterGroupByPath(path);
|
| | handle->Attach(this);
|
| | }
|
| |
|
| | ~Private() override
|
| | {
|
| | handle->Detach(this);
|
| | }
|
| |
|
| | void OnChange(Base::Subject<const char*>& sub, const char* reason) override
|
| | {
|
| | Q_UNUSED(sub)
|
| | if (!updating && reason && strcmp(reason, "RecentFiles") == 0) {
|
| | Base::StateLocker guard(updating);
|
| | master->restore();
|
| | }
|
| | }
|
| |
|
| | void trySaveUserParameter()
|
| | {
|
| |
|
| | bool saveParameter = App::GetApplication()
|
| | .GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
| | ->GetBool("SaveUserParameter", true);
|
| | if (saveParameter) {
|
| | saveUserParameter();
|
| | }
|
| | }
|
| |
|
| | void saveUserParameter()
|
| | {
|
| | ParameterManager* parmgr = App::GetApplication().GetParameterSet("User parameter");
|
| | parmgr->SaveDocument(App::Application::Config()["UserParameter"].c_str());
|
| | }
|
| |
|
| | public:
|
| | RecentFilesAction* master;
|
| | ParameterGrp::handle handle;
|
| | bool updating = false;
|
| | };
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | RecentFilesAction::RecentFilesAction(Command* pcCmd, QObject* parent)
|
| | : ActionGroup(pcCmd, parent)
|
| | , visibleItems(4)
|
| | , maximumItems(20)
|
| | {
|
| | _pimpl = std::make_unique<Private>(this, "User parameter:BaseApp/Preferences/RecentFiles");
|
| | restore();
|
| |
|
| | sep.setSeparator(true);
|
| | sep.setToolTip({});
|
| | this->groupAction()->addAction(&sep);
|
| |
|
| |
|
| | clearRecentFilesListAction.setText(tr("Clear Recent Files"));
|
| | clearRecentFilesListAction.setToolTip({});
|
| | this->groupAction()->addAction(&clearRecentFilesListAction);
|
| |
|
| | auto clearFun = [this, hGrp = _pimpl->handle]() {
|
| | const size_t recentFilesListSize = hGrp->GetASCIIs("MRU").size();
|
| | for (size_t i = 0; i < recentFilesListSize; i++) {
|
| | const QByteArray key = QStringLiteral("MRU%1").arg(i).toLocal8Bit();
|
| | hGrp->SetASCII(key.data(), "");
|
| | }
|
| | restore();
|
| | clearRecentFilesListAction.setEnabled(false);
|
| | };
|
| |
|
| | connect(&clearRecentFilesListAction, &QAction::triggered, this, clearFun);
|
| |
|
| | connect(
|
| | &clearRecentFilesListAction,
|
| | &QAction::triggered,
|
| | this,
|
| | &RecentFilesAction::recentFilesListModified
|
| | );
|
| | }
|
| |
|
| | RecentFilesAction::~RecentFilesAction()
|
| | {
|
| | _pimpl.reset(nullptr);
|
| | }
|
| |
|
| |
|
| | void RecentFilesAction::appendFile(const QString& filename)
|
| | {
|
| |
|
| | QStringList files = this->files();
|
| |
|
| |
|
| | files.removeAll(filename);
|
| | files.prepend(filename);
|
| | setFiles(files);
|
| | save();
|
| |
|
| | _pimpl->trySaveUserParameter();
|
| |
|
| | clearRecentFilesListAction.setEnabled(true);
|
| |
|
| | Q_EMIT recentFilesListModified();
|
| | }
|
| |
|
| | static QString numberToLabel(int number)
|
| | {
|
| | if (number > 0 && number < 10) {
|
| | return QStringLiteral("&%1").arg(number);
|
| | }
|
| | if (number == 10) {
|
| | return QStringLiteral("1&0");
|
| | }
|
| |
|
| |
|
| | constexpr char lettersStart = 11;
|
| | constexpr char lettersEnd = lettersStart + ('Z' - 'A');
|
| | if (number >= lettersStart && number < lettersEnd) {
|
| | QChar letter = QChar::fromLatin1('A' + (number - lettersStart));
|
| | return QStringLiteral("%1 (&%2)").arg(number).arg(letter);
|
| | }
|
| |
|
| | return QStringLiteral("%1").arg(number);
|
| | }
|
| |
|
| | |
| | |
| | |
| |
|
| | void RecentFilesAction::setFiles(const QStringList& files)
|
| | {
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| |
|
| | int numRecentFiles = std::min<int>(recentFiles.count(), files.count());
|
| | for (int index = 0; index < numRecentFiles; index++) {
|
| | QString numberLabel = numberToLabel(index + 1);
|
| | QFileInfo fi(files[index]);
|
| | QString fileName {fi.fileName()};
|
| | fileName.replace(QLatin1Char('&'), QStringLiteral("&&"));
|
| | recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel, fileName));
|
| | recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index]));
|
| | recentFiles[index]->setToolTip(files[index]);
|
| | recentFiles[index]->setData(QVariant(index));
|
| | recentFiles[index]->setVisible(true);
|
| | }
|
| |
|
| |
|
| | numRecentFiles = std::min<int>(numRecentFiles, this->visibleItems);
|
| | for (int index = numRecentFiles; index < recentFiles.count(); index++) {
|
| | if (recentFiles[index] == &sep || recentFiles[index] == &clearRecentFilesListAction) {
|
| | continue;
|
| | }
|
| | recentFiles[index]->setVisible(false);
|
| | recentFiles[index]->setText(QString());
|
| | recentFiles[index]->setToolTip(QString());
|
| | }
|
| | }
|
| |
|
| | |
| | |
| |
|
| | QStringList RecentFilesAction::files() const
|
| | {
|
| | QStringList files;
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| | for (int index = 0; index < recentFiles.count(); index++) {
|
| | QString file = recentFiles[index]->toolTip();
|
| | if (file.isEmpty()) {
|
| | break;
|
| | }
|
| | files.append(file);
|
| | }
|
| |
|
| | return files;
|
| | }
|
| |
|
| | void RecentFilesAction::activateFile(int id)
|
| | {
|
| |
|
| | QStringList files = this->files();
|
| | if (id < 0 || id >= files.count()) {
|
| | return;
|
| | }
|
| |
|
| | QString filename = files[id];
|
| | if (!ModuleIO::verifyFile(filename)) {
|
| | files.removeAll(filename);
|
| | setFiles(files);
|
| | save();
|
| | }
|
| | else {
|
| | ModuleIO::openFile(filename);
|
| | }
|
| | }
|
| |
|
| | void RecentFilesAction::resizeList(int size)
|
| | {
|
| | this->visibleItems = size;
|
| | int diff = this->visibleItems - this->maximumItems;
|
| |
|
| | for (int i = 0; i < diff; i++) {
|
| | groupAction()->addAction(QLatin1String(""))->setVisible(false);
|
| | }
|
| | setFiles(files());
|
| | }
|
| |
|
| |
|
| | void RecentFilesAction::restore()
|
| | {
|
| | ParameterGrp::handle hGrp = _pimpl->handle;
|
| |
|
| |
|
| | this->visibleItems = hGrp->GetInt("RecentFiles", this->visibleItems);
|
| |
|
| | int count = std::max<int>(this->maximumItems, this->visibleItems);
|
| | for (int i = 0; i < count; i++) {
|
| | groupAction()->addAction(QLatin1String(""))->setVisible(false);
|
| | }
|
| | std::vector<std::string> MRU = hGrp->GetASCIIs("MRU");
|
| | QStringList files;
|
| | for (const auto& it : MRU) {
|
| | auto filePath = QString::fromUtf8(it.c_str());
|
| | if (QFileInfo::exists(filePath)) {
|
| | files.append(filePath);
|
| | }
|
| | }
|
| | setFiles(files);
|
| | }
|
| |
|
| |
|
| | void RecentFilesAction::save()
|
| | {
|
| | ParameterGrp::handle hGrp = _pimpl->handle;
|
| | int count = hGrp->GetInt("RecentFiles", this->visibleItems);
|
| | hGrp->Clear();
|
| |
|
| |
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| | int num = std::min<int>(count, recentFiles.count());
|
| | for (int index = 0; index < num; index++) {
|
| | QString key = QStringLiteral("MRU%1").arg(index);
|
| | QString value = recentFiles[index]->toolTip();
|
| | if (value.isEmpty()) {
|
| | break;
|
| | }
|
| | hGrp->SetASCII(key.toLatin1(), value.toUtf8());
|
| | }
|
| |
|
| | Base::StateLocker guard(_pimpl->updating);
|
| | hGrp->SetInt("RecentFiles", count);
|
| | }
|
| |
|
| |
|
| |
|
| |
|
| |
|
| | RecentMacrosAction::RecentMacrosAction(Command* pcCmd, QObject* parent)
|
| | : ActionGroup(pcCmd, parent)
|
| | , visibleItems(4)
|
| | , maximumItems(20)
|
| | {
|
| | restore();
|
| | }
|
| |
|
| |
|
| | void RecentMacrosAction::appendFile(const QString& filename)
|
| | {
|
| |
|
| | QStringList files = this->files();
|
| |
|
| |
|
| | files.removeAll(filename);
|
| | files.prepend(filename);
|
| | setFiles(files);
|
| | save();
|
| |
|
| |
|
| | bool saveParameter = App::GetApplication()
|
| | .GetParameterGroupByPath("User parameter:BaseApp/Preferences/General")
|
| | ->GetBool("SaveUserParameter", true);
|
| | if (saveParameter) {
|
| | ParameterManager* parmgr = App::GetApplication().GetParameterSet("User parameter");
|
| | parmgr->SaveDocument(App::Application::Config()["UserParameter"].c_str());
|
| | }
|
| | }
|
| |
|
| | |
| | |
| | |
| |
|
| | void RecentMacrosAction::setFiles(const QStringList& files)
|
| | {
|
| | ParameterGrp::handle hGrp = App::GetApplication()
|
| | .GetUserParameter()
|
| | .GetGroup("BaseApp")
|
| | ->GetGroup("Preferences")
|
| | ->GetGroup("RecentMacros");
|
| | this->shortcut_modifiers = hGrp->GetASCII("ShortcutModifiers", "Ctrl+Shift+");
|
| | this->shortcut_count = std::min<int>(hGrp->GetInt("ShortcutCount", 3), 9);
|
| |
|
| | this->visibleItems = hGrp->GetInt("RecentMacros", 12);
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| |
|
| | int numRecentFiles = std::min<int>(recentFiles.count(), files.count());
|
| | QStringList existingCommands;
|
| | auto accel_col = QString::fromStdString(shortcut_modifiers);
|
| | for (int index = 0; index < numRecentFiles; index++) {
|
| | QFileInfo fi(files[index]);
|
| | QString numberLabel = numberToLabel(index + 1);
|
| | recentFiles[index]->setText(
|
| | QStringLiteral("%1 %2").arg(numberLabel).arg(fi.completeBaseName())
|
| | );
|
| | recentFiles[index]->setToolTip(files[index]);
|
| | recentFiles[index]->setData(QVariant(index));
|
| | QString accel(tr("none"));
|
| | if (index < shortcut_count) {
|
| | auto accel_tmp = QString::fromStdString(shortcut_modifiers);
|
| | accel_tmp.append(QString::number(index + 1, 10)).toStdString();
|
| | auto check = Application::Instance->commandManager().checkAcceleratorForConflicts(
|
| | qPrintable(accel_tmp)
|
| | );
|
| | if (check) {
|
| | recentFiles[index]->setShortcut(QKeySequence());
|
| | accel_col.append(accel_tmp);
|
| | existingCommands.append(QLatin1String(check->getName()));
|
| | }
|
| | else {
|
| | accel = accel_tmp;
|
| | recentFiles[index]->setShortcut(accel);
|
| | }
|
| | }
|
| | recentFiles[index]->setStatusTip(
|
| | tr("Run macro %1 (Shift+click to edit) keyboard shortcut: %2").arg(files[index], accel)
|
| | );
|
| | recentFiles[index]->setVisible(true);
|
| | }
|
| |
|
| |
|
| | numRecentFiles = std::min<int>(numRecentFiles, this->visibleItems);
|
| | for (int index = numRecentFiles; index < recentFiles.count(); index++) {
|
| | recentFiles[index]->setVisible(false);
|
| | recentFiles[index]->setText(QString());
|
| | recentFiles[index]->setToolTip(QString());
|
| | }
|
| |
|
| | if (!existingCommands.isEmpty()) {
|
| | auto msgMain = QStringLiteral("Recent macros : keyboard shortcuts");
|
| | for (int index = 0; index < accel_col.size(); index++) {
|
| | msgMain += QStringLiteral(" %1").arg(accel_col[index]);
|
| | }
|
| | msgMain += QStringLiteral(" disabled because of conflicts with");
|
| | for (int index = 0; index < existingCommands.count(); index++) {
|
| | msgMain += QStringLiteral(" %1").arg(existingCommands[index]);
|
| | }
|
| | msgMain += QStringLiteral(
|
| | " respectively.\nHint: In Preferences → Python → Macro →"
|
| | " Recent Macros menu → Keyboard Modifiers this should be Ctrl+Shift+"
|
| | " by default, if this is now blank then you should revert it back to"
|
| | " Ctrl+Shift+ by pressing both keys at the same time."
|
| | );
|
| | Base::Console().warning("%s\n", qPrintable(msgMain));
|
| | }
|
| | }
|
| |
|
| | |
| | |
| |
|
| | QStringList RecentMacrosAction::files() const
|
| | {
|
| | QStringList files;
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| | for (int index = 0; index < recentFiles.count(); index++) {
|
| | QString file = recentFiles[index]->toolTip();
|
| | if (file.isEmpty()) {
|
| | break;
|
| | }
|
| | files.append(file);
|
| | }
|
| |
|
| | return files;
|
| | }
|
| |
|
| | void RecentMacrosAction::activateFile(int id)
|
| | {
|
| |
|
| | QStringList files = this->files();
|
| | if (id < 0 || id >= files.count()) {
|
| | return;
|
| | }
|
| |
|
| | QString filename = files[id];
|
| | QFileInfo fi(filename);
|
| | if (!ModuleIO::verifyFile(filename)) {
|
| | files.removeAll(filename);
|
| | setFiles(files);
|
| | }
|
| | else {
|
| | if (QApplication::keyboardModifiers()
|
| | == Qt::ShiftModifier) {
|
| | auto editor = new PythonEditor();
|
| | editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python"));
|
| | auto edit = new PythonEditorView(editor, getMainWindow());
|
| | edit->setDisplayName(PythonEditorView::FileName);
|
| | edit->open(filename);
|
| | edit->resize(400, 300);
|
| | getMainWindow()->addWindow(edit);
|
| | getMainWindow()->appendRecentMacro(filename);
|
| | edit->setWindowTitle(fi.fileName());
|
| | }
|
| | else {
|
| | try {
|
| | getMainWindow()->appendRecentMacro(fi.filePath());
|
| | Application::Instance->macroManager()->run(
|
| | Gui::MacroManager::File,
|
| | fi.filePath().toUtf8()
|
| | );
|
| |
|
| | if (Application::Instance->activeDocument()) {
|
| | Application::Instance->activeDocument()->getDocument()->recompute();
|
| | }
|
| | }
|
| | catch (const Base::SystemExitException&) {
|
| |
|
| | Base::PyGILStateLocker locker;
|
| | Base::PyException exc;
|
| | exc.reportException();
|
| | }
|
| | }
|
| | }
|
| | }
|
| |
|
| | void RecentMacrosAction::resizeList(int size)
|
| | {
|
| | this->visibleItems = size;
|
| | int diff = this->visibleItems - this->maximumItems;
|
| |
|
| | for (int i = 0; i < diff; i++) {
|
| | groupAction()->addAction(QLatin1String(""))->setVisible(false);
|
| | }
|
| | setFiles(files());
|
| | }
|
| |
|
| |
|
| | void RecentMacrosAction::restore()
|
| | {
|
| | ParameterGrp::handle hGrp = App::GetApplication()
|
| | .GetUserParameter()
|
| | .GetGroup("BaseApp")
|
| | ->GetGroup("Preferences")
|
| | ->GetGroup("RecentMacros");
|
| |
|
| | for (int i = groupAction()->actions().size(); i < this->maximumItems; i++) {
|
| | groupAction()->addAction(QLatin1String(""))->setVisible(false);
|
| | }
|
| | resizeList(hGrp->GetInt("RecentMacros"));
|
| |
|
| | std::vector<std::string> MRU = hGrp->GetASCIIs("MRU");
|
| | QStringList files;
|
| | for (auto& filename : MRU) {
|
| | files.append(QString::fromUtf8(filename.c_str()));
|
| | }
|
| | setFiles(files);
|
| | }
|
| |
|
| |
|
| | void RecentMacrosAction::save()
|
| | {
|
| | ParameterGrp::handle hGrp = App::GetApplication()
|
| | .GetUserParameter()
|
| | .GetGroup("BaseApp")
|
| | ->GetGroup("Preferences")
|
| | ->GetGroup("RecentMacros");
|
| | int count = hGrp->GetInt("RecentMacros", this->visibleItems);
|
| | hGrp->Clear();
|
| |
|
| |
|
| | QList<QAction*> recentFiles = groupAction()->actions();
|
| | int num = std::min<int>(count, recentFiles.count());
|
| | for (int index = 0; index < num; index++) {
|
| | QString key = QStringLiteral("MRU%1").arg(index);
|
| | QString value = recentFiles[index]->toolTip();
|
| | if (value.isEmpty()) {
|
| | break;
|
| | }
|
| | hGrp->SetASCII(key.toLatin1(), value.toUtf8());
|
| | }
|
| |
|
| | hGrp->SetInt("RecentMacros", count);
|
| | hGrp->SetInt("ShortcutCount", this->shortcut_count);
|
| | hGrp->SetASCII("ShortcutModifiers", this->shortcut_modifiers.c_str());
|
| | }
|
| |
|
| |
|
| |
|
| | UndoAction::UndoAction(Command* pcCmd, QObject* parent)
|
| | : Action(pcCmd, parent)
|
| | {
|
| | _toolAction = new QAction(this);
|
| | _toolAction->setMenu(new UndoDialog());
|
| | connect(_toolAction, &QAction::triggered, this, &UndoAction::onActivated);
|
| | }
|
| |
|
| | UndoAction::~UndoAction()
|
| | {
|
| | QMenu* menu = _toolAction->menu();
|
| | delete menu;
|
| | delete _toolAction;
|
| | }
|
| |
|
| | void UndoAction::addTo(QWidget* widget)
|
| | {
|
| | if (widget->inherits("QToolBar")) {
|
| | actionChanged();
|
| | connect(action(), &QAction::changed, this, &UndoAction::actionChanged);
|
| | widget->addAction(_toolAction);
|
| | }
|
| | else {
|
| | widget->addAction(action());
|
| | }
|
| | }
|
| |
|
| | void UndoAction::actionChanged()
|
| | {
|
| |
|
| |
|
| |
|
| | _toolAction->setText(action()->text());
|
| | _toolAction->setToolTip(action()->toolTip());
|
| | _toolAction->setStatusTip(action()->statusTip());
|
| | _toolAction->setWhatsThis(action()->whatsThis());
|
| | _toolAction->setIcon(action()->icon());
|
| | }
|
| |
|
| | void UndoAction::setEnabled(bool check)
|
| | {
|
| | Action::setEnabled(check);
|
| | _toolAction->setEnabled(check);
|
| | }
|
| |
|
| | void UndoAction::setVisible(bool check)
|
| | {
|
| | Action::setVisible(check);
|
| | _toolAction->setVisible(check);
|
| | }
|
| |
|
| |
|
| |
|
| | RedoAction::RedoAction(Command* pcCmd, QObject* parent)
|
| | : Action(pcCmd, parent)
|
| | {
|
| | _toolAction = new QAction(this);
|
| | _toolAction->setMenu(new RedoDialog());
|
| | connect(_toolAction, &QAction::triggered, this, &RedoAction::onActivated);
|
| | }
|
| |
|
| | RedoAction::~RedoAction()
|
| | {
|
| | QMenu* menu = _toolAction->menu();
|
| | delete menu;
|
| | delete _toolAction;
|
| | }
|
| |
|
| | void RedoAction::addTo(QWidget* widget)
|
| | {
|
| | if (widget->inherits("QToolBar")) {
|
| | actionChanged();
|
| | connect(action(), &QAction::changed, this, &RedoAction::actionChanged);
|
| | widget->addAction(_toolAction);
|
| | }
|
| | else {
|
| | widget->addAction(action());
|
| | }
|
| | }
|
| |
|
| | void RedoAction::actionChanged()
|
| | {
|
| |
|
| |
|
| |
|
| | _toolAction->setText(action()->text());
|
| | _toolAction->setToolTip(action()->toolTip());
|
| | _toolAction->setStatusTip(action()->statusTip());
|
| | _toolAction->setWhatsThis(action()->whatsThis());
|
| | _toolAction->setIcon(action()->icon());
|
| | }
|
| |
|
| | void RedoAction::setEnabled(bool check)
|
| | {
|
| | Action::setEnabled(check);
|
| | _toolAction->setEnabled(check);
|
| | }
|
| |
|
| | void RedoAction::setVisible(bool check)
|
| | {
|
| | Action::setVisible(check);
|
| | _toolAction->setVisible(check);
|
| | }
|
| |
|
| |
|
| |
|
| | DockWidgetAction::DockWidgetAction(Command* pcCmd, QObject* parent)
|
| | : Action(pcCmd, parent)
|
| | , _menu(nullptr)
|
| | {}
|
| |
|
| | DockWidgetAction::~DockWidgetAction()
|
| | {
|
| | delete _menu;
|
| | }
|
| |
|
| | void DockWidgetAction::addTo(QWidget* widget)
|
| | {
|
| | if (!_menu) {
|
| | _menu = new QMenu();
|
| | action()->setMenu(_menu);
|
| | getMainWindow()->setDockWindowMenu(_menu);
|
| | }
|
| |
|
| | widget->addAction(action());
|
| | }
|
| |
|
| |
|
| |
|
| | ToolBarAction::ToolBarAction(Command* pcCmd, QObject* parent)
|
| | : Action(pcCmd, parent)
|
| | , _menu(nullptr)
|
| | {}
|
| |
|
| | ToolBarAction::~ToolBarAction()
|
| | {
|
| | delete _menu;
|
| | }
|
| |
|
| | void ToolBarAction::addTo(QWidget* widget)
|
| | {
|
| | if (!_menu) {
|
| | _menu = new QMenu();
|
| | action()->setMenu(_menu);
|
| | getMainWindow()->setToolBarMenu(_menu);
|
| | }
|
| |
|
| | widget->addAction(action());
|
| | }
|
| |
|
| |
|
| |
|
| | WindowAction::WindowAction(Command* pcCmd, QObject* parent)
|
| | : ActionGroup(pcCmd, parent)
|
| | , _menu(nullptr)
|
| | {}
|
| |
|
| | void WindowAction::addTo(QWidget* widget)
|
| | {
|
| | auto menu = qobject_cast<QMenu*>(widget);
|
| | if (!menu) {
|
| | if (!_menu) {
|
| | _menu = new QMenu();
|
| | action()->setMenu(_menu);
|
| | _menu->addActions(groupAction()->actions());
|
| | getMainWindow()->setWindowsMenu(_menu);
|
| | }
|
| |
|
| | widget->addAction(action());
|
| | }
|
| | else {
|
| | menu->addActions(groupAction()->actions());
|
| | getMainWindow()->setWindowsMenu(menu);
|
| | }
|
| | }
|
| |
|
| | #include "moc_Action.cpp"
|
| |
|