Skip to content
Snippets Groups Projects
Commit 2202150a authored by merov's avatar merov
Browse files

ACME-1243 : WIP : Populate filter drop down with filter list dynamically

parent 0c7cab77
No related branches found
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "llflickrconnect.h" #include "llflickrconnect.h"
#include "llfloaterreg.h" #include "llfloaterreg.h"
#include "lliconctrl.h" #include "lliconctrl.h"
#include "llimagefiltersmanager.h"
#include "llresmgr.h" // LLLocale #include "llresmgr.h" // LLLocale
#include "llsdserialize.h" #include "llsdserialize.h"
#include "llloadingindicator.h" #include "llloadingindicator.h"
...@@ -106,6 +107,14 @@ BOOL LLFlickrPhotoPanel::postBuild() ...@@ -106,6 +107,14 @@ BOOL LLFlickrPhotoPanel::postBuild()
mPostButton = getChild<LLUICtrl>("post_photo_btn"); mPostButton = getChild<LLUICtrl>("post_photo_btn");
mCancelButton = getChild<LLUICtrl>("cancel_photo_btn"); mCancelButton = getChild<LLUICtrl>("cancel_photo_btn");
// Update filter list
std::vector<std::string> filter_list = LLImageFiltersManager::getInstance()->getFiltersList();
LLComboBox* filterbox = static_cast<LLComboBox *>(mFilterComboBox);
for (U32 i = 0; i < filter_list.size(); i++)
{
filterbox->add(filter_list[i]);
}
return LLPanel::postBuild(); return LLPanel::postBuild();
} }
......
/** /**
* @file llimagefilters.cpp * @file llimagefiltersmanager.cpp
* @brief Load and execute image filters. Mostly used for Flickr at the moment. * @brief Load and execute image filters. Mostly used for Flickr at the moment.
* *
* $LicenseInfo:firstyear=2001&license=viewerlgpl$ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "llviewerprecompiledheaders.h" #include "llviewerprecompiledheaders.h"
#include "llimagefilters.h" #include "llimagefiltersmanager.h"
#include "lldiriterator.h" #include "lldiriterator.h"
...@@ -35,34 +35,36 @@ ...@@ -35,34 +35,36 @@
// LLImageFilters // LLImageFilters
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
LLImageFilters::LLImageFilters() LLImageFiltersManager::LLImageFiltersManager()
{ {
} }
LLImageFilters::~LLImageFilters() LLImageFiltersManager::~LLImageFiltersManager()
{ {
} }
// virtual static // virtual static
void LLImageFilters::initSingleton() void LLImageFiltersManager::initSingleton()
{ {
loadAllFilters(); loadAllFilters();
} }
// static // static
std::string LLImageFilters::getSysDir() std::string LLImageFiltersManager::getSysDir()
{ {
return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "filters", ""); return gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "filters", "");
} }
void LLImageFilters::loadAllFilters() void LLImageFiltersManager::loadAllFilters()
{ {
// Load system (coming out of the box) filters // Load system (coming out of the box) filters
loadFiltersFromDir(getSysDir()); loadFiltersFromDir(getSysDir());
} }
void LLImageFilters::loadFiltersFromDir(const std::string& dir) void LLImageFiltersManager::loadFiltersFromDir(const std::string& dir)
{ {
mFiltersList.clear();
LLDirIterator dir_iter(dir, "*.xml"); LLDirIterator dir_iter(dir, "*.xml");
while (1) while (1)
{ {
...@@ -71,11 +73,15 @@ void LLImageFilters::loadFiltersFromDir(const std::string& dir) ...@@ -71,11 +73,15 @@ void LLImageFilters::loadFiltersFromDir(const std::string& dir)
{ {
break; // no more files break; // no more files
} }
// Get the ".xml" out of the file name to get the filter name
std::string filter_name = file.substr(0,file.length()-4);
mFiltersList.push_back(filter_name);
std::string path = gDirUtilp->add(dir, file); std::string path = gDirUtilp->add(dir, file);
// For the moment, just output the file found to the log // For the moment, just output the file found to the log
llinfos << "Merov : loadFiltersFromDir, filter = " << path << llendl; llinfos << "Merov : loadFiltersFromDir, filter = " << file << ",path = " << path << llendl;
} }
} }
......
/** /**
* @file llimagefilters.h * @file llimagefiltersmanager.h
* @brief Load and execute image filters. Mostly used for Flickr at the moment. * @brief Load and execute image filters. Mostly used for Flickr at the moment.
* *
* $LicenseInfo:firstyear=2000&license=viewerlgpl$ * $LicenseInfo:firstyear=2000&license=viewerlgpl$
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
#ifndef LL_LLIMAGEFILTERS_H #ifndef LL_LLIMAGEFILTERSMANAGER_H
#define LL_LLIMAGEFILTERS_H #define LL_LLIMAGEFILTERSMANAGER_H
#include "llsingleton.h" #include "llsingleton.h"
#include "llimage.h" #include "llimage.h"
...@@ -46,29 +46,30 @@ typedef enum e_screen_mode ...@@ -46,29 +46,30 @@ typedef enum e_screen_mode
//============================================================================ //============================================================================
// library initialization class // library initialization class
class LLImageFilters : public LLSingleton<LLImageFilters> class LLImageFiltersManager : public LLSingleton<LLImageFiltersManager>
{ {
LOG_CLASS(LLImageFilters); LOG_CLASS(LLImageFiltersManager);
public: public:
// getFilters(); get a vector of std::string containing the filter names // getFilters(); get a vector of std::string containing the filter names
//LLSD loadFilter(const std::string& filter_name); //LLSD loadFilter(const std::string& filter_name);
//void executeFilter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image); //void executeFilter(const LLSD& filter_data, LLPointer<LLImageRaw> raw_image);
const std::vector<std::string> &getFiltersList() const { return mFiltersList; }
protected: protected:
private: private:
void loadAllFilters(); void loadAllFilters();
void loadFiltersFromDir(const std::string& dir); void loadFiltersFromDir(const std::string& dir);
LLSD loadFilter(const std::string& path); // LLSD loadFilter(const std::string& path);
static std::string getSysDir(); static std::string getSysDir();
friend class LLSingleton<LLImageFilters>; friend class LLSingleton<LLImageFiltersManager>;
/*virtual*/ void initSingleton(); /*virtual*/ void initSingleton();
LLImageFilters(); LLImageFiltersManager();
~LLImageFilters(); ~LLImageFiltersManager();
// Needed here: // List of filters
// - a map of filter files with name and path std::vector<std::string> mFiltersList;
}; };
#endif #endif // LL_LLIMAGEFILTERSMANAGER_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment