office-gobmx/vcl/qt5/QtInstanceDialog.cxx
Michael Weghorn 8f5d8342e4 tdf#130857 qt weld: Move button response prop to QtInstanceDialog
It will be used for QDialog as well, not just QMessageBox

Change-Id: I887b3fe45beea40cc92f2b0b77f316ad73d7f922
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174078
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
2024-09-28 09:35:58 +02:00

97 lines
2.5 KiB
C++

/* -*- 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 <QtInstanceDialog.hxx>
const char* const QtInstanceDialog::PROPERTY_VCL_RESPONSE_CODE = "response-code";
QtInstanceDialog::QtInstanceDialog(QDialog* pDialog)
: QtInstanceWindow(pDialog)
, m_pDialog(pDialog)
{
}
QtInstanceDialog::~QtInstanceDialog()
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pDialog.reset(); });
}
bool QtInstanceDialog::runAsync(std::shared_ptr<Dialog> const&,
const std::function<void(sal_Int32)>&)
{
return true;
}
bool QtInstanceDialog::runAsync(const std::shared_ptr<weld::DialogController>&,
const std::function<void(sal_Int32)>&)
{
return true;
}
void QtInstanceDialog::collapse(weld::Widget*, weld::Widget*) {}
void QtInstanceDialog::undo_collapse() {}
void QtInstanceDialog::SetInstallLOKNotifierHdl(const Link<void*, vcl::ILibreOfficeKitNotifier*>&)
{
}
int QtInstanceDialog::run()
{
SolarMutexGuard g;
QtInstance& rQtInstance = GetQtInstance();
if (!rQtInstance.IsMainThread())
{
int nResult = 0;
rQtInstance.RunInMainThread([&] { nResult = run(); });
return nResult;
}
return qtResponseTypeToVclResponseType(m_pDialog->exec());
}
void QtInstanceDialog::response(int) {}
void QtInstanceDialog::add_button(const OUString&, int, const OUString&) {}
void QtInstanceDialog::set_modal(bool bModal)
{
SolarMutexGuard g;
QtInstance& rQtInstance = GetQtInstance();
if (!rQtInstance.IsMainThread())
{
rQtInstance.RunInMainThread([&] { set_modal(bModal); });
return;
}
m_pDialog->setModal(bModal);
}
bool QtInstanceDialog::get_modal() const
{
SolarMutexGuard g;
QtInstance& rQtInstance = GetQtInstance();
if (!rQtInstance.IsMainThread())
{
bool bModal = false;
rQtInstance.RunInMainThread([&] { bModal = get_modal(); });
return bModal;
}
return m_pDialog->isModal();
}
weld::Button* QtInstanceDialog::weld_widget_for_response(int) { return nullptr; }
void QtInstanceDialog::set_default_response(int) {}
weld::Container* QtInstanceDialog::weld_content_area() { return nullptr; }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */