]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
ModuleBase_WidgetChoice is extended to use in a combo box a list of values read from...
authornds <nds@opencascade.com>
Thu, 2 Nov 2017 12:31:35 +0000 (15:31 +0300)
committernds <nds@opencascade.com>
Thu, 2 Nov 2017 12:31:35 +0000 (15:31 +0300)
ModuleBase_WidgetFileSelector uses "import_initial_path" key for QFileDialog initial directory.

src/ModuleBase/ModuleBase_WidgetChoice.cpp
src/ModuleBase/ModuleBase_WidgetFileSelector.cpp
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Workshop.cpp

index 1bc6987e13ca85abce3a4453421d18871d0226da..0930fa73b78497327fdb54d7b6d761a0f9174f46 100644 (file)
 #include <ModelAPI_AttributeInteger.h>
 #include <ModelAPI_Data.h>
 #include <Config_WidgetAPI.h>
+#include <Config_PropManager.h>
 
+#include <QDir>
+#include <QFile>
 #include <QWidget>
 #include <QLayout>
 #include <QLabel>
 #include <QButtonGroup>
 #include <QGroupBox>
 #include <QRadioButton>
+#include <QTextStream>
 #include <QToolButton>
 
+void getValues(const std::string& thePath, const std::string& theFileName,
+               QStringList& theValues)
+{
+  QString aFileName = thePath.c_str();
+  aFileName += QDir::separator();
+  aFileName += theFileName.c_str();
+
+  QFile aFile(aFileName);
+  if (!aFile.open(QIODevice::ReadOnly | QIODevice::Text))
+    return;
+
+  QTextStream aStream(&aFile);
+  while (!aStream.atEnd()) {
+    QString aLine = aStream.readLine();
+    if (!aLine.isEmpty())
+      theValues.append(aLine);
+  }
+}
 
 ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
                                                  const Config_WidgetAPI* theData)
@@ -51,6 +73,14 @@ ModuleBase_WidgetChoice::ModuleBase_WidgetChoice(QWidget* theParent,
   foreach(QString aType, QString(aTypes.c_str()).split(' ')) {
     aList.append(translate(aType.toStdString()));
   }
+  if (aTypes.empty()) {
+    aList.clear();
+    std::string aFileName = theData->getProperty("file_name");
+    if (!aFileName.empty()) {
+      std::string aPath = Config_PropManager::string("Plugins", "combo_box_elements_path");
+      getValues(aPath, aFileName, aList);
+    }
+  }
 
   if (theData->getBooleanAttribute("use_in_title", false))
     myButtonTitles = aList;
index 57db592c3cf6fe3cf48906ac00119df2a133bcd2..c7e1c0df92794d744a46abb995fcd6ad9cd41465 100644 (file)
@@ -26,6 +26,7 @@
 #include <ModuleBase_WidgetFileSelector.h>
 #include <ModuleBase_Tools.h>
 
+#include <Config_PropManager.h>
 #include <Config_WidgetAPI.h>
 
 #include <QFileDialog>
@@ -49,6 +50,9 @@ ModuleBase_WidgetFileSelector::ModuleBase_WidgetFileSelector(QWidget* theParent,
   myType = (theData->getProperty("type") == "save") ? WFS_SAVE : WFS_OPEN;
   myDefaultPath = QString::fromStdString(theData->getProperty("path"));
 
+  if (myDefaultPath.isEmpty())
+    myDefaultPath = Config_PropManager::string("Plugins", "import_initial_path").c_str();
+
   QGridLayout* aMainLay = new QGridLayout(this);
   ModuleBase_Tools::adjustMargins(aMainLay);
   QLabel* aTitleLabel = new QLabel(myTitle, this);
index 9663e386aaa7d07f0f1d15f9ebc2b3e4511d3881..7f0fe59ff7d9dd72c9f9f147f36063391d4f495a 100644 (file)
@@ -164,7 +164,7 @@ SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESO
 #SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES})
 SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES} ${PREFERENCES_XML})
 
-ADD_DEFINITIONS( -DXGUI_EXPORTS ${CAS_DEFINITIONS} )
+ADD_DEFINITIONS( -DXGUI_EXPORTS ${CAS_DEFINITIONS} -D_CRT_SECURE_NO_WARNINGS)
 
 SET(PROJECT_INCLUDES
     ${PROJECT_SOURCE_DIR}/src/Events
index 737d28e91f7ef3f5120228cf6f9320c036e94234..43f6f446eb4863ce024be4a2b97bd6d10c291404 100755 (executable)
@@ -295,7 +295,17 @@ void XGUI_Workshop::startApplication()
   Config_PropManager::registerProp("Plugins", "default_path", "Default Path",
                                    Config_Prop::Directory, "");
 
+  QString aDefaultPath = QString("%1Resources").arg(ModuleBase_Preferences::resourceMgr()->appName());
+  std::string aDir = getenv(aDefaultPath.toLatin1());
+  Config_PropManager::registerProp("Plugins", "combo_box_elements_path", "ComboBox elements directory",
+                                   Config_Prop::Directory, aDir);
+  Config_PropManager::registerProp("Plugins", "import_initial_path", "Import initial directory",
+                                   Config_Prop::Directory, aDir);
 
+#ifdef _DEBUG
+  Config_PropManager::registerProp("Plugins", "create_part_by_start", "Create Part by Start",
+    Config_Prop::Boolean, "false");
+#endif
   registerValidators();
 
   // Calling of  loadCustomProps before activating module is required
@@ -315,6 +325,13 @@ void XGUI_Workshop::startApplication()
           SLOT(onTrihedronVisibilityChanged(bool)));
 
   emit applicationStarted();
+
+#ifdef _DEBUG
+  bool aNewPart = Config_PropManager::boolean("Plugins", "create_part_by_start");
+  if (aNewPart) {
+      module()->launchOperation("Part", false);
+  }
+#endif
 }
 
 void XGUI_Workshop::activateModule()