/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include QtInstanceBuilder::QtInstanceBuilder(QWidget* pParent, std::u16string_view sUIRoot, const OUString& rUIFile) : m_xBuilder(std::make_unique(pParent, sUIRoot, rUIFile)) { } QtInstanceBuilder::~QtInstanceBuilder() {} bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile) { // set of supported UI files // // The idea is to implement functionality needed for a specific UI file/dialog // in QtInstanceBuilder, then add it to the set of supported UI files here. // This allows looking at one .ui file at a time and only having to implement // what is relevant for that particular one, without having to implement the full // weld API at once. static std::unordered_set aSupportedUIFiles = { u"cui/ui/aboutdialog.ui"_ustr, u"cui/ui/insertrowcolumn.ui"_ustr, u"cui/ui/objecttitledescdialog.ui"_ustr, u"cui/ui/optnewdictionarydialog.ui"_ustr, u"cui/ui/password.ui"_ustr, u"cui/ui/pastespecial.ui"_ustr, u"cui/ui/qrcodegen.ui"_ustr, u"cui/ui/querysetinsmodedialog.ui"_ustr, u"cui/ui/securityoptionsdialog.ui"_ustr, u"cui/ui/splitcellsdialog.ui"_ustr, u"cui/ui/tipofthedaydialog.ui"_ustr, u"cui/ui/toolbarmodedialog.ui"_ustr, u"modules/scalc/ui/inputstringdialog.ui"_ustr, u"modules/scalc/ui/insertcells.ui"_ustr, u"modules/scalc/ui/selectsource.ui"_ustr, u"modules/scalc/ui/showsheetdialog.ui"_ustr, u"modules/schart/ui/insertaxisdlg.ui"_ustr, u"modules/smath/ui/alignmentdialog.ui"_ustr, u"modules/swriter/ui/authenticationsettingsdialog.ui"_ustr, u"modules/swriter/ui/endnotepage.ui"_ustr, u"modules/swriter/ui/footendnotedialog.ui"_ustr, u"modules/swriter/ui/footnotepage.ui"_ustr, u"modules/swriter/ui/inforeadonlydialog.ui"_ustr, u"modules/swriter/ui/insertbreak.ui"_ustr, u"modules/swriter/ui/renameobjectdialog.ui"_ustr, u"modules/swriter/ui/splittable.ui"_ustr, u"modules/swriter/ui/wordcount.ui"_ustr, u"sfx/ui/helpmanual.ui"_ustr, u"sfx/ui/licensedialog.ui"_ustr, u"sfx/ui/password.ui"_ustr, u"sfx/ui/querysavedialog.ui"_ustr, u"sfx/ui/safemodequerydialog.ui"_ustr, u"svt/ui/printersetupdialog.ui"_ustr, u"svt/ui/restartdialog.ui"_ustr, u"svx/ui/compressgraphicdialog.ui"_ustr, u"svx/ui/gotopagedialog.ui"_ustr, u"svx/ui/safemodedialog.ui"_ustr, u"vcl/ui/openlockedquerybox.ui"_ustr, u"vcl/ui/printerdevicepage.ui"_ustr, u"vcl/ui/printerpaperpage.ui"_ustr, u"vcl/ui/printerpropertiesdialog.ui"_ustr, u"vcl/ui/printprogressdialog.ui"_ustr, u"writerperfect/ui/exportepub.ui"_ustr, }; return aSupportedUIFiles.contains(rUIFile); } std::unique_ptr QtInstanceBuilder::weld_message_dialog(const OUString& id) { QMessageBox* pMessageBox = m_xBuilder->get(id); std::unique_ptr xRet( pMessageBox ? std::make_unique(pMessageBox) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_dialog(const OUString& rId) { QDialog* pDialog = m_xBuilder->get(rId); std::unique_ptr xRet(pDialog ? std::make_unique(pDialog) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_assistant(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::create_screenshot_window() { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_widget(const OUString& rId) { QWidget* pWidget = m_xBuilder->get(rId); std::unique_ptr xRet(pWidget ? std::make_unique(pWidget) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_container(const OUString& rId) { QWidget* pWidget = m_xBuilder->get(rId); if (!pWidget) return nullptr; assert(pWidget->layout() && "no layout"); return std::make_unique(pWidget); } std::unique_ptr QtInstanceBuilder::weld_box(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_grid(const OUString& rId) { QWidget* pWidget = m_xBuilder->get(rId); if (!pWidget) return nullptr; assert(qobject_cast(pWidget->layout()) && "no grid layout"); return std::make_unique(pWidget); } std::unique_ptr QtInstanceBuilder::weld_paned(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_frame(const OUString& rId) { QGroupBox* pGroupBox = m_xBuilder->get(rId); std::unique_ptr xRet(pGroupBox ? std::make_unique(pGroupBox) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_scrolled_window(const OUString& rId, bool) { QScrollArea* pScrollArea = m_xBuilder->get(rId); std::unique_ptr xRet( pScrollArea ? std::make_unique(pScrollArea) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_notebook(const OUString& rId) { QTabWidget* pTabWidget = m_xBuilder->get(rId); std::unique_ptr xRet( pTabWidget ? std::make_unique(pTabWidget) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_button(const OUString& rId) { QPushButton* pButton = m_xBuilder->get(rId); std::unique_ptr xRet(pButton ? std::make_unique(pButton) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_menu_button(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_menu_toggle_button(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_link_button(const OUString& rId) { QtHyperlinkLabel* pLabel = m_xBuilder->get(rId); std::unique_ptr xRet(pLabel ? std::make_unique(pLabel) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_toggle_button(const OUString& rId) { QAbstractButton* pButton = m_xBuilder->get(rId); std::unique_ptr xRet( pButton ? std::make_unique(pButton) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_radio_button(const OUString& rId) { QRadioButton* pRadioButton = m_xBuilder->get(rId); std::unique_ptr xRet( pRadioButton ? std::make_unique(pRadioButton) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_check_button(const OUString& rId) { QCheckBox* pCheckBox = m_xBuilder->get(rId); std::unique_ptr xRet( pCheckBox ? std::make_unique(pCheckBox) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_scale(const OUString& rId) { QSlider* pSlider = m_xBuilder->get(rId); std::unique_ptr xRet(pSlider ? std::make_unique(pSlider) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_progress_bar(const OUString& rId) { QProgressBar* pProgressBar = m_xBuilder->get(rId); std::unique_ptr xRet( pProgressBar ? std::make_unique(pProgressBar) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_level_bar(const OUString& rId) { QProgressBar* pProgressBar = m_xBuilder->get(rId); std::unique_ptr xRet( pProgressBar ? std::make_unique(pProgressBar) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_spinner(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_image(const OUString& rId) { QLabel* pLabel = m_xBuilder->get(rId); std::unique_ptr xRet(pLabel ? std::make_unique(pLabel) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_calendar(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_entry(const OUString& rId) { QLineEdit* pLineEdit = m_xBuilder->get(rId); std::unique_ptr xRet(pLineEdit ? std::make_unique(pLineEdit) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_spin_button(const OUString& rId) { QtDoubleSpinBox* pSpinBox = m_xBuilder->get(rId); std::unique_ptr xRet( pSpinBox ? std::make_unique(pSpinBox) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_metric_spin_button(const OUString&, FieldUnit) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_formatted_spin_button(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_combo_box(const OUString& rId) { QComboBox* pComboBox = m_xBuilder->get(rId); std::unique_ptr xRet(pComboBox ? std::make_unique(pComboBox) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_entry_tree_view(const OUString&, const OUString&, const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_tree_view(const OUString& rId) { QTreeView* pTreeView = m_xBuilder->get(rId); std::unique_ptr xRet(pTreeView ? std::make_unique(pTreeView) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_icon_view(const OUString& rId) { QListView* pListView = m_xBuilder->get(rId); std::unique_ptr xRet(pListView ? std::make_unique(pListView) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_label(const OUString& rId) { QLabel* pLabel = m_xBuilder->get(rId); std::unique_ptr xRet(pLabel ? std::make_unique(pLabel) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_text_view(const OUString& rId) { QPlainTextEdit* pTextEdit = m_xBuilder->get(rId); std::unique_ptr xRet(pTextEdit ? std::make_unique(pTextEdit) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_expander(const OUString& rId) { QtExpander* pExpander = m_xBuilder->get(rId); std::unique_ptr xRet(pExpander ? std::make_unique(pExpander) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_drawing_area(const OUString& rId, const a11yref&, FactoryFunction, void*) { QLabel* pLabel = m_xBuilder->get(rId); std::unique_ptr xRet(pLabel ? std::make_unique(pLabel) : nullptr); return xRet; } std::unique_ptr QtInstanceBuilder::weld_menu(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_popover(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_toolbar(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::weld_scrollbar(const OUString&) { assert(false && "Not implemented yet"); return nullptr; } std::unique_ptr QtInstanceBuilder::create_size_group() { assert(false && "Not implemented yet"); return nullptr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */