[Libreoffice-commits] core.git: dbaccess/source
Caolán McNamara (via logerrit)
logerrit at kemper.freedesktop.org
Wed Nov 13 16:19:40 UTC 2019
dbaccess/source/ui/dlg/paramdialog.cxx | 42 ++++++++++++---------------------
dbaccess/source/ui/inc/paramdialog.hxx | 4 ---
2 files changed, 17 insertions(+), 29 deletions(-)
New commits:
commit e151c12a14c1a2536393c82fa6027f251be1a7d6
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 13 14:34:14 2019 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Nov 13 17:18:46 2019 +0100
Resolves: tdf#128748 warning dialog appearing on focus change
so can't use cancel because focus out of the entry happens on
the effort to get to the cancel button
instead only show the dialog on ok, next and selecting a new
param in the treeview. Show an error indicator in the entry
on focus-out instead.
Change-Id: I5770142d7a1e7c62bb9ed89a171e72129a43f6c8
Reviewed-on: https://gerrit.libreoffice.org/82613
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/dbaccess/source/ui/dlg/paramdialog.cxx b/dbaccess/source/ui/dlg/paramdialog.cxx
index d05fcec33879..a163e8a7606a 100644
--- a/dbaccess/source/ui/dlg/paramdialog.cxx
+++ b/dbaccess/source/ui/dlg/paramdialog.cxx
@@ -55,7 +55,6 @@ namespace dbaui
, m_nCurrentlySelected(-1)
, m_xConnection(_rxConnection)
, m_aPredicateInput( rxContext, _rxConnection, getParseContext() )
- , m_bNeedErrorOnCurrent(true)
, m_xAllParams(m_xBuilder->weld_tree_view("allParamTreeview"))
, m_xParam(m_xBuilder->weld_entry("paramEntry"))
, m_xTravelNext(m_xBuilder->weld_button("next"))
@@ -145,10 +144,10 @@ namespace dbaui
IMPL_LINK_NOARG(OParameterDialog, OnValueLoseFocusHdl, weld::Widget&, void)
{
- OnValueLoseFocus();
+ CheckValueForError(false);
}
- bool OParameterDialog::OnValueLoseFocus()
+ bool OParameterDialog::CheckValueForError(bool bShowDialog)
{
if (m_nCurrentlySelected != -1)
{
@@ -166,6 +165,7 @@ namespace dbaui
OUString sParamValue(m_xParam->get_text());
bool bValid = m_aPredicateInput.normalizePredicateString( sParamValue, xParamAsSet );
m_xParam->set_text(sParamValue);
+ m_xParam->set_message_type(bValid ? weld::EntryMessageType::Normal : weld::EntryMessageType::Error);
if ( bValid )
{
// with this the value isn't dirty anymore
@@ -174,9 +174,6 @@ namespace dbaui
}
else
{
- if (!m_bNeedErrorOnCurrent)
- return true;
-
OUString sName;
try
{
@@ -187,13 +184,16 @@ namespace dbaui
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- OUString sMessage(DBA_RES(STR_COULD_NOT_CONVERT_PARAM));
- sMessage = sMessage.replaceAll( "$name$", sName );
- std::unique_ptr<weld::MessageDialog> xDialog(Application::CreateMessageDialog(m_xDialog.get(),
- VclMessageType::Warning, VclButtonsType::Ok,
- sMessage));
- xDialog->run();
- m_xParam->grab_focus();
+ if (bShowDialog)
+ {
+ OUString sMessage(DBA_RES(STR_COULD_NOT_CONVERT_PARAM));
+ sMessage = sMessage.replaceAll( "$name$", sName );
+ std::unique_ptr<weld::MessageDialog> xDialog(Application::CreateMessageDialog(m_xDialog.get(),
+ VclMessageType::Warning, VclButtonsType::Ok,
+ sMessage));
+ xDialog->run();
+ m_xParam->grab_focus();
+ }
return true;
}
}
@@ -208,7 +208,6 @@ namespace dbaui
{
// no interpreting of the given values anymore...
m_xParam->connect_focus_out(Link<weld::Widget&, void>()); // no direct call from the control anymore ...
- m_bNeedErrorOnCurrent = false; // in case of any indirect calls -> no error message
m_xDialog->response(RET_CANCEL);
}
else if (m_xOKBtn.get() == &rButton)
@@ -216,10 +215,6 @@ namespace dbaui
// transfer the current values into the Any
if (OnEntrySelected())
{ // there was an error interpreting the current text
- m_bNeedErrorOnCurrent = true;
- // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now,
- // so the next time it is called we need an error message, again...
- // (TODO : there surely are better solutions for this...)
return;
}
@@ -265,10 +260,6 @@ namespace dbaui
m_xAllParams->select(nNext);
OnEntrySelected();
- m_bNeedErrorOnCurrent = true;
- // we're are out of the complex web :) of direct and indirect calls to OnValueLoseFocus now,
- // so the next time it is called we need an error message, again...
- // (TODO : there surely are better solutions for this...)
}
}
}
@@ -289,7 +280,7 @@ namespace dbaui
if (m_nCurrentlySelected != -1)
{
// do the transformation of the current text
- if (OnValueLoseFocus())
+ if (CheckValueForError(true))
{ // there was an error interpreting the text
m_xAllParams->select(m_nCurrentlySelected);
return true;
@@ -342,13 +333,12 @@ namespace dbaui
}
}
- IMPL_LINK_NOARG(OParameterDialog, OnValueModified, weld::Entry&, void)
+ IMPL_LINK(OParameterDialog, OnValueModified, weld::Entry&, rEdit, void)
{
// mark the currently selected entry as dirty
OSL_ENSURE(static_cast<size_t>(m_nCurrentlySelected) < m_aVisitedParams.size(), "OParameterDialog::OnValueModified : invalid entry !");
m_aVisitedParams[m_nCurrentlySelected] |= VisitFlags::Dirty;
-
- m_bNeedErrorOnCurrent = true;
+ rEdit.set_message_type(weld::EntryMessageType::Normal);
}
} // namespace dbaui
diff --git a/dbaccess/source/ui/inc/paramdialog.hxx b/dbaccess/source/ui/inc/paramdialog.hxx
index 49ddf496de3c..5a434e49e1cb 100644
--- a/dbaccess/source/ui/inc/paramdialog.hxx
+++ b/dbaccess/source/ui/inc/paramdialog.hxx
@@ -70,8 +70,6 @@ namespace dbaui
Timer m_aResetVisitFlag;
// we reset the "visited flag" 1 second after and entry has been selected
- bool m_bNeedErrorOnCurrent;
-
css::uno::Sequence< css::beans::PropertyValue >
m_aFinalValues; /// the final values as entered by the user
@@ -100,7 +98,7 @@ namespace dbaui
DECL_LINK(OnEntryListBoxSelected, weld::TreeView&, void);
DECL_LINK(OnButtonClicked, weld::Button&, void);
DECL_LINK(OnValueLoseFocusHdl, weld::Widget&, void);
- bool OnValueLoseFocus();
+ bool CheckValueForError(bool bShowDialog);
bool OnEntrySelected();
};
More information about the Libreoffice-commits
mailing list