Kaydet (Commit) f1e52cbd authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#123291 set hex input to overwrite by default

and ensure the modify arrives after the input text has been
filtered

Change-Id: I16c0bd095700e7d9858e3e74884b5a1ad3eb7e4c
Reviewed-on: https://gerrit.libreoffice.org/69764
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 223eac2d
......@@ -788,6 +788,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="activates_default">True</property>
<property name="overwrite_mode">True</property>
</object>
<packing>
<property name="left_attach">1</property>
......
......@@ -34,12 +34,17 @@ class SVX_DLLPUBLIC HexColorControl
{
private:
std::unique_ptr<weld::Entry> m_xEntry;
Link<weld::Entry&, void> m_aModifyHdl;
ImplSVEvent* m_nAsyncModifyEvent;
DECL_STATIC_LINK(HexColorControl, ImplProcessInputHdl, OUString&, bool);
DECL_LINK(ImplProcessModifyHdl, weld::Entry&, void);
DECL_LINK(OnAsyncModifyHdl, void*, void);
public:
HexColorControl(std::unique_ptr<weld::Entry> pEdit);
~HexColorControl();
void connect_changed(const Link<Entry&, void>& rLink) { m_xEntry->connect_changed(rLink); }
void connect_changed(const Link<weld::Entry&, void>& rLink) { m_aModifyHdl = rLink; }
void SetColor( ::Color nColor );
::Color GetColor();
......
......@@ -19,22 +19,49 @@
#include <svx/hexcolorcontrol.hxx>
#include <rtl/character.hxx>
#include <vcl/svapp.hxx>
namespace weld {
HexColorControl::HexColorControl(std::unique_ptr<weld::Entry> pEntry)
: m_xEntry(std::move(pEntry))
, m_nAsyncModifyEvent(nullptr)
{
m_xEntry->set_max_length(6);
m_xEntry->set_width_chars(6);
m_xEntry->connect_insert_text(LINK(this, HexColorControl, ImplProcessInputHdl));
m_xEntry->connect_changed(LINK(this, HexColorControl, ImplProcessModifyHdl));
}
HexColorControl::~HexColorControl()
{
if (m_nAsyncModifyEvent)
Application::RemoveUserEvent(m_nAsyncModifyEvent);
}
IMPL_LINK_NOARG(HexColorControl, OnAsyncModifyHdl, void*, void)
{
m_nAsyncModifyEvent = nullptr;
m_aModifyHdl.Call(*m_xEntry);
}
// tdf#123291 resend it async so it arrives after ImplProcessInputHdl has been
// processed
IMPL_LINK_NOARG(HexColorControl, ImplProcessModifyHdl, weld::Entry&, void)
{
if (m_nAsyncModifyEvent)
Application::RemoveUserEvent(m_nAsyncModifyEvent);
m_nAsyncModifyEvent = Application::PostUserEvent(LINK(this, HexColorControl, OnAsyncModifyHdl));
}
void HexColorControl::SetColor(Color nColor)
{
OUStringBuffer aBuffer;
sax::Converter::convertColor(aBuffer, nColor);
m_xEntry->set_text(aBuffer.makeStringAndClear().copy(1));
OUString sColor = aBuffer.makeStringAndClear().copy(1);
if (sColor == m_xEntry->get_text())
return;
m_xEntry->set_text(sColor);
}
Color HexColorControl::GetColor()
......
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