cui/UIConfig_cui.mk                                        |    1 
 cui/uiconfig/ui/querysetinsmodedialog.ui                   |  157 +++++++++++++
 icon-themes/colibre/res/queryinsmode.png                   |binary
 officecfg/registry/schema/org/openoffice/Office/Common.xcs |    7 
 solenv/sanitizers/ui/cui.false                             |    1 
 sw/inc/bitmaps.hlst                                        |    2 
 sw/source/uibase/wrtsh/select.cxx                          |   25 ++
 7 files changed, 193 insertions(+)

New commits:
commit a52bc9b5d6f86b6919931db21d83834d6c14e955
Author:     Heiko Tietze <tietze.he...@gmail.com>
AuthorDate: Fri Jun 23 14:57:54 2023 +0200
Commit:     Heiko Tietze <heiko.tie...@documentfoundation.org>
CommitDate: Wed Sep 27 17:04:57 2023 +0200

    Resolves tdf#155561 - Notification for the overwrite mode
    
    Dialog shown when it's enabled for the first time
    Introduces the registry variable QuerySetInsMode
    Adds an eye-catching image under res/queryinsmode.png
    
    Change-Id: I0131177fb54238d48a671bc9ceb88283f796a526
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153505
    Tested-by: Jenkins
    Reviewed-by: Heiko Tietze <heiko.tie...@documentfoundation.org>

diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index a863e155dd04..b9863422c64a 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -192,6 +192,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
        cui/uiconfig/ui/querynosavefiledialog \
        cui/uiconfig/ui/querysavelistdialog \
        cui/uiconfig/ui/queryupdategalleryfilelistdialog \
+       cui/uiconfig/ui/querysetinsmodedialog \
        cui/uiconfig/ui/recordnumberdialog \
        cui/uiconfig/ui/rotationtabpage \
        cui/uiconfig/ui/scriptorganizer \
diff --git a/cui/uiconfig/ui/querysetinsmodedialog.ui 
b/cui/uiconfig/ui/querysetinsmodedialog.ui
new file mode 100644
index 000000000000..a21659afae5e
--- /dev/null
+++ b/cui/uiconfig/ui/querysetinsmodedialog.ui
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.40.0 -->
+<interface domain="cui">
+  <requires lib="gtk+" version="3.20"/>
+  <object class="GtkDialog" id="SetInsModeDialog">
+    <property name="can-focus">False</property>
+    <property name="title" translatable="yes" 
context="SetInsModeDialog|Dialog_Title">Confirm overwrite mode</property>
+    <property name="resizable">False</property>
+    <property name="type-hint">dialog</property>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="can-focus">False</property>
+        <property name="margin-start">12</property>
+        <property name="margin-end">12</property>
+        <property name="margin-top">12</property>
+        <property name="margin-bottom">12</property>
+        <property name="orientation">vertical</property>
+        <child internal-child="action_area">
+          <object class="GtkButtonBox">
+            <property name="can-focus">False</property>
+            <property name="margin-top">12</property>
+            <property name="hexpand">True</property>
+            <property name="layout-style">end</property>
+            <child>
+              <object class="GtkCheckButton" id="cbDontShowAgain">
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Checkbox">Don't show again</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">False</property>
+                <property name="hexpand">True</property>
+                <property name="active">True</property>
+                <property name="draw-indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+                <property name="secondary">True</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btnNo">
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Button_No">No</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="btnYes">
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Button_Yes">Yes</property>
+                <property name="visible">True</property>
+                <property name="can-focus">True</property>
+                <property name="receives-default">True</property>
+              </object>
+              <packing>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="pack-type">end</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <!-- n-columns=2 n-rows=3 -->
+          <object class="GtkGrid">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="row-spacing">12</property>
+            <property name="column-spacing">12</property>
+            <child>
+              <object class="GtkLabel" id="lbTitle">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">False</property>
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Label_Title">You are switching to the overwrite 
mode</property>
+                <property name="xalign">0</property>
+                <attributes>
+                  <attribute name="weight" value="bold"/>
+                  <attribute name="scale" value="1"/>
+                </attributes>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbText">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">False</property>
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Label_Info">The overwrite mode allows to type over 
text. It is indicated by a block cursor and at the statusbar. Press Insert 
again to switch back.</property>
+                <property name="wrap">True</property>
+                <property name="wrap-mode">word-char</property>
+                <property name="max-width-chars">40</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lbQuestion">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="valign">start</property>
+                <property name="label" translatable="yes" 
context="SetInsModeDialog|Label_Question">Do you want to continue?</property>
+                <property name="wrap">True</property>
+                <property name="xalign">0</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">2</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkImage" id="imSetInsMode">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">1</property>
+                <property name="height">2</property>
+              </packing>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-9">btnNo</action-widget>
+      <action-widget response="-8">btnYes</action-widget>
+    </action-widgets>
+  </object>
+</interface>
diff --git a/icon-themes/colibre/res/queryinsmode.png 
b/icon-themes/colibre/res/queryinsmode.png
new file mode 100644
index 000000000000..029c7570a7bf
Binary files /dev/null and b/icon-themes/colibre/res/queryinsmode.png differ
diff --git a/officecfg/registry/schema/org/openoffice/Office/Common.xcs 
b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
index 681d8499183a..6ae673e5b46f 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Common.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Common.xcs
@@ -5253,6 +5253,13 @@
           </info>
           <value>-1</value>
       </prop>
+      <prop oor:name="QuerySetInsMode" oor:type="xs:boolean" 
oor:nillable="false">
+        <!-- UIHints: Tools - Options - General -->
+        <info>
+          <desc>Determines whether to query when switching into the overwrite 
mode.</desc>
+        </info>
+        <value>true</value>
+      </prop>
       <prop oor:name="PerformFileExtCheck" oor:type="xs:boolean" 
oor:nillable="false">
         <!-- UIHints: Tools - Options - General -->
         <info>
diff --git a/solenv/sanitizers/ui/cui.false b/solenv/sanitizers/ui/cui.false
index fcd145e35547..f779cafe8ce0 100644
--- a/solenv/sanitizers/ui/cui.false
+++ b/solenv/sanitizers/ui/cui.false
@@ -2,3 +2,4 @@ cui/uiconfig/ui/aboutdialog.ui://GtkImage[@id='imAbout'] 
no-labelled-by
 cui/uiconfig/ui/aboutdialog.ui://GtkImage[@id='imBrand'] no-labelled-by
 cui/uiconfig/ui/aboutdialog.ui://GtkLabel[@id='lbAbout'] orphan-label
 cui/uiconfig/ui/aboutdialog.ui://GtkLabel[@id='lbCopyright'] orphan-label
+cui/uiconfig/ui/querysetinsmodedialog.ui://GtkImage[@id='imSetInsMode'] 
no-labelled-by
diff --git a/sw/inc/bitmaps.hlst b/sw/inc/bitmaps.hlst
index 3d1e322af006..98509bd5993e 100644
--- a/sw/inc/bitmaps.hlst
+++ b/sw/inc/bitmaps.hlst
@@ -116,4 +116,6 @@ inline constexpr OUStringLiteral RID_BMP_PREVIEW_FALLBACK = 
u"sw/res/image-examp
 inline constexpr OUStringLiteral RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND = 
u"svx/res/a11y_check_issues_not_found.png";
 inline constexpr OUStringLiteral RID_BMP_A11Y_CHECK_ISSUES_FOUND = 
u"svx/res/a11y_check_issues_found.png";
 
+inline constexpr OUStringLiteral RID_BMP_QUERYINSMODE = 
u"res/queryinsmode.png";
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/sw/source/uibase/wrtsh/select.cxx 
b/sw/source/uibase/wrtsh/select.cxx
index a23c1ec6a830..ebec0dbfed2a 100644
--- a/sw/source/uibase/wrtsh/select.cxx
+++ b/sw/source/uibase/wrtsh/select.cxx
@@ -41,6 +41,12 @@
 #include <vcl/uitest/logger.hxx>
 #include <vcl/uitest/eventdescription.hxx>
 
+#include <vcl/weld.hxx>
+#include <vcl/builder.hxx>
+#include <officecfg/Office/Common.hxx>
+#include <unotools/configmgr.hxx>
+#include <bitmaps.hlst>
+
 namespace com::sun::star::util {
     struct SearchOptions2;
 }
@@ -678,6 +684,25 @@ void SwWrtShell::LeaveBlockMode()
 
 void SwWrtShell::SetInsMode( bool bOn )
 {
+    const bool bDoAsk = 
officecfg::Office::Common::Misc::QuerySetInsMode::get();
+    if (!bOn && bDoAsk) {
+        std::unique_ptr<weld::Builder> 
xBuilder(Application::CreateBuilder(GetView().GetFrameWeld(), 
"cui/ui/querysetinsmodedialog.ui"));
+        std::unique_ptr<weld::Dialog> 
xQuery(xBuilder->weld_dialog("SetInsModeDialog"));
+        std::unique_ptr<weld::Image> 
xImage(xBuilder->weld_image("imSetInsMode"));
+        std::unique_ptr<weld::CheckButton> 
xCheckBox(xBuilder->weld_check_button("cbDontShowAgain"));
+
+        xImage->set_from_icon_name(RID_BMP_QUERYINSMODE);
+
+        const int nResult = xQuery->run();
+
+        std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
+            comphelper::ConfigurationChanges::create());
+        
officecfg::Office::Common::Misc::QuerySetInsMode::set(xCheckBox->get_active(), 
xChanges);
+        xChanges->commit();
+
+        if ( nResult == static_cast<int>(RET_NO) )
+            return;
+    }
     m_bIns = bOn;
     SwCursorShell::SetOverwriteCursor( !m_bIns );
     const SfxBoolItem aTmp( SID_ATTR_INSERT, m_bIns );

Reply via email to