tdf#163785, tdf#163838 - Use common color picker control for tab color
Change-Id: I09e72150b63aa4633cf9c6c9e365c69fb7a127fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205994 Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org> Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> Tested-by: Jenkins
This commit is contained in:
@@ -534,9 +534,9 @@ public:
|
||||
const OUString& rHelpId,
|
||||
const OUString& rEditHelpId) = 0;
|
||||
|
||||
virtual VclPtr<AbstractScTabBgColorDlg>
|
||||
CreateScTabBgColorDlg(weld::Window* pParent,
|
||||
const OUString& rTitle) = 0; //Dialog Title
|
||||
virtual VclPtr<AbstractScTabBgColorDlg> CreateScTabBgColorDlg(weld::Window* pParent,
|
||||
const OUString& rTitle, //Dialog Title
|
||||
const Color& rDefaultColor) = 0; //Currently selected Color
|
||||
|
||||
virtual VclPtr<AbstractScImportOptionsDlg> CreateScImportOptionsDlg(weld::Window* pParent, bool bAscii,
|
||||
const ScImportOptions* pOptions,
|
||||
|
||||
@@ -93,7 +93,7 @@ dialogs = [
|
||||
# tested in sc/qa/uitest/calc_tests/sheetRename.py
|
||||
# {"command": ".uno:Move", "closeButton": "cancel"},
|
||||
# tested in sc/qa/uitest/calc_tests6/moveCopySheet.py
|
||||
{"command": ".uno:SetTabBgColor", "closeButton": "cancel"},
|
||||
{"command": ".uno:SetTabBgColor", "closeButton": "close", "skipTestOK": True},
|
||||
{"command": ".uno:TableEvents", "closeButton": "cancel"},
|
||||
# {"command": ".uno:DataSort", "closeButton": "cancel"},
|
||||
# cancel button tested in sc/qa/uitest/calc_tests/sorting.py
|
||||
|
||||
@@ -197,8 +197,8 @@ VclPtr<VclAbstractDialog> ScScreenshotTest::createDialogByID(sal_uInt32 nID)
|
||||
|
||||
case 9: // "modules/scalc/ui/tabcolordialog.ui"
|
||||
{
|
||||
pReturnDialog = mpFact->CreateScTabBgColorDlg(mpViewShell->GetFrameWeld(),
|
||||
ScResId(SCSTR_SET_TAB_BG_COLOR));
|
||||
pReturnDialog = mpFact->CreateScTabBgColorDlg(
|
||||
mpViewShell->GetFrameWeld(), ScResId(SCSTR_SET_TAB_BG_COLOR), COL_LIGHTMAGENTA);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -780,10 +780,12 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
VclPtr<AbstractScTabBgColorDlg>
|
||||
ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle)
|
||||
VclPtr<AbstractScTabBgColorDlg> ScAbstractDialogFactory_Impl::CreateScTabBgColorDlg(
|
||||
weld::Window* pParent,
|
||||
const OUString& rTitle,
|
||||
const Color& rDefaultColor)
|
||||
{
|
||||
return VclPtr<AbstractScTabBgColorDlg_Impl>::Create(pParent, rTitle);
|
||||
return VclPtr<AbstractScTabBgColorDlg_Impl>::Create(pParent, rTitle, rDefaultColor);
|
||||
}
|
||||
|
||||
namespace
|
||||
|
||||
@@ -143,9 +143,9 @@ public:
|
||||
const OUString& rHelpId,
|
||||
const OUString& rEditHelpId) override;
|
||||
|
||||
virtual VclPtr<AbstractScTabBgColorDlg>
|
||||
CreateScTabBgColorDlg(weld::Window* pParent,
|
||||
const OUString& rTitle) override; //Dialog Title
|
||||
virtual VclPtr<AbstractScTabBgColorDlg> CreateScTabBgColorDlg(weld::Window* pParent,
|
||||
const OUString& rTitle, //Dialog Title
|
||||
const Color& rDefaultColor) override; //Currently selected Color
|
||||
|
||||
virtual VclPtr<AbstractScImportOptionsDlg> CreateScImportOptionsDlg(weld::Window* pParent, bool bAscii,
|
||||
const ScImportOptions* pOptions,
|
||||
|
||||
@@ -19,36 +19,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <svx/ColorIconView.hxx>
|
||||
#include <svx/PaletteManager.hxx>
|
||||
#include <vcl/weld/Button.hxx>
|
||||
#include <vcl/weld/ComboBox.hxx>
|
||||
#include <vcl/weld/DialogController.hxx>
|
||||
#include <vcl/weld/ToggleButton.hxx>
|
||||
#include <svx/colorbox.hxx>
|
||||
|
||||
class ScTabBgColorDlg : public weld::GenericDialogController
|
||||
{
|
||||
public:
|
||||
ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle);
|
||||
ScTabBgColorDlg(weld::Window* pParent,
|
||||
const OUString& rTitle,
|
||||
const Color& rDefaultColor);
|
||||
virtual ~ScTabBgColorDlg() override;
|
||||
|
||||
Color GetSelectedColor() const;
|
||||
|
||||
private:
|
||||
PaletteManager m_aPaletteManager;
|
||||
Color m_aTabBgColor;
|
||||
std::unique_ptr<ColorListBox> m_xColorListBox;
|
||||
|
||||
std::unique_ptr<weld::ComboBox> m_xSelectPalette;
|
||||
std::unique_ptr<weld::ToggleButton> m_xDefaultButton;
|
||||
ColorIconView m_aTabBgColorIconView;
|
||||
std::unique_ptr<weld::Button> m_xBtnOk;
|
||||
|
||||
void FillPaletteLB();
|
||||
|
||||
DECL_LINK(SelectPaletteLBHdl, weld::ComboBox&, void);
|
||||
DECL_LINK(DefaultButtonToggled, weld::Toggleable&, void);
|
||||
DECL_LINK(TabBgColorSelectHdl, const ColorIconView&, void);
|
||||
DECL_LINK(TabBgColorActivatedHdl, const Color&, void);
|
||||
DECL_LINK(TabBgColorOKHdl_Impl, weld::Button&, void);
|
||||
DECL_LINK(ColorSelectedHdl, ColorListBox&, void);
|
||||
DECL_LINK(AutoOpenPickerHdl, void*, void);
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -19,36 +19,30 @@
|
||||
|
||||
#undef SC_DLLIMPLEMENTATION
|
||||
|
||||
#include <scresid.hxx>
|
||||
#include <strings.hrc>
|
||||
#include <tabbgcolordlg.hxx>
|
||||
|
||||
#include <tools/color.hxx>
|
||||
#include <vcl/event.hxx>
|
||||
#include <svx/colorwindow.hxx>
|
||||
#include <vcl/svapp.hxx>
|
||||
#include <vcl/weld/Builder.hxx>
|
||||
#include <vcl/weld/ScrolledWindow.hxx>
|
||||
#include <vcl/weld/Dialog.hxx>
|
||||
#include <vcl/weld/IconView.hxx>
|
||||
|
||||
#include <officecfg/Office/Common.hxx>
|
||||
|
||||
ScTabBgColorDlg::ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle)
|
||||
ScTabBgColorDlg::ScTabBgColorDlg(weld::Window* pParent, const OUString& rTitle,
|
||||
const Color& rDefaultColor)
|
||||
: GenericDialogController(pParent, u"modules/scalc/ui/tabcolordialog.ui"_ustr,
|
||||
u"TabColorDialog"_ustr)
|
||||
, m_xSelectPalette(m_xBuilder->weld_combo_box(u"paletteselector"_ustr))
|
||||
, m_xDefaultButton(m_xBuilder->weld_toggle_button(u"defaultbutton"_ustr))
|
||||
, m_aTabBgColorIconView(m_xBuilder->weld_icon_view(u"coloriconview"_ustr))
|
||||
, m_xBtnOk(m_xBuilder->weld_button(u"ok"_ustr))
|
||||
, m_aTabBgColor(rDefaultColor)
|
||||
, m_xColorListBox(new ColorListBox(m_xBuilder->weld_menu_button(u"colorlistbox"_ustr),
|
||||
[pParent] { return pParent; }))
|
||||
{
|
||||
m_xDialog->set_title(rTitle);
|
||||
m_xColorListBox->SetSlotId(0, /*bShowNoneButton=*/true);
|
||||
|
||||
FillPaletteLB();
|
||||
// tdf#163838 - select the current tab color when reopening the dialog
|
||||
if (rDefaultColor != COL_AUTO)
|
||||
m_xColorListBox->SelectEntry(rDefaultColor);
|
||||
|
||||
m_xSelectPalette->connect_changed(LINK(this, ScTabBgColorDlg, SelectPaletteLBHdl));
|
||||
m_xDefaultButton->connect_toggled(LINK(this, ScTabBgColorDlg, DefaultButtonToggled));
|
||||
m_aTabBgColorIconView.setSelectionChangedHdl(LINK(this, ScTabBgColorDlg, TabBgColorSelectHdl));
|
||||
m_aTabBgColorIconView.setColorActivatedHdl(LINK(this, ScTabBgColorDlg, TabBgColorActivatedHdl));
|
||||
m_xBtnOk->connect_clicked(LINK(this, ScTabBgColorDlg, TabBgColorOKHdl_Impl));
|
||||
m_xColorListBox->SetSelectHdl(LINK(this, ScTabBgColorDlg, ColorSelectedHdl));
|
||||
Application::PostUserEvent(LINK(this, ScTabBgColorDlg, AutoOpenPickerHdl));
|
||||
}
|
||||
|
||||
ScTabBgColorDlg::~ScTabBgColorDlg()
|
||||
@@ -57,68 +51,19 @@ ScTabBgColorDlg::~ScTabBgColorDlg()
|
||||
|
||||
Color ScTabBgColorDlg::GetSelectedColor() const
|
||||
{
|
||||
if (m_xDefaultButton->get_active())
|
||||
return COL_AUTO;
|
||||
|
||||
const int nIndex = m_aTabBgColorIconView.get_selected_index();
|
||||
Color aColor = nIndex >= 0 ? (m_aTabBgColorIconView.getColor(nIndex)) : COL_AUTO;
|
||||
return aColor;
|
||||
return m_aTabBgColor;
|
||||
}
|
||||
|
||||
void ScTabBgColorDlg::FillPaletteLB()
|
||||
{
|
||||
m_xSelectPalette->clear();
|
||||
std::vector<OUString> aPaletteList = m_aPaletteManager.GetPaletteList();
|
||||
for (auto const& palette : aPaletteList)
|
||||
{
|
||||
m_xSelectPalette->append_text(palette);
|
||||
}
|
||||
OUString aPaletteName( officecfg::Office::Common::UserColors::PaletteName::get() );
|
||||
m_xSelectPalette->set_active_text(aPaletteName);
|
||||
if (m_xSelectPalette->get_active() != -1)
|
||||
{
|
||||
SelectPaletteLBHdl(*m_xSelectPalette);
|
||||
}
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, SelectPaletteLBHdl, weld::ComboBox&, void)
|
||||
{
|
||||
m_aTabBgColorIconView.clear();
|
||||
sal_Int32 nPos = m_xSelectPalette->get_active();
|
||||
m_aPaletteManager.SetPalette( nPos );
|
||||
m_aPaletteManager.ReloadColorSet(m_aTabBgColorIconView);
|
||||
m_xDefaultButton->set_active(true);
|
||||
m_aTabBgColorIconView.unselect_all();
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, DefaultButtonToggled, weld::Toggleable&, void)
|
||||
{
|
||||
// Only allow toggling default color on, not off by clicking the button.
|
||||
// Disabling instead happens by selecting another color.
|
||||
if (!m_xDefaultButton->get_active())
|
||||
{
|
||||
m_xDefaultButton->set_active(true);
|
||||
return;
|
||||
}
|
||||
|
||||
m_aTabBgColorIconView.unselect_all();
|
||||
}
|
||||
|
||||
// Handler, called when color selection is changed
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorSelectHdl, const ColorIconView&, void)
|
||||
{
|
||||
m_xDefaultButton->set_active(false);
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorActivatedHdl, const Color&, void)
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, ColorSelectedHdl, ColorListBox&, void)
|
||||
{
|
||||
Color aColor = m_xColorListBox->GetSelectEntryColor();
|
||||
m_aTabBgColor = aColor == COL_NONE_COLOR ? COL_AUTO : aColor;
|
||||
m_xDialog->response(RET_OK);
|
||||
}
|
||||
|
||||
// Handler, called when the OK button is pushed
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, TabBgColorOKHdl_Impl, weld::Button&, void)
|
||||
IMPL_LINK_NOARG(ScTabBgColorDlg, AutoOpenPickerHdl, void*, void)
|
||||
{
|
||||
m_xDialog->response(RET_OK);
|
||||
m_xColorListBox->get_widget().set_active(true);
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
||||
@@ -1244,11 +1244,13 @@ void ScTabViewShell::ExecuteSetTableBackgroundCol(SfxRequest& rReq)
|
||||
}
|
||||
else
|
||||
{
|
||||
Color aTabBgColor = rDoc.GetTabBgColor( nCurrentTab );
|
||||
ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
|
||||
VclPtr<AbstractScTabBgColorDlg> pDlg(
|
||||
pFact->CreateScTabBgColorDlg(GetFrameWeld(), ScResId(SCSTR_SET_TAB_BG_COLOR)));
|
||||
VclPtr<AbstractScTabBgColorDlg> pDlg(pFact->CreateScTabBgColorDlg(
|
||||
GetFrameWeld(),
|
||||
ScResId(SCSTR_SET_TAB_BG_COLOR),
|
||||
aTabBgColor));
|
||||
|
||||
Color aTabBgColor = rDoc.GetTabBgColor(nCurrentTab);
|
||||
auto xRequest = std::make_shared<SfxRequest>(rReq);
|
||||
rReq.Ignore(); // the 'old' request is not relevant any more
|
||||
ExecuteTableBackgroundDialog(pDlg, xRequest, aTabBgColor, nSlot);
|
||||
|
||||
@@ -2,30 +2,17 @@
|
||||
<!-- Generated with glade 3.40.0 -->
|
||||
<interface domain="sc">
|
||||
<requires lib="gtk+" version="3.24"/>
|
||||
<object class="GtkImage" id="auto_icon">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="icon-name">cmd/sc_square_unfilled.png</property>
|
||||
</object>
|
||||
<object class="GtkTreeStore" id="coloriconview_model">
|
||||
<columns>
|
||||
<!-- column-name pixbuf -->
|
||||
<column type="GdkPixbuf"/>
|
||||
<!-- column-name id -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name tooltip -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkDialog" id="TabColorDialog">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="border-width">6</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="default-width">0</property>
|
||||
<property name="default-height">0</property>
|
||||
<property name="type-hint">dialog</property>
|
||||
<child internal-child="vbox">
|
||||
<object class="GtkBox" id="dialog-vbox1">
|
||||
<property name="can-focus">False</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<child internal-child="action_area">
|
||||
@@ -33,8 +20,8 @@
|
||||
<property name="can-focus">False</property>
|
||||
<property name="layout-style">end</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="ok">
|
||||
<property name="label" translatable="yes" context="stock">_OK</property>
|
||||
<object class="GtkButton" id="close">
|
||||
<property name="label" translatable="yes" context="stock">_Close</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
@@ -48,41 +35,27 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="cancel">
|
||||
<property name="label" translatable="yes" context="stock">_Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<property name="use-underline">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack-type">end</property>
|
||||
<property name="position">3</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">3</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="label1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="label" translatable="yes" context="tabcolordialog |label1">Palette:</property>
|
||||
<property name="label" translatable="yes" context="tabcolordialog|label1">_Color:</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="mnemonic-widget">paletteselector</property>
|
||||
<property name="mnemonic-widget">colorlistbox</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0</property>
|
||||
</object>
|
||||
@@ -93,9 +66,9 @@
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBoxText" id="paletteselector">
|
||||
<object class="GtkMenuButton" id="colorlistbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="can-focus">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
@@ -110,58 +83,10 @@
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToggleButton" id="defaultbutton">
|
||||
<property name="label" translatable="yes" context="tabcolordialog|defaultbutton">Default</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="can-default">True</property>
|
||||
<property name="receives-default">False</property>
|
||||
<property name="image">auto_icon</property>
|
||||
<property name="use-underline">True</property>
|
||||
<property name="always-show-image">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow" id="colorsetwin">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="propagate-natural-width">True</property>
|
||||
<property name="propagate-natural-height">True</property>
|
||||
<child>
|
||||
<object class="GtkIconView" id="coloriconview">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="margin">6</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
<property name="model">coloriconview_model</property>
|
||||
<property name="columns">12</property>
|
||||
<property name="pixbuf-column">0</property>
|
||||
<property name="tooltip-column">2</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-5">ok</action-widget>
|
||||
<action-widget response="-6">cancel</action-widget>
|
||||
<action-widget response="-7">close</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user