2f5acb3545
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
74 lines
2 KiB
C++
74 lines
2 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 <QtExpander.hxx>
|
|
#include <QtExpander.moc>
|
|
|
|
QtExpander::QtExpander(QWidget* pParent)
|
|
: QWidget(pParent)
|
|
, m_pContentWidget(nullptr)
|
|
, m_bExpanded(false)
|
|
{
|
|
m_pLayout = new QGridLayout;
|
|
setLayout(m_pLayout);
|
|
|
|
m_pButton = new QPushButton;
|
|
m_pButton->setFlat(true);
|
|
m_pButton->setSizePolicy(QSizePolicy::Policy::Maximum, QSizePolicy::Policy::Maximum);
|
|
m_pLayout->addWidget(m_pButton, 0, 0);
|
|
m_pLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Policy::MinimumExpanding,
|
|
QSizePolicy::Policy::MinimumExpanding),
|
|
0, 1);
|
|
|
|
update();
|
|
|
|
connect(m_pButton, &QAbstractButton::clicked, this, &QtExpander::handleButtonClick);
|
|
}
|
|
|
|
void QtExpander::setContentWidget(QWidget* pWidget)
|
|
{
|
|
assert(pWidget);
|
|
m_pContentWidget = pWidget;
|
|
m_pLayout->addWidget(m_pContentWidget, 1, 0, 1, 2);
|
|
update();
|
|
}
|
|
|
|
void QtExpander::setText(const QString& rText) { m_pButton->setText(rText); }
|
|
|
|
QString QtExpander::text() const { return m_pButton->text(); }
|
|
|
|
void QtExpander::setExpanded(bool bExpand)
|
|
{
|
|
if (m_bExpanded == bExpand)
|
|
return;
|
|
|
|
m_bExpanded = bExpand;
|
|
update();
|
|
|
|
emit expandedChanged(isExpanded());
|
|
}
|
|
|
|
bool QtExpander::isExpanded() const { return m_bExpanded; }
|
|
|
|
void QtExpander::update()
|
|
{
|
|
const QString sIcon = m_bExpanded ? "go-down" : "go-next";
|
|
m_pButton->setIcon(QIcon::fromTheme(sIcon));
|
|
|
|
if (m_pContentWidget)
|
|
m_pContentWidget->setVisible(m_bExpanded);
|
|
}
|
|
|
|
void QtExpander::handleButtonClick()
|
|
{
|
|
// toggle
|
|
setExpanded(!isExpanded());
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|