summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorJim Raykowski <raykowj@gmail.com>2018-10-14 16:51:25 -0800
committerJim Raykowski <raykowj@gmail.com>2018-10-27 22:43:14 +0200
commit68c73b2cc26313de315e828cb9f8db53d9aeb6bf (patch)
treedaa39ae56cf63a3eb1498d054d6f501f335832c0 /svx
parentd666b6b19d3e400561edc585d967ecab266c6b8f (diff)
tdf#108751 Show currently selected color name in color button tooltip
Based on Heiko Tietze's work in I26f0500527d2b86049948ca64e636e1ff566f262 Change-Id: I20541dd6ad155a39c0f87361088b44923406064f Reviewed-on: https://gerrit.libreoffice.org/61815 Tested-by: Jenkins Reviewed-by: Heiko Tietze <tietze.heiko@gmail.com> Tested-by: Heiko Tietze <tietze.heiko@gmail.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/tbxctrls/PaletteManager.cxx4
-rw-r--r--svx/source/tbxctrls/tbcontrl.cxx6
-rw-r--r--svx/source/tbxctrls/tbxcolorupdate.cxx30
3 files changed, 30 insertions, 10 deletions
diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx
index 40f99c9074ab..779298d77ac5 100644
--- a/svx/source/tbxctrls/PaletteManager.cxx
+++ b/svx/source/tbxctrls/PaletteManager.cxx
@@ -354,10 +354,10 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo
if (aColorDlg.Execute(pParent) == RET_OK)
{
Color aLastColor = aColorDlg.GetColor();
- if (mpBtnUpdater)
- mpBtnUpdater->Update(aLastColor);
OUString sColorName = ("#" + aLastColor.AsRGBHexString().toAsciiUpperCase());
NamedColor aNamedColor = std::make_pair(aLastColor, sColorName);
+ if (mpBtnUpdater)
+ mpBtnUpdater->Update(aNamedColor);
AddRecentColor(aLastColor, sColorName);
maColorSelectFunction(aCommandCopy, aNamedColor);
}
diff --git a/svx/source/tbxctrls/tbcontrl.cxx b/svx/source/tbxctrls/tbcontrl.cxx
index 9f8ed9f7f771..8188a5832332 100644
--- a/svx/source/tbxctrls/tbcontrl.cxx
+++ b/svx/source/tbxctrls/tbcontrl.cxx
@@ -3110,7 +3110,9 @@ void SvxColorToolBoxControl::initialize( const css::uno::Sequence<css::uno::Any>
// Sidebar uses wide buttons for those.
m_bSplitButton = typeid( *pToolBox ) != typeid( sfx2::sidebar::SidebarToolBox );
- m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( m_nSlotId, nId, pToolBox, !m_bSplitButton ) );
+ OUString aCommandLabel = vcl::CommandInfoProvider::GetLabelForCommand( getCommandURL(), getModuleName() );
+
+ m_xBtnUpdater.reset( new svx::ToolboxButtonColorUpdater( m_nSlotId, nId, pToolBox, !m_bSplitButton, aCommandLabel ) );
pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ( m_bSplitButton ? ToolBoxItemBits::DROPDOWN : ToolBoxItemBits::DROPDOWNONLY ) );
}
@@ -3181,7 +3183,7 @@ VclPtr<vcl::Window> SvxColorToolBoxControl::createPopupWindow( vcl::Window* pPar
IMPL_LINK(SvxColorToolBoxControl, SelectedHdl, const NamedColor&, rColor, void)
{
- m_xBtnUpdater->Update(rColor.first);
+ m_xBtnUpdater->Update(rColor);
}
void SvxColorToolBoxControl::statusChanged( const css::frame::FeatureStateEvent& rEvent )
diff --git a/svx/source/tbxctrls/tbxcolorupdate.cxx b/svx/source/tbxctrls/tbxcolorupdate.cxx
index eb877795c3ae..45558e51b533 100644
--- a/svx/source/tbxctrls/tbxcolorupdate.cxx
+++ b/svx/source/tbxctrls/tbxcolorupdate.cxx
@@ -28,14 +28,18 @@
#include <vcl/settings.hxx>
#include <tools/debug.hxx>
+#include <svx/strings.hrc>
+#include <svx/dialmgr.hxx>
+
namespace svx
{
ToolboxButtonColorUpdater::ToolboxButtonColorUpdater(
- sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* pToolBox, bool bWideButton)
+ sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* pToolBox, bool bWideButton, const OUString& rCommandLabel)
: mbWideButton(bWideButton)
, mnBtnId(nTbxBtnId)
, mpTbx(pToolBox)
, maCurColor(COL_TRANSPARENT)
+ , maCommandLabel(rCommandLabel)
{
DBG_ASSERT(pToolBox, "ToolBox not found :-(");
mbWasHiContrastMode = pToolBox && pToolBox->GetSettings().GetStyleSettings().GetHighContrastMode();
@@ -43,21 +47,21 @@ namespace svx
{
case SID_ATTR_CHAR_COLOR:
case SID_ATTR_CHAR_COLOR2:
- Update(COL_RED_FONTCOLOR);
+ Update(NamedColor(COL_DEFAULT_FONT, SvxResId(RID_SVXSTR_COLOR_DEFAULT_FONT)));
break;
case SID_FRAME_LINECOLOR:
- Update(COL_BLUE);
+ Update(NamedColor(COL_DEFAULT_FRAMELINE, SvxResId(RID_SVXSTR_COLOR_DEFAULT_FRAMELINE)));
break;
case SID_ATTR_CHAR_COLOR_BACKGROUND:
case SID_ATTR_CHAR_BACK_COLOR:
case SID_BACKGROUND_COLOR:
- Update(COL_YELLOW_HIGHLIGHT);
+ Update(NamedColor(COL_DEFAULT_HIGHLIGHT, SvxResId(RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT)));
break;
case SID_ATTR_LINE_COLOR:
- Update(COL_DEFAULT_SHAPE_STROKE);
+ Update(NamedColor(COL_DEFAULT_SHAPE_STROKE, SvxResId(RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE)));
break;
case SID_ATTR_FILL_COLOR:
- Update(COL_DEFAULT_SHAPE_FILLING);
+ Update(NamedColor(COL_DEFAULT_SHAPE_FILLING, SvxResId(RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING)));
break;
default:
Update(COL_TRANSPARENT);
@@ -67,6 +71,20 @@ namespace svx
ToolboxButtonColorUpdater::~ToolboxButtonColorUpdater()
{}
+ void ToolboxButtonColorUpdater::Update(const NamedColor &rNamedColor)
+ {
+ Update(rNamedColor.first);
+ if (!mbWideButton && !rNamedColor.second.isEmpty())
+ {
+ // Also show the current color as QuickHelpText
+ OUString colorSuffix = " (%1)";
+ colorSuffix = colorSuffix.replaceFirst("%1", rNamedColor.second);
+ OUString colorHelpText = maCommandLabel + colorSuffix;
+
+ mpTbx->SetQuickHelpText(mnBtnId, colorHelpText);
+ }
+ }
+
void ToolboxButtonColorUpdater::Update(const Color& rColor, bool bForceUpdate)
{
Image aImage(mpTbx->GetItemImage(mnBtnId));