LibreOffice Module sfx2 (master) 1
inputdlg.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
10#include <sfx2/inputdlg.hxx>
11
12InputDialog::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"))
18{
19 m_xLabel->set_label(rLabelText);
20}
21
23
24OUString InputDialog::GetEntryText() const { return m_xEntry->get_text(); }
25
26void InputDialog::SetEntryText(const OUString& rStr)
27{
28 m_xEntry->set_text(rStr);
29 m_xEntry->set_position(-1);
30}
31
33{
34 m_xEntry->set_message_type(aType);
36 {
37 m_xEntry->select_region(0, -1);
38 m_xEntry->grab_focus();
39 m_xOk->set_sensitive(false);
40 }
41 else
42 {
43 m_xOk->set_sensitive(true);
44 SetTooltip("");
45 }
46}
47
48void InputDialog::SetTooltip(const OUString& rStr)
49{
50 m_xEntry->set_tooltip_text(rStr);
51 m_xOk->set_tooltip_text(rStr);
52}
53
54void InputDialog::setCheckEntry(std::function<bool(OUString)> aFunc)
55{
56 mCheckEntry = aFunc;
57 m_xEntry->connect_changed(LINK(this, InputDialog, EntryChangedHdl));
58}
59
60IMPL_LINK_NOARG(InputDialog, EntryChangedHdl, weld::Entry&, void)
61{
62 if (mCheckEntry(m_xEntry->get_text()))
63 SetEntryMessageType(weld::EntryMessageType::Normal);
64 else
65 SetEntryMessageType(weld::EntryMessageType::Error);
66}
67/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetEntryText() const
Definition: inputdlg.cxx:24
void SetTooltip(const OUString &rStr)
Definition: inputdlg.cxx:48
std::unique_ptr< weld::Label > m_xLabel
Definition: inputdlg.hxx:20
std::unique_ptr< weld::Entry > m_xEntry
Definition: inputdlg.hxx:19
std::unique_ptr< weld::Button > m_xHelp
Definition: inputdlg.hxx:21
void setCheckEntry(std::function< bool(OUString)> aFunc)
Definition: inputdlg.cxx:54
void SetEntryText(const OUString &rStr)
Definition: inputdlg.cxx:26
std::unique_ptr< weld::Button > m_xOk
Definition: inputdlg.hxx:22
InputDialog(weld::Widget *pParent, const OUString &rLabelText)
Definition: inputdlg.cxx:12
std::function< bool(OUString)> mCheckEntry
Definition: inputdlg.hxx:23
void HideHelpBtn()
Definition: inputdlg.cxx:22
void SetEntryMessageType(weld::EntryMessageType aType)
Definition: inputdlg.cxx:32
std::unique_ptr< weld::Label > m_xLabel
IMPL_LINK_NOARG(InputDialog, EntryChangedHdl, weld::Entry &, void)
Definition: inputdlg.cxx:60
EntryMessageType