2024-09-18 09:35:09 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* 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 <QtInstanceBuilder.hxx>
|
|
|
|
|
|
|
|
#include <unordered_set>
|
|
|
|
|
2024-09-25 09:48:09 +02:00
|
|
|
#include <QtBuilder.hxx>
|
2024-10-02 17:36:21 +02:00
|
|
|
#include <QtInstanceCheckButton.hxx>
|
2024-10-22 18:19:45 +02:00
|
|
|
#include <QtInstanceComboBox.hxx>
|
2024-10-04 16:36:16 +02:00
|
|
|
#include <QtInstanceEntry.hxx>
|
2024-10-25 10:04:10 +02:00
|
|
|
#include <QtInstanceFrame.hxx>
|
2024-10-25 20:26:15 +02:00
|
|
|
#include <QtInstanceImage.hxx>
|
2024-10-01 23:10:42 +02:00
|
|
|
#include <QtInstanceLabel.hxx>
|
2024-10-25 20:41:48 +02:00
|
|
|
#include <QtInstanceLinkButton.hxx>
|
2024-09-25 09:48:09 +02:00
|
|
|
#include <QtInstanceMessageDialog.hxx>
|
2024-10-25 13:21:55 +02:00
|
|
|
#include <QtInstanceRadioButton.hxx>
|
2024-10-04 16:54:31 +02:00
|
|
|
#include <QtInstanceTextView.hxx>
|
2024-09-25 09:48:09 +02:00
|
|
|
|
|
|
|
QtInstanceBuilder::QtInstanceBuilder(QWidget* pParent, std::u16string_view sUIRoot,
|
|
|
|
const OUString& rUIFile)
|
|
|
|
: m_xBuilder(std::make_unique<QtBuilder>(pParent, sUIRoot, rUIFile))
|
|
|
|
{
|
|
|
|
}
|
2024-09-18 09:35:09 +02:00
|
|
|
|
|
|
|
QtInstanceBuilder::~QtInstanceBuilder() {}
|
|
|
|
|
|
|
|
bool QtInstanceBuilder::IsUIFileSupported(const OUString& rUIFile)
|
|
|
|
{
|
2024-09-25 09:48:09 +02:00
|
|
|
// set of supported UI files
|
2024-09-18 09:35:09 +02:00
|
|
|
//
|
2024-09-18 21:26:05 +02:00
|
|
|
// The idea is to implement functionality needed for a specific UI file/dialog
|
2024-09-18 09:35:09 +02:00
|
|
|
// 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.
|
2024-09-25 09:48:09 +02:00
|
|
|
static std::unordered_set<OUString> aSupportedUIFiles = {
|
2024-10-29 07:00:09 +01:00
|
|
|
u"cui/ui/aboutdialog.ui"_ustr,
|
2024-10-24 12:38:18 +02:00
|
|
|
u"cui/ui/optnewdictionarydialog.ui"_ustr,
|
2024-10-29 15:28:29 +01:00
|
|
|
u"cui/ui/querysetinsmodedialog.ui"_ustr,
|
2024-10-29 19:58:18 +01:00
|
|
|
u"cui/ui/securityoptionsdialog.ui"_ustr,
|
2024-10-18 21:41:38 +02:00
|
|
|
u"modules/scalc/ui/inputstringdialog.ui"_ustr,
|
2024-10-29 20:16:06 +01:00
|
|
|
u"modules/scalc/ui/selectsource.ui"_ustr,
|
2024-10-04 10:53:28 +02:00
|
|
|
u"modules/schart/ui/insertaxisdlg.ui"_ustr,
|
2024-10-25 13:43:09 +02:00
|
|
|
u"modules/smath/ui/alignmentdialog.ui"_ustr,
|
2024-09-25 09:48:09 +02:00
|
|
|
u"modules/swriter/ui/inforeadonlydialog.ui"_ustr,
|
2024-10-25 10:41:45 +02:00
|
|
|
u"modules/swriter/ui/renameobjectdialog.ui"_ustr,
|
2024-10-21 18:42:40 +02:00
|
|
|
u"modules/swriter/ui/wordcount.ui"_ustr,
|
2024-09-28 00:43:21 +02:00
|
|
|
u"sfx/ui/licensedialog.ui"_ustr,
|
2024-09-25 12:28:52 +02:00
|
|
|
u"sfx/ui/querysavedialog.ui"_ustr,
|
2024-10-23 22:32:50 +02:00
|
|
|
u"svt/ui/printersetupdialog.ui"_ustr,
|
2024-10-18 15:08:00 +02:00
|
|
|
u"svt/ui/restartdialog.ui"_ustr,
|
2024-10-25 10:08:35 +02:00
|
|
|
u"writerperfect/ui/exportepub.ui"_ustr,
|
2024-09-25 09:48:09 +02:00
|
|
|
};
|
2024-09-18 09:35:09 +02:00
|
|
|
|
|
|
|
return aSupportedUIFiles.contains(rUIFile);
|
|
|
|
}
|
|
|
|
|
2024-09-25 09:48:09 +02:00
|
|
|
std::unique_ptr<weld::MessageDialog> QtInstanceBuilder::weld_message_dialog(const OUString& id)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-09-25 09:48:09 +02:00
|
|
|
QMessageBox* pMessageBox = m_xBuilder->get<QMessageBox>(id);
|
|
|
|
std::unique_ptr<weld::MessageDialog> xRet(
|
|
|
|
pMessageBox ? std::make_unique<QtInstanceMessageDialog>(pMessageBox) : nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
2024-09-28 00:07:28 +02:00
|
|
|
std::unique_ptr<weld::Dialog> QtInstanceBuilder::weld_dialog(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-09-28 00:07:28 +02:00
|
|
|
QDialog* pDialog = m_xBuilder->get<QDialog>(rId);
|
|
|
|
std::unique_ptr<weld::Dialog> xRet(pDialog ? std::make_unique<QtInstanceDialog>(pDialog)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Assistant> QtInstanceBuilder::weld_assistant(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Window> QtInstanceBuilder::create_screenshot_window()
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-11 22:25:34 +02:00
|
|
|
std::unique_ptr<weld::Widget> QtInstanceBuilder::weld_widget(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-11 22:25:34 +02:00
|
|
|
QWidget* pWidget = m_xBuilder->get<QWidget>(rId);
|
|
|
|
std::unique_ptr<weld::Widget> xRet(pWidget ? std::make_unique<QtInstanceWidget>(pWidget)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Container> QtInstanceBuilder::weld_container(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Box> QtInstanceBuilder::weld_box(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Paned> QtInstanceBuilder::weld_paned(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 10:04:10 +02:00
|
|
|
std::unique_ptr<weld::Frame> QtInstanceBuilder::weld_frame(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-25 10:04:10 +02:00
|
|
|
QGroupBox* pGroupBox = m_xBuilder->get<QGroupBox>(rId);
|
|
|
|
std::unique_ptr<weld::Frame> xRet(pGroupBox ? std::make_unique<QtInstanceFrame>(pGroupBox)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::ScrolledWindow> QtInstanceBuilder::weld_scrolled_window(const OUString&, bool)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Notebook> QtInstanceBuilder::weld_notebook(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-11 22:20:45 +02:00
|
|
|
std::unique_ptr<weld::Button> QtInstanceBuilder::weld_button(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-11 22:20:45 +02:00
|
|
|
QPushButton* pButton = m_xBuilder->get<QPushButton>(rId);
|
|
|
|
std::unique_ptr<weld::Button> xRet(pButton ? std::make_unique<QtInstanceButton>(pButton)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::MenuButton> QtInstanceBuilder::weld_menu_button(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::MenuToggleButton> QtInstanceBuilder::weld_menu_toggle_button(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 20:41:48 +02:00
|
|
|
std::unique_ptr<weld::LinkButton> QtInstanceBuilder::weld_link_button(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-25 20:41:48 +02:00
|
|
|
QtHyperlinkLabel* pLabel = m_xBuilder->get<QtHyperlinkLabel>(rId);
|
|
|
|
std::unique_ptr<weld::LinkButton> xRet(pLabel ? std::make_unique<QtInstanceLinkButton>(pLabel)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::ToggleButton> QtInstanceBuilder::weld_toggle_button(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 13:21:55 +02:00
|
|
|
std::unique_ptr<weld::RadioButton> QtInstanceBuilder::weld_radio_button(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-25 13:21:55 +02:00
|
|
|
QRadioButton* pRadioButton = m_xBuilder->get<QRadioButton>(rId);
|
|
|
|
std::unique_ptr<weld::RadioButton> xRet(
|
|
|
|
pRadioButton ? std::make_unique<QtInstanceRadioButton>(pRadioButton) : nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
2024-10-02 17:36:21 +02:00
|
|
|
std::unique_ptr<weld::CheckButton> QtInstanceBuilder::weld_check_button(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-02 17:36:21 +02:00
|
|
|
QCheckBox* pCheckBox = m_xBuilder->get<QCheckBox>(rId);
|
|
|
|
std::unique_ptr<weld::CheckButton> xRet(
|
|
|
|
pCheckBox ? std::make_unique<QtInstanceCheckButton>(pCheckBox) : nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Scale> QtInstanceBuilder::weld_scale(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::ProgressBar> QtInstanceBuilder::weld_progress_bar(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::LevelBar> QtInstanceBuilder::weld_level_bar(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Spinner> QtInstanceBuilder::weld_spinner(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-25 20:26:15 +02:00
|
|
|
std::unique_ptr<weld::Image> QtInstanceBuilder::weld_image(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-25 20:26:15 +02:00
|
|
|
QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
|
|
|
|
std::unique_ptr<weld::Image> xRet(pLabel ? std::make_unique<QtInstanceImage>(pLabel) : nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Calendar> QtInstanceBuilder::weld_calendar(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-04 16:36:16 +02:00
|
|
|
std::unique_ptr<weld::Entry> QtInstanceBuilder::weld_entry(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-04 16:36:16 +02:00
|
|
|
QLineEdit* pLineEdit = m_xBuilder->get<QLineEdit>(rId);
|
|
|
|
std::unique_ptr<weld::Entry> xRet(pLineEdit ? std::make_unique<QtInstanceEntry>(pLineEdit)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::SpinButton> QtInstanceBuilder::weld_spin_button(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::MetricSpinButton> QtInstanceBuilder::weld_metric_spin_button(const OUString&,
|
|
|
|
FieldUnit)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::FormattedSpinButton>
|
|
|
|
QtInstanceBuilder::weld_formatted_spin_button(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-22 18:19:45 +02:00
|
|
|
std::unique_ptr<weld::ComboBox> QtInstanceBuilder::weld_combo_box(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-22 18:19:45 +02:00
|
|
|
QComboBox* pComboBox = m_xBuilder->get<QComboBox>(rId);
|
|
|
|
std::unique_ptr<weld::ComboBox> xRet(pComboBox ? std::make_unique<QtInstanceComboBox>(pComboBox)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::EntryTreeView>
|
|
|
|
QtInstanceBuilder::weld_entry_tree_view(const OUString&, const OUString&, const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::TreeView> QtInstanceBuilder::weld_tree_view(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::IconView> QtInstanceBuilder::weld_icon_view(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2024-10-01 23:10:42 +02:00
|
|
|
std::unique_ptr<weld::Label> QtInstanceBuilder::weld_label(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-01 23:10:42 +02:00
|
|
|
QLabel* pLabel = m_xBuilder->get<QLabel>(rId);
|
|
|
|
std::unique_ptr<weld::Label> xRet(pLabel ? std::make_unique<QtInstanceLabel>(pLabel) : nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
2024-10-04 16:54:31 +02:00
|
|
|
std::unique_ptr<weld::TextView> QtInstanceBuilder::weld_text_view(const OUString& rId)
|
2024-09-18 09:35:09 +02:00
|
|
|
{
|
2024-10-04 16:54:31 +02:00
|
|
|
QPlainTextEdit* pTextEdit = m_xBuilder->get<QPlainTextEdit>(rId);
|
|
|
|
std::unique_ptr<weld::TextView> xRet(pTextEdit ? std::make_unique<QtInstanceTextView>(pTextEdit)
|
|
|
|
: nullptr);
|
|
|
|
return xRet;
|
2024-09-18 09:35:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::DrawingArea>
|
|
|
|
QtInstanceBuilder::weld_drawing_area(const OUString&, const a11yref&, FactoryFunction, void*)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Menu> QtInstanceBuilder::weld_menu(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Popover> QtInstanceBuilder::weld_popover(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Toolbar> QtInstanceBuilder::weld_toolbar(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::Scrollbar> QtInstanceBuilder::weld_scrollbar(const OUString&)
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unique_ptr<weld::SizeGroup> QtInstanceBuilder::create_size_group()
|
|
|
|
{
|
|
|
|
assert(false && "Not implemented yet");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|