#include <sstream> // for stringstream\r
\r
#include <string>\r
-#include <algorithm> // for std::transform\r\r
+#include <algorithm> // for std::transform\r
+\r
bool isElementNode(xmlNodePtr theNode)\r
{\r
return theNode->type == XML_ELEMENT_NODE;\r
\r
std::string library(const std::string& theLibName)\r
{\r
+ if(theLibName.empty())\r
+ return std::string();\r
std::string aLibName = theLibName;\r
#ifndef WIN32\r
static std::string aLibExt( ".so" );\r
Shortcut,
ShortcutTree,
BiColor,
- Background
+ Background,
+ Directory
};
/**
#include <Config_Keywords.h>
#include <Config_Common.h>
#include <Config_ValidatorMessage.h>
+#include <Config_PropManager.h>
#include <Events_Loop.h>
+#include <Events_Error.h>
#include <libxml/parser.h>
#include <libxml/tree.h>
+#include <fstream>
+
#ifdef WIN32
#pragma warning(disable : 4996) // for getenv
#endif
Config_XMLReader::Config_XMLReader(const std::string& theXmlFileName)
: myXmlDoc(NULL)
{
- std::string prefix = "";
+ std::string prefix = "";
+ Config_Prop* aProp = Config_PropManager::findProp("Plugins", "default_path");
+ if (aProp)
+ prefix = aProp->value();
/*
* Get path to *.xml files (typically ./bin/../plugins/)
* the problem: application may be launched using python executable,
* to use environment variable (at least for the current moment)
*/
- char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
- if (anEnv) {
- prefix = std::string(anEnv) + "/";
+ if (prefix.empty()) {
+ char* anEnv = getenv("NEW_GEOM_CONFIG_FILE");
+ if (anEnv) {
+ prefix = std::string(anEnv);
+ }
}
-
+#ifdef WIN32
+ prefix += "\\";
+#else
+ prefix += "/";
+#endif
myDocumentPath = prefix + theXmlFileName;
+ std::ifstream aTestFile(myDocumentPath);
+ if (!aTestFile) Events_Error::send("Unable to open " + myDocumentPath);
+ aTestFile.close();
}
Config_XMLReader::~Config_XMLReader()
<parameter name="item_size" value="25" />
<parameter name="rows_number" value="3" />
</section>
+ <section name="Plugins" >
+ <!-- Plugins preferences -->
+ <parameter name="default_path" value="" />
+ </section>
+
</document>
class XGUI_IPrefMgr
{
public:
+
/**
* Add preference item into preference dialog box
* \param theLbl - label of the item
SUIT_PreferenceMgr::PrefItemType theType,
const QString& theSection, const QString& theName ) = 0;
+ virtual void setItemProperty(const QString& thePropName,
+ const QVariant& theValue,
+ const int theId = -1) = 0;
+
/// Returns incapsulated preference manager
virtual SUIT_PreferenceMgr* prefMgr() const = 0;
};
-#endif
\ No newline at end of file
+#endif
#include <SUIT_ResourceMgr.h>
#include <SUIT_PreferenceMgr.h>
+#include <Qtx.h>
#include <QLayout>
#include <QApplication>
isResModified = true;
}
// Add item
- if (aProp->type() != Config_Prop::Disabled)
- thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab,
- (SUIT_PreferenceMgr::PrefItemType) aProp->type(),
- QString(aProp->section().c_str()), QString(aProp->name().c_str()));
+ if (aProp->type() != Config_Prop::Disabled) {
+ SUIT_PreferenceMgr::PrefItemType aPrefType = SUIT_PreferenceMgr::Auto;
+ if (aProp->type() == Config_Prop::Directory) {
+ aPrefType = SUIT_PreferenceMgr::File;
+ } else {
+ aPrefType = (SUIT_PreferenceMgr::PrefItemType) aProp->type();
+ }
+ int anId = thePref->addPreference(QObject::tr(aProp->title().c_str()), aTab, aPrefType,
+ QString::fromStdString(aProp->section()),
+ QString::fromStdString(aProp->name()));
+ if(aProp->type() == Config_Prop::Directory) {
+ thePref->setItemProperty("path_type", Qtx::PT_Directory, anId);
+ }
+ }
}
}
}
return myMgr->addItem(theLbl, pId, theType, theSection, theName);
}
+ virtual void setItemProperty( const QString& thePropName, const QVariant& theValue,
+ const int theId = -1) {
+ myMgr->setItemProperty(thePropName, theValue, theId);
+ }
+
virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; }
private:
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
+#include <Config_PropManager.h>
#include <QApplication>
#include <QFileDialog>
void XGUI_Workshop::startApplication()
{
initMenu();
+
+ Config_PropManager::registerProp("Plugins", "default_path", "Default Path",
+ Config_Prop::Directory, "");
+
//Initialize event listening
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
registerValidators();
+ // Calling of loadCustomProps before activating module is required
+ // by Config_PropManger to restore user-defined path to plugins
+ XGUI_Preferences::loadCustomProps();
activateModule();
if (myMainWindow) {
myMainWindow->show();
updateCommandStatus();
}
- XGUI_Preferences::loadCustomProps();
+
onNew();
}