LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / sfx2 / source / dialog / inputdlg.cxx
blob243f2fa092e482e4785fcc1a892f735340ec5034
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <sfx2/inputdlg.hxx>
12 InputDialog::InputDialog(weld::Widget* pParent, const OUString& rLabelText)
13 : GenericDialogController(pParent, "sfx/ui/inputdialog.ui", "InputDialog")
14 , m_xEntry(m_xBuilder->weld_entry("entry"))
15 , m_xLabel(m_xBuilder->weld_label("label"))
16 , m_xHelp(m_xBuilder->weld_button("help"))
17 , m_xOk(m_xBuilder->weld_button("ok"))
19 m_xLabel->set_label(rLabelText);
22 void InputDialog::HideHelpBtn() { m_xHelp->hide(); }
24 OUString InputDialog::GetEntryText() const { return m_xEntry->get_text(); }
26 void InputDialog::SetEntryText(const OUString& rStr)
28 m_xEntry->set_text(rStr);
29 m_xEntry->set_position(-1);
32 void InputDialog::SetEntryMessageType(weld::EntryMessageType aType)
34 m_xEntry->set_message_type(aType);
35 if (aType == weld::EntryMessageType::Error)
37 m_xEntry->select_region(0, -1);
38 m_xEntry->grab_focus();
39 m_xOk->set_sensitive(false);
41 else
43 m_xOk->set_sensitive(true);
44 SetTooltip("");
48 void InputDialog::SetTooltip(const OUString& rStr)
50 m_xEntry->set_tooltip_text(rStr);
51 m_xOk->set_tooltip_text(rStr);
54 void InputDialog::setCheckEntry(std::function<bool(OUString)> aFunc)
56 mCheckEntry = aFunc;
57 m_xEntry->connect_changed(LINK(this, InputDialog, EntryChangedHdl));
60 IMPL_LINK_NOARG(InputDialog, EntryChangedHdl, weld::Entry&, void)
62 if (mCheckEntry(m_xEntry->get_text()))
63 SetEntryMessageType(weld::EntryMessageType::Normal);
64 else
65 SetEntryMessageType(weld::EntryMessageType::Error);
67 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */