From f54ccf09a5073b6e544c976da68de0c9fc0bdf6c Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Fri, 16 Jul 2021 10:06:43 +0200 Subject: Make Custom Color Picker dialog async MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - now supports also XAsynchronousExecutableDialog - inherits from SfxDialogController to attach correct LOKNotifier Change-Id: Ic21db4057b8087d74a437b1c8ec95408ade5264d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119012 Tested-by: Jenkins CollaboraOffice Reviewed-by: Szymon Kłos Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120670 Tested-by: Jenkins --- svx/source/tbxctrls/PaletteManager.cxx | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'svx') diff --git a/svx/source/tbxctrls/PaletteManager.cxx b/svx/source/tbxctrls/PaletteManager.cxx index 4084dffc993c..7bb067952438 100644 --- a/svx/source/tbxctrls/PaletteManager.cxx +++ b/svx/source/tbxctrls/PaletteManager.cxx @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -301,19 +300,21 @@ void PaletteManager::PopupColorPicker(weld::Window* pParent, const OUString& aCo { // The calling object goes away during aColorDlg.Execute(), so we must copy this OUString aCommandCopy = aCommand; - SvColorDialog aColorDlg; - aColorDlg.SetColor(rInitialColor); - aColorDlg.SetMode(svtools::ColorPickerMode::Modify); - if (aColorDlg.Execute(pParent) == RET_OK) - { - Color aLastColor = aColorDlg.GetColor(); - OUString sColorName = "#" + aLastColor.AsRGBHexString().toAsciiUpperCase(); - NamedColor aNamedColor = std::make_pair(aLastColor, sColorName); - if (mpBtnUpdater) - mpBtnUpdater->Update(aNamedColor); - AddRecentColor(aLastColor, sColorName); - maColorSelectFunction(aCommandCopy, aNamedColor); - } + m_pColorDlg = std::make_unique(); + m_pColorDlg->SetColor(rInitialColor); + m_pColorDlg->SetMode(svtools::ColorPickerMode::Modify); + m_pColorDlg->ExecuteAsync(pParent, [this, aCommandCopy] (sal_Int32 nResult) { + if (nResult == RET_OK) + { + Color aLastColor = m_pColorDlg->GetColor(); + OUString sColorName = "#" + aLastColor.AsRGBHexString().toAsciiUpperCase(); + NamedColor aNamedColor = std::make_pair(aLastColor, sColorName); + if (mpBtnUpdater) + mpBtnUpdater->Update(aNamedColor); + AddRecentColor(aLastColor, sColorName); + maColorSelectFunction(aCommandCopy, aNamedColor); + } + }); } void PaletteManager::DispatchColorCommand(const OUString& aCommand, const NamedColor& rColor) -- cgit