starmath/source/dialog.cxx |   83 +++++++++++++++++++++++++--------------------
 1 file changed, 47 insertions(+), 36 deletions(-)

New commits:
commit 220937946881882babec2893b6d64e6af07b734b
Author:     Gülşah Köse <gulsah.k...@collabora.com>
AuthorDate: Thu Apr 24 18:18:58 2025 +0300
Commit:     Gülşah Köse <gulsah.k...@collabora.com>
CommitDate: Fri Apr 25 16:00:01 2025 +0200

    ONLINE: Make math related dialogs async
    
    Following dialogs run async:
    Fonts->Default
    Fonts-> Modify
    Font Size->Default
    Spacing->Default
    Alignment->Default
    
    Signed-off-by: Gülşah Köse <gulsah.k...@collabora.com>
    Change-Id: I40faa18d8a171aab9832223b3ca4cef6e5834037
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184569
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index 498c3070f0be..82c22daeb868 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -468,14 +468,16 @@ public:
 
 IMPL_LINK_NOARG( SmFontSizeDialog, DefaultButtonClickHdl, weld::Button&, void )
 {
-    SaveDefaultsQuery aQuery(m_xDialog.get());
-    if (aQuery.run() == RET_YES)
-    {
-        auto* config = SmModule::get()->GetConfig();
-        SmFormat aFmt(config->GetStandardFormat());
-        WriteTo( aFmt );
-        config->SetStandardFormat(aFmt);
-    }
+    auto pQuery = std::make_shared<SaveDefaultsQuery>(m_xDialog.get());
+    weld::DialogController::runAsync(pQuery, [this](sal_Int32 nResult) {
+        if (nResult == RET_YES)
+        {
+            auto* config = SmModule::get()->GetConfig();
+            SmFormat aFmt(config->GetStandardFormat());
+            WriteTo( aFmt );
+            config->SetStandardFormat(aFmt);
+        }
+    });
 }
 
 SmFontSizeDialog::SmFontSizeDialog(weld::Window* pParent)
@@ -561,24 +563,29 @@ IMPL_LINK(SmFontTypeDialog, MenuSelectHdl, const 
OUString&, rIdent, void)
 
     if (pActiveListBox)
     {
-        SmFontDialog aFontDialog(m_xDialog.get(), pFontListDev, 
bHideCheckboxes);
+        auto pFontDialog = std::make_shared<SmFontDialog>(m_xDialog.get(), 
pFontListDev, bHideCheckboxes);
 
-        pActiveListBox->WriteTo(aFontDialog);
-        if (aFontDialog.run() == RET_OK)
-            pActiveListBox->ReadFrom(aFontDialog);
+        pActiveListBox->WriteTo(*pFontDialog);
+        weld::DialogController::runAsync(pFontDialog, [pFontDialog, 
pActiveListBox](sal_Int32 nResult) {
+            if (nResult == RET_OK)
+                pActiveListBox->ReadFrom(*pFontDialog);
+        });
     }
 }
 
 IMPL_LINK_NOARG(SmFontTypeDialog, DefaultButtonClickHdl, weld::Button&, void)
 {
-    SaveDefaultsQuery aQuery(m_xDialog.get());
-    if (aQuery.run() == RET_YES)
-    {
-        auto* config = SmModule::get()->GetConfig();
-        SmFormat aFmt(config->GetStandardFormat());
-        WriteTo( aFmt );
-        config->SetStandardFormat(aFmt, true);
-    }
+
+    auto pQuery = std::make_shared<SaveDefaultsQuery>(m_xDialog.get());
+    weld::DialogController::runAsync(pQuery, [this](sal_Int32 nResult) {
+        if (nResult == RET_YES)
+        {
+            auto* config = SmModule::get()->GetConfig();
+            SmFormat aFmt(config->GetStandardFormat());
+            WriteTo( aFmt );
+            config->SetStandardFormat(aFmt, true);
+        }
+    });
 }
 
 SmFontTypeDialog::SmFontTypeDialog(weld::Window* pParent, OutputDevice 
*pFntListDevice)
@@ -755,14 +762,16 @@ IMPL_LINK(SmDistanceDialog, MenuSelectHdl, const 
OUString&, rId, void)
 
 IMPL_LINK_NOARG( SmDistanceDialog, DefaultButtonClickHdl, weld::Button&, void )
 {
-    SaveDefaultsQuery aQuery(m_xDialog.get());
-    if (aQuery.run() == RET_YES)
-    {
-        auto* config = SmModule::get()->GetConfig();
-        SmFormat aFmt(config->GetStandardFormat());
-        WriteTo( aFmt );
-        config->SetStandardFormat( aFmt );
-    }
+    auto pQuery = std::make_shared<SaveDefaultsQuery>(m_xDialog.get());
+    weld::DialogController::runAsync(pQuery, [this](sal_Int32 nResult) {
+        if (nResult == RET_YES)
+        {
+            auto* config = SmModule::get()->GetConfig();
+            SmFormat aFmt(config->GetStandardFormat());
+            WriteTo( aFmt );
+            config->SetStandardFormat( aFmt );
+        }
+    });
 }
 
 IMPL_LINK( SmDistanceDialog, CheckBoxClickHdl, weld::Toggleable&, rCheckBox, 
void )
@@ -1000,14 +1009,16 @@ void SmDistanceDialog::WriteTo(SmFormat &rFormat) 
/*const*/
 
 IMPL_LINK_NOARG( SmAlignDialog, DefaultButtonClickHdl, weld::Button&, void )
 {
-    SaveDefaultsQuery aQuery(m_xDialog.get());
-    if (aQuery.run() == RET_YES)
-    {
-        auto* config = SmModule::get()->GetConfig();
-        SmFormat aFmt(config->GetStandardFormat());
-        WriteTo( aFmt );
-        config->SetStandardFormat(aFmt);
-    }
+    auto pQuery = std::make_shared<SaveDefaultsQuery>(m_xDialog.get());
+    weld::DialogController::runAsync(pQuery, [this](sal_Int32 nResult) {
+        if (nResult == RET_YES)
+        {
+            auto* config = SmModule::get()->GetConfig();
+            SmFormat aFmt(config->GetStandardFormat());
+            WriteTo( aFmt );
+            config->SetStandardFormat(aFmt);
+        }
+    });
 }
 
 SmAlignDialog::SmAlignDialog(weld::Window* pParent)

Reply via email to