Salome HOME
Merge branch 'master' of newgeom:newgeom.git
authorsbh <sergey.belash@opencascade.com>
Wed, 13 Aug 2014 09:27:08 +0000 (13:27 +0400)
committersbh <sergey.belash@opencascade.com>
Wed, 13 Aug 2014 09:27:08 +0000 (13:27 +0400)
1  2 
src/XGUI/XGUI_MainMenu.cpp
src/XGUI/XGUI_MainMenu.h
src/XGUI/XGUI_Workshop.cpp

index a558cdb36f052c09ef5327f80022683aea9c3e99,4e64c9e6eec6d317d9cd753afafd2ea5e462e84f..273e248dfccfc7c9e36e3f5dabdc3b06a89dea5c
@@@ -3,6 -3,9 +3,9 @@@
  #include <XGUI_MenuGroupPanel.h>
  #include <XGUI_MainWindow.h>
  #include <XGUI_Command.h>
+ #include <XGUI_Preferences.h>
+ #include <SUIT_ResourceMgr.h>
  
  #include <QLayout>
  #include <QTabWidget>
@@@ -115,11 -118,23 +118,11 @@@ QList<XGUI_Command*> XGUI_MainMenu::fea
    return aList;
  }
  
 -QList<XGUI_Workbench*> XGUI_MainMenu::workbenches() const
 -{
 -  QList<XGUI_Workbench*> aList;
 -  for (int aTabIdx = 0; aTabIdx < myMenuTabs->count(); ++aTabIdx) {
 -    XGUI_Workbench* aWb = dynamic_cast<XGUI_Workbench*>(myMenuTabs->widget(aTabIdx));
 -    if (aWb) {
 -      aList.append(aWb);
 -    }
 -  }
 -  return aList;
 -}
 -
  int XGUI_MainMenu::menuItemSize() const
  {
-   //TODO(sbh, vsv): get this value from the preferences
-   static const ItemSize DEFAULT_ITEM_SIZE = Medium;
-   return (int) DEFAULT_ITEM_SIZE;
+   int DEFAULT_ITEM_SIZE = XGUI_Preferences::resourceMgr()->integerValue(
+     XGUI_Preferences::MENU_SECTION, "item_size");
+   return DEFAULT_ITEM_SIZE;
  }
  
  int XGUI_MainMenu::menuHeight() const
  
  int XGUI_MainMenu::menuItemRowsCount() const
  {
-   //TODO(sbh, vsv): get this value from the preferences
-   static const int DEFAULT_ITEM_ROWS_COUNT = 3;
+   int DEFAULT_ITEM_ROWS_COUNT = XGUI_Preferences::resourceMgr()->integerValue(
+     XGUI_Preferences::MENU_SECTION, "rows_number");
    return DEFAULT_ITEM_ROWS_COUNT;
  }
+ void XGUI_MainMenu::updateFromResources()
+ {
+ }
diff --combined src/XGUI/XGUI_MainMenu.h
index 718bd50a7b59197df2e47a28e31f5bb86c5a4acd,b583bf02cc0d415f7769d153f39c53b7915065be..29b87063f602f1289d15ce4e23851c7e1086be77
@@@ -28,11 -28,11 +28,11 @@@ class XGUI_EXPORT XGUI_MainMenu: publi
  
    //! Size of menu item
    //TODO(sbh, vsv): Move to the settings
-   enum ItemSize {
-     Small = 20,
-     Medium = 25,
-     Large = 30
-   };
+   //enum ItemSize {
+   //  Small = 20,
+   //  Medium = 25,
+   //  Large = 30
+   //};
  
  public:
    XGUI_MainMenu(XGUI_MainWindow *parent);
@@@ -56,6 -56,8 +56,6 @@@
    //! Returns list of created commands
    QList<XGUI_Command*> features() const;
  
 -  QList<XGUI_Workbench*> workbenches() const;
 -
    virtual bool eventFilter(QObject *theWatched, QEvent *theEvent);
  
    //! Displays given console as a tab in the workbench
    //! Removes already created tab with python console
    void removeConsole();
  
 +  //! Defines size of menu item.
 +  //! In the future this value should be extracted from the preferences.
    int menuItemSize() const;
 +  //! Defines number of menu item rows.
 +  //! In the future this value should be extracted from the preferences.
    int menuItemRowsCount() const;
 +  //! Defines height of the main menu. (Number of rows * row height)
    int menuHeight() const;
  
+   void updateFromResources();
  private:
    XGUI_MainWindow* myDesktop;
    QTabWidget* myMenuTabs;
index c02b053506a033106a0a168edfa26f78517a5211,f6c41a9f4bb5892d76c5718817327e5eeae6bbb3..3d5441be77fa9b022830fd5e788ec24ace9d5bfb
@@@ -321,7 -321,6 +321,7 @@@ void XGUI_Workshop::onFeatureUpdatedMsg
        } 
      }
    }
 +  myOperationMgr->validateCurrentOperation();
  }
  
  //******************************************************
@@@ -385,7 -384,7 +385,7 @@@ void XGUI_Workshop::onObjectDeletedMsg(
  {
    //std::set<ObjectPtr> aFeatures = theMsg->objects();
  }
 - 
 +
  //******************************************************
  void XGUI_Workshop::onOperationStarted()
  {
  
      showPropertyPanel();
      QString aXmlRepr = aOperation->getDescription()->xmlRepresentation();
 -    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(), myModuleConnector);
 +    ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
 +                                                                 myModuleConnector);
  
      myPropertyPanel->cleanContent();
      aFactory.createWidget(myPropertyPanel->contentWidget());
@@@ -670,7 -668,21 +670,21 @@@ void XGUI_Workshop::onRedo(
  //******************************************************
  void XGUI_Workshop::onPreferences()
  {
-   XGUI_Preferences::editPreferences();
+   XGUI_Prefs aModif;
+   XGUI_Preferences::editPreferences(aModif);
+   if (aModif.size() > 0) {
+     QString aSection;
+     foreach (XGUI_Pref aPref, aModif) {
+       aSection = aPref.first;
+       if (aSection == XGUI_Preferences::VIEWER_SECTION) {
+         if (!isSalomeMode()) 
+           myMainWindow->viewer()->updateFromResources();
+       } else if (aSection == XGUI_Preferences::MENU_SECTION) {
+         if (!isSalomeMode()) 
+           myMainWindow->menuObject()->updateFromResources();
+       }
+     }
+   }
  }
  
  //******************************************************
@@@ -796,8 -808,9 +810,8 @@@ QList<QAction*> XGUI_Workshop::getModul
      aCommands = salomeConnector()->commandList();
    } else {
      XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
 -    foreach (XGUI_Workbench* aWb, aMenuBar->workbenches()) {
 -      foreach(XGUI_Command* aCmd, aWb->features())
 -        aCommands.append(aCmd);
 +    foreach(XGUI_Command* aCmd, aMenuBar->features()) {
 +      aCommands.append(aCmd);
      }
    }
    return aCommands;
@@@ -847,9 -860,6 +861,9 @@@ void XGUI_Workshop::createDockWidgets(
            myOperationMgr, SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
    connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)),
            myPropertyPanel, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
 +  connect(myOperationMgr, SIGNAL(operationValidated(bool)),
 +          myPropertyPanel, SLOT(setAcceptEnabled(bool)));
 +
  }
  
  //******************************************************