Kaydet (Commit) 2fb266bb authored tarafından Caolán McNamara's avatar Caolán McNamara

unify the message dialogs with extra widgets cases

Change-Id: I9ad3573b15d24c3d1737b9f450792952ae20a31b
Reviewed-on: https://gerrit.libreoffice.org/51476Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 6709db94
...@@ -41,6 +41,21 @@ using namespace ::com::sun::star::beans; ...@@ -41,6 +41,21 @@ using namespace ::com::sun::star::beans;
using namespace ::com::sun::star::lang; using namespace ::com::sun::star::lang;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
namespace
{
class MessageWithCheck : public weld::MessageDialogController
{
private:
std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
public:
MessageWithCheck(weld::Window *pParent)
: weld::MessageDialogController(pParent, "modules/sbibliography/ui/querydialog.ui", "QueryDialog", "ask")
, m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
{
}
bool get_active() const { return m_xWarningOnBox->get_active(); }
};
}
namespace bib namespace bib
{ {
...@@ -139,24 +154,11 @@ namespace bib ...@@ -139,24 +154,11 @@ namespace bib
sErrorString += "\n"; sErrorString += "\n";
sErrorString += BibResId(RID_MAP_QUESTION); sErrorString += BibResId(RID_MAP_QUESTION);
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(GetFrameWeld(), "modules/sbibliography/ui/querydialog.ui")); MessageWithCheck aQueryBox(GetFrameWeld());
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("QueryDialog")); aQueryBox.set_primary_text(sErrorString);
xQueryBox->set_primary_text(sErrorString);
std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask"));
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent());
std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area());
xOrigParent->remove(xWarningOnBox.get());
xContentArea->add(xWarningOnBox.get());
short nResult = xQueryBox->run();
BibModul::GetConfig()->SetShowColumnAssignmentWarning(!xWarningOnBox->get_active());
//put them back as they were short nResult = aQueryBox.run();
xContentArea->remove(xWarningOnBox.get()); BibModul::GetConfig()->SetShowColumnAssignmentWarning(!aQueryBox.get_active());
xOrigParent->add(xWarningOnBox.get());
if( RET_YES != nResult ) if( RET_YES != nResult )
{ {
......
...@@ -613,13 +613,19 @@ private: ...@@ -613,13 +613,19 @@ private:
protected: protected:
std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Builder> m_xBuilder;
std::unique_ptr<weld::MessageDialog> m_xDialog; std::unique_ptr<weld::MessageDialog> m_xDialog;
std::unique_ptr<weld::Container> m_xContentArea;
std::unique_ptr<weld::Widget> m_xRelocate;
std::unique_ptr<weld::Container> m_xOrigParent;
public: public:
MessageDialogController(weld::Widget* pParent, const OUString& rUIFile, MessageDialogController(weld::Widget* pParent, const OUString& rUIFile,
const OString& rDialogId); const OString& rDialogId, const OString& rRelocateId = OString());
~MessageDialogController() override; ~MessageDialogController() override;
void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); } void set_title(const OUString& rTitle) { m_xDialog->set_title(rTitle); }
void set_help_id(const OString& rHelpId) { m_xDialog->set_help_id(rHelpId); } void set_help_id(const OString& rHelpId) { m_xDialog->set_help_id(rHelpId); }
void set_primary_text(const OUString& rText) { m_xDialog->set_primary_text(rText); }
OUString get_primary_text() const { return m_xDialog->get_primary_text(); }
void set_default_response(int response) { m_xDialog->set_default_response(response); }
}; };
} }
#endif #endif
......
...@@ -516,6 +516,19 @@ ScDocShell& getDocShell(const ScDocument& rDoc) ...@@ -516,6 +516,19 @@ ScDocShell& getDocShell(const ScDocument& rDoc)
return static_cast<ScDocShell&>(*rDoc.GetDocumentShell()); return static_cast<ScDocShell&>(*rDoc.GetDocumentShell());
} }
class MessageWithCheck : public weld::MessageDialogController
{
private:
std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
public:
MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
: weld::MessageDialogController(pParent, rUIFile, rDialogId, "ask")
, m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
{
}
bool get_active() const { return m_xWarningOnBox->get_active(); }
};
} }
void WorkbookFragment::recalcFormulaCells() void WorkbookFragment::recalcFormulaCells()
...@@ -534,27 +547,13 @@ void WorkbookFragment::recalcFormulaCells() ...@@ -534,27 +547,13 @@ void WorkbookFragment::recalcFormulaCells()
// Ask the user if full re-calculation is desired. // Ask the user if full re-calculation is desired.
vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); vcl::Window* pWin = ScDocShell::GetActiveDialogParent();
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, MessageWithCheck aQueryBox(pWin ? pWin->GetFrameWeld() : nullptr, "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
"modules/scalc/ui/recalcquerydialog.ui")); aQueryBox.set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); aQueryBox.set_default_response(RET_YES);
xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_XLS));
xQueryBox->set_default_response(RET_YES);
std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask"));
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent());
std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area());
xOrigParent->remove(xWarningOnBox.get());
xContentArea->add(xWarningOnBox.get());
bHardRecalc = xQueryBox->run() == RET_YES;
//put them back as they were bHardRecalc = aQueryBox.run() == RET_YES;
xContentArea->remove(xWarningOnBox.get());
xOrigParent->add(xWarningOnBox.get());
if (xWarningOnBox->get_active()) if (aQueryBox.get_active())
{ {
// Always perform selected action in the future. // Always perform selected action in the future.
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
......
...@@ -428,6 +428,19 @@ void processDataStream( ScDocShell& rShell, const sc::ImportPostProcessData& rDa ...@@ -428,6 +428,19 @@ void processDataStream( ScDocShell& rShell, const sc::ImportPostProcessData& rDa
rMgr.setDataStream(pStrm); rMgr.setDataStream(pStrm);
} }
class MessageWithCheck : public weld::MessageDialogController
{
private:
std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
public:
MessageWithCheck(weld::Window *pParent, const OUString& rUIFile, const OString& rDialogId)
: weld::MessageDialogController(pParent, rUIFile, rDialogId, "ask")
, m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
{
}
bool get_active() const { return m_xWarningOnBox->get_active(); }
};
} }
bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor ) bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css::embed::XStorage >& xStor )
...@@ -475,27 +488,14 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css ...@@ -475,27 +488,14 @@ bool ScDocShell::LoadXML( SfxMedium* pLoadMedium, const css::uno::Reference< css
// full re-calculation. // full re-calculation.
vcl::Window* pWin = GetActiveDialogParent(); vcl::Window* pWin = GetActiveDialogParent();
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, MessageWithCheck aQueryBox(pWin ? pWin->GetFrameWeld() : nullptr,
"modules/scalc/ui/recalcquerydialog.ui")); "modules/scalc/ui/recalcquerydialog.ui", "RecalcQueryDialog");
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("RecalcQueryDialog")); aQueryBox.set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS));
xQueryBox->set_primary_text(ScGlobal::GetRscString(STR_QUERY_FORMULA_RECALC_ONLOAD_ODS)); aQueryBox.set_default_response(RET_YES);
xQueryBox->set_default_response(RET_YES);
std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask"));
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent());
std::unique_ptr<weld::Container> xContentArea(xQueryBox->weld_message_area());
xOrigParent->remove(xWarningOnBox.get());
xContentArea->add(xWarningOnBox.get());
bHardRecalc = xQueryBox->run() == RET_YES;
//put them back as they were bHardRecalc = aQueryBox.run() == RET_YES;
xContentArea->remove(xWarningOnBox.get());
xOrigParent->add(xWarningOnBox.get());
if (xWarningOnBox->get_active()) if (aQueryBox.get_active())
{ {
// Always perform selected action in the future. // Always perform selected action in the future.
std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
...@@ -725,25 +725,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint ) ...@@ -725,25 +725,11 @@ void ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
{ {
vcl::Window* pWin = ScDocShell::GetActiveDialogParent(); vcl::Window* pWin = ScDocShell::GetActiveDialogParent();
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWin ? pWin->GetFrameWeld() : nullptr, MessageWithCheck aWarningBox(pWin ? pWin->GetFrameWeld() : nullptr,
"modules/scalc/ui/sharedwarningdialog.ui")); "modules/scalc/ui/sharedwarningdialog.ui", "SharedWarningDialog");
std::unique_ptr<weld::MessageDialog> xWarningBox(xBuilder->weld_message_dialog("SharedWarningDialog")); aWarningBox.run();
std::unique_ptr<weld::CheckButton> xWarningOnBox(xBuilder->weld_check_button("ask"));
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
std::unique_ptr<weld::Container> xOrigParent(xWarningOnBox->weld_parent());
std::unique_ptr<weld::Container> xContentArea(xWarningBox->weld_message_area());
xOrigParent->remove(xWarningOnBox.get());
xContentArea->add(xWarningOnBox.get());
xWarningBox->run();
//put them back as they were
xContentArea->remove(xWarningOnBox.get());
xOrigParent->add(xWarningOnBox.get());
bool bChecked = xWarningOnBox->get_active(); bool bChecked = aWarningBox.get_active();
if (bChecked) if (bChecked)
{ {
aAppOptions.SetShowSharedDocumentWarning( !bChecked ); aAppOptions.SetShowSharedDocumentWarning( !bChecked );
......
...@@ -27,11 +27,8 @@ ...@@ -27,11 +27,8 @@
class ScReplaceWarnBox : public weld::MessageDialogController class ScReplaceWarnBox : public weld::MessageDialogController
{ {
std::unique_ptr<weld::CheckButton> m_xWarningOnBox; std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
std::unique_ptr<weld::Container> m_xOrigParent;
std::unique_ptr<weld::Container> m_xContentArea;
public: public:
ScReplaceWarnBox(weld::Window* pParent); ScReplaceWarnBox(weld::Window* pParent);
virtual ~ScReplaceWarnBox() override;
/** Opens dialog if IsDialogEnabled() returns true. /** Opens dialog if IsDialogEnabled() returns true.
@descr If after executing the dialog the checkbox "Do not show again" is set, @descr If after executing the dialog the checkbox "Do not show again" is set,
......
...@@ -27,26 +27,12 @@ ...@@ -27,26 +27,12 @@
ScReplaceWarnBox::ScReplaceWarnBox(weld::Window* pParent) ScReplaceWarnBox::ScReplaceWarnBox(weld::Window* pParent)
: MessageDialogController(pParent, "modules/scalc/ui/checkwarningdialog.ui", : MessageDialogController(pParent, "modules/scalc/ui/checkwarningdialog.ui",
"CheckWarningDialog") "CheckWarningDialog", "ask")
// By default, the check box is ON, and the user needs to un-check it to // By default, the check box is ON, and the user needs to un-check it to
// disable all future warnings. // disable all future warnings.
, m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
, m_xOrigParent(m_xWarningOnBox->weld_parent())
, m_xContentArea(m_xDialog->weld_message_area())
{ {
m_xDialog->set_default_response(RET_YES); m_xDialog->set_default_response(RET_YES);
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
m_xOrigParent->remove(m_xWarningOnBox.get());
m_xContentArea->add(m_xWarningOnBox.get());
}
ScReplaceWarnBox::~ScReplaceWarnBox()
{
//put them back as they were
m_xContentArea->remove(m_xWarningOnBox.get());
m_xOrigParent->add(m_xWarningOnBox.get());
} }
short ScReplaceWarnBox::execute() short ScReplaceWarnBox::execute()
......
...@@ -27,18 +27,11 @@ ...@@ -27,18 +27,11 @@
SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName,
const OUString& _rDefaultExtension, bool rDefaultIsAlien) const OUString& _rDefaultExtension, bool rDefaultIsAlien)
: MessageDialogController(pParent, "sfx/ui/alienwarndialog.ui", "AlienWarnDialog") : MessageDialogController(pParent, "sfx/ui/alienwarndialog.ui", "AlienWarnDialog", "ask")
, m_xKeepCurrentBtn(m_xBuilder->weld_button("save")) , m_xKeepCurrentBtn(m_xBuilder->weld_button("save"))
, m_xUseDefaultFormatBtn(m_xBuilder->weld_button("cancel")) , m_xUseDefaultFormatBtn(m_xBuilder->weld_button("cancel"))
, m_xWarningOnBox(m_xBuilder->weld_check_button("ask")) , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
, m_xOrigParent(m_xWarningOnBox->weld_parent())
, m_xContentArea(m_xDialog->weld_message_area())
{ {
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
m_xOrigParent->remove(m_xWarningOnBox.get());
m_xContentArea->add(m_xWarningOnBox.get());
OUString aExtension = "ODF"; OUString aExtension = "ODF";
// replace formatname (text) // replace formatname (text)
...@@ -70,8 +63,6 @@ SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUStri ...@@ -70,8 +63,6 @@ SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window* pParent, const OUStri
SfxAlienWarningDialog::~SfxAlienWarningDialog() SfxAlienWarningDialog::~SfxAlienWarningDialog()
{ {
m_xContentArea->remove(m_xWarningOnBox.get());
m_xOrigParent->add(m_xWarningOnBox.get());
// save value of "warning off" checkbox, if necessary // save value of "warning off" checkbox, if necessary
SvtSaveOptions aSaveOpt; SvtSaveOptions aSaveOpt;
bool bChecked = m_xWarningOnBox->get_active(); bool bChecked = m_xWarningOnBox->get_active();
......
...@@ -28,9 +28,6 @@ private: ...@@ -28,9 +28,6 @@ private:
std::unique_ptr<weld::Button> m_xUseDefaultFormatBtn; std::unique_ptr<weld::Button> m_xUseDefaultFormatBtn;
std::unique_ptr<weld::CheckButton> m_xWarningOnBox; std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
std::unique_ptr<weld::Container> m_xOrigParent;
std::unique_ptr<weld::Container> m_xContentArea;
public: public:
SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName, SfxAlienWarningDialog(weld::Window* pParent, const OUString& _rFormatName,
const OUString& _rDefaultExtension, bool rDefaultIsAlien); const OUString& _rDefaultExtension, bool rDefaultIsAlien);
......
...@@ -120,74 +120,73 @@ static OUString lcl_GetColumnValueOf(const OUString& rColumn, Reference < contai ...@@ -120,74 +120,73 @@ static OUString lcl_GetColumnValueOf(const OUString& rColumn, Reference < contai
class SwSaveWarningBox_Impl : public SwMessageAndEditDialog class SwSaveWarningBox_Impl : public SwMessageAndEditDialog
{ {
DECL_LINK( ModifyHdl, Edit&, void); DECL_LINK( ModifyHdl, weld::Entry&, void);
public: public:
SwSaveWarningBox_Impl(vcl::Window* pParent, const OUString& rFileName); SwSaveWarningBox_Impl(weld::Window* pParent, const OUString& rFileName);
OUString GetFileName() const OUString GetFileName() const
{ {
return m_pEdit->GetText(); return m_xEdit->get_text();
} }
}; };
class SwSendQueryBox_Impl : public SwMessageAndEditDialog class SwSendQueryBox_Impl : public SwMessageAndEditDialog
{ {
bool bIsEmptyAllowed; bool bIsEmptyAllowed;
DECL_LINK( ModifyHdl, Edit&, void); DECL_LINK( ModifyHdl, weld::Entry&, void);
public: public:
SwSendQueryBox_Impl(vcl::Window* pParent, const OUString& rID, SwSendQueryBox_Impl(weld::Window* pParent, const OString& rID,
const OUString& rUIXMLDescription); const OUString& rUIXMLDescription);
void SetValue(const OUString& rSet) void SetValue(const OUString& rSet)
{ {
m_pEdit->SetText(rSet); m_xEdit->set_text(rSet);
ModifyHdl(*m_pEdit); ModifyHdl(*m_xEdit);
} }
OUString GetValue() const OUString GetValue() const
{ {
return m_pEdit->GetText(); return m_xEdit->get_text();
} }
void SetIsEmptyTextAllowed(bool bSet) void SetIsEmptyTextAllowed(bool bSet)
{ {
bIsEmptyAllowed = bSet; bIsEmptyAllowed = bSet;
ModifyHdl(*m_pEdit); ModifyHdl(*m_xEdit);
} }
}; };
SwSaveWarningBox_Impl::SwSaveWarningBox_Impl(vcl::Window* pParent, const OUString& rFileName) SwSaveWarningBox_Impl::SwSaveWarningBox_Impl(weld::Window* pParent, const OUString& rFileName)
: SwMessageAndEditDialog(pParent, "AlreadyExistsDialog", : SwMessageAndEditDialog(pParent, "AlreadyExistsDialog",
"modules/swriter/ui/alreadyexistsdialog.ui") "modules/swriter/ui/alreadyexistsdialog.ui")
{ {
m_pEdit->SetText(rFileName); m_xEdit->set_text(rFileName);
m_pEdit->SetModifyHdl(LINK(this, SwSaveWarningBox_Impl, ModifyHdl)); m_xEdit->connect_changed(LINK(this, SwSaveWarningBox_Impl, ModifyHdl));
INetURLObject aTmp(rFileName); INetURLObject aTmp(rFileName);
m_pPrimaryMessage->SetText(m_pPrimaryMessage->GetText().replaceAll("%1", aTmp.getName( m_xDialog->set_primary_text(m_xDialog->get_primary_text().replaceAll("%1", aTmp.getName(
INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset))); INetURLObject::LAST_SEGMENT, true, INetURLObject::DecodeMechanism::WithCharset)));
ModifyHdl(*m_pEdit); ModifyHdl(*m_xEdit);
} }
IMPL_LINK( SwSaveWarningBox_Impl, ModifyHdl, Edit&, rEdit, void) IMPL_LINK( SwSaveWarningBox_Impl, ModifyHdl, weld::Entry&, rEdit, void)
{ {
m_pOKPB->Enable(!rEdit.GetText().isEmpty()); m_xOKPB->set_sensitive(!rEdit.get_text().isEmpty());
} }
SwSendQueryBox_Impl::SwSendQueryBox_Impl(vcl::Window* pParent, const OUString& rID, SwSendQueryBox_Impl::SwSendQueryBox_Impl(weld::Window* pParent, const OString& rID,
const OUString& rUIXMLDescription) const OUString& rUIXMLDescription)
: SwMessageAndEditDialog(pParent, rID, rUIXMLDescription) : SwMessageAndEditDialog(pParent, rID, rUIXMLDescription)
, bIsEmptyAllowed(true) , bIsEmptyAllowed(true)
{ {
m_pImageIM->SetImage(GetStandardQueryBoxImage()); m_xEdit->connect_changed(LINK(this, SwSendQueryBox_Impl, ModifyHdl));
m_pEdit->SetModifyHdl(LINK(this, SwSendQueryBox_Impl, ModifyHdl)); ModifyHdl(*m_xEdit);
ModifyHdl(*m_pEdit);
} }
IMPL_LINK( SwSendQueryBox_Impl, ModifyHdl, Edit&, rEdit, void) IMPL_LINK( SwSendQueryBox_Impl, ModifyHdl, weld::Entry&, rEdit, void)
{ {
m_pOKPB->Enable(bIsEmptyAllowed || !rEdit.GetText().isEmpty()); m_xOKPB->set_sensitive(bIsEmptyAllowed || !rEdit.get_text().isEmpty());
} }
class SwCopyToDialog : public SfxModalDialog class SwCopyToDialog : public SfxModalDialog
...@@ -734,9 +733,9 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void) ...@@ -734,9 +733,9 @@ IMPL_LINK(SwMMResultSaveDialog, SaveOutputHdl_Impl, Button*, pButton, void)
if(bFailed) if(bFailed)
{ {
ScopedVclPtrInstance< SwSaveWarningBox_Impl > aWarning( pButton, sOutPath ); std::unique_ptr<SwSaveWarningBox_Impl> xWarning(new SwSaveWarningBox_Impl(pButton->GetFrameWeld(), sOutPath));
if(RET_OK == aWarning->Execute()) if (RET_OK == xWarning->run())
sOutPath = aWarning->GetFileName(); sOutPath = xWarning->GetFileName();
else else
{ {
xTempDocShell->DoClose(); xTempDocShell->DoClose();
...@@ -1011,26 +1010,26 @@ IMPL_LINK(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void) ...@@ -1011,26 +1010,26 @@ IMPL_LINK(SwMMResultEmailDialog, SendDocumentsHdl_Impl, Button*, pButton, void)
if(m_pSubjectED->GetText().isEmpty()) if(m_pSubjectED->GetText().isEmpty())
{ {
ScopedVclPtrInstance<SwSendQueryBox_Impl> aQuery(pButton, "SubjectDialog", std::unique_ptr<SwSendQueryBox_Impl> xQuery(new SwSendQueryBox_Impl(pButton->GetFrameWeld(), "SubjectDialog",
"modules/swriter/ui/subjectdialog.ui"); "modules/swriter/ui/subjectdialog.ui"));
aQuery->SetIsEmptyTextAllowed(true); xQuery->SetIsEmptyTextAllowed(true);
aQuery->SetValue(""); xQuery->SetValue("");
if(RET_OK == aQuery->Execute()) if(RET_OK == xQuery->run())
{ {
if(!aQuery->GetValue().isEmpty()) if(!xQuery->GetValue().isEmpty())
m_pSubjectED->SetText(aQuery->GetValue()); m_pSubjectED->SetText(xQuery->GetValue());
} }
else else
return; // back to the dialog return; // back to the dialog
} }
if(!bAsBody && m_pAttachmentED->GetText().isEmpty()) if(!bAsBody && m_pAttachmentED->GetText().isEmpty())
{ {
ScopedVclPtrInstance<SwSendQueryBox_Impl> aQuery(pButton, "AttachNameDialog", std::unique_ptr<SwSendQueryBox_Impl> xQuery(new SwSendQueryBox_Impl(pButton->GetFrameWeld(), "AttachNameDialog",
"modules/swriter/ui/attachnamedialog.ui"); "modules/swriter/ui/attachnamedialog.ui"));
aQuery->SetIsEmptyTextAllowed(false); xQuery->SetIsEmptyTextAllowed(false);
if(RET_OK == aQuery->Execute()) if (RET_OK == xQuery->run())
{ {
OUString sAttach(aQuery->GetValue()); OUString sAttach(xQuery->GetValue());
sal_Int32 nTokenCount = comphelper::string::getTokenCount(sAttach, '.'); sal_Int32 nTokenCount = comphelper::string::getTokenCount(sAttach, '.');
if (2 > nTokenCount) if (2 > nTokenCount)
{ {
......
...@@ -8,41 +8,13 @@ ...@@ -8,41 +8,13 @@
*/ */
#include <swmessdialog.hxx> #include <swmessdialog.hxx>
#include <vcl/button.hxx>
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
#include <vcl/messagedialog.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/vclmedit.hxx>
SwMessageAndEditDialog::SwMessageAndEditDialog(vcl::Window* pParent, const OUString& rID, SwMessageAndEditDialog::SwMessageAndEditDialog(weld::Window* pParent, const OString& rID,
const OUString& rUIXMLDescription) const OUString& rUIXMLDescription)
: ModalDialog(pParent, rID, rUIXMLDescription) : MessageDialogController(pParent, rUIXMLDescription, rID, "grid")
, m_xEdit(m_xBuilder->weld_entry("edit"))
, m_xOKPB(m_xBuilder->weld_button("ok"))
{ {
get(m_pOKPB, "ok");
get(m_pPrimaryMessage, "primarymessage");
m_pPrimaryMessage->SetPaintTransparent(true);
get(m_pSecondaryMessage, "secondarymessage");
m_pSecondaryMessage->SetPaintTransparent(true);
MessageDialog::SetMessagesWidths(this, m_pPrimaryMessage, m_pSecondaryMessage);
get(m_pImageIM, "image");
m_pImageIM->SetImage(GetStandardWarningBoxImage());
get(m_pEdit, "edit");
}
SwMessageAndEditDialog::~SwMessageAndEditDialog()
{
disposeOnce();
}
void SwMessageAndEditDialog::dispose()
{
m_pOKPB.clear();
m_pImageIM.clear();
m_pPrimaryMessage.clear();
m_pSecondaryMessage.clear();
m_pEdit.clear();
ModalDialog::dispose();
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -10,26 +10,16 @@ ...@@ -10,26 +10,16 @@
#ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX #ifndef INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX
#define INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX #define INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX
#include <vcl/dialog.hxx> #include <vcl/weld.hxx>
class Edit; class SwMessageAndEditDialog : public weld::MessageDialogController
class FixedImage;
class OKButton;
class VclMultiLineEdit;
class SwMessageAndEditDialog : public ModalDialog
{ {
protected: protected:
VclPtr<OKButton> m_pOKPB; std::unique_ptr<weld::Entry> m_xEdit;
VclPtr<FixedImage> m_pImageIM; std::unique_ptr<weld::Button> m_xOKPB;
VclPtr<VclMultiLineEdit> m_pPrimaryMessage;
VclPtr<VclMultiLineEdit> m_pSecondaryMessage;
VclPtr<Edit> m_pEdit;
public: public:
SwMessageAndEditDialog(vcl::Window* pParent, const OUString& rID, SwMessageAndEditDialog(weld::Window* pParent, const OString& rID,
const OUString& rUIXMLDescription); const OUString& rUIXMLDescription);
virtual ~SwMessageAndEditDialog() override;
virtual void dispose() override;
}; };
#endif // INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX #endif // INCLUDED_SW_SOURCE_UIBASE_INC_SWMESSDIALOG_HXX
......
...@@ -1598,13 +1598,31 @@ namespace weld ...@@ -1598,13 +1598,31 @@ namespace weld
Dialog* MessageDialogController::getDialog() { return m_xDialog.get(); } Dialog* MessageDialogController::getDialog() { return m_xDialog.get(); }
MessageDialogController::MessageDialogController(weld::Widget* pParent, const OUString &rUIFile, const OString& rDialogId) MessageDialogController::MessageDialogController(weld::Widget* pParent, const OUString &rUIFile, const OString& rDialogId,
const OString& rRelocateId)
: m_xBuilder(Application::CreateBuilder(pParent, rUIFile)) : m_xBuilder(Application::CreateBuilder(pParent, rUIFile))
, m_xDialog(m_xBuilder->weld_message_dialog(rDialogId)) , m_xDialog(m_xBuilder->weld_message_dialog(rDialogId))
, m_xContentArea(m_xDialog->weld_message_area())
{ {
if (!rRelocateId.isEmpty())
{
m_xRelocate.reset(m_xBuilder->weld_container(rRelocateId));
m_xOrigParent.reset(m_xRelocate->weld_parent());
//fdo#75121, a bit tricky because the widgets we want to align with
//don't actually exist in the ui description, they're implied
m_xOrigParent->remove(m_xRelocate.get());
m_xContentArea->add(m_xRelocate.get());
}
} }
MessageDialogController::~MessageDialogController() = default; MessageDialogController::~MessageDialogController()
{
if (m_xRelocate)
{
m_xContentArea->remove(m_xRelocate.get());
m_xOrigParent->add(m_xRelocate.get());
}
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment