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 <cui/dlgname.hxx>
21
22/*************************************************************************
23|*
24|* Dialog for editing a name
25|*
26\************************************************************************/
27
28SvxNameDialog::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
53 OUString rTip = "";
54 if (!bEnable && m_aCheckNameTooltipHdl.IsSet())
55 rTip = m_aCheckNameTooltipHdl.Call(*this);
56 m_xBtnOK->set_tooltip_text(rTip);
57 m_xEdtName->set_tooltip_text(rTip);
58}
59
60// #i68101#
61// Dialog for editing Object Name
62// plus uniqueness-callback-linkHandler
63
65 : GenericDialogController(pParent, "cui/ui/objectnamedialog.ui", "ObjectNameDialog")
66 , m_xEdtName(m_xBuilder->weld_entry("object_name_entry"))
67 , m_xBtnOK(m_xBuilder->weld_button("ok"))
68{
69 // set name
70 m_xEdtName->set_text(rName);
71 m_xEdtName->select_region(0, -1);
72
73 // activate name
74 ModifyHdl(*m_xEdtName);
75 m_xEdtName->connect_changed(LINK(this, SvxObjectNameDialog, ModifyHdl));
76}
77
79{
80 if (aCheckNameHdl.IsSet())
81 {
82 m_xBtnOK->set_sensitive(aCheckNameHdl.Call(*this));
83 }
84}
85
86// #i68101#
87// Dialog for editing Object Title and Description
88
90 const OUString& rDescription,
91 bool const isDecorative)
92 : GenericDialogController(pParent, "cui/ui/objecttitledescdialog.ui", "ObjectTitleDescDialog")
93 , m_xTitleFT(m_xBuilder->weld_label("object_title_label"))
94 , m_xEdtTitle(m_xBuilder->weld_entry("object_title_entry"))
95 , m_xDescriptionFT(m_xBuilder->weld_label("desc_label"))
96 , m_xEdtDescription(m_xBuilder->weld_text_view("desc_entry"))
97 , m_xDecorativeCB(m_xBuilder->weld_check_button("decorative"))
98{
99 //lock height to initial height
100 m_xEdtDescription->set_size_request(-1, m_xEdtDescription->get_text_height() * 5);
101 // set title & desc
102 m_xEdtTitle->set_text(rTitle);
103 m_xEdtDescription->set_text(rDescription);
104
105 // activate title
106 m_xEdtTitle->select_region(0, -1);
107
108 m_xDecorativeCB->set_active(isDecorative);
109 m_xDecorativeCB->connect_toggled(LINK(this, SvxObjectTitleDescDialog, DecorativeHdl));
110 DecorativeHdl(*m_xDecorativeCB);
111}
112
114{
115 bool const bEnable(!m_xDecorativeCB->get_active());
116 m_xEdtTitle->set_sensitive(bEnable);
117 m_xTitleFT->set_sensitive(bEnable);
118 m_xEdtDescription->set_sensitive(bEnable);
119 m_xDescriptionFT->set_sensitive(bEnable);
120}
121
122/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Dialog for editing a name.
Definition: dlgname.hxx:27
std::unique_ptr< weld::Entry > m_xEdtName
Definition: dlgname.hxx:29
std::unique_ptr< weld::Label > m_xFtDescription
Definition: dlgname.hxx:30
SvxNameDialog(weld::Window *pWindow, const OUString &rName, const OUString &rDesc)
Definition: dlgname.cxx:28
#i68101# Dialog for editing Object name plus uniqueness-callback-linkHandler
Definition: dlgname.hxx:78
SvxObjectNameDialog(weld::Window *pWindow, const OUString &rName)
Definition: dlgname.cxx:64
std::unique_ptr< weld::Entry > m_xEdtName
Definition: dlgname.hxx:81
#i68101# Dialog for editing Object Title and Description
Definition: dlgname.hxx:105
std::unique_ptr< weld::CheckButton > m_xDecorativeCB
Definition: dlgname.hxx:115
std::unique_ptr< weld::Entry > m_xEdtTitle
Definition: dlgname.hxx:109
SvxObjectTitleDescDialog(weld::Window *pWindow, const OUString &rTitle, const OUString &rDesc, bool isDecorative)
Definition: dlgname.cxx:89
std::unique_ptr< weld::TextView > m_xEdtDescription
Definition: dlgname.hxx:113
Link< AbstractSvxNameDialog &, bool > aCheckNameHdl
Definition: dlgfact.hxx:277
IMPL_LINK_NOARG(SvxNameDialog, ModifyHdl, weld::Entry &, void)
Definition: dlgname.cxx:41