summaryrefslogtreecommitdiff
path: root/cui/source
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2021-07-16 10:06:43 +0200
committerSzymon Kłos <szymon.klos@collabora.com>2021-08-19 10:02:15 +0200
commitf54ccf09a5073b6e544c976da68de0c9fc0bdf6c (patch)
tree63f5c2db742cb8c53cb8763e15e535c578d58ac6 /cui/source
parentabd08d042fb397fbf97b93d8ca1a6426c1b304e6 (diff)
Make Custom Color Picker dialog async
- 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 <jenkinscollaboraoffice@gmail.com> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120670 Tested-by: Jenkins
Diffstat (limited to 'cui/source')
-rw-r--r--cui/source/dialogs/colorpicker.cxx33
1 files changed, 29 insertions, 4 deletions
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index 3f1bb0e8c53d..1ecaa887e206 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
+#include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp>
#include <com/sun/star/beans/XPropertyAccess.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
@@ -31,6 +32,7 @@
#include <vcl/svapp.hxx>
#include <vcl/virdev.hxx>
#include <vcl/weld.hxx>
+#include <sfx2/basedlgs.hxx>
#include <svx/hexcolorcontrol.hxx>
#include <basegfx/color/bcolortools.hxx>
#include <cmath>
@@ -727,7 +729,7 @@ void ColorSliderControl::SetValue(const Color& rColor, ColorMode eMode, double d
namespace {
-class ColorPickerDialog : public weld::GenericDialogController
+class ColorPickerDialog : public SfxDialogController
{
private:
ColorFieldControl m_aColorField;
@@ -790,7 +792,7 @@ private:
}
ColorPickerDialog::ColorPickerDialog(weld::Window* pParent, Color nColor, sal_Int16 nDialogMode)
- : GenericDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker")
+ : SfxDialogController(pParent, "cui/ui/colorpickerdialog.ui", "ColorPicker")
, m_xColorField(new weld::CustomWeld(*m_xBuilder, "colorField", m_aColorField))
, m_xColorSlider(new weld::CustomWeld(*m_xBuilder, "colorSlider", m_aColorSlider))
, m_xColorPreview(new weld::CustomWeld(*m_xBuilder, "preview", m_aColorPreview))
@@ -1205,7 +1207,7 @@ void ColorPickerDialog::setColorComponent( ColorComponent nComp, double dValue )
}
}
-typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
+typedef ::cppu::WeakComponentImplHelper< XServiceInfo, XExecutableDialog, XAsynchronousExecutableDialog, XInitialization, XPropertyAccess > ColorPickerBase;
namespace {
@@ -1231,6 +1233,10 @@ public:
virtual void SAL_CALL setTitle( const OUString& aTitle ) override;
virtual sal_Int16 SAL_CALL execute( ) override;
+ // XAsynchronousExecutableDialog
+ virtual void SAL_CALL setDialogTitle( const OUString& aTitle ) override;
+ virtual void SAL_CALL startExecuteModal( const css::uno::Reference< css::ui::dialogs::XDialogClosedListener >& xListener ) override;
+
private:
Color mnColor;
sal_Int16 mnMode;
@@ -1279,7 +1285,8 @@ sal_Bool SAL_CALL ColorPicker::supportsService( const OUString& sServiceName )
Sequence< OUString > SAL_CALL ColorPicker::getSupportedServiceNames( )
{
- return { "com.sun.star.ui.dialogs.ColorPicker" };
+ return { "com.sun.star.ui.dialogs.ColorPicker",
+ "com.sun.star.ui.dialogs.AsyncColorPicker" };
}
// XPropertyAccess
@@ -1320,6 +1327,24 @@ sal_Int16 SAL_CALL ColorPicker::execute()
return ret;
}
+// XAsynchronousExecutableDialog
+void SAL_CALL ColorPicker::setDialogTitle( const OUString& )
+{
+}
+
+void SAL_CALL ColorPicker::startExecuteModal( const css::uno::Reference< css::ui::dialogs::XDialogClosedListener >& xListener )
+{
+ std::shared_ptr<ColorPickerDialog> xDlg = std::make_shared<ColorPickerDialog>(Application::GetFrameWeld(mxParent), mnColor, mnMode);
+ weld::DialogController::runAsync(xDlg, [this, xDlg, xListener] (sal_Int32 nResult) {
+ if (nResult)
+ mnColor = xDlg->GetColor();
+
+ sal_Int16 nRet = static_cast<sal_Int16>(nResult);
+ css::ui::dialogs::DialogClosedEvent aEvent( *this, nRet );
+ xListener->dialogClosed( aEvent );
+ });
+}
+
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */