cui/UIConfig_cui.mk                        |    1 
 cui/qa/unit/data/cui-dialogs-test.txt      |    1 
 cui/source/dialogs/dlgname.cxx             |    4 
 cui/source/options/optaboutconfig.cxx      |  104 ++---------------------
 cui/source/options/optaboutconfig.hxx      |   21 ----
 cui/uiconfig/ui/aboutconfigvaluedialog.ui  |  131 -----------------------------
 include/cui/dlgname.hxx                    |    2 
 static/CustomTarget_emscripten_fs_image.mk |    1 
 8 files changed, 18 insertions(+), 247 deletions(-)

New commits:
commit ee4eb828fbf7ead62fca85239d78c48003bbc41e
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Nov 9 12:56:30 2023 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Mon Nov 13 10:38:37 2023 +0100

    Use SvxNameDialog for editing config values
    
    Instead of having a separate dialog which does the same.
    
    Change-Id: I3b20920fa1c68593b6787a01592621c7b02fa715
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159209
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>

diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index b9863422c64a..e36cfc7f11b6 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -24,7 +24,6 @@ endif
 $(eval $(call gb_UIConfig_add_uifiles,cui,\
        cui/uiconfig/ui/aboutdialog \
        cui/uiconfig/ui/aboutconfigdialog\
-       cui/uiconfig/ui/aboutconfigvaluedialog \
        cui/uiconfig/ui/accelconfigpage \
        cui/uiconfig/ui/additionsdialog \
        cui/uiconfig/ui/additionsfragment \
diff --git a/cui/qa/unit/data/cui-dialogs-test.txt 
b/cui/qa/unit/data/cui-dialogs-test.txt
index cb176088446c..7a8e55240c93 100644
--- a/cui/qa/unit/data/cui-dialogs-test.txt
+++ b/cui/qa/unit/data/cui-dialogs-test.txt
@@ -53,7 +53,6 @@ cui/ui/textdialog.ui
 
 
 cui/ui/aboutconfigdialog.ui
-cui/ui/aboutconfigvaluedialog.ui
 cui/ui/aboutdialog.ui
 cui/ui/accelconfigpage.ui
 cui/ui/acorexceptpage.ui
diff --git a/cui/source/dialogs/dlgname.cxx b/cui/source/dialogs/dlgname.cxx
index 4e6847e0f5cc..a1f6283d92b5 100644
--- a/cui/source/dialogs/dlgname.cxx
+++ b/cui/source/dialogs/dlgname.cxx
@@ -43,10 +43,10 @@ SvxNameDialog::SvxNameDialog(weld::Window* pParent, const 
OUString& rName, const
 
 IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl, weld::Entry&, void)
 {
-    // Do not allow empty names
+    // Do not allow empty names, unless custom CheckNameHdl is specified
     bool bEnable;
     if (m_aCheckNameHdl.IsSet())
-        bEnable = !m_xEdtName->get_text().isEmpty() && 
m_aCheckNameHdl.Call(*this);
+        bEnable = m_aCheckNameHdl.Call(*this);
     else
         bEnable = !m_xEdtName->get_text().isEmpty();
     m_xBtnOK->set_sensitive(bEnable);
diff --git a/cui/source/options/optaboutconfig.cxx 
b/cui/source/options/optaboutconfig.cxx
index 791856ef2ae5..a5d6ac9757a5 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -31,6 +31,7 @@
 #include <com/sun/star/util/SearchFlags.hpp>
 #include <com/sun/star/util/SearchAlgorithms2.hpp>
 #include <cppu/unotype.hxx>
+#include <cui/dlgname.hxx>
 #include <rtl/ustrbuf.hxx>
 #include <unotools/textsearch.hxx>
 #include <utility>
@@ -49,10 +50,6 @@ using namespace ::com::sun::star;
 using namespace com::sun::star::uno;
 using namespace com::sun::star::container;
 
-#define SHORT_LEN_LIMIT     7
-#define LONG_LEN_LIMIT      11
-#define HYPER_LEN_LIMIT     20
-
 struct Prop_Impl
 {
     OUString    Name;
@@ -91,64 +88,6 @@ struct UserData
     {}
 };
 
-IMPL_LINK(CuiAboutConfigValueDialog, KeyInputHdl, const KeyEvent&, rKeyEvent, 
bool)
-{
-    bool bValid = false;
-    bool bNonSpace = rKeyEvent.GetKeyCode().GetCode() != KEY_SPACE;
-    if (m_bNumericOnly && bNonSpace )
-    {
-        const vcl::KeyCode& rKeyCode = rKeyEvent.GetKeyCode();
-        sal_uInt16 nGroup = rKeyCode.GetGroup();
-        sal_uInt16 nKey = rKeyCode.GetCode();
-
-        switch ( nGroup ) {
-            case KEYGROUP_NUM :
-            case KEYGROUP_CURSOR :
-            {
-                bValid = true;
-                break;
-            }
-
-            case KEYGROUP_MISC :
-            {
-                switch ( nKey ) {
-                    case KEY_SUBTRACT :
-                    case KEY_COMMA :
-                    case KEY_POINT :
-                    {
-                        bValid = true;
-                        break;
-                    }
-
-                    default :
-                    {
-                        if( nKey < KEY_ADD || nKey > KEY_EQUAL )
-                            bValid = true;
-                        break;
-                    }
-                }
-                break;
-            }
-
-            default :
-            {
-                bValid = false;
-                break;
-            }
-        }
-
-        //Select all, Copy, Paste, Cut, Undo Keys
-        if ( !bValid && ( rKeyCode.IsMod1() && (
-             KEY_A == nKey || KEY_C == nKey || KEY_V == nKey || KEY_X == nKey 
|| KEY_Z == nKey ) ) )
-            bValid = true;
-    }
-    else
-        bValid = true;
-
-    //if value return true to claim that it has been handled
-    return !bValid;
-}
-
 CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* pParent)
     : GenericDialogController(pParent, "cui/ui/aboutconfigdialog.ui", 
"AboutConfig")
     , m_xResetBtn(m_xBuilder->weld_button("reset"))
@@ -158,6 +97,7 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage(weld::Window* 
pParent)
     , m_xPrefBox(m_xBuilder->weld_tree_view("preferences"))
     , m_xScratchIter(m_xPrefBox->make_iterator())
     , m_bSorted(false)
+    , m_pParent(pParent)
 {
     m_xPrefBox->set_size_request(m_xPrefBox->get_approximate_digit_width() * 
100,
                                  m_xPrefBox->get_height_rows(23));
@@ -235,6 +175,12 @@ IMPL_LINK(CuiAboutConfigTabPage, HeaderBarClick, int, 
nColumn, void)
     }
 }
 
+IMPL_STATIC_LINK_NOARG(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, 
bool)
+{
+    // Allow empty value
+    return true;
+}
+
 CuiAboutConfigTabPage::~CuiAboutConfigTabPage()
 {
 }
@@ -649,23 +595,6 @@ std::vector< OUString > 
CuiAboutConfigTabPage::commaStringToSequence( std::u16st
     return tempVector;
 }
 
-CuiAboutConfigValueDialog::CuiAboutConfigValueDialog(weld::Window* pWindow,
-                                                     const OUString& rValue,
-                                                     int limit)
-    : GenericDialogController(pWindow, "cui/ui/aboutconfigvaluedialog.ui", 
"AboutConfigValueDialog")
-    , m_bNumericOnly(limit != 0)
-    , m_xEDValue(m_xBuilder->weld_entry("valuebox"))
-{
-    if (limit)
-        m_xEDValue->set_max_length(limit);
-    m_xEDValue->set_text(rValue);
-    m_xEDValue->connect_key_press(LINK(this, CuiAboutConfigValueDialog, 
KeyInputHdl));
-}
-
-CuiAboutConfigValueDialog::~CuiAboutConfigValueDialog()
-{
-}
-
 IMPL_LINK_NOARG( CuiAboutConfigTabPage, ResetBtnHdl_Impl, weld::Button&, void )
 {
     Reset();
@@ -725,20 +654,11 @@ IMPL_LINK_NOARG( CuiAboutConfigTabPage, StandardHdl_Impl, 
weld::Button&, void )
     {
         if( bOpenDialog )
         {
-            //Cosmetic length limit for integer values.
-            int limit=0;
-            if( sPropertyType == "short" )
-                limit = SHORT_LEN_LIMIT;
-            else if( sPropertyType == "int" )
-                limit = LONG_LEN_LIMIT;
-            else if( sPropertyType == "long" )
-                limit = HYPER_LEN_LIMIT;
-
-            CuiAboutConfigValueDialog aValueDialog(m_xDialog.get(), 
sDialogValue, limit);
-
-            if (aValueDialog.run() == RET_OK )
+            SvxNameDialog aNameDialog(m_pParent, sDialogValue, sPropertyName);
+            aNameDialog.SetCheckNameHdl( LINK( this, CuiAboutConfigTabPage, 
ValidNameHdl ), true );
+            if (aNameDialog.run() == RET_OK )
             {
-                OUString sNewValue = aValueDialog.getValue();
+                OUString sNewValue = aNameDialog.GetName();
                 bSaveChanges = true;
                 if ( sPropertyType == "short")
                 {
diff --git a/cui/source/options/optaboutconfig.hxx 
b/cui/source/options/optaboutconfig.hxx
index c7278be7b19b..136ed0b11e8b 100644
--- a/cui/source/options/optaboutconfig.hxx
+++ b/cui/source/options/optaboutconfig.hxx
@@ -12,6 +12,7 @@
 #include <com/sun/star/container/XNameAccess.hpp>
 
 #include <i18nutil/searchopt.hxx>
+#include <cui/dlgname.hxx>
 #include <vcl/weld.hxx>
 
 #include <vector>
@@ -50,6 +51,7 @@ private:
     std::vector<prefBoxEntry> m_prefBoxEntries;
 
     bool m_bSorted;
+    weld::Window* m_pParent;
 
     void AddToModifiedVector( const std::shared_ptr< Prop_Impl >& rProp );
     static std::vector< OUString > commaStringToSequence( std::u16string_view 
rCommaSepString );
@@ -62,6 +64,7 @@ private:
     DECL_LINK(SearchHdl_Impl, weld::Button&, void);
     DECL_LINK(ExpandingHdl_Impl, const weld::TreeIter&, bool);
     DECL_LINK(HeaderBarClick, int, void);
+    DECL_STATIC_LINK(CuiAboutConfigTabPage, ValidNameHdl, SvxNameDialog&, 
bool);
 
 public:
    explicit CuiAboutConfigTabPage(weld::Window* pParent);
@@ -76,22 +79,4 @@ public:
    void FillItemSet();
 };
 
-class CuiAboutConfigValueDialog : public weld::GenericDialogController
-{
-private:
-    bool m_bNumericOnly;
-    std::unique_ptr<weld::Entry> m_xEDValue;
-
-    DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
-
-public:
-    CuiAboutConfigValueDialog(weld::Window* pWindow, const OUString& rValue , 
int limit);
-    virtual ~CuiAboutConfigValueDialog() override;
-
-    OUString getValue() const
-    {
-        return m_xEDValue->get_text();
-    }
-};
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cui/uiconfig/ui/aboutconfigvaluedialog.ui 
b/cui/uiconfig/ui/aboutconfigvaluedialog.ui
deleted file mode 100644
index e4c33bc4d780..000000000000
--- a/cui/uiconfig/ui/aboutconfigvaluedialog.ui
+++ /dev/null
@@ -1,131 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.1 -->
-<interface domain="cui">
-  <requires lib="gtk+" version="3.20"/>
-  <object class="GtkDialog" id="AboutConfigValueDialog">
-    <property name="can_focus">False</property>
-    <property name="border_width">6</property>
-    <property name="title" translatable="yes" 
context="aboutconfigvaluedialog|AboutConfigValueDialog">Name</property>
-    <property name="modal">True</property>
-    <property name="default_width">0</property>
-    <property name="default_height">0</property>
-    <property name="type_hint">dialog</property>
-    <child>
-      <placeholder/>
-    </child>
-    <child internal-child="vbox">
-      <object class="GtkBox" id="dialog-vbox1">
-        <property name="can_focus">False</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">12</property>
-        <child internal-child="action_area">
-          <object class="GtkButtonBox" id="dialog-action_area1">
-            <property name="can_focus">False</property>
-            <property name="layout_style">end</property>
-            <child>
-              <object class="GtkButton" id="ok">
-                <property name="label" translatable="yes" 
context="stock">_OK</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use-underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="cancel">
-                <property name="label" translatable="yes" 
context="stock">_Cancel</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use-underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkButton" id="help">
-                <property name="label" translatable="yes" 
context="stock">_Help</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use-underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">2</property>
-                <property name="secondary">True</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="pack_type">end</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkBox" id="box1">
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="hexpand">True</property>
-            <property name="vexpand">True</property>
-            <property name="orientation">vertical</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="label1">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="label" translatable="yes" 
context="aboutconfigvaluedialog|label1">Value:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">valuebox</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="valuebox">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hexpand">True</property>
-                <property name="activates_default">True</property>
-                <property name="truncate-multiline">True</property>
-                <property name="width_chars">50</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-    <action-widgets>
-      <action-widget response="-5">ok</action-widget>
-      <action-widget response="-6">cancel</action-widget>
-      <action-widget response="-11">help</action-widget>
-    </action-widgets>
-  </object>
-</interface>
diff --git a/include/cui/dlgname.hxx b/include/cui/dlgname.hxx
index 16938734ff97..9eb388caa078 100644
--- a/include/cui/dlgname.hxx
+++ b/include/cui/dlgname.hxx
@@ -60,7 +60,7 @@ public:
     {
         m_aCheckNameHdl = rLink;
         if (bCheckImmediately)
-            m_xBtnOK->set_sensitive(rLink.Call(*this));
+            ModifyHdl(*m_xEdtName);
     }
 
     void SetCheckNameTooltipHdl(const Link<SvxNameDialog&, OUString>& rLink)
diff --git a/static/CustomTarget_emscripten_fs_image.mk 
b/static/CustomTarget_emscripten_fs_image.mk
index 44ef645faded..d6d85c17fdbd 100644
--- a/static/CustomTarget_emscripten_fs_image.mk
+++ b/static/CustomTarget_emscripten_fs_image.mk
@@ -43,7 +43,6 @@ gb_emscripten_fs_image_files := \
     $(INSTROOT)/$(LIBO_ETC_FOLDER)/$(call gb_Helper_get_rcfile,version) \
     $(INSTROOT)/$(LIBO_ETC_FOLDER)/services/services.rdb \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/cui/ui/aboutconfigdialog.ui 
\
-    
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/cui/ui/aboutconfigvaluedialog.ui
 \
     $(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/cui/ui/aboutdialog.ui \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/cui/ui/accelconfigpage.ui \
     
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/cui/ui/acorexceptpage.ui \

Reply via email to