1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <QtInstanceBuilder.hxx>
12 #include <unordered_set>
14 #include <QtBuilder.hxx>
15 #include <QtInstanceCheckButton.hxx>
16 #include <QtInstanceComboBox.hxx>
17 #include <QtInstanceDrawingArea.hxx>
18 #include <QtInstanceEntry.hxx>
19 #include <QtInstanceExpander.hxx>
20 #include <QtInstanceFrame.hxx>
21 #include <QtInstanceGrid.hxx>
22 #include <QtInstanceImage.hxx>
23 #include <QtInstanceLabel.hxx>
24 #include <QtInstanceLevelBar.hxx>
25 #include <QtInstanceLinkButton.hxx>
26 #include <QtInstanceIconView.hxx>
27 #include <QtInstanceMenu.hxx>
28 #include <QtInstanceMenuButton.hxx>
29 #include <QtInstanceMessageDialog.hxx>
30 #include <QtInstanceNotebook.hxx>
31 #include <QtInstancePopover.hxx>
32 #include <QtInstanceProgressBar.hxx>
33 #include <QtInstanceRadioButton.hxx>
34 #include <QtInstanceScale.hxx>
35 #include <QtInstanceScrolledWindow.hxx>
36 #include <QtInstanceSpinButton.hxx>
37 #include <QtInstanceTextView.hxx>
38 #include <QtInstanceToggleButton.hxx>
39 #include <QtInstanceToolbar.hxx>
40 #include <QtInstanceTreeView.hxx>
42 #include <QtWidgets/QToolButton>
44 QtInstanceBuilder::QtInstanceBuilder(QWidget
* pParent
, std::u16string_view sUIRoot
,
45 const OUString
& rUIFile
)
46 : m_xBuilder(std::make_unique
<QtBuilder
>(pParent
, sUIRoot
, rUIFile
))
50 QtInstanceBuilder::~QtInstanceBuilder() {}
52 bool QtInstanceBuilder::IsUIFileSupported(const OUString
& rUIFile
)
54 // set of supported UI files
56 // The idea is to implement functionality needed for a specific UI file/dialog
57 // in QtInstanceBuilder, then add it to the set of supported UI files here.
58 // This allows looking at one .ui file at a time and only having to implement
59 // what is relevant for that particular one, without having to implement the full
61 static std::unordered_set
<OUString
> aSupportedUIFiles
= {
62 u
"cui/ui/aboutdialog.ui"_ustr
,
63 u
"cui/ui/insertrowcolumn.ui"_ustr
,
64 u
"cui/ui/namedialog.ui"_ustr
,
65 u
"cui/ui/objecttitledescdialog.ui"_ustr
,
66 u
"cui/ui/optnewdictionarydialog.ui"_ustr
,
67 u
"cui/ui/password.ui"_ustr
,
68 u
"cui/ui/pastespecial.ui"_ustr
,
69 u
"cui/ui/qrcodegen.ui"_ustr
,
70 u
"cui/ui/querysetinsmodedialog.ui"_ustr
,
71 u
"cui/ui/securityoptionsdialog.ui"_ustr
,
72 u
"cui/ui/splitcellsdialog.ui"_ustr
,
73 u
"cui/ui/tipofthedaydialog.ui"_ustr
,
74 u
"cui/ui/toolbarmodedialog.ui"_ustr
,
75 u
"modules/scalc/ui/inputstringdialog.ui"_ustr
,
76 u
"modules/scalc/ui/insertcells.ui"_ustr
,
77 u
"modules/scalc/ui/movecopysheet.ui"_ustr
,
78 u
"modules/scalc/ui/selectsource.ui"_ustr
,
79 u
"modules/scalc/ui/showsheetdialog.ui"_ustr
,
80 u
"modules/schart/ui/insertaxisdlg.ui"_ustr
,
81 u
"modules/smath/ui/alignmentdialog.ui"_ustr
,
82 u
"modules/swriter/ui/authenticationsettingsdialog.ui"_ustr
,
83 u
"modules/swriter/ui/endnotepage.ui"_ustr
,
84 u
"modules/swriter/ui/footendnotedialog.ui"_ustr
,
85 u
"modules/swriter/ui/footnotepage.ui"_ustr
,
86 u
"modules/swriter/ui/inforeadonlydialog.ui"_ustr
,
87 u
"modules/swriter/ui/insertbreak.ui"_ustr
,
88 u
"modules/swriter/ui/renameobjectdialog.ui"_ustr
,
89 u
"modules/swriter/ui/splittable.ui"_ustr
,
90 u
"modules/swriter/ui/wordcount.ui"_ustr
,
91 u
"sfx/ui/helpmanual.ui"_ustr
,
92 u
"sfx/ui/licensedialog.ui"_ustr
,
93 u
"sfx/ui/password.ui"_ustr
,
94 u
"sfx/ui/querysavedialog.ui"_ustr
,
95 u
"sfx/ui/safemodequerydialog.ui"_ustr
,
96 u
"svt/ui/printersetupdialog.ui"_ustr
,
97 u
"svt/ui/restartdialog.ui"_ustr
,
98 u
"svx/ui/compressgraphicdialog.ui"_ustr
,
99 u
"svx/ui/gotopagedialog.ui"_ustr
,
100 u
"svx/ui/safemodedialog.ui"_ustr
,
101 u
"vcl/ui/openlockedquerybox.ui"_ustr
,
102 u
"vcl/ui/printerdevicepage.ui"_ustr
,
103 u
"vcl/ui/printerpaperpage.ui"_ustr
,
104 u
"vcl/ui/printerpropertiesdialog.ui"_ustr
,
105 u
"vcl/ui/printprogressdialog.ui"_ustr
,
106 u
"writerperfect/ui/exportepub.ui"_ustr
,
109 return aSupportedUIFiles
.contains(rUIFile
);
112 std::unique_ptr
<weld::MessageDialog
> QtInstanceBuilder::weld_message_dialog(const OUString
& id
)
114 QMessageBox
* pMessageBox
= m_xBuilder
->get
<QMessageBox
>(id
);
115 std::unique_ptr
<weld::MessageDialog
> xRet(
116 pMessageBox
? std::make_unique
<QtInstanceMessageDialog
>(pMessageBox
) : nullptr);
120 std::unique_ptr
<weld::Dialog
> QtInstanceBuilder::weld_dialog(const OUString
& rId
)
122 QDialog
* pDialog
= m_xBuilder
->get
<QDialog
>(rId
);
123 std::unique_ptr
<weld::Dialog
> xRet(pDialog
? std::make_unique
<QtInstanceDialog
>(pDialog
)
128 std::unique_ptr
<weld::Assistant
> QtInstanceBuilder::weld_assistant(const OUString
&)
130 assert(false && "Not implemented yet");
134 std::unique_ptr
<weld::Window
> QtInstanceBuilder::create_screenshot_window()
136 assert(false && "Not implemented yet");
140 std::unique_ptr
<weld::Widget
> QtInstanceBuilder::weld_widget(const OUString
& rId
)
142 QWidget
* pWidget
= m_xBuilder
->get
<QWidget
>(rId
);
143 std::unique_ptr
<weld::Widget
> xRet(pWidget
? std::make_unique
<QtInstanceWidget
>(pWidget
)
148 std::unique_ptr
<weld::Container
> QtInstanceBuilder::weld_container(const OUString
& rId
)
150 QWidget
* pWidget
= m_xBuilder
->get
<QWidget
>(rId
);
154 assert(pWidget
->layout() && "no layout");
155 return std::make_unique
<QtInstanceContainer
>(pWidget
);
158 std::unique_ptr
<weld::Box
> QtInstanceBuilder::weld_box(const OUString
&)
160 assert(false && "Not implemented yet");
164 std::unique_ptr
<weld::Grid
> QtInstanceBuilder::weld_grid(const OUString
& rId
)
166 QWidget
* pWidget
= m_xBuilder
->get
<QWidget
>(rId
);
170 assert(qobject_cast
<QGridLayout
*>(pWidget
->layout()) && "no grid layout");
171 return std::make_unique
<QtInstanceGrid
>(pWidget
);
174 std::unique_ptr
<weld::Paned
> QtInstanceBuilder::weld_paned(const OUString
&)
176 assert(false && "Not implemented yet");
180 std::unique_ptr
<weld::Frame
> QtInstanceBuilder::weld_frame(const OUString
& rId
)
182 QGroupBox
* pGroupBox
= m_xBuilder
->get
<QGroupBox
>(rId
);
183 std::unique_ptr
<weld::Frame
> xRet(pGroupBox
? std::make_unique
<QtInstanceFrame
>(pGroupBox
)
188 std::unique_ptr
<weld::ScrolledWindow
> QtInstanceBuilder::weld_scrolled_window(const OUString
& rId
,
191 QScrollArea
* pScrollArea
= m_xBuilder
->get
<QScrollArea
>(rId
);
192 std::unique_ptr
<weld::ScrolledWindow
> xRet(
193 pScrollArea
? std::make_unique
<QtInstanceScrolledWindow
>(pScrollArea
) : nullptr);
197 std::unique_ptr
<weld::Notebook
> QtInstanceBuilder::weld_notebook(const OUString
& rId
)
199 QTabWidget
* pTabWidget
= m_xBuilder
->get
<QTabWidget
>(rId
);
200 std::unique_ptr
<weld::Notebook
> xRet(
201 pTabWidget
? std::make_unique
<QtInstanceNotebook
>(pTabWidget
) : nullptr);
205 std::unique_ptr
<weld::Button
> QtInstanceBuilder::weld_button(const OUString
& rId
)
207 QPushButton
* pButton
= m_xBuilder
->get
<QPushButton
>(rId
);
208 std::unique_ptr
<weld::Button
> xRet(pButton
? std::make_unique
<QtInstanceButton
>(pButton
)
213 std::unique_ptr
<weld::MenuButton
> QtInstanceBuilder::weld_menu_button(const OUString
& rId
)
215 QToolButton
* pButton
= m_xBuilder
->get
<QToolButton
>(rId
);
216 std::unique_ptr
<weld::MenuButton
> xRet(pButton
? std::make_unique
<QtInstanceMenuButton
>(pButton
)
221 std::unique_ptr
<weld::MenuToggleButton
> QtInstanceBuilder::weld_menu_toggle_button(const OUString
&)
223 assert(false && "Not implemented yet");
227 std::unique_ptr
<weld::LinkButton
> QtInstanceBuilder::weld_link_button(const OUString
& rId
)
229 QtHyperlinkLabel
* pLabel
= m_xBuilder
->get
<QtHyperlinkLabel
>(rId
);
230 std::unique_ptr
<weld::LinkButton
> xRet(pLabel
? std::make_unique
<QtInstanceLinkButton
>(pLabel
)
235 std::unique_ptr
<weld::ToggleButton
> QtInstanceBuilder::weld_toggle_button(const OUString
& rId
)
237 QAbstractButton
* pButton
= m_xBuilder
->get
<QAbstractButton
>(rId
);
238 std::unique_ptr
<weld::ToggleButton
> xRet(
239 pButton
? std::make_unique
<QtInstanceToggleButton
>(pButton
) : nullptr);
243 std::unique_ptr
<weld::RadioButton
> QtInstanceBuilder::weld_radio_button(const OUString
& rId
)
245 QRadioButton
* pRadioButton
= m_xBuilder
->get
<QRadioButton
>(rId
);
246 std::unique_ptr
<weld::RadioButton
> xRet(
247 pRadioButton
? std::make_unique
<QtInstanceRadioButton
>(pRadioButton
) : nullptr);
251 std::unique_ptr
<weld::CheckButton
> QtInstanceBuilder::weld_check_button(const OUString
& rId
)
253 QCheckBox
* pCheckBox
= m_xBuilder
->get
<QCheckBox
>(rId
);
254 std::unique_ptr
<weld::CheckButton
> xRet(
255 pCheckBox
? std::make_unique
<QtInstanceCheckButton
>(pCheckBox
) : nullptr);
259 std::unique_ptr
<weld::Scale
> QtInstanceBuilder::weld_scale(const OUString
& rId
)
261 QSlider
* pSlider
= m_xBuilder
->get
<QSlider
>(rId
);
262 std::unique_ptr
<weld::Scale
> xRet(pSlider
? std::make_unique
<QtInstanceScale
>(pSlider
)
267 std::unique_ptr
<weld::ProgressBar
> QtInstanceBuilder::weld_progress_bar(const OUString
& rId
)
269 QProgressBar
* pProgressBar
= m_xBuilder
->get
<QProgressBar
>(rId
);
270 std::unique_ptr
<weld::ProgressBar
> xRet(
271 pProgressBar
? std::make_unique
<QtInstanceProgressBar
>(pProgressBar
) : nullptr);
275 std::unique_ptr
<weld::LevelBar
> QtInstanceBuilder::weld_level_bar(const OUString
& rId
)
277 QProgressBar
* pProgressBar
= m_xBuilder
->get
<QProgressBar
>(rId
);
278 std::unique_ptr
<weld::LevelBar
> xRet(
279 pProgressBar
? std::make_unique
<QtInstanceLevelBar
>(pProgressBar
) : nullptr);
283 std::unique_ptr
<weld::Spinner
> QtInstanceBuilder::weld_spinner(const OUString
&)
285 assert(false && "Not implemented yet");
289 std::unique_ptr
<weld::Image
> QtInstanceBuilder::weld_image(const OUString
& rId
)
291 QLabel
* pLabel
= m_xBuilder
->get
<QLabel
>(rId
);
292 std::unique_ptr
<weld::Image
> xRet(pLabel
? std::make_unique
<QtInstanceImage
>(pLabel
) : nullptr);
296 std::unique_ptr
<weld::Calendar
> QtInstanceBuilder::weld_calendar(const OUString
&)
298 assert(false && "Not implemented yet");
302 std::unique_ptr
<weld::Entry
> QtInstanceBuilder::weld_entry(const OUString
& rId
)
304 QLineEdit
* pLineEdit
= m_xBuilder
->get
<QLineEdit
>(rId
);
305 std::unique_ptr
<weld::Entry
> xRet(pLineEdit
? std::make_unique
<QtInstanceEntry
>(pLineEdit
)
310 std::unique_ptr
<weld::SpinButton
> QtInstanceBuilder::weld_spin_button(const OUString
& rId
)
312 QtDoubleSpinBox
* pSpinBox
= m_xBuilder
->get
<QtDoubleSpinBox
>(rId
);
313 std::unique_ptr
<weld::SpinButton
> xRet(
314 pSpinBox
? std::make_unique
<QtInstanceSpinButton
>(pSpinBox
) : nullptr);
318 std::unique_ptr
<weld::MetricSpinButton
> QtInstanceBuilder::weld_metric_spin_button(const OUString
&,
321 assert(false && "Not implemented yet");
325 std::unique_ptr
<weld::FormattedSpinButton
>
326 QtInstanceBuilder::weld_formatted_spin_button(const OUString
&)
328 assert(false && "Not implemented yet");
332 std::unique_ptr
<weld::ComboBox
> QtInstanceBuilder::weld_combo_box(const OUString
& rId
)
334 QComboBox
* pComboBox
= m_xBuilder
->get
<QComboBox
>(rId
);
335 std::unique_ptr
<weld::ComboBox
> xRet(pComboBox
? std::make_unique
<QtInstanceComboBox
>(pComboBox
)
340 std::unique_ptr
<weld::EntryTreeView
>
341 QtInstanceBuilder::weld_entry_tree_view(const OUString
&, const OUString
&, const OUString
&)
343 assert(false && "Not implemented yet");
347 std::unique_ptr
<weld::TreeView
> QtInstanceBuilder::weld_tree_view(const OUString
& rId
)
349 QTreeView
* pTreeView
= m_xBuilder
->get
<QTreeView
>(rId
);
350 std::unique_ptr
<weld::TreeView
> xRet(pTreeView
? std::make_unique
<QtInstanceTreeView
>(pTreeView
)
355 std::unique_ptr
<weld::IconView
> QtInstanceBuilder::weld_icon_view(const OUString
& rId
)
357 QListView
* pListView
= m_xBuilder
->get
<QListView
>(rId
);
358 std::unique_ptr
<weld::IconView
> xRet(pListView
? std::make_unique
<QtInstanceIconView
>(pListView
)
363 std::unique_ptr
<weld::Label
> QtInstanceBuilder::weld_label(const OUString
& rId
)
365 QLabel
* pLabel
= m_xBuilder
->get
<QLabel
>(rId
);
366 std::unique_ptr
<weld::Label
> xRet(pLabel
? std::make_unique
<QtInstanceLabel
>(pLabel
) : nullptr);
370 std::unique_ptr
<weld::TextView
> QtInstanceBuilder::weld_text_view(const OUString
& rId
)
372 QPlainTextEdit
* pTextEdit
= m_xBuilder
->get
<QPlainTextEdit
>(rId
);
373 std::unique_ptr
<weld::TextView
> xRet(pTextEdit
? std::make_unique
<QtInstanceTextView
>(pTextEdit
)
378 std::unique_ptr
<weld::Expander
> QtInstanceBuilder::weld_expander(const OUString
& rId
)
380 QtExpander
* pExpander
= m_xBuilder
->get
<QtExpander
>(rId
);
381 std::unique_ptr
<weld::Expander
> xRet(pExpander
? std::make_unique
<QtInstanceExpander
>(pExpander
)
386 std::unique_ptr
<weld::DrawingArea
>
387 QtInstanceBuilder::weld_drawing_area(const OUString
& rId
, const a11yref
&, FactoryFunction
, void*)
389 QLabel
* pLabel
= m_xBuilder
->get
<QLabel
>(rId
);
390 std::unique_ptr
<weld::DrawingArea
> xRet(pLabel
? std::make_unique
<QtInstanceDrawingArea
>(pLabel
)
395 std::unique_ptr
<weld::Menu
> QtInstanceBuilder::weld_menu(const OUString
& rId
)
397 QMenu
* pMenu
= m_xBuilder
->get
<QMenu
>(rId
);
398 std::unique_ptr
<weld::Menu
> xRet(pMenu
? std::make_unique
<QtInstanceMenu
>(pMenu
) : nullptr);
402 std::unique_ptr
<weld::Popover
> QtInstanceBuilder::weld_popover(const OUString
& rId
)
404 QWidget
* pWidget
= m_xBuilder
->get
<QWidget
>(rId
);
405 std::unique_ptr
<weld::Popover
> xRet(pWidget
? std::make_unique
<QtInstancePopover
>(pWidget
)
410 std::unique_ptr
<weld::Toolbar
> QtInstanceBuilder::weld_toolbar(const OUString
& rId
)
412 QToolBar
* pToolBar
= m_xBuilder
->get
<QToolBar
>(rId
);
413 std::unique_ptr
<weld::Toolbar
> xRet(pToolBar
? std::make_unique
<QtInstanceToolbar
>(pToolBar
)
418 std::unique_ptr
<weld::Scrollbar
> QtInstanceBuilder::weld_scrollbar(const OUString
&)
420 assert(false && "Not implemented yet");
424 std::unique_ptr
<weld::SizeGroup
> QtInstanceBuilder::create_size_group()
426 assert(false && "Not implemented yet");
430 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */