office-gobmx/vcl/qt5/QtInstanceExpander.cxx
Michael Weghorn 2f5acb3545 tdf#130857 qt weld: Notify about Expander state change
Call weld::Expander::signal_expanded when the
QtExpander expanded state changes, e.g. when
its button gets clicked.

In order to do that, introduce a signal in
QtExpander and connect to that in
QtInstanceExpander.

With this in place, a breakpoint in
weld::Expander::signal_expanded now gets
hit as expected when (un)expanding the
expander in the "Set Password" dialog triggered in Writer
using "File" -> "Save As", check "Save with password"
checkbox and press "Save" when using the qt6 VCL
plugin with SAL_VCL_QT_USE_WELDED_WIDGETS=1 set.

This implements what was mentioned as still
missing in earlier commit

    Change-Id: I7e3a332c0417b1897ae57d7d4c29609245fb5e19
    Author: Michael Weghorn <m.weghorn@posteo.de>
    Date:   Sun Nov 24 01:20:31 2024 +0100

        tdf#130857 qt weld: Add QtInstanceExpander

as

> Signal handling still needs to be implemented
> (calling `weld::Expander::signal_expanded` when
> the expanded state is toggled).

Change-Id: I9cd1b2cc99018f84ba930d55399953266119bed0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177199
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Tested-by: Jenkins
2024-11-24 17:05:02 +01:00

52 lines
1.5 KiB
C++

/* -*- 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 <QtInstanceExpander.hxx>
#include <QtInstanceExpander.moc>
#include <vcl/qt/QtUtils.hxx>
QtInstanceExpander::QtInstanceExpander(QtExpander* pExpander)
: QtInstanceWidget(pExpander)
, m_pExpander(pExpander)
{
assert(m_pExpander);
connect(m_pExpander, &QtExpander::expandedChanged, this, [&] { signal_expanded(); });
}
void QtInstanceExpander::set_label(const OUString& rText)
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pExpander->setText(toQString(rText)); });
}
OUString QtInstanceExpander::get_label() const
{
SolarMutexGuard g;
OUString sLabel;
GetQtInstance().RunInMainThread([&] { sLabel = toOUString(m_pExpander->text()); });
return sLabel;
}
bool QtInstanceExpander::get_expanded() const
{
SolarMutexGuard g;
bool bExpanded = false;
GetQtInstance().RunInMainThread([&] { bExpanded = m_pExpander->isExpanded(); });
return bExpanded;
}
void QtInstanceExpander::set_expanded(bool bExpand)
{
SolarMutexGuard g;
GetQtInstance().RunInMainThread([&] { m_pExpander->setExpanded(bExpand); });
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */