diff options
author | Jim Raykowski <raykowj@gmail.com> | 2018-10-14 16:51:25 -0800 |
---|---|---|
committer | Jim Raykowski <raykowj@gmail.com> | 2018-10-27 22:43:14 +0200 |
commit | 68c73b2cc26313de315e828cb9f8db53d9aeb6bf (patch) | |
tree | daa39ae56cf63a3eb1498d054d6f501f335832c0 | |
parent | d666b6b19d3e400561edc585d967ecab266c6b8f (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>
-rw-r--r-- | include/svx/strings.hrc | 6 | ||||
-rw-r--r-- | include/svx/tbxcolorupdate.hxx | 7 | ||||
-rw-r--r-- | include/svx/xdef.hxx | 7 | ||||
-rw-r--r-- | include/tools/color.hxx | 2 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.cxx | 19 | ||||
-rw-r--r-- | reportdesign/source/ui/dlg/Condition.hxx | 2 | ||||
-rw-r--r-- | sfx2/source/sidebar/ControllerFactory.cxx | 3 | ||||
-rw-r--r-- | svx/source/tbxctrls/PaletteManager.cxx | 4 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbcontrl.cxx | 6 | ||||
-rw-r--r-- | svx/source/tbxctrls/tbxcolorupdate.cxx | 30 |
10 files changed, 61 insertions, 25 deletions
diff --git a/include/svx/strings.hrc b/include/svx/strings.hrc index e0b57303719e..b93953e046e7 100644 --- a/include/svx/strings.hrc +++ b/include/svx/strings.hrc @@ -552,6 +552,12 @@ #define RID_SVXSTR_GRAFMODE_GREYS NC_("RID_SVXSTR_GRAFMODE_GREYS", "Grayscale") #define RID_SVXSTR_GRAFMODE_MONO NC_("RID_SVXSTR_GRAFMODE_MONO", "Black/White") #define RID_SVXSTR_GRAFMODE_WATERMARK NC_("RID_SVXSTR_GRAFMODE_WATERMARK", "Watermark") +// Default colors +#define RID_SVXSTR_COLOR_DEFAULT_FONT NC_("RID_SVXSTR_COLOR_DEFAULT_FONTCOLOR", "Dark Red 2") +#define RID_SVXSTR_COLOR_DEFAULT_FRAMELINE NC_("RID_SVXSTR_COLOR_DEFAULT_FRAMELINE", "Blue") +#define RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT NC_("RID_SVXSTR_COLOR_DEFAULT_HIGHLIGHT", "Yellow") +#define RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE NC_("RID_SVXSTR_COLOR_DEFAULT_SHAPE_STROKE", "Dark Blue 1") +#define RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING NC_("RID_SVXSTR_COLOR_DEFAULT_SHAPE_FILLING", "Light Blue 2") // Elements of the standard color palette #define RID_SVXSTR_COLOR_BLACK NC_("RID_SVXSTR_COLOR_BLACK", "Black") #define RID_SVXSTR_COLOR_GREY NC_("RID_SVXSTR_COLOR_GREY", "Gray") diff --git a/include/svx/tbxcolorupdate.hxx b/include/svx/tbxcolorupdate.hxx index 2c3b61b8f386..8f5b7902b757 100644 --- a/include/svx/tbxcolorupdate.hxx +++ b/include/svx/tbxcolorupdate.hxx @@ -26,6 +26,8 @@ #include <tools/color.hxx> #include <vcl/vclptr.hxx> +#include <svx/Palette.hxx> + class ToolBox; class VirtualDevice; @@ -43,9 +45,11 @@ namespace svx class SVX_DLLPUBLIC ToolboxButtonColorUpdater { public: - ToolboxButtonColorUpdater( sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* ptrTbx, bool bWideButton = false); + ToolboxButtonColorUpdater( sal_uInt16 nSlotId, sal_uInt16 nTbxBtnId, ToolBox* ptrTbx, bool bWideButton, + const OUString& rCommandLabel ); ~ToolboxButtonColorUpdater(); + void Update( const NamedColor& rNamedColor ); void Update( const Color& rColor, bool bForceUpdate = false ); Color const & GetCurrentColor() const { return maCurColor; } @@ -60,6 +64,7 @@ namespace svx tools::Rectangle maUpdRect; Size maBmpSize; bool mbWasHiContrastMode; + OUString maCommandLabel; }; diff --git a/include/svx/xdef.hxx b/include/svx/xdef.hxx index 75ea49bc8c3a..aa539648cad0 100644 --- a/include/svx/xdef.hxx +++ b/include/svx/xdef.hxx @@ -78,8 +78,11 @@ class XLineTransparenceItem; class XLineWidthItem; class XSecondaryFillColorItem; -#define COL_DEFAULT_SHAPE_FILLING ::Color(0x729fcf) -#define COL_DEFAULT_SHAPE_STROKE ::Color(0x3465a4) +#define COL_DEFAULT_FONT ::Color(0xC9211E) // dark red 2 +#define COL_DEFAULT_FRAMELINE ::Color(0x2A6099) // blue +#define COL_DEFAULT_HIGHLIGHT ::Color(0xFFFF00) // yellow +#define COL_DEFAULT_SHAPE_FILLING ::Color(0x729fcf) // light blue 2 +#define COL_DEFAULT_SHAPE_STROKE ::Color(0x3465a4) // dark blue 1 #define XATTR_START 1000 diff --git a/include/tools/color.hxx b/include/tools/color.hxx index 1b8fb3eecdd1..26d587b7e1f5 100644 --- a/include/tools/color.hxx +++ b/include/tools/color.hxx @@ -241,7 +241,6 @@ constexpr ::Color COL_BLUE ( 0x00, 0x00, 0x80 ); constexpr ::Color COL_GREEN ( 0x00, 0x80, 0x00 ); constexpr ::Color COL_CYAN ( 0x00, 0x80, 0x80 ); constexpr ::Color COL_RED ( 0x80, 0x00, 0x00 ); -constexpr ::Color COL_RED_FONTCOLOR ( 0xCE, 0x18, 0x1E ); constexpr ::Color COL_MAGENTA ( 0x80, 0x00, 0x80 ); constexpr ::Color COL_BROWN ( 0x80, 0x80, 0x00 ); constexpr ::Color COL_GRAY ( 0x80, 0x80, 0x80 ); @@ -255,7 +254,6 @@ constexpr ::Color COL_LIGHTRED ( 0xFF, 0x00, 0x00 ); constexpr ::Color COL_LIGHTMAGENTA ( 0xFF, 0x00, 0xFF ); constexpr ::Color COL_LIGHTGRAYBLUE ( 0xE0, 0xE0, 0xFF ); constexpr ::Color COL_YELLOW ( 0xFF, 0xFF, 0x00 ); -constexpr ::Color COL_YELLOW_HIGHLIGHT ( 0xFF, 0xF2, 0x00 ); constexpr ::Color COL_WHITE ( 0xFF, 0xFF, 0xFF ); constexpr ::Color COL_TRANSPARENT ( 0xFF, 0xFF, 0xFF, 0xFF ); constexpr ::Color COL_AUTO ( 0xFF, 0xFF, 0xFF, 0xFF ); diff --git a/reportdesign/source/ui/dlg/Condition.cxx b/reportdesign/source/ui/dlg/Condition.cxx index d3382478b766..5e8194fd7214 100644 --- a/reportdesign/source/ui/dlg/Condition.cxx +++ b/reportdesign/source/ui/dlg/Condition.cxx @@ -96,7 +96,7 @@ void ConditionColorWrapper::dispose() void ConditionColorWrapper::operator()(const OUString& /*rCommand*/, const NamedColor& rNamedColor) { - mxControl->ApplyCommand(mnSlotId, rNamedColor.first); + mxControl->ApplyCommand(mnSlotId, rNamedColor); } // = Condition @@ -161,9 +161,11 @@ Condition::Condition( vcl::Window* _pParent, IConditionalFormatAction& _rAction, m_nFontDialogId = m_pActions->GetItemId(".uno:FontDialog"); m_pBtnUpdaterBackgroundColor.reset( new svx::ToolboxButtonColorUpdater( - SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions ) ); + SID_BACKGROUND_COLOR, m_nBackgroundColorId, m_pActions, false, + m_pActions->GetItemText( m_nBackgroundColorId ) ) ); m_pBtnUpdaterFontColor.reset( new svx::ToolboxButtonColorUpdater( - SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions ) ); + SID_ATTR_CHAR_COLOR2, m_nFontColorId, m_pActions, false, + m_pActions->GetItemText( m_nFontColorId ) ) ); Show(); @@ -238,7 +240,8 @@ IMPL_LINK(Condition, DropdownClick, ToolBox*, pToolBox, void) IMPL_LINK_NOARG( Condition, OnFormatAction, ToolBox*, void ) { - ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()),COL_AUTO); + ApplyCommand(mapToolbarItemToSlotId(m_pActions->GetCurItemId()), + NamedColor(COL_AUTO, "#" + COL_AUTO.AsRGBHexString())); } IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton, void ) @@ -253,14 +256,14 @@ IMPL_LINK( Condition, OnConditionAction, Button*, _pClickedButton, void ) m_rAction.deleteCondition( getConditionIndex() ); } -void Condition::ApplyCommand( sal_uInt16 _nCommandId, const ::Color& _rColor) +void Condition::ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor ) { if ( _nCommandId == SID_ATTR_CHAR_COLOR2 ) - m_pBtnUpdaterFontColor->Update( _rColor ); + m_pBtnUpdaterFontColor->Update( rNamedColor ); else if ( _nCommandId == SID_BACKGROUND_COLOR ) - m_pBtnUpdaterBackgroundColor->Update( _rColor ); + m_pBtnUpdaterBackgroundColor->Update( rNamedColor ); - m_rAction.applyCommand( m_nCondIndex, _nCommandId, _rColor ); + m_rAction.applyCommand( m_nCondIndex, _nCommandId, rNamedColor.first ); } void Condition::setImageList(sal_Int16 /*_eBitmapSet*/) diff --git a/reportdesign/source/ui/dlg/Condition.hxx b/reportdesign/source/ui/dlg/Condition.hxx index 04e228707b22..ceca03281ecc 100644 --- a/reportdesign/source/ui/dlg/Condition.hxx +++ b/reportdesign/source/ui/dlg/Condition.hxx @@ -162,7 +162,7 @@ namespace rptui /** forward to the parent class */ - void ApplyCommand(sal_uInt16 _nCommandId, const ::Color& _aColor ); + void ApplyCommand( sal_uInt16 _nCommandId, const NamedColor& rNamedColor ); ::rptui::OReportController& getController() const { return m_rController; } diff --git a/sfx2/source/sidebar/ControllerFactory.cxx b/sfx2/source/sidebar/ControllerFactory.cxx index e96d4cff6b2d..b023da87d184 100644 --- a/sfx2/source/sidebar/ControllerFactory.cxx +++ b/sfx2/source/sidebar/ControllerFactory.cxx @@ -127,7 +127,8 @@ Reference<frame::XToolbarController> ControllerFactory::CreateToolBoxController( const OUString sTooltip (vcl::CommandInfoProvider::GetTooltipForCommand( rsCommandName, rxFrame)); - pToolBox->SetQuickHelpText(nItemId, sTooltip); + if (pToolBox->GetQuickHelpText(nItemId).isEmpty()) + pToolBox->SetQuickHelpText(nItemId, sTooltip); pToolBox->EnableItem(nItemId); } } 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)); |