[Libreoffice-commits] core.git: 2 commits - sfx2/source vcl/qt5

Jan-Marek Glogowski (via logerrit) logerrit at kemper.freedesktop.org
Tue Jun 18 18:25:40 UTC 2019


 sfx2/source/doc/autoredactdialog.cxx |   73 ++++++++++++++++++++++++++++++++---
 vcl/qt5/Qt5Instance.cxx              |    6 +-
 2 files changed, 71 insertions(+), 8 deletions(-)

New commits:
commit 17c91a53d25c0b82524e04a0c108f8e0abc76685
Author:     Jan-Marek Glogowski <glogow at fbihome.de>
AuthorDate: Tue Jun 18 14:11:31 2019 +0000
Commit:     Jan-Marek Glogowski <glogow at fbihome.de>
CommitDate: Tue Jun 18 20:22:32 2019 +0200

    tdf#125934 Qt5 set the desktop file name...
    
    .. but only on wayland, as this also overrides the individual
    window icons on X11.
    
    Change-Id: I1b453b23f0dfd4ef2616d7b8054580a6018cdc53
    Reviewed-on: https://gerrit.libreoffice.org/74293
    Tested-by: Jenkins
    Reviewed-by: Jan-Marek Glogowski <glogow at fbihome.de>

diff --git a/vcl/qt5/Qt5Instance.cxx b/vcl/qt5/Qt5Instance.cxx
index 7961d5be0209..f83cf86b25ba 100644
--- a/vcl/qt5/Qt5Instance.cxx
+++ b/vcl/qt5/Qt5Instance.cxx
@@ -243,8 +243,10 @@ Qt5Instance::~Qt5Instance()
 
 void Qt5Instance::AfterAppInit()
 {
-    // sets the default application icon on Wayland
-    QGuiApplication::setDesktopFileName(QStringLiteral("libreoffice-startcenter.desktop"));
+    // set the default application icon via destop file just on Wayland,
+    // as this otherwise overrides the individual desktop icons on X11.
+    if (QGuiApplication::platformName() == "wayland")
+        QGuiApplication::setDesktopFileName(QStringLiteral("libreoffice-startcenter.desktop"));
 }
 
 void Qt5Instance::deleteObjectLater(QObject* pObject) { pObject->deleteLater(); }
commit 3cc152695af2117fecc0006ac2d34d43a9df0d86
Author:     Muhammet Kara <muhammet.kara at collabora.com>
AuthorDate: Mon Jun 17 15:33:37 2019 +0300
Commit:     Muhammet Kara <muhammet.kara at collabora.com>
CommitDate: Tue Jun 18 20:20:08 2019 +0200

    Let autoredact dialog remember last state
    
    * By storing the JSON string as SvtViewOptions
    
    Change-Id: I08e323005612cb0181d2176af659eb54267fbb3f
    Reviewed-on: https://gerrit.libreoffice.org/74169
    Tested-by: Jenkins
    Reviewed-by: Muhammet Kara <muhammet.kara at collabora.com>

diff --git a/sfx2/source/doc/autoredactdialog.cxx b/sfx2/source/doc/autoredactdialog.cxx
index cc0aa1456db8..950684ac4d1c 100644
--- a/sfx2/source/doc/autoredactdialog.cxx
+++ b/sfx2/source/doc/autoredactdialog.cxx
@@ -557,6 +557,7 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent)
     OUString sExtraData;
     SvtViewOptions aDlgOpt(EViewType::Dialog,
                            OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+
     if (aDlgOpt.Exists())
     {
         css::uno::Any aUserItem = aDlgOpt.GetUserItem("UserItem");
@@ -564,12 +565,34 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent)
     }
 
     // update the targets configuration if necessary
+    if (!sExtraData.isEmpty())
     {
         weld::WaitObject aWaitCursor(m_xDialog.get());
-        //m_aTargets.Update();
-    }
 
-    // TODO: fill the targets box
+        try
+        {
+            // Create path string, and read JSON from file
+            boost::property_tree::ptree aTargetsJSON;
+            std::stringstream aStream(std::string(sExtraData.toUtf8()));
+
+            boost::property_tree::read_json(aStream, aTargetsJSON);
+
+            // Recreate & add the targets to the dialog
+            for (const boost::property_tree::ptree::value_type& rValue :
+                 aTargetsJSON.get_child("RedactionTargets"))
+            {
+                RedactionTarget* pTarget = JSONtoRedactionTarget(rValue);
+                addTarget(pTarget);
+            }
+        }
+        catch (css::uno::Exception& e)
+        {
+            SAL_WARN("sfx.doc",
+                     "Exception caught while trying to load the last dialog state: " << e.Message);
+            return;
+            //TODO: Warn the user with a message box
+        }
+    }
 
     // Handler connections
     m_xLoadBtn->connect_clicked(LINK(this, SfxAutoRedactDialog, Load));
@@ -581,9 +604,47 @@ SfxAutoRedactDialog::SfxAutoRedactDialog(weld::Window* pParent)
 
 SfxAutoRedactDialog::~SfxAutoRedactDialog()
 {
-    // Store the view options
-    /*SvtViewOptions aDlgOpt(EViewType::Dialog, OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
-    aDlgOpt.SetUserItem("UserItem", css::uno::makeAny(m_xMoreBt->get_expanded() ? OUString("Y") : OUString("N")));*/
+    if (m_aTableTargets.empty())
+    {
+        // Clear the dialog data
+        SvtViewOptions aDlgOpt(EViewType::Dialog,
+                               OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+        aDlgOpt.Delete();
+        return;
+    }
+
+    try
+    {
+        // Put the targets into a JSON array
+        boost::property_tree::ptree aTargetsArray;
+        for (const auto& targetPair : m_aTableTargets)
+        {
+            aTargetsArray.push_back(std::make_pair("", redactionTargetToJSON(targetPair.first)));
+        }
+
+        // Build the JSON tree
+        boost::property_tree::ptree aTargetsTree;
+        aTargetsTree.add_child("RedactionTargets", aTargetsArray);
+        std::stringstream aStream;
+
+        boost::property_tree::write_json(aStream, aTargetsTree, false);
+
+        OUString sUserDataStr(OUString::fromUtf8(aStream.str().c_str()));
+
+        // Store the dialog data
+        SvtViewOptions aDlgOpt(EViewType::Dialog,
+                               OStringToOUString(m_xDialog->get_help_id(), RTL_TEXTENCODING_UTF8));
+        aDlgOpt.SetUserItem("UserItem", css::uno::makeAny(sUserDataStr));
+
+        clearTargets();
+    }
+    catch (css::uno::Exception& e)
+    {
+        SAL_WARN("sfx.doc",
+                 "Exception caught while trying to store the dialog state: " << e.Message);
+        return;
+        //TODO: Warn the user with a message box
+    }
 }
 
 bool SfxAutoRedactDialog::hasTargets() const


More information about the Libreoffice-commits mailing list