From 6af7745439b9101ae3f544f7c773a6b12c5b4ea4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 18 Oct 2011 07:37:15 +0000 Subject: [PATCH] + save/restore custom icon paths git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5035 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Gui/BitmapFactory.cpp | 22 ++++++++++++++++++++++ src/Gui/BitmapFactory.h | 4 ++++ src/Gui/DlgActionsImp.cpp | 1 + 3 files changed, 27 insertions(+) diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index c1785492a..2e794be5c 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -34,6 +34,7 @@ # include # include # include +# include #endif #include @@ -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 group = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/Bitmaps"); + std::vector 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 group = App::GetApplication().GetParameterGroupByPath + ("User parameter:BaseApp/Preferences/Bitmaps"); + std::vector paths = group->GetASCIIs("CustomPath"); + for (std::vector::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); diff --git a/src/Gui/BitmapFactory.h b/src/Gui/BitmapFactory.h index 5b1edd85a..822156ab7 100644 --- a/src/Gui/BitmapFactory.h +++ b/src/Gui/BitmapFactory.h @@ -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(); diff --git a/src/Gui/DlgActionsImp.cpp b/src/Gui/DlgActionsImp.cpp index a7596c94e..f71727825 100644 --- a/src/Gui/DlgActionsImp.cpp +++ b/src/Gui/DlgActionsImp.cpp @@ -427,6 +427,7 @@ void IconDialog::onAddIconPath() } BitmapFactory().addPath(dir); + BitmapFactory().addCustomPath(dir); } }