Kaydet (Commit) 7f262a41 authored tarafından Rishabh Kumar's avatar Rishabh Kumar Kaydeden (comit) Rishabh Kumar

[GSoC] Fix recent colors in color popup widget

Save recent colors in user configuration.

Change-Id: I1637e9fe3150bd1892f72ff9df06dc2a7c3e1e9e
Reviewed-on: https://gerrit.libreoffice.org/27688Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst bb01247f
...@@ -52,7 +52,7 @@ class PaletteManager ...@@ -52,7 +52,7 @@ class PaletteManager
std::vector<std::unique_ptr<Palette>> m_Palettes; std::vector<std::unique_ptr<Palette>> m_Palettes;
std::function<void(const OUString&, const Color&)> maColorSelectFunction; std::function<void(const OUString&, const Color&)> maColorSelectFunction;
css::uno::Reference < css::uno::XComponentContext > m_context;
public: public:
PaletteManager(); PaletteManager();
~PaletteManager(); ~PaletteManager();
......
...@@ -3406,6 +3406,16 @@ ...@@ -3406,6 +3406,16 @@
</info> </info>
</prop> </prop>
</group> </group>
<group oor:name="UserColors">
<info>
<desc>Contains recent colors and custom colors</desc>
</info>
<prop oor:name="RecentColor" oor:type="oor:int-list" oor:nillable="false">
<info>
<desc>List of Recent colors</desc>
</info>
<value/> </prop>
</group>
<group oor:name="Help"> <group oor:name="Help">
<info> <info>
<desc>Contains settings that specify the common help settings.</desc> <desc>Contains settings that specify the common help settings.</desc>
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include <vcl/settings.hxx> #include <vcl/settings.hxx>
#include <stack> #include <stack>
#include <set> #include <set>
#include <cppu/unotype.hxx>
#include <officecfg/Office/Common.hxx>
PaletteManager::PaletteManager() : PaletteManager::PaletteManager() :
mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()), mnMaxRecentColors(Application::GetSettings().GetStyleSettings().GetColorValueSetColumnCount()),
...@@ -38,7 +40,8 @@ PaletteManager::PaletteManager() : ...@@ -38,7 +40,8 @@ PaletteManager::PaletteManager() :
mnColorCount(0), mnColorCount(0),
mpBtnUpdater(nullptr), mpBtnUpdater(nullptr),
mLastColor(COL_AUTO), mLastColor(COL_AUTO),
maColorSelectFunction(PaletteManager::DispatchColorCommand) maColorSelectFunction(PaletteManager::DispatchColorCommand),
m_context(comphelper::getProcessComponentContext())
{ {
SfxObjectShell* pDocSh = SfxObjectShell::Current(); SfxObjectShell* pDocSh = SfxObjectShell::Current();
if(pDocSh) if(pDocSh)
...@@ -134,6 +137,13 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet) ...@@ -134,6 +137,13 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet) void PaletteManager::ReloadRecentColorSet(SvxColorValueSet& rColorSet)
{ {
maRecentColors.clear();
css::uno::Sequence< sal_Int32 > Colorlist(officecfg::Office::Common::UserColors::RecentColor::get());
for(int i = 0;i < Colorlist.getLength();i++)
{
Color aColor( Colorlist[i] );
maRecentColors.push_back( aColor );
}
rColorSet.Clear(); rColorSet.Clear();
int nIx = 1; int nIx = 1;
for(std::deque<Color>::const_iterator it = maRecentColors.begin(); for(std::deque<Color>::const_iterator it = maRecentColors.begin();
...@@ -217,6 +227,14 @@ void PaletteManager::AddRecentColor(const Color& rRecentColor) ...@@ -217,6 +227,14 @@ void PaletteManager::AddRecentColor(const Color& rRecentColor)
maRecentColors.push_front( rRecentColor ); maRecentColors.push_front( rRecentColor );
if( maRecentColors.size() > mnMaxRecentColors ) if( maRecentColors.size() > mnMaxRecentColors )
maRecentColors.pop_back(); maRecentColors.pop_back();
css::uno::Sequence< sal_Int32 > aColorList(maRecentColors.size());
for(sal_uInt16 i = 0;i < maRecentColors.size();i++)
{
aColorList[i] = (int)maRecentColors[i].GetColor();
}
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create(m_context));
officecfg::Office::Common::UserColors::RecentColor::set(aColorList, batch);
batch->commit();
} }
void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater) void PaletteManager::SetBtnUpdater(svx::ToolboxButtonColorUpdater* pBtnUpdater)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment