tdf#164749 make "Compare by: " label in Duplicates dialog translatable
[LibreOffice.git] / cui / inc / dlgname.hxx
blobd12b8edb1bea82dcbbebc8e3eb65db95e9d87eab
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <vcl/formatter.hxx>
22 #include <vcl/weld.hxx>
23 #include <sal/log.hxx>
25 /// Dialog for editing a name
26 class SvxNameDialog final : public weld::GenericDialogController
28 private:
29 std::unique_ptr<weld::Entry> m_xEdtName;
30 std::unique_ptr<weld::Label> m_xFtDescription;
31 std::unique_ptr<weld::Button> m_xBtnOK;
33 Link<SvxNameDialog&, bool> m_aCheckNameHdl;
34 Link<SvxNameDialog&, OUString> m_aCheckNameTooltipHdl;
36 DECL_LINK(ModifyHdl, weld::Entry&, void);
38 public:
39 SvxNameDialog(weld::Window* pWindow, const OUString& rName, const OUString& rDesc,
40 const OUString& rTitle = u""_ustr);
42 OUString GetName() const { return m_xEdtName->get_text(); }
44 /** add a callback Link that is called whenever the content of the edit
45 field is changed. The Link result determines whether the OK
46 Button is enabled (> 0) or disabled (== 0).
48 @param rLink a Callback declared with DECL_DLLPRIVATE_LINK and implemented with
49 IMPL_LINK, that is executed on modification.
51 void SetCheckNameHdl(const Link<SvxNameDialog&, bool>& rLink)
53 m_aCheckNameHdl = rLink;
54 ModifyHdl(*m_xEdtName);
57 void SetCheckNameTooltipHdl(const Link<SvxNameDialog&, OUString>& rLink)
59 m_aCheckNameTooltipHdl = rLink;
60 m_xBtnOK->set_tooltip_text(rLink.Call(*this));
63 void SetEditHelpId(const OUString& aHelpId) { m_xEdtName->set_help_id(aHelpId); }
66 /// Dialog for editing a number
67 class SvxNumberDialog final : public weld::GenericDialogController
69 private:
70 std::unique_ptr<weld::SpinButton> m_xEdtNumber;
71 std::unique_ptr<weld::Label> m_xFtDescription;
73 public:
74 SvxNumberDialog(weld::Window* pWindow, const OUString& rDesc, sal_Int64 nValue, sal_Int64 nMin,
75 sal_Int64 nMax);
77 sal_Int64 GetNumber() const { return m_xEdtNumber->get_value(); }
80 class SvxDecimalNumberDialog final : public weld::GenericDialogController
82 private:
83 std::unique_ptr<weld::FormattedSpinButton> m_xEdtNumber;
84 std::unique_ptr<weld::Label> m_xFtDescription;
86 public:
87 SvxDecimalNumberDialog(weld::Window* pWindow, const OUString& rDesc, double fValue);
89 double GetNumber() const { return m_xEdtNumber->GetFormatter().GetValue(); }
92 /** #i68101#
93 Dialog for editing Object name
94 plus uniqueness-callback-linkHandler */
95 class SvxObjectNameDialog final : public weld::GenericDialogController
97 private:
98 // name
99 std::unique_ptr<weld::Entry> m_xEdtName;
101 // buttons
102 std::unique_ptr<weld::Button> m_xBtnOK;
104 // callback link for name uniqueness
105 Link<SvxObjectNameDialog&, bool> aCheckNameHdl;
107 DECL_LINK(ModifyHdl, weld::Entry&, void);
109 public:
110 // constructor
111 SvxObjectNameDialog(weld::Window* pWindow, const OUString& rName);
113 // data access
114 OUString GetName() const { return m_xEdtName->get_text(); }
116 // set handler
117 void SetCheckNameHdl(const Link<SvxObjectNameDialog&, bool>& rLink) { aCheckNameHdl = rLink; }
120 /** #i68101#
121 Dialog for editing Object Title and Description */
122 class SvxObjectTitleDescDialog final : public weld::GenericDialogController
124 private:
125 // title
126 std::unique_ptr<weld::Label> m_xTitleFT;
127 std::unique_ptr<weld::Entry> m_xEdtTitle;
129 // description
130 std::unique_ptr<weld::Label> m_xDescriptionFT;
131 std::unique_ptr<weld::TextView> m_xEdtDescription;
133 std::unique_ptr<weld::CheckButton> m_xDecorativeCB;
135 DECL_LINK(DecorativeHdl, weld::Toggleable&, void);
137 public:
138 // constructor
139 SvxObjectTitleDescDialog(weld::Window* pWindow, const OUString& rTitle, const OUString& rDesc,
140 bool isDecorative);
141 // data access
142 OUString GetTitle() const { return m_xEdtTitle->get_text(); }
143 OUString GetDescription() const { return m_xEdtDescription->get_text(); }
144 bool IsDecorative() const { return m_xDecorativeCB->get_active(); }
147 enum class ListMode
149 String,
150 Int64,
151 Int32,
152 Int16,
153 Double
156 /** Generic dialog to edit lists */
157 class SvxListDialog : public weld::GenericDialogController
159 private:
160 ListMode m_aMode;
161 std::unique_ptr<weld::TreeView> m_xList;
162 std::unique_ptr<weld::Button> m_xAddBtn;
163 std::unique_ptr<weld::Button> m_xRemoveBtn;
164 std::unique_ptr<weld::Button> m_xEditBtn;
166 DECL_LINK(SelectHdl_Impl, weld::TreeView&, void);
167 DECL_LINK(DblClickHdl_Impl, weld::TreeView&, bool);
168 DECL_LINK(AddHdl_Impl, weld::Button&, void);
169 DECL_LINK(RemoveHdl_Impl, weld::Button&, void);
170 DECL_LINK(EditHdl_Impl, weld::Button&, void);
172 void SelectionChanged();
174 public:
175 explicit SvxListDialog(weld::Window* pParent);
176 virtual ~SvxListDialog() override;
178 std::vector<OUString> GetEntries();
179 void SetEntries(std::vector<OUString> const& rParams);
180 void EditEntry();
181 void SetMode(ListMode aMode);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */