sd: keep a non-owning pointer to the OverridingShell
[LibreOffice.git] / sfx2 / source / dialog / inputdlg.cxx
blob6334240d6faa8e23e8b56c54a816a3ed03d6ce88
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, u"sfx/ui/inputdialog.ui"_ustr, u"InputDialog"_ustr)
14 , m_xEntry(m_xBuilder->weld_entry(u"entry"_ustr))
15 , m_xLabel(m_xBuilder->weld_label(u"label"_ustr))
16 , m_xHelp(m_xBuilder->weld_button(u"help"_ustr))
17 , m_xOk(m_xBuilder->weld_button(u"ok"_ustr))
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(u""_ustr);
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(const std::function<bool(OUString)>& rFunc)
56 mCheckEntry = rFunc;
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: */