ModuleBase_WidgetFileSelector uses "import_initial_path" key for QFileDialog initial directory.
#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)
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;
#include <ModuleBase_WidgetFileSelector.h>
#include <ModuleBase_Tools.h>
+#include <Config_PropManager.h>
#include <Config_WidgetAPI.h>
#include <QFileDialog>
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);
#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
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
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()