+ save/restore custom icon paths

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5035 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer 2011-10-18 07:37:15 +00:00
parent ac6cf98c98
commit 6af7745439
3 changed files with 27 additions and 0 deletions

View File

@ -34,6 +34,7 @@
# include <QPalette>
# include <QSvgRenderer>
# include <QStyleOption>
# include <sstream>
#endif
#include <string>
@ -88,6 +89,7 @@ void BitmapFactoryInst::destruct (void)
BitmapFactoryInst::BitmapFactoryInst()
{
d = new BitmapFactoryInstP;
restoreCustomPaths();
}
BitmapFactoryInst::~BitmapFactoryInst()
@ -95,6 +97,26 @@ BitmapFactoryInst::~BitmapFactoryInst()
delete d;
}
void BitmapFactoryInst::addCustomPath(const QString& path)
{
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Bitmaps");
std::vector<std::string> paths = group->GetASCIIs("CustomPath");
std::stringstream str;
str << "CustomPath" << paths.size();
group->SetASCII(str.str().c_str(), (const char*)path.toUtf8());
}
void BitmapFactoryInst::restoreCustomPaths()
{
Base::Reference<ParameterGrp> group = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Bitmaps");
std::vector<std::string> paths = group->GetASCIIs("CustomPath");
for (std::vector<std::string>::iterator it = paths.begin(); it != paths.end(); ++it) {
addPath(QString::fromUtf8(it->c_str()));
}
}
void BitmapFactoryInst::addPath(const QString& path)
{
d->paths.push_back(path);

View File

@ -54,6 +54,8 @@ public:
static BitmapFactoryInst& instance(void);
static void destruct (void);
void addCustomPath(const QString&);
/// Adds a path where pixmaps can be found
void addPath(const QString& path);
/// Removes a path from the list of pixmap paths
@ -122,6 +124,8 @@ public:
void convert(const SoSFImage& img, QImage& out) const;
private:
void restoreCustomPaths();
static BitmapFactoryInst* _pcSingleton;
BitmapFactoryInst();
~BitmapFactoryInst();

View File

@ -427,6 +427,7 @@ void IconDialog::onAddIconPath()
}
BitmapFactory().addPath(dir);
BitmapFactory().addCustomPath(dir);
}
}