| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| |
|
| | # include <QApplication> |
| | # include <QMessageBox> |
| |
|
| |
|
| | #include <App/DocumentObject.h> |
| | #include <Base/Console.h> |
| | #include <Gui/Action.h> |
| | #include <Gui/Application.h> |
| | #include <Gui/BitmapFactory.h> |
| | #include <Gui/Command.h> |
| | #include <Gui/Control.h> |
| | #include <Gui/Document.h> |
| | #include <Gui/MainWindow.h> |
| | #include <Gui/Selection/Selection.h> |
| | #include <Gui/ViewProvider.h> |
| | #include <Mod/TechDraw/App/DrawPage.h> |
| | #include <Mod/TechDraw/App/DrawView.h> |
| |
|
| | #include "DrawGuiUtil.h" |
| | #include "ViewProviderDrawingView.h" |
| |
|
| |
|
| | using namespace TechDrawGui; |
| | using namespace TechDraw; |
| |
|
| | void execStackTop(Gui::Command* cmd); |
| | void execStackBottom(Gui::Command* cmd); |
| | void execStackUp(Gui::Command* cmd); |
| | void execStackDown(Gui::Command* cmd); |
| |
|
| | |
| | |
| | |
| |
|
| | DEF_STD_CMD_ACL(CmdTechDrawStackGroup) |
| |
|
| | CmdTechDrawStackGroup::CmdTechDrawStackGroup() |
| | : Command("TechDraw_StackGroup") |
| | { |
| | sAppModule = "TechDraw"; |
| | sGroup = QT_TR_NOOP("TechDraw"); |
| | sMenuText = QT_TR_NOOP("View Stacking Order"); |
| | sToolTipText = QT_TR_NOOP("Adjusts the stacking order of the selected views"); |
| | sWhatsThis = "TechDraw_StackGroup"; |
| | sStatusTip = sToolTipText; |
| | } |
| |
|
| | void CmdTechDrawStackGroup::activated(int iMsg) |
| | { |
| | Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); |
| | if (dlg) { |
| | QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task in progress"), |
| | QObject::tr("Close the active task dialog and try again.")); |
| | return; |
| | } |
| |
|
| | Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction); |
| | pcAction->setIcon(pcAction->actions().at(iMsg)->icon()); |
| | switch(iMsg) { |
| | case 0: |
| | execStackTop(this); |
| | break; |
| | case 1: |
| | execStackBottom(this); |
| | break; |
| | case 2: |
| | execStackUp(this); |
| | break; |
| | case 3: |
| | execStackDown(this); |
| | break; |
| | default: |
| | Base::Console().message("CMD::StackGrp - invalid iMsg: %d\n",iMsg); |
| | }; |
| | } |
| |
|
| | Gui::Action * CmdTechDrawStackGroup::createAction(void) |
| | { |
| | Gui::ActionGroup* pcAction = new Gui::ActionGroup(this, Gui::getMainWindow()); |
| | pcAction->setDropDownMenu(true); |
| | applyCommandData(this->className(), pcAction); |
| |
|
| | QAction* p1 = pcAction->addAction(QString()); |
| | p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackTop")); |
| | p1->setObjectName(QStringLiteral("TechDraw_StackTop")); |
| | p1->setWhatsThis(QStringLiteral("TechDraw_StackTop")); |
| | QAction* p2 = pcAction->addAction(QString()); |
| | p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackBottom")); |
| | p2->setObjectName(QStringLiteral("TechDraw_StackBottom")); |
| | p2->setWhatsThis(QStringLiteral("TechDraw_StackBottom")); |
| | QAction* p3 = pcAction->addAction(QString()); |
| | p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackUp")); |
| | p3->setObjectName(QStringLiteral("TechDraw_StackUp")); |
| | p3->setWhatsThis(QStringLiteral("TechDraw_StackUp")); |
| | QAction* p4 = pcAction->addAction(QString()); |
| | p4->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_StackDown")); |
| | p4->setObjectName(QStringLiteral("TechDraw_StackDown")); |
| | p4->setWhatsThis(QStringLiteral("TechDraw_StackDown")); |
| |
|
| | _pcAction = pcAction; |
| | languageChange(); |
| |
|
| | pcAction->setIcon(p1->icon()); |
| | int defaultId = 0; |
| | pcAction->setProperty("defaultAction", QVariant(defaultId)); |
| |
|
| | return pcAction; |
| | } |
| |
|
| | void CmdTechDrawStackGroup::languageChange() |
| | { |
| | Command::languageChange(); |
| |
|
| | if (!_pcAction) |
| | return; |
| | Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction); |
| | QList<QAction*> a = pcAction->actions(); |
| |
|
| | QAction* arc1 = a[0]; |
| | arc1->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Top")); |
| | arc1->setToolTip(QApplication::translate("TechDraw_StackTop","Moves the view to the top of the stack")); |
| | arc1->setStatusTip(arc1->toolTip()); |
| | QAction* arc2 = a[1]; |
| | arc2->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Bottom")); |
| | arc2->setToolTip(QApplication::translate("TechDraw_StackBottom","Moves the view to the bottom of the stack")); |
| | arc2->setStatusTip(arc2->toolTip()); |
| | QAction* arc3 = a[2]; |
| | arc3->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Up")); |
| | arc3->setToolTip(QApplication::translate("TechDraw_StackUp","Moves the view up one level")); |
| | arc3->setStatusTip(arc3->toolTip()); |
| | QAction* arc4 = a[3]; |
| | arc4->setText(QApplication::translate("CmdTechDrawStackGroup","Stack Down")); |
| | arc4->setToolTip(QApplication::translate("TechDraw_StackDown","Moves the view down one level")); |
| | arc4->setStatusTip(arc4->toolTip()); |
| | } |
| |
|
| | bool CmdTechDrawStackGroup::isActive(void) |
| | { |
| | bool havePage = DrawGuiUtil::needPage(this); |
| | bool haveView = DrawGuiUtil::needView(this, false); |
| | return (havePage && haveView); |
| | } |
| |
|
| | |
| | |
| | |
| |
|
| | DEF_STD_CMD_A(CmdTechDrawStackTop) |
| |
|
| | CmdTechDrawStackTop::CmdTechDrawStackTop() |
| | : Command("TechDraw_StackTop") |
| | { |
| | sAppModule = "TechDraw"; |
| | sGroup = QT_TR_NOOP("TechDraw"); |
| | sMenuText = QT_TR_NOOP("Stack Top"); |
| | sToolTipText = QT_TR_NOOP("Moves the selected view to the top of the stack"); |
| | sWhatsThis = "TechDraw_StackTop"; |
| | sStatusTip = sToolTipText; |
| | sPixmap = "actions/TechDraw_StackTop"; |
| | } |
| |
|
| | void CmdTechDrawStackTop::activated(int iMsg) |
| | { |
| | Q_UNUSED(iMsg); |
| |
|
| | Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); |
| | if (dlg) { |
| | QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task in progress"), |
| | QObject::tr("Close the active task dialog and try again.")); |
| | return; |
| | } |
| |
|
| | execStackTop(this); |
| | } |
| |
|
| | bool CmdTechDrawStackTop::isActive(void) |
| | { |
| | bool havePage = DrawGuiUtil::needPage(this); |
| | bool haveView = DrawGuiUtil::needView(this, false); |
| | return (havePage && haveView); |
| | } |
| |
|
| | void execStackTop(Gui::Command* cmd) |
| | { |
| | TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); |
| | if (!page) { |
| | return; |
| | } |
| |
|
| | std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); |
| | if (!views.empty()) { |
| | for (auto& v: views) { |
| | TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v); |
| | Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( |
| | cmd->getDocument())->getViewProvider(dv); |
| | ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp); |
| | if (vpdv) { |
| | vpdv->stackTop(); |
| | } |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| |
|
| | DEF_STD_CMD_A(CmdTechDrawStackBottom) |
| |
|
| | CmdTechDrawStackBottom::CmdTechDrawStackBottom() |
| | : Command("TechDraw_StackBottom") |
| | { |
| | sAppModule = "TechDraw"; |
| | sGroup = QT_TR_NOOP("TechDraw"); |
| | sMenuText = QT_TR_NOOP("Stack Bottom"); |
| | sToolTipText = QT_TR_NOOP("Moves the selected view to the bottom of the stack"); |
| | sWhatsThis = "TechDraw_StackBottom"; |
| | sStatusTip = sToolTipText; |
| | sPixmap = "actions/TechDraw_StackBottom"; |
| | } |
| |
|
| | void CmdTechDrawStackBottom::activated(int iMsg) |
| | { |
| | Q_UNUSED(iMsg); |
| |
|
| | Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); |
| | if (dlg) { |
| | QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task in progress"), |
| | QObject::tr("Close the active task dialog and try again.")); |
| | return; |
| | } |
| |
|
| | execStackBottom(this); |
| | } |
| |
|
| | bool CmdTechDrawStackBottom::isActive(void) |
| | { |
| | bool havePage = DrawGuiUtil::needPage(this); |
| | bool haveView = DrawGuiUtil::needView(this, false); |
| | return (havePage && haveView); |
| | } |
| |
|
| | void execStackBottom(Gui::Command* cmd) |
| | { |
| | TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); |
| | if (!page) { |
| | return; |
| | } |
| |
|
| | std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); |
| | if (!views.empty()) { |
| | for (auto& v: views) { |
| | TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v); |
| | Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( |
| | cmd->getDocument())->getViewProvider(dv); |
| | ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp); |
| | if (vpdv) { |
| | vpdv->stackBottom(); |
| | } |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| |
|
| | DEF_STD_CMD_A(CmdTechDrawStackUp) |
| |
|
| | CmdTechDrawStackUp::CmdTechDrawStackUp() |
| | : Command("TechDraw_StackUp") |
| | { |
| | sAppModule = "TechDraw"; |
| | sGroup = QT_TR_NOOP("TechDraw"); |
| | sMenuText = QT_TR_NOOP("Stack Up"); |
| | sToolTipText = QT_TR_NOOP("Moves the selected view up 1 level in the view stack"); |
| | sWhatsThis = "TechDraw_StackUp"; |
| | sStatusTip = sToolTipText; |
| | sPixmap = "actions/TechDraw_StackUp"; |
| | } |
| |
|
| | void CmdTechDrawStackUp::activated(int iMsg) |
| | { |
| | Q_UNUSED(iMsg); |
| |
|
| | Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); |
| | if (dlg) { |
| | QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task in progress"), |
| | QObject::tr("Close the active task dialog and try again.")); |
| | return; |
| | } |
| |
|
| | execStackUp(this); |
| | } |
| |
|
| | bool CmdTechDrawStackUp::isActive(void) |
| | { |
| | bool havePage = DrawGuiUtil::needPage(this); |
| | bool haveView = DrawGuiUtil::needView(this, false); |
| | return (havePage && haveView); |
| | } |
| |
|
| | void execStackUp(Gui::Command* cmd) |
| | { |
| | TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); |
| | if (!page) { |
| | return; |
| | } |
| |
|
| | std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); |
| | if (!views.empty()) { |
| | for (auto& v: views) { |
| | TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v); |
| | Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( |
| | cmd->getDocument())->getViewProvider(dv); |
| | ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp); |
| | if (vpdv) { |
| | vpdv->stackUp(); |
| | } |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| |
|
| | DEF_STD_CMD_A(CmdTechDrawStackDown) |
| |
|
| | CmdTechDrawStackDown::CmdTechDrawStackDown() |
| | : Command("TechDraw_StackDown") |
| | { |
| | sAppModule = "TechDraw"; |
| | sGroup = QT_TR_NOOP("TechDraw"); |
| | sMenuText = QT_TR_NOOP("Stack Down"); |
| | sToolTipText = QT_TR_NOOP("Moves the selected view down 1 level in the view stack"); |
| | sWhatsThis = "TechDraw_StackDown"; |
| | sStatusTip = sToolTipText; |
| | sPixmap = "actions/TechDraw_StackDown"; |
| | } |
| |
|
| | void CmdTechDrawStackDown::activated(int iMsg) |
| | { |
| | Q_UNUSED(iMsg); |
| |
|
| | Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); |
| | if (dlg) { |
| | QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"), |
| | QObject::tr("Close active task dialog and try again.")); |
| | return; |
| | } |
| |
|
| | execStackDown(this); |
| | } |
| |
|
| | bool CmdTechDrawStackDown::isActive(void) |
| | { |
| | bool havePage = DrawGuiUtil::needPage(this); |
| | bool haveView = DrawGuiUtil::needView(this, false); |
| | return (havePage && haveView); |
| | } |
| |
|
| | void execStackDown(Gui::Command* cmd) |
| | { |
| | TechDraw::DrawPage* page = DrawGuiUtil::findPage(cmd); |
| | if (!page) { |
| | return; |
| | } |
| |
|
| | std::vector<App::DocumentObject*> views = cmd->getSelection().getObjectsOfType(TechDraw::DrawView::getClassTypeId()); |
| | if (!views.empty()) { |
| | for (auto& v: views) { |
| | TechDraw::DrawView* dv = static_cast<TechDraw::DrawView*>(v); |
| | Gui::ViewProvider* vp = Gui::Application::Instance->getDocument( |
| | cmd->getDocument())->getViewProvider(dv); |
| | ViewProviderDrawingView* vpdv = static_cast<ViewProviderDrawingView*>(vp); |
| | if (vpdv) { |
| | vpdv->stackDown(); |
| | } |
| | } |
| | } |
| | } |
| |
|
| | void CreateTechDrawCommandsStack(void) |
| | { |
| | Gui::CommandManager& rcCmdMgr = Gui::Application::Instance->commandManager(); |
| |
|
| | rcCmdMgr.addCommand(new CmdTechDrawStackGroup()); |
| | rcCmdMgr.addCommand(new CmdTechDrawStackTop()); |
| | rcCmdMgr.addCommand(new CmdTechDrawStackBottom()); |
| | rcCmdMgr.addCommand(new CmdTechDrawStackUp()); |
| | rcCmdMgr.addCommand(new CmdTechDrawStackDown()); |
| | } |
| |
|