LibreOffice Module cui (master)  1
dlgname.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  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <dlgname.hxx>
21 
22 /*************************************************************************
23 |*
24 |* Dialog for editing a name
25 |*
26 \************************************************************************/
27 
28 SvxNameDialog::SvxNameDialog(weld::Window* pParent, const OUString& rName, const OUString& rDesc)
29  : GenericDialogController(pParent, "cui/ui/namedialog.ui", "NameDialog")
30  , m_xEdtName(m_xBuilder->weld_entry("name_entry"))
31  , m_xFtDescription(m_xBuilder->weld_label("description_label"))
32  , m_xBtnOK(m_xBuilder->weld_button("ok"))
33 {
34  m_xFtDescription->set_label(rDesc);
35  m_xEdtName->set_text(rName);
36  m_xEdtName->select_region(0, -1);
37  ModifyHdl(*m_xEdtName);
38  m_xEdtName->connect_changed(LINK(this, SvxNameDialog, ModifyHdl));
39 }
40 
42 {
43  // Do not allow empty names
44  bool bEnable;
45  if (m_aCheckNameHdl.IsSet())
46  bEnable = !m_xEdtName->get_text().isEmpty() && m_aCheckNameHdl.Call(*this);
47  else
48  bEnable = !m_xEdtName->get_text().isEmpty();
49  m_xBtnOK->set_sensitive(bEnable);
50  // tdf#129032: feedback on reason to disabled controls
51  m_xEdtName->set_message_type(bEnable ? weld::EntryMessageType::Normal : weld::EntryMessageType::Error);
52  OUString rTip = "";
53  if (!bEnable && m_aCheckNameTooltipHdl.IsSet())
54  rTip = m_aCheckNameTooltipHdl.Call(*this);
55  m_xBtnOK->set_tooltip_text(rTip);
56  m_xEdtName->set_tooltip_text(rTip);
57 }
58 
59 // #i68101#
60 // Dialog for editing Object Name
61 // plus uniqueness-callback-linkHandler
62 
64  : GenericDialogController(pParent, "cui/ui/objectnamedialog.ui", "ObjectNameDialog")
65  , m_xEdtName(m_xBuilder->weld_entry("object_name_entry"))
66  , m_xBtnOK(m_xBuilder->weld_button("ok"))
67 {
68  // set name
69  m_xEdtName->set_text(rName);
70  m_xEdtName->select_region(0, -1);
71 
72  // activate name
73  ModifyHdl(*m_xEdtName);
74  m_xEdtName->connect_changed(LINK(this, SvxObjectNameDialog, ModifyHdl));
75 }
76 
78 {
79  if (aCheckNameHdl.IsSet())
80  {
81  m_xBtnOK->set_sensitive(aCheckNameHdl.Call(*this));
82  }
83 }
84 
85 // #i68101#
86 // Dialog for editing Object Title and Description
87 
89  const OUString& rDescription)
90  : GenericDialogController(pParent, "cui/ui/objecttitledescdialog.ui", "ObjectTitleDescDialog")
91  , m_xEdtTitle(m_xBuilder->weld_entry("object_title_entry"))
92  , m_xEdtDescription(m_xBuilder->weld_text_view("desc_entry"))
93 {
94  //lock height to initial height
95  m_xEdtDescription->set_size_request(-1, m_xEdtDescription->get_text_height() * 5);
96  // set title & desc
97  m_xEdtTitle->set_text(rTitle);
98  m_xEdtDescription->set_text(rDescription);
99 
100  // activate title
101  m_xEdtTitle->select_region(0, -1);
102 }
103 
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::TextView > m_xEdtDescription
Definition: dlgname.hxx:113
Dialog for editing a name.
Definition: dlgname.hxx:25
IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl, weld::Entry &, void)
Definition: dlgname.cxx:41
std::unique_ptr< weld::Label > m_xFtDescription
Definition: dlgname.hxx:29
std::unique_ptr< weld::Entry > m_xEdtName
Definition: dlgname.hxx:28
#i68101# Dialog for editing Object name plus uniqueness-callback-linkHandler
Definition: dlgname.hxx:76
SvxObjectNameDialog(weld::Window *pWindow, const OUString &rName)
Definition: dlgname.cxx:63
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: dlgname.hxx:110
SvxNameDialog(weld::Window *pWindow, const OUString &rName, const OUString &rDesc)
Definition: dlgname.cxx:28
std::unique_ptr< weld::Entry > m_xEdtName
Definition: dlgname.hxx:80
SvxObjectTitleDescDialog(weld::Window *pWindow, const OUString &rTitle, const OUString &rDesc)
Definition: dlgname.cxx:88