More flexible query dialog

Modifies and reverts a52bc9b5d6f86b6919931db21d83834d6c14e955
and 8b84691d5e2c02429c53fe9a8dc2f20e39a9d35c

Prerequiste for tdf#164586

Change-Id: If35a94ce25c634a6d583aeb8188d2f9ed75bc0fc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180547
Tested-by: Jenkins
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
This commit is contained in:
Heiko Tietze 2025-01-21 13:11:58 +01:00 committed by Heiko Tietze
parent 1103b0bd28
commit 35487636da
15 changed files with 182 additions and 67 deletions

View File

@ -144,6 +144,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
cui/source/dialogs/screenshotannotationdlg \
cui/source/dialogs/pastedlg \
cui/source/dialogs/postdlg \
cui/source/dialogs/querydialog \
cui/source/dialogs/QrCodeGenDialog \
cui/source/dialogs/GraphicTestsDialog \
cui/source/dialogs/ImageViewerDialog \

View File

@ -187,12 +187,12 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/querydeletehatchdialog \
cui/uiconfig/ui/querydeletelineenddialog \
cui/uiconfig/ui/querydeletelinestyledialog \
cui/uiconfig/ui/querydialog \
cui/uiconfig/ui/queryduplicatedialog \
cui/uiconfig/ui/querynoloadedfiledialog \
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 \

View File

@ -89,4 +89,6 @@ inline constexpr OUString RID_SVXBMP_TOTD_DRAW = u"res/tipoftheday_d.png"_ustr;
inline constexpr OUString RID_SVXBMP_TOTD_IMPRESS = u"res/tipoftheday_i.png"_ustr;
inline constexpr OUString RID_SVXBMP_TOTD_SOFFICE = u"res/tipoftheday.png"_ustr;
inline constexpr OUString RID_CUIBMP_QUERY = u"res/query.png"_ustr;
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */

View File

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <querydialog.hxx>
#include <bitmaps.hlst>
QueryDialog::QueryDialog(weld::Window* pParent, const OUString& sTitle, const OUString& sText,
const OUString& sQuestion, bool bShowAgain)
: GenericDialogController(pParent, u"cui/ui/querydialog.ui"_ustr, u"QueryDialog"_ustr)
, m_pTitle(m_xBuilder->weld_label(u"lbTitle"_ustr))
, m_pText(m_xBuilder->weld_label(u"lbText"_ustr))
, m_pQuestion(m_xBuilder->weld_label(u"lbQuestion"_ustr))
, m_pImage(m_xBuilder->weld_image(u"imQuery"_ustr))
, m_pCheckBox(m_xBuilder->weld_check_button(u"cbDontShowAgain"_ustr))
{
m_pTitle->set_label(sTitle);
m_pText->set_label(sText);
m_pQuestion->set_label(sQuestion);
m_pImage->set_from_icon_name(RID_CUIBMP_QUERY);
if (!bShowAgain)
m_pCheckBox->hide();
}

View File

@ -98,6 +98,7 @@
#include <DiagramDialog.hxx>
#include <fileextcheckdlg.hxx>
#include <TextColumnsPage.hxx>
#include <querydialog.hxx>
#include <MacroManagerDialog.hxx>
@ -1607,4 +1608,25 @@ AbstractDialogFactory_Impl::CreateFileExtCheckDialog(weld::Window* pParent, cons
}
#endif
namespace
{
class AbstractQueryDialog_Impl final
: public vcl::AbstractDialogImpl_Async<AbstractQueryDialog,
QueryDialog>
{
public:
using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
bool ShowAgain() const override { return m_pDlg->ShowAgain(); }
};
}
VclPtr<AbstractQueryDialog>
AbstractDialogFactory_Impl::CreateQueryDialog(
weld::Window* pParent,
const OUString& sTitle, const OUString& sText, const OUString& sQuestion,
bool bShowAgain)
{
return VclPtr<AbstractQueryDialog_Impl>::Create(pParent, sTitle, sText, sQuestion, bShowAgain);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -223,6 +223,11 @@ public:
weld::Window* pParent,
SdrObjGroup& rDiagram) override;
virtual VclPtr<AbstractQueryDialog> CreateQueryDialog(
weld::Window* pParent,
const OUString& sTitle, const OUString& sText, const OUString& sQuestion,
bool bShowAgain) override;
#ifdef _WIN32
virtual VclPtr<VclAbstractDialog> CreateFileExtCheckDialog(weld::Window* pParent,
const OUString& sTitle,

View File

@ -0,0 +1,38 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <vcl/weld.hxx>
class QueryDialog final : public weld::GenericDialogController
{
private:
std::unique_ptr<weld::Label> m_pTitle;
std::unique_ptr<weld::Label> m_pText;
std::unique_ptr<weld::Label> m_pQuestion;
std::unique_ptr<weld::Image> m_pImage;
std::unique_ptr<weld::CheckButton> m_pCheckBox;
public:
QueryDialog(weld::Window* pParent, const OUString& sTitle, const OUString& sText,
const OUString& sQuestion, bool bShowAgain = true);
bool ShowAgain() const { return m_pCheckBox->get_active(); }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -2,9 +2,8 @@
<!-- Generated with glade 3.40.0 -->
<interface domain="cui">
<requires lib="gtk+" version="3.20"/>
<object class="GtkDialog" id="SetInsModeDialog">
<object class="GtkDialog" id="QueryDialog">
<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">
@ -23,7 +22,7 @@
<property name="layout-style">end</property>
<child>
<object class="GtkButton" id="btnNo">
<property name="label" translatable="yes" context="SetInsModeDialog|Button_No">No</property>
<property name="label" translatable="yes" context="QueryDialog|Button_No">No</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
@ -36,7 +35,7 @@
</child>
<child>
<object class="GtkButton" id="btnYes">
<property name="label" translatable="yes" context="SetInsModeDialog|Button_Yes">Yes</property>
<property name="label" translatable="yes" context="QueryDialog|Button_Yes">Yes</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
@ -66,13 +65,16 @@
<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>
<child internal-child="accessible">
<object class="AtkObject" id="lbTitle-atkobject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
@ -84,11 +86,15 @@
<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>
<child internal-child="accessible">
<object class="AtkObject" id="lbText-atkobject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
@ -100,33 +106,27 @@
<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>
<child internal-child="accessible">
<object class="AtkObject" id="lbQuestion-atkobject">
<property name="AtkObject::accessible-role">static</property>
</object>
</child>
</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>
<object class="GtkCheckButton" id="cbDontShowAgain">
<property name="label" translatable="yes" context="SetInsModeDialog|Checkbox">Do not show again</property>
<property name="label" translatable="yes" context="QueryDialog|Checkbox">Do 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="halign">start</property>
<property name="active">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
@ -135,10 +135,24 @@
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
<object class="GtkImage" id="imQuery">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="pixel-size">150</property>
<property name="icon_size">0</property>
<child internal-child="accessible">
<object class="AtkObject" id="imQuery-atkobject">
<property name="AtkObject::accessible-role">dialog</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
<property name="height">4</property>
</packing>
</child>
</object>
<packing>

View File

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

View File

@ -157,6 +157,14 @@ protected:
virtual ~AbstractDiagramDialog() override = default;
};
class VCL_DLLPUBLIC AbstractQueryDialog : public VclAbstractDialog
{
protected:
virtual ~AbstractQueryDialog() override = default;
public:
virtual bool ShowAgain() const = 0;
};
class VCL_DLLPUBLIC VclAbstractDialogFactory
{
public:
@ -200,6 +208,11 @@ public:
weld::Window* pParent,
SdrObjGroup& rDiagram) = 0;
virtual VclPtr<AbstractQueryDialog> CreateQueryDialog(
weld::Window* pParent,
const OUString& sTitle, const OUString& sText, const OUString& sQuestion,
bool bShowAgain) = 0;
#ifdef _WIN32
virtual VclPtr<VclAbstractDialog>
CreateFileExtCheckDialog(weld::Window* _pParent, const OUString& sTitle, const OUString& sMsg)

View File

@ -2,4 +2,3 @@ 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

View File

@ -115,8 +115,6 @@ inline constexpr OUString RID_BMP_PREVIEW_FALLBACK = u"sw/res/image-example.png"
inline constexpr OUString RID_BMP_A11Y_CHECK_ISSUES_NOT_FOUND = u"svx/res/a11y_check_issues_not_found.png"_ustr;
inline constexpr OUString RID_BMP_A11Y_CHECK_ISSUES_FOUND = u"svx/res/a11y_check_issues_found.png"_ustr;
inline constexpr OUString RID_BMP_QUERYINSMODE = u"res/queryinsmode.png"_ustr;
inline constexpr OUString RID_SVXBMP_LOCKED = u"res/locked.png"_ustr;
inline constexpr OUString RID_SVXBMP_UNLOCKED = u"res/unlocked.png"_ustr;

View File

@ -1548,6 +1548,10 @@
#define STR_UNDO_MAKE_FOOTNOTES_ENDNOTES NC_("STR_UNDO_MAKE_FOOTNOTES_ENDNOTES", "Make all footnotes endnotes")
#define STR_UNDO_MAKE_ENDNOTES_FOOTNOTES NC_("STR_UNDO_MAKE_ENDNOTES_FOOTNOTES", "Make all endnotes footnotes")
// To translators: title, text, question for confirmation whether to switch overwrite mode on
#define STR_QUERY_INSMODE_TITLE NC_("STR_QUERY_INSMODE_TITLE", "You are switching to the overwrite mode")
#define STR_QUERY_INSMODE_TEXT NC_("STR_QUERY_INSMODE_TEXT", "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.")
#define STR_QUERY_INSMODE_QUESTION NC_("STR_QUERY_INSMODE_QUESTION", "Do you want to continue?")
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -41,11 +41,8 @@
#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>
#include <strings.hrc>
#include <svx/svdview.hxx>
@ -724,44 +721,27 @@ void SwWrtShell::ImplSetInsMode(bool bOn)
Invalidate();
}
namespace
{
class QuerySetInsModeDialog : public weld::GenericDialogController
{
std::unique_ptr<weld::Image> m_xImage;
std::unique_ptr<weld::CheckButton> m_xCheckBox;
public:
QuerySetInsModeDialog(weld::Window* pParent)
: GenericDialogController(pParent, u"cui/ui/querysetinsmodedialog.ui"_ustr, u"SetInsModeDialog"_ustr)
, m_xImage(m_xBuilder->weld_image(u"imSetInsMode"_ustr))
, m_xCheckBox(m_xBuilder->weld_check_button(u"cbDontShowAgain"_ustr))
{
m_xImage->set_from_icon_name(RID_BMP_QUERYINSMODE);
}
bool GetDoNotShowAgain() const
{
return m_xCheckBox->get_active();
}
};
}
void SwWrtShell::SetInsMode( bool bOn )
{
const bool bDoAsk = officecfg::Office::Common::Misc::QuerySetInsMode::get();
if (!bOn && bDoAsk)
{
auto xDialog = std::make_shared<QuerySetInsModeDialog>(GetView().GetFrameWeld());
weld::DialogController::runAsync(xDialog, [this, bOn, xDialog](sal_Int32 nResult){
std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::QuerySetInsMode::set(!xDialog->GetDoNotShowAgain(), xChanges);
xChanges->commit();
if ( nResult == static_cast<int>(RET_NO) )
return;
ImplSetInsMode(bOn);
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
auto pDlg = pFact->CreateQueryDialog(
GetView().GetFrameWeld(), SwResId(STR_QUERY_INSMODE_TITLE),
SwResId(STR_QUERY_INSMODE_TEXT), SwResId(STR_QUERY_INSMODE_QUESTION), true);
pDlg->StartExecuteAsync( [this, pDlg] (sal_Int32 nResult)->void
{
if (pDlg->ShowAgain() == false)
{
std::shared_ptr<comphelper::ConfigurationChanges> xChanges(
comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Misc::QuerySetInsMode::set(false, xChanges);
xChanges->commit();
}
if (nResult == RET_YES)
ImplSetInsMode(false);
pDlg->disposeOnce();
});
return;
}

View File

@ -67,7 +67,7 @@ bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile)
u"cui/ui/password.ui"_ustr,
u"cui/ui/pastespecial.ui"_ustr,
u"cui/ui/qrcodegen.ui"_ustr,
u"cui/ui/querysetinsmodedialog.ui"_ustr,
u"cui/ui/querydialog.ui"_ustr,
u"cui/ui/securityoptionsdialog.ui"_ustr,
u"cui/ui/splitcellsdialog.ui"_ustr,
u"cui/ui/tipofthedaydialog.ui"_ustr,