More appealing design for alientformat warn dialog

Change-Id: I575f24e6b8f9dd08bd8797343a86ac25b49f19b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180713
Reviewed-by: Heiko Tietze <heiko.tietze@documentfoundation.org>
Tested-by: Jenkins
This commit is contained in:
Heiko Tietze
2025-01-30 09:52:31 +01:00
committed by Heiko Tietze
parent 7a9e303d0f
commit 7f4901ded7
22 changed files with 55 additions and 231 deletions
+2
View File
@@ -28,6 +28,8 @@ QueryDialog::QueryDialog(weld::Window* pParent, const OUString& sTitle, const OU
, 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_pYes(m_xBuilder->weld_button(u"btnYes"_ustr))
, m_pNo(m_xBuilder->weld_button(u"btnNo"_ustr))
{
m_pTitle->set_label(sTitle);
m_pText->set_label(sText);
+2
View File
@@ -1617,6 +1617,8 @@ class AbstractQueryDialog_Impl final
public:
using AbstractDialogImpl_BASE::AbstractDialogImpl_BASE;
bool ShowAgain() const override { return m_pDlg->ShowAgain(); }
void SetYesLabel(const OUString& sLabel) override { m_pDlg->SetYesLabel(sLabel); }
void SetNoLabel(const OUString& sLabel) override { m_pDlg->SetNoLabel(sLabel); }
};
}
+4
View File
@@ -28,11 +28,15 @@ private:
std::unique_ptr<weld::Label> m_pQuestion;
std::unique_ptr<weld::Image> m_pImage;
std::unique_ptr<weld::CheckButton> m_pCheckBox;
std::unique_ptr<weld::Button> m_pYes;
std::unique_ptr<weld::Button> m_pNo;
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(); }
void SetYesLabel(const OUString& sLabel) { m_pYes->set_label(sLabel); }
void SetNoLabel(const OUString& sLabel) { m_pNo->set_label(sLabel); }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+5 -2
View File
@@ -65,6 +65,7 @@
<object class="GtkLabel" id="lbTitle">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
@@ -85,10 +86,10 @@
<object class="GtkLabel" id="lbText">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">False</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="wrap-mode">word-char</property>
<property name="max-width-chars">40</property>
<property name="max-width-chars">50</property>
<property name="xalign">0</property>
<child internal-child="accessible">
<object class="AtkObject" id="lbText-atkobject">
@@ -106,7 +107,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="max-width-chars">50</property>
<property name="xalign">0</property>
<child internal-child="accessible">
<object class="AtkObject" id="lbQuestion-atkobject">
+6
View File
@@ -47,6 +47,12 @@
#define STR_HIDDENINFO_NOTES NC_("STR_HIDDENINFO_NOTES", "Notes")
#define STR_HIDDENINFO_DOCVERSIONS NC_("STR_HIDDENINFO_DOCVERSIONS", "Document versions")
#define STR_NEW_FILENAME_SAVE NC_("STR_NEW_FILENAME_SAVE", "If you do not want to overwrite the original document, you should save your work under a new filename.")
#define STR_QUERY_ALIENFORMAT_TTITLE NC_("STR_QUERY_ALIENFORMAT_TITLE", "Non-standard file format")
#define STR_QUERY_ALIENFORMAT_TEXT NC_("STR_QUERY_ALIENFORMAT_TEXT", "This document may contain formatting or content that cannot be saved in the currently selected file format “%FORMATNAME (*.%EXTENSION)”.")
#define STR_QUERY_ALIENFORMAT_QUESTION NC_("STR_QUERY_ALIENFORMAT_QUESTION", "Use the default ODF file format (*.%EXTENSION) to be sure that the document is saved correctly.")
#define STR_QUERY_ALIENFORMAT_YES NC_("STR_QUERY_ALIENFORMAT_YES", "Use %FORMATNAME Format")
#define STR_QUERY_ALIENFORMAT_NO NC_("STR_QUERY_ALIENFORMAT_No", "Use %DEFAULTEXTENSION Format")
// Used in the title of a shared document.
#define STR_SHARED NC_("STR_SHARED", " (shared)")
#define STR_XMLSEC_ODF12_EXPECTED NC_("STR_XMLSEC_ODF12_EXPECTED", "The document format version is set to ODF 1.1 (OpenOffice.org 2.x) in Tools-Options-Load/Save-General. Signing documents requires ODF 1.2 (OpenOffice.org 3.x).")
+2
View File
@@ -163,6 +163,8 @@ protected:
virtual ~AbstractQueryDialog() override = default;
public:
virtual bool ShowAgain() const = 0;
virtual void SetYesLabel(const OUString& sLabel) = 0;
virtual void SetNoLabel(const OUString& sLabel) = 0;
};
class VCL_DLLPUBLIC VclAbstractDialogFactory
+1 -1
View File
@@ -46,7 +46,7 @@ class saveToCSV(UITestCase):
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="") as xWarnDialog:
# CSV confirmation dialog is displayed
xSave = xWarnDialog.getChild("save")
xSave = xWarnDialog.getChild("btnYes")
with self.ui_test.execute_dialog_through_action(xSave, "CLICK") as xCsvDialog:
xFormulas = xCsvDialog.getChild("formulas")
@@ -44,7 +44,7 @@ class save_readonly_with_password(UITestCase):
xOk = xPasswordDialog.getChild("ok")
# XLSX confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document:
+1 -1
View File
@@ -42,7 +42,7 @@ class tdf147086(UITestCase):
xOk = xPasswordDialog.getChild("ok")
# XLSX confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath), [PropertyValue(Name="Silent", Value=True)]) as document:
+1 -1
View File
@@ -30,7 +30,7 @@ class tdf144996(UITestCase):
self.assertFalse(document.isReadonly())
with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="save"):
with self.ui_test.execute_dialog_through_command(".uno:Save", close_button="btnYes"):
# Confirm file format popup
pass
@@ -48,7 +48,7 @@ class save_readonly_with_password(UITestCase):
xOk = xPasswordDialog.getChild("ok")
# PPTX confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
-1
View File
@@ -172,7 +172,6 @@ $(eval $(call gb_Library_add_exception_objects,sfx,\
sfx2/source/devtools/DocumentModelTreeHandler \
sfx2/source/devtools/ObjectInspectorTreeHandler \
sfx2/source/devtools/ObjectInspectorWidgets \
sfx2/source/dialog/alienwarn \
sfx2/source/dialog/basedlgs \
sfx2/source/dialog/checkin \
sfx2/source/dialog/dialoghelper \
-1
View File
@@ -10,7 +10,6 @@
$(eval $(call gb_UIConfig_UIConfig,sfx))
$(eval $(call gb_UIConfig_add_uifiles,sfx,\
sfx2/uiconfig/ui/alienwarndialog \
sfx2/uiconfig/ui/addtargetdialog \
sfx2/uiconfig/ui/autoredactdialog \
sfx2/uiconfig/ui/bookmarkdialog \
-1
View File
@@ -62,7 +62,6 @@ sfx/ui/loadtemplatedialog.ui
sfx/ui/templatedlg.ui
sfx/ui/printeroptionsdialog.ui
sfx/ui/searchdialog.ui
sfx/ui/alienwarndialog.ui
sfx/ui/errorfindemaildialog.ui
sfx/ui/querysavedialog.ui
sfx/ui/floatingrecord.ui
-89
View File
@@ -1,89 +0,0 @@
/* -*- 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 <alienwarn.hxx>
#include <officecfg/Office/Common.hxx>
SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent,
std::u16string_view _rFormatName,
std::u16string_view _rExtension,
const OUString& _rDefaultExtension,
bool rDefaultIsAlien)
: MessageDialogController(pParent, u"sfx/ui/alienwarndialog.ui"_ustr, u"AlienWarnDialog"_ustr,
u"ask"_ustr)
, m_xKeepCurrentBtn(m_xBuilder->weld_button(u"save"_ustr))
, m_xUseDefaultFormatBtn(m_xBuilder->weld_button(u"cancel"_ustr))
, m_xWarningOnBox(m_xBuilder->weld_check_button(u"ask"_ustr))
{
OUString aExtension = u"ODF"_ustr;
// replace formatname and extension (text)
OUString sInfoText = m_xDialog->get_primary_text();
sInfoText = sInfoText.replaceAll("%FORMATNAME", _rFormatName);
sInfoText = sInfoText.replaceAll("%EXTENSION", _rExtension);
m_xDialog->set_primary_text(sInfoText);
// replace formatname (button)
sInfoText = m_xKeepCurrentBtn->get_label();
sInfoText = sInfoText.replaceAll("%FORMATNAME", _rFormatName);
m_xKeepCurrentBtn->set_label(sInfoText);
// hide ODF explanation if default format is alien
// and set the proper extension in the button
if (rDefaultIsAlien)
{
m_xDialog->set_secondary_text(OUString());
aExtension = _rDefaultExtension.toAsciiUpperCase();
}
else
{
// replace extension (secondary-text)
sInfoText = m_xDialog->get_secondary_text();
sInfoText = sInfoText.replaceAll("%EXTENSION", _rDefaultExtension);
m_xDialog->set_secondary_text(sInfoText);
}
// replace defaultextension (button)
sInfoText = m_xUseDefaultFormatBtn->get_label();
sInfoText = sInfoText.replaceAll("%DEFAULTEXTENSION", aExtension);
m_xUseDefaultFormatBtn->set_label(sInfoText);
// load value of "warning on" checkbox from save options
m_xWarningOnBox->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get());
}
SfxAlienWarningDialog::~SfxAlienWarningDialog()
{
try
{
// save value of "warning off" checkbox, if necessary
bool bChecked = m_xWarningOnBox->get_active();
if (officecfg::Office::Common::Save::Document::WarnAlienFormat::get() != bChecked)
{
auto xChanges = comphelper::ConfigurationChanges::create();
officecfg::Office::Common::Save::Document::WarnAlienFormat::set(bChecked, xChanges);
xChanges->commit();
}
}
catch (...)
{
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
+26 -3
View File
@@ -89,7 +89,6 @@
#include <sfx2/sfxuno.hxx>
#include <sfx2/viewsh.hxx>
#include <sfx2/bindings.hxx>
#include <alienwarn.hxx>
#include <memory>
#include <string_view>
@@ -103,6 +102,8 @@
#include <osl/file.hxx>
#include <svl/cryptosign.hxx>
#include <vcl/abstdlg.hxx>
#ifdef _WIN32
#include <Shlobj.h>
#ifdef GetTempPath
@@ -2100,9 +2101,31 @@ bool SfxStoringHelper::WarnUnacceptableFormat( const uno::Reference< frame::XMod
return true;
weld::Window* pWin = SfxStoringHelper::GetModelWindow(xModel);
SfxAlienWarningDialog aDlg(pWin, aOldUIName,aExtension, aDefExtension, bDefIsAlien);
return aDlg.run() == RET_OK;
OUString sInfoText = SfxResId(STR_QUERY_ALIENFORMAT_TEXT);
sInfoText = sInfoText.replaceAll("%FORMATNAME", aOldUIName);
sInfoText = sInfoText.replaceAll("%EXTENSION", aExtension);
OUString sExtension = u"ODF"_ustr;
OUString sQuestion = "";
if (bDefIsAlien) {
sExtension = aDefExtension.toAsciiUpperCase();
}
else
{
sQuestion = SfxResId(STR_QUERY_ALIENFORMAT_QUESTION);
sQuestion = sQuestion.replaceAll("%EXTENSION", aDefExtension);
}
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
auto pDlg = pFact->CreateQueryDialog(pWin, SfxResId(STR_QUERY_ALIENFORMAT_TTITLE), sInfoText, sQuestion, false);
pDlg->SetYesLabel(SfxResId(STR_QUERY_ALIENFORMAT_YES).replaceAll("%FORMATNAME", aOldUIName)); // "Use %FORMATNAME Format"
pDlg->SetNoLabel(SfxResId(STR_QUERY_ALIENFORMAT_NO).replaceAll("%DEFAULTEXTENSION", sExtension)); // "Use %DEFAULTEXTENSION _Format"
sal_Int32 nResult = pDlg->Execute();
pDlg->disposeOnce();
return nResult == RET_YES;
}
uno::Reference<awt::XWindow> SfxStoringHelper::GetModelXWindow(const uno::Reference<frame::XModel>& xModel)
-40
View File
@@ -1,40 +0,0 @@
/* -*- 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 .
*/
#ifndef INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
#define INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
#include <vcl/weld.hxx>
class SfxAlienWarningDialog final : public weld::MessageDialogController
{
private:
std::unique_ptr<weld::Button> m_xKeepCurrentBtn;
std::unique_ptr<weld::Button> m_xUseDefaultFormatBtn;
std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
public:
SfxAlienWarningDialog(weld::Window* pParent, std::u16string_view _rFormatName,
std::u16string_view _rExtension, const OUString& _rDefaultExtension,
bool rDefaultIsAlien);
virtual ~SfxAlienWarningDialog() override;
};
#endif // INCLUDED_SFX2_SOURCE_INC_ALIENWARN_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
-85
View File
@@ -1,85 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface domain="sfx">
<requires lib="gtk+" version="3.20"/>
<object class="GtkMessageDialog" id="AlienWarnDialog">
<property name="can-focus">False</property>
<property name="title" translatable="yes" context="alienwarndialog|AlienWarnDialog">Confirm File Format</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="type-hint">dialog</property>
<property name="skip-taskbar-hint">True</property>
<property name="message-type">question</property>
<property name="text" translatable="yes" context="alienwarndialog|AlienWarnDialog">This document may contain formatting or content that cannot be saved in the currently selected file format “%FORMATNAME (*.%EXTENSION)”.</property>
<property name="secondary-text" translatable="yes" context="alienwarndialog|AlienWarnDialog">Use the default ODF file format (*.%EXTENSION) to be sure that the document is saved correctly.</property>
<child internal-child="vbox">
<object class="GtkBox" id="messagedialog-vbox">
<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="messagedialog-action_area">
<property name="can-focus">False</property>
<child>
<object class="GtkButton" id="cancel">
<property name="label" translatable="yes" context="alienwarndialog|cancel">Use %DEFAULTEXTENSION _Format</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">0</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="save">
<property name="label" translatable="yes" context="alienwarndialog|save">_Use %FORMATNAME Format</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">1</property>
<property name="non-homogeneous">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="GtkCheckButton" id="ask">
<property name="label" translatable="yes" context="alienwarndialog|ask">_Ask when not saving in ODF or default format</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="use-underline">True</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">cancel</action-widget>
<action-widget response="-5">save</action-widget>
</action-widgets>
</object>
</interface>
@@ -1101,7 +1101,6 @@ endif # !ENABLE_WASM_STRIP_CALC
gb_emscripten_fs_image_files += \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/addtargetdialog.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/alienwarndialog.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/autoredactdialog.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/bookmarkdialog.ui \
$(INSTROOT)/$(LIBO_SHARE_FOLDER)/config/soffice.cfg/sfx/ui/bookmarkmenu.ui \
+1 -1
View File
@@ -393,7 +393,7 @@ class trackedchanges(UITestCase):
xOpen = xDialog.getChild("open")
# DOC confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
@@ -44,7 +44,7 @@ class save_readonly_with_password(UITestCase):
xOk = xPasswordDialog.getChild("ok")
# DOCX confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOk, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as document:
+1 -1
View File
@@ -108,7 +108,7 @@ class tdf90401(UITestCase):
xOpen = xDialog.getChild("open")
# DOCX confirmation dialog is displayed
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="save"):
with self.ui_test.execute_dialog_through_action(xOpen, "CLICK", close_button="btnYes"):
pass
with self.ui_test.load_file(systemPathToFileUrl(xFilePath)) as writer_doc2: