From: vsv Date: Thu, 13 Mar 2014 10:09:12 +0000 (+0400) Subject: Updated GUI according to GUI specification V3. X-Git-Tag: V_0.1~57^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dcfbdb77dfd1e8f4f5a9f636ff5534d74af3592e;p=modules%2Fshaper.git Updated GUI according to GUI specification V3. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ffaeb0c8..d58767ec6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,4 +10,4 @@ INCLUDE(FindQt5) #ADD_SUBDIRECTORY (src/ModelAPI) #ADD_SUBDIRECTORY (src/Model) ADD_SUBDIRECTORY (src/XGUI) -#ADD_SUBDIRECTORY (src/GeomModule) +ADD_SUBDIRECTORY (src/GeomModule) diff --git a/src/GeomModule/GeomModule.cpp b/src/GeomModule/GeomModule.cpp index 37ec7e5b2..5bac10336 100644 --- a/src/GeomModule/GeomModule.cpp +++ b/src/GeomModule/GeomModule.cpp @@ -25,12 +25,27 @@ GeomModule::~GeomModule() void GeomModule::createFeatures() { - int aPageId = myWorkshop->addWorkbench("Primitives"); - int aGroupId = myWorkshop->addGroup(aPageId); - int aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Box", "Create Box", QIcon(":icons/box.png"), QKeySequence()); - aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Cylinder", "Create Cylinder", QIcon(":icons/cylinder.png"), QKeySequence()); - aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Disk", "Create Disk", QIcon(":icons/disk.png"), QKeySequence()); - aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Torus", "Create Torus", QIcon(":icons/torus.png"), QKeySequence()); - - aPageId = myWorkshop->addWorkbench("Operations"); + IWorkbench* aPage = myWorkshop->addWorkbench("Primitives"); + IMenuGroup* aGroup = aPage->addGroup(); + + IFeatureMenu* aCommand = aGroup->addFeature("new_part", "Part", "Creates a new part", QIcon(":pictures/part_ico.png")); + aCommand = aGroup->addFeature("new_point", "Point", "Create a new point", QIcon(":icons/point.png")); + aCommand = aGroup->addFeature("new_axis", "Axis", "Create a new axis", QIcon(":icons/axis.png"), QKeySequence()); + aCommand = aGroup->addFeature("new_plane", "Plane", "Create a new plane", QIcon(":icons/plane.png"), QKeySequence()); + + //aGroup = aPage->addGroup(); + aCommand = aGroup->addFeature("duplicate", "Duplicate", "Duplicate selected object", QIcon(":icons/duplicate.png")); + aCommand = aGroup->addFeature("remove", "Remove", "Remove selected object", QIcon(":icons/remove.png")); + + aPage = myWorkshop->addWorkbench("Features"); + aGroup = aPage->addGroup(); + + aCommand = aGroup->addFeature("extrusion", "Extrusion", "Make extrusion", QIcon(":icons/extrusion.png")); + aCommand = aGroup->addFeature("cut", "Cut", "Make cut", QIcon(":icons/cut.png")); + aCommand = aGroup->addFeature("fusion", "Fusion", "Make fusion", QIcon(":icons/fusion.png")); + aCommand = aGroup->addFeature("revolution", "Revolution", "Make revolution", QIcon(":icons/revol.png")); + aCommand = aGroup->addFeature("common", "Common", "Make common", QIcon(":icons/common.png")); + + //aGroup = aPage->addGroup(); + aCommand = aGroup->addFeature("import", "Import", "Make import", QIcon(":icons/import.png")); } \ No newline at end of file diff --git a/src/GeomModule/GeomModule_icons.qrc b/src/GeomModule/GeomModule_icons.qrc index 3f6a8a361..571e1cd6f 100644 --- a/src/GeomModule/GeomModule_icons.qrc +++ b/src/GeomModule/GeomModule_icons.qrc @@ -1,8 +1,15 @@ - icons/box.png - icons/cylinder.png - icons/disk.png - icons/torus.png + icons/point.png + icons/plane.png + icons/axis.png + icons/duplicate.png + icons/remove.png + icons/extrusion.png + icons/cut.png + icons/fusion.png + icons/revol.png + icons/common.png + icons/import.png diff --git a/src/GeomModule/icons/axis.png b/src/GeomModule/icons/axis.png new file mode 100644 index 000000000..5f5bfffd8 Binary files /dev/null and b/src/GeomModule/icons/axis.png differ diff --git a/src/GeomModule/icons/box.png b/src/GeomModule/icons/box.png deleted file mode 100644 index 3047d9212..000000000 Binary files a/src/GeomModule/icons/box.png and /dev/null differ diff --git a/src/GeomModule/icons/common.png b/src/GeomModule/icons/common.png new file mode 100644 index 000000000..7deab358a Binary files /dev/null and b/src/GeomModule/icons/common.png differ diff --git a/src/GeomModule/icons/cut.png b/src/GeomModule/icons/cut.png new file mode 100644 index 000000000..0d43adb8b Binary files /dev/null and b/src/GeomModule/icons/cut.png differ diff --git a/src/GeomModule/icons/cylinder.png b/src/GeomModule/icons/cylinder.png deleted file mode 100644 index a00136dab..000000000 Binary files a/src/GeomModule/icons/cylinder.png and /dev/null differ diff --git a/src/GeomModule/icons/disk.png b/src/GeomModule/icons/disk.png deleted file mode 100644 index 8aad056b9..000000000 Binary files a/src/GeomModule/icons/disk.png and /dev/null differ diff --git a/src/GeomModule/icons/duplicate.png b/src/GeomModule/icons/duplicate.png new file mode 100644 index 000000000..1a5de9b5f Binary files /dev/null and b/src/GeomModule/icons/duplicate.png differ diff --git a/src/GeomModule/icons/extrusion.png b/src/GeomModule/icons/extrusion.png new file mode 100644 index 000000000..12bbe4530 Binary files /dev/null and b/src/GeomModule/icons/extrusion.png differ diff --git a/src/GeomModule/icons/fusion.png b/src/GeomModule/icons/fusion.png new file mode 100644 index 000000000..7fca3fe67 Binary files /dev/null and b/src/GeomModule/icons/fusion.png differ diff --git a/src/GeomModule/icons/import.png b/src/GeomModule/icons/import.png new file mode 100644 index 000000000..2a6ba81ec Binary files /dev/null and b/src/GeomModule/icons/import.png differ diff --git a/src/GeomModule/icons/plane.png b/src/GeomModule/icons/plane.png new file mode 100644 index 000000000..3075a34aa Binary files /dev/null and b/src/GeomModule/icons/plane.png differ diff --git a/src/GeomModule/icons/point.png b/src/GeomModule/icons/point.png new file mode 100644 index 000000000..de84d9652 Binary files /dev/null and b/src/GeomModule/icons/point.png differ diff --git a/src/GeomModule/icons/remove.png b/src/GeomModule/icons/remove.png new file mode 100644 index 000000000..6c6452718 Binary files /dev/null and b/src/GeomModule/icons/remove.png differ diff --git a/src/GeomModule/icons/revol.png b/src/GeomModule/icons/revol.png new file mode 100644 index 000000000..3400b6200 Binary files /dev/null and b/src/GeomModule/icons/revol.png differ diff --git a/src/GeomModule/icons/torus.png b/src/GeomModule/icons/torus.png deleted file mode 100644 index af76fc00c..000000000 Binary files a/src/GeomModule/icons/torus.png and /dev/null differ diff --git a/src/XGUI/XGUI_Command.cpp b/src/XGUI/XGUI_Command.cpp index 4c4249c6f..3ba1689a3 100644 --- a/src/XGUI/XGUI_Command.cpp +++ b/src/XGUI/XGUI_Command.cpp @@ -2,13 +2,13 @@ #include -XGUI_Command::XGUI_Command(QObject * parent) : - QWidgetAction(parent) +XGUI_Command::XGUI_Command(const QString& theId, QObject * parent) : + QWidgetAction(parent), myId(theId) { } -XGUI_Command::XGUI_Command(const QIcon& icon, const QString& text, QObject* parent): - QWidgetAction(parent) +XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent): + QWidgetAction(parent), myId(theId) { setIcon(icon); setText(text); @@ -39,4 +39,24 @@ QWidget* XGUI_Command::createWidget(QWidget* theParent) return aBtn; } return QWidgetAction::createWidget(theParent); +} + +bool XGUI_Command::enabled() const +{ + return isEnabled(); +} + +void XGUI_Command::enable() +{ + setEnabled(true); +} + +void XGUI_Command::disable() +{ + setEnabled(false); +} + +void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot) +{ + connect(this, SIGNAL(triggered()), theResiver, theSlot); } \ No newline at end of file diff --git a/src/XGUI/XGUI_Command.h b/src/XGUI/XGUI_Command.h index 8f1caf154..e3759a4aa 100644 --- a/src/XGUI/XGUI_Command.h +++ b/src/XGUI/XGUI_Command.h @@ -1,22 +1,34 @@ #ifndef XGUI_Command_H #define XGUI_Command_H +#include "XGUI_Interfaces.h" + #include #define MIN_BUTTON_HEIGHT 18 #define MIN_BUTTON_WIDTH 40 -class XGUI_Command : public QWidgetAction +class XGUI_Command : public QWidgetAction, public IFeatureMenu { Q_OBJECT public: - XGUI_Command(QObject * parent); - XGUI_Command(const QIcon& icon, const QString& text, QObject* parent); + XGUI_Command(const QString& theId, QObject * parent); + XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent); ~XGUI_Command(); + virtual bool enabled() const; + virtual void enable(); + virtual void disable(); + virtual QString getId() const { return myId; } + + virtual void connectTo(const QObject* theResiver, const char* theSlot); + protected: virtual QWidget* createWidget(QWidget* theParent); + +private: + QString myId; }; #endif \ No newline at end of file diff --git a/src/XGUI/XGUI_Interfaces.h b/src/XGUI/XGUI_Interfaces.h index 12725017c..d54bba43b 100644 --- a/src/XGUI/XGUI_Interfaces.h +++ b/src/XGUI/XGUI_Interfaces.h @@ -6,17 +6,40 @@ #include #include -class IWorkshop + +class IFeatureMenu +{ +public: + virtual bool enabled() const = 0; + virtual void enable() = 0; + virtual void disable() = 0; + virtual QString getId() const = 0; + virtual void connectTo(const QObject* theResiver, const char* theSlot) = 0; +}; + + +class IMenuGroup +{ +public: + virtual IFeatureMenu* addFeature(const QString& theId, + const QString& theTitle, + const QString& theTip, + const QIcon& theIcon, + const QKeySequence& theKeys = QKeySequence()) = 0; +}; + + +class IWorkbench { public: - virtual int addWorkbench(const QString& theName) = 0; + virtual IMenuGroup* addGroup() = 0; +}; - virtual int addGroup(int thePageId) = 0; - virtual int addFeature(int thePageId, int theGroupId, - const QString& theTitle, const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys = QKeySequence()) = 0; +class IWorkshop +{ +public: + virtual IWorkbench* addWorkbench(const QString& theName) = 0; }; diff --git a/src/XGUI/XGUI_MainMenu.cpp b/src/XGUI/XGUI_MainMenu.cpp index 0be7579aa..0a4903bce 100644 --- a/src/XGUI/XGUI_MainMenu.cpp +++ b/src/XGUI/XGUI_MainMenu.cpp @@ -18,7 +18,7 @@ XGUI_MainMenu::~XGUI_MainMenu(void) { } -int XGUI_MainMenu::addWorkbench(QString theTitle) +IWorkbench* XGUI_MainMenu::addWorkbench(QString theTitle) { QDockWidget* aDoc = new QDockWidget(myDesktop); aDoc->setFeatures(QDockWidget::DockWidgetVerticalTitleBar); @@ -37,19 +37,13 @@ int XGUI_MainMenu::addWorkbench(QString theTitle) myMenuTabs.append(aDoc); - return myMenuTabs.length() - 1; + return aPage; } -int XGUI_MainMenu::addGroup(int thePageId) +IMenuGroup* XGUI_MainMenu::addGroup(int thePageId) { XGUI_Workbench* aPage = dynamic_cast(myMenuTabs[thePageId]->widget()); return aPage->addGroup(); } -void XGUI_MainMenu::addCommand(int thePageId, int theGroupId, XGUI_Command* theCommand) -{ - XGUI_Workbench* aPage = dynamic_cast(myMenuTabs[thePageId]->widget()); - aPage->addCommand(theGroupId, theCommand); -} - diff --git a/src/XGUI/XGUI_MainMenu.h b/src/XGUI/XGUI_MainMenu.h index 3521be3c0..ef4dc0511 100644 --- a/src/XGUI/XGUI_MainMenu.h +++ b/src/XGUI/XGUI_MainMenu.h @@ -1,6 +1,8 @@ #ifndef XGUI_MainMenu_H #define XGUI_MainMenu_H +#include "XGUI_Interfaces.h" + #include #include @@ -19,11 +21,9 @@ public: XGUI_MainMenu(XGUI_MainWindow *parent); virtual ~XGUI_MainMenu(); - int addWorkbench(QString theTitle); - - int addGroup(int thePageId); + IWorkbench* addWorkbench(QString theTitle); - void addCommand(int thePageId, int theGroupId, XGUI_Command* theCommand); + IMenuGroup* addGroup(int thePageId); private: XGUI_MainWindow* myDesktop; diff --git a/src/XGUI/XGUI_MainWindow.cpp b/src/XGUI/XGUI_MainWindow.cpp index 729f1869b..f5c82a4bc 100644 --- a/src/XGUI/XGUI_MainWindow.cpp +++ b/src/XGUI/XGUI_MainWindow.cpp @@ -17,6 +17,7 @@ #include #include #include +#include XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : QMainWindow(parent), myObjectBrowser(0) @@ -36,12 +37,12 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : aDoc = new QDockWidget(this); aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar); - aDoc->setMinimumHeight(20); + aDoc->setMinimumHeight(0); aDoc->setWindowTitle("Console"); QTextEdit* aTextEdt = new QTextEdit(aDoc); aTextEdt->setText(">>>"); - aTextEdt->setMinimumHeight(20); aDoc->setWidget(aTextEdt); + aTextEdt->setMinimumHeight(0); addDockWidget(Qt::BottomDockWidgetArea, aDoc); QMdiArea* aMdiArea = new QMdiArea(this); @@ -57,7 +58,6 @@ XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) : QWidget* XGUI_MainWindow::getSubWindow() { QMdiSubWindow* aSub = new QMdiSubWindow(this); - aSub->setGeometry(0,0, 600, 400); QLabel* aLbl = new QLabel(aSub); aLbl->setFrameStyle(QFrame::Sunken); aLbl->setFrameShape(QFrame::Panel); diff --git a/src/XGUI/XGUI_MenuGroupPanel.cpp b/src/XGUI/XGUI_MenuGroupPanel.cpp index b88960f7b..0753625d5 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.cpp +++ b/src/XGUI/XGUI_MenuGroupPanel.cpp @@ -20,7 +20,8 @@ XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent) : void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction) { - addWidget(theAction->requestWidget(this)); + myActions[theAction] = theAction->requestWidget(this); + addWidget(myActions[theAction]); } void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt) @@ -36,14 +37,13 @@ void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt) void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt) { placeWidget(theWgt); - myWidgets.append(theWgt); } void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent) { QWidget::resizeEvent(theEvent); - if (myWidgets.size() == 0) + if (myActions.size() == 0) return; int aH = theEvent->size().height(); @@ -52,10 +52,24 @@ void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent) return; myMaxRow = aMaxRow; - QListIterator aIt(myWidgets); + QListIterator aIt(myActions.values()); myNewRow = 0; myNewCol = 0; while (aIt.hasNext()) { placeWidget(aIt.next()); } } + +IFeatureMenu* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle, + const QString& theTip, + const QIcon& theIcon, + const QKeySequence& theKeys) +{ + XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this); + aCommand->setToolTip(theTip); + if (!theKeys.isEmpty()) + aCommand->setShortcut(theKeys); + + addCommand(aCommand); + return aCommand; +} diff --git a/src/XGUI/XGUI_MenuGroupPanel.h b/src/XGUI/XGUI_MenuGroupPanel.h index 7fe95cff5..cda62888c 100644 --- a/src/XGUI/XGUI_MenuGroupPanel.h +++ b/src/XGUI/XGUI_MenuGroupPanel.h @@ -2,19 +2,25 @@ #ifndef XGUI_MenuGroupPanel_H #define XGUI_MenuGroupPanel_H +#include "XGUI_Interfaces.h" + #include -#include +#include class QGridLayout; class XGUI_Command; -class XGUI_MenuGroupPanel : public QWidget +class XGUI_MenuGroupPanel : public QWidget, public IMenuGroup { Q_OBJECT public: explicit XGUI_MenuGroupPanel(QWidget *parent = 0); - void addCommand(XGUI_Command* theAction); + virtual IFeatureMenu* addFeature(const QString& theId, + const QString& theTitle, + const QString& theTip, + const QIcon& theIcon, + const QKeySequence& theKeys = QKeySequence()); protected: virtual void resizeEvent(QResizeEvent *theEvent); @@ -22,8 +28,9 @@ protected: private: void addWidget(QWidget* theWgt); void placeWidget(QWidget* theWgt); + void addCommand(XGUI_Command* theAction); - QList myWidgets; + QMap myActions; QGridLayout* myLayout; int myNewRow; int myNewCol; diff --git a/src/XGUI/XGUI_Workbench.cpp b/src/XGUI/XGUI_Workbench.cpp index 3cecc44b9..f73c693fc 100644 --- a/src/XGUI/XGUI_Workbench.cpp +++ b/src/XGUI/XGUI_Workbench.cpp @@ -43,7 +43,6 @@ XGUI_Workbench::XGUI_Workbench(QWidget *theParent) : myLeftButton = new QPushButton("<", this); myLeftButton->setMaximumWidth(14); - //myLeftButton->setEnabled(false); myLeftButton->setVisible(false); connect(myLeftButton,SIGNAL(clicked()), this, SLOT(onLeftScroll())); aMainLayout->addWidget(myLeftButton); @@ -70,7 +69,7 @@ XGUI_Workbench::XGUI_Workbench(QWidget *theParent) : } -int XGUI_Workbench::addGroup() +IMenuGroup* XGUI_Workbench::addGroup() { if (!myLayout->isEmpty()) { int aNb = myLayout->count(); @@ -82,7 +81,7 @@ int XGUI_Workbench::addGroup() addSeparator(); myLayout->addStretch(); myGroups.append(aGroup); - return myGroups.size() - 1; + return aGroup; } void XGUI_Workbench::addSeparator() @@ -93,13 +92,6 @@ void XGUI_Workbench::addSeparator() myLayout->addWidget(aLine); } -void XGUI_Workbench::addCommand(int theGroupId, XGUI_Command* theCommand) -{ - XGUI_MenuGroupPanel* aGroup = myGroups.at(theGroupId); - aGroup->addCommand(theCommand); -} - - void XGUI_Workbench::resizeEvent(QResizeEvent* theEvent) { QWidget::resizeEvent(theEvent); diff --git a/src/XGUI/XGUI_Workbench.h b/src/XGUI/XGUI_Workbench.h index d7916351a..506845adb 100644 --- a/src/XGUI/XGUI_Workbench.h +++ b/src/XGUI/XGUI_Workbench.h @@ -2,6 +2,8 @@ #ifndef XGUI_Workbench_H #define XGUI_Workbench_H +#include "XGUI_Interfaces.h" + #include #include #include @@ -13,15 +15,13 @@ class CommandsArea; class XGUI_Command; -class XGUI_Workbench : public QWidget +class XGUI_Workbench : public QWidget, public IWorkbench { Q_OBJECT public: XGUI_Workbench(QWidget* theParent); - int addGroup(); - - void addCommand(int theGroupId, XGUI_Command* theCommand); + virtual IMenuGroup* addGroup(); private slots: void onLeftScroll(); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 810e0344b..191e960a0 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -37,110 +37,57 @@ void XGUI_Workshop::startApplication() //****************************************************** void XGUI_Workshop::initMenu() { - int aPageId = addWorkbench(tr("HOME_MENU_TITLE")); + IWorkbench* aPage = addWorkbench(tr("HOME_MENU_TITLE")); // File commands group - int aGroupId = addGroup(aPageId); + IMenuGroup* aGroup = aPage->addGroup(); - XGUI_Command* aCommand; + IFeatureMenu* aCommand; - //aCommand = createMenuCommand(aPageId, aGroupId, NEW_CMD, tr("NEW_MENU"), tr("NEW_MENU_TIP"), - // QIcon(":pictures/new.png"), QKeySequence::New); - //connect(aCommand, SIGNAL(triggered()), this, SLOT(onNew())); + aCommand = aGroup->addFeature("NEW_CMD", tr("NEW_MENU"), tr("NEW_MENU_TIP"), + QIcon(":pictures/new.png"), QKeySequence::New); + aCommand->connectTo(this, SLOT(onNew())); - //aCommand = createMenuCommand(aPageId, aGroupId, OPEN_CMD, tr("OPEN_MENU"), tr("OPEN_MENU_TIP"), - // QIcon(":pictures/open.png"), QKeySequence::Open); - //connect(aCommand, SIGNAL(triggered()), this, SLOT(onOpen())); + aCommand = aGroup->addFeature("OPEN_CMD", tr("OPEN_MENU"), tr("OPEN_MENU_TIP"), + QIcon(":pictures/open.png"), QKeySequence::Open); + aCommand->connectTo(this, SLOT(onOpen())); - aCommand = createMenuCommand(aPageId, aGroupId, SAVE_CMD, tr("SAVE_MENU"), tr("SAVE_MENU_TIP"), - QIcon(":pictures/save.png"), QKeySequence::Save); - connect(aCommand, SIGNAL(triggered()), this, SLOT(onSave())); - aCommand->setEnabled(false); + aCommand = aGroup->addFeature("SAVE_CMD", tr("SAVE_MENU"), tr("SAVE_MENU_TIP"), + QIcon(":pictures/save.png"), QKeySequence::Save); + aCommand->connectTo(this, SLOT(onSave())); + aCommand->disable(); - aCommand = createMenuCommand(aPageId, aGroupId, SAVEAS_CMD, tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"), - QIcon(":pictures/save.png")); - connect(aCommand, SIGNAL(triggered()), this, SLOT(onSaveAs())); - aCommand->setEnabled(false); + aCommand = aGroup->addFeature("SAVEAS_CMD", tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"), + QIcon(":pictures/save.png")); + aCommand->connectTo(this, SLOT(onSaveAs())); + aCommand->disable(); // Edit commands group - //aGroupId = addGroup(aPageId); + //aGroup = aPage->addGroup(); - aCommand = createMenuCommand(aPageId, aGroupId, UNDO_CMD, tr("UNDO_MENU"), tr("UNDO_MENU_TIP"), - QIcon(":pictures/undo.png"), QKeySequence::Undo); + aCommand = aGroup->addFeature("UNDO_CMD", tr("UNDO_MENU"), tr("UNDO_MENU_TIP"), + QIcon(":pictures/undo.png"), QKeySequence::Undo); - aCommand = createMenuCommand(aPageId, aGroupId, REDO_CMD, tr("REDO_MENU"), tr("REDO_MENU_TIP"), + aCommand = aGroup->addFeature("REDO_CMD", tr("REDO_MENU"), tr("REDO_MENU_TIP"), QIcon(":pictures/redo.png"), QKeySequence::Redo); - //aCommand = createMenuCommand(aPageId, aGroupId, CUT_CMD, tr("CUT_MENU"), tr("CUT_MENU_TIP"), - // QIcon(":pictures/cut.png"), QKeySequence::Cut); + aCommand = aGroup->addFeature("REBUILD_CMD", tr("REBUILD_MENU"), tr("REBUILD_MENU_TIP"), + QIcon(":pictures/rebuild.png")); - //aCommand = createMenuCommand(aPageId, aGroupId, COPY_CMD, tr("COPY_MENU"), tr("COPY_MENU_TIP"), - // QIcon(":pictures/copy.png"), QKeySequence::Copy); - - //aCommand = createMenuCommand(aPageId, aGroupId, PASTE_CMD, tr("PASTE_MENU"), tr("PASTE_MENU_TIP"), - // QIcon(":pictures/paste.png"), QKeySequence::Paste); - - aCommand = createMenuCommand(aPageId, aGroupId, EXIT_CMD, tr("EXIT_MENU"), tr("EXIT_MENU_TIP"), - QIcon(":pictures/close.png"), QKeySequence::Close); - connect(aCommand, SIGNAL(triggered()), this, SLOT(onExit())); - - // Tests - //aPageId = addWorkbench("Primitives"); - //aGroupId = addGroup(aPageId); - // - //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Box", "Create Box", QIcon(":pictures/box.png")); - //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Cylinder", "Create Cylinder", QIcon(":pictures/cylinder.png")); - //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Disk", "Create Disk", QIcon(":pictures/disk.png")); - //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Torus", "Create Torus", QIcon(":pictures/torus.png")); - - //aPageId = addWorkbench("Operations"); + aCommand = aGroup->addFeature("EXIT_CMD", tr("EXIT_MENU"), tr("EXIT_MENU_TIP"), + QIcon(":pictures/close.png"), QKeySequence::Close); + aCommand->connectTo(this, SLOT(onExit())); } //****************************************************** -XGUI_Command* XGUI_Workshop::createMenuCommand(int thePageId, int theGroupId, XCommandId theCmdId, - const QString& theTitle, const QString& theTip, - const QIcon& theIcon, const QKeySequence& theKeys) -{ - XGUI_Command* aCommand = new XGUI_Command(theIcon, theTitle, this); - aCommand->setToolTip(theTip); - if (!theKeys.isEmpty()) - aCommand->setShortcut(theKeys); - addCommand(theCmdId, thePageId, theGroupId, aCommand); - return aCommand; -} - -//****************************************************** -int XGUI_Workshop::addWorkbench(const QString& theName) +IWorkbench* XGUI_Workshop::addWorkbench(const QString& theName) { XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); return aMenuBar->addWorkbench(theName); } -//****************************************************** -int XGUI_Workshop::addGroup(int thePageId) -{ - XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); - return aMenuBar->addGroup(thePageId); -} - -//****************************************************** -void XGUI_Workshop::addCommand(XCommandId theCommandId, int thePageId, int theGroupId, XGUI_Command* theCommand) -{ - XGUI_MainMenu* aMenuBar = myMainWindow->menuObject(); - aMenuBar->addCommand(thePageId, theGroupId, theCommand); - myCommands[theCommandId] = theCommand; -} - -//****************************************************** -XGUI_Command* XGUI_Workshop::command(XCommandId theId) const -{ - if (myCommands.contains(theId)) - return myCommands[theId]; - return 0; -} - //****************************************************** void XGUI_Workshop::onExit() { @@ -242,11 +189,3 @@ bool XGUI_Workshop::activateModule() return true; } -//****************************************************** -int XGUI_Workshop::addFeature(int thePageId, int theGroupId, - const QString& theTitle, const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys) -{ - return (int) createMenuCommand(thePageId, theGroupId, LAST_CMD, theTitle, theTip, theIcon, theKeys); -} diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index cfeb70092..c941f42d0 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -13,40 +13,19 @@ class XGUI_MainWindow; class XGUI_Command; class XGUI_Module; -class XGUI_Workshop: public QObject, IWorkshop +class XGUI_Workshop: public QObject, public IWorkshop { Q_OBJECT public: - enum XCommandId { - NEW_CMD, - OPEN_CMD, - SAVE_CMD, - SAVEAS_CMD, - EXIT_CMD, - UNDO_CMD, - REDO_CMD, - COPY_CMD, - CUT_CMD, - PASTE_CMD, - LAST_CMD - }; XGUI_Workshop(); virtual ~XGUI_Workshop(); void startApplication(); - XGUI_Command* command(XCommandId theId) const; - XGUI_MainWindow* mainWindow() const { return myMainWindow; } - virtual int addWorkbench(const QString& theName); - virtual int addGroup(int thePageId); - virtual int addFeature(int thePageId, int theGroupId, - const QString& theTitle, const QString& theTip, - const QIcon& theIcon, - const QKeySequence& theKeys = QKeySequence()); - + virtual IWorkbench* addWorkbench(const QString& theName); public slots: void onNew(); @@ -61,13 +40,6 @@ private: IModule* loadModule(const QString& theModule); bool activateModule(); - void addCommand(XCommandId theCommandId, int thePageId, int theGroupId, XGUI_Command* theCommand); - XGUI_Command* createMenuCommand(int thePageId, int theGroupId, XCommandId theCmdId, - const QString& theTitle, const QString& theTip, - const QIcon& theIcon = QIcon(), const QKeySequence& theKeys = QKeySequence()); - - QMap myCommands; - XGUI_MainWindow* myMainWindow; }; diff --git a/src/XGUI/XGUI_msg_en.ts b/src/XGUI/XGUI_msg_en.ts index 94a8cc9a9..4f72790d6 100644 --- a/src/XGUI/XGUI_msg_en.ts +++ b/src/XGUI/XGUI_msg_en.ts @@ -90,6 +90,14 @@ PASTE_MENU_TIP Paste copied object + + REBUILD_MENU + Rebuild + + + REBUILD_MENU_TIP + Rebuild data objects + XGUI_MainWindow diff --git a/src/XGUI/XGUI_pictures.qrc b/src/XGUI/XGUI_pictures.qrc index ee262ff3f..ddcb76b47 100644 --- a/src/XGUI/XGUI_pictures.qrc +++ b/src/XGUI/XGUI_pictures.qrc @@ -4,11 +4,9 @@ pictures/open.png pictures/save.png pictures/close.png - pictures/copy.png - pictures/cut.png - pictures/paste.png pictures/redo.png pictures/undo.png + pictures/rebuild.png pictures/ViewPort.png diff --git a/src/XGUI/pictures/copy.png b/src/XGUI/pictures/copy.png deleted file mode 100644 index 0c90599da..000000000 Binary files a/src/XGUI/pictures/copy.png and /dev/null differ diff --git a/src/XGUI/pictures/cut.png b/src/XGUI/pictures/cut.png deleted file mode 100644 index 5f022d096..000000000 Binary files a/src/XGUI/pictures/cut.png and /dev/null differ diff --git a/src/XGUI/pictures/paste.png b/src/XGUI/pictures/paste.png deleted file mode 100644 index 12e3ce92c..000000000 Binary files a/src/XGUI/pictures/paste.png and /dev/null differ diff --git a/src/XGUI/pictures/rebuild.png b/src/XGUI/pictures/rebuild.png new file mode 100644 index 000000000..8d4bb27ee Binary files /dev/null and b/src/XGUI/pictures/rebuild.png differ