tdf#130857 qt weld: Add QtInstanceExpander
Add a new QtInstanceExpander class that is the
weld::Expander implementation using a native
Qt widget. It uses the custom QtExpander widget
added in
Change-Id: Id2366834cb542eba613ea087e70f3a812d20fa89
Author: Michael Weghorn <m.weghorn@posteo.de>
Date: Sun Nov 24 00:07:44 2024 +0100
tdf#130857 qt weld: Implement "GtkExpander" equivalent
Extend QtExpander to provide what's needed
to implement the QtInstanceExpander methods.
Let QtInstanceBuilder::weld_expander return an
instance of the new class.
Signal handling still needs to be implemented
(calling `weld::Expander::signal_expanded` when
the expanded state is toggled).
QtInstanceExpander is e.g. needed by the "Set Password"
dialog. ("File" -> "Save As", check "Save with password"
checkbox and press "Save" to trigger the dialog.)
Change-Id: I7e3a332c0417b1897ae57d7d4c29609245fb5e19
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/177197
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -21,6 +21,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDialog.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceDrawingArea.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceEntry.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceExpander.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLevelBar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceLinkButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceMessageDialog.moc \
|
||||
|
||||
@@ -21,6 +21,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDialog.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceDrawingArea.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceEntry.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceExpander.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLevelBar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceLinkButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceMessageDialog.moc \
|
||||
|
||||
@@ -106,6 +106,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
|
||||
vcl/qt5/QtInstanceDialog \
|
||||
vcl/qt5/QtInstanceDrawingArea \
|
||||
vcl/qt5/QtInstanceEntry \
|
||||
vcl/qt5/QtInstanceExpander \
|
||||
vcl/qt5/QtInstanceFrame \
|
||||
vcl/qt5/QtInstanceImage \
|
||||
vcl/qt5/QtInstanceLabel \
|
||||
|
||||
@@ -105,6 +105,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
|
||||
vcl/qt6/QtInstanceDialog \
|
||||
vcl/qt6/QtInstanceDrawingArea \
|
||||
vcl/qt6/QtInstanceEntry \
|
||||
vcl/qt6/QtInstanceExpander \
|
||||
vcl/qt6/QtInstanceFrame \
|
||||
vcl/qt6/QtInstanceImage \
|
||||
vcl/qt6/QtInstanceLabel \
|
||||
|
||||
@@ -25,7 +25,12 @@ class QtExpander : public QWidget
|
||||
public:
|
||||
QtExpander(QWidget* pParent);
|
||||
void setContentWidget(QWidget* pWidget);
|
||||
|
||||
void setText(const QString& rText);
|
||||
QString text() const;
|
||||
|
||||
void setExpanded(bool bExpand);
|
||||
bool isExpanded() const;
|
||||
|
||||
private:
|
||||
void update();
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
virtual std::unique_ptr<weld::IconView> weld_icon_view(const OUString&) override;
|
||||
virtual std::unique_ptr<weld::Label> weld_label(const OUString&) override;
|
||||
virtual std::unique_ptr<weld::TextView> weld_text_view(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::Expander> weld_expander(const OUString&) override;
|
||||
virtual std::unique_ptr<weld::Expander> weld_expander(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::DrawingArea>
|
||||
weld_drawing_area(const OUString&, const a11yref& rA11yImpl = nullptr,
|
||||
FactoryFunction pUITestFactoryFunction = nullptr,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/* -*- 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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QtInstanceWidget.hxx"
|
||||
#include "QtExpander.hxx"
|
||||
|
||||
class QtInstanceExpander : public QObject, public QtInstanceWidget, public virtual weld::Expander
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QtExpander* m_pExpander;
|
||||
|
||||
public:
|
||||
QtInstanceExpander(QtExpander* pExpander);
|
||||
|
||||
virtual void set_label(const OUString& rText);
|
||||
virtual OUString get_label() const;
|
||||
virtual bool get_expanded() const;
|
||||
virtual void set_expanded(bool bExpand);
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
@@ -0,0 +1,12 @@
|
||||
/* -*- 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 "../qt5/QtInstanceExpander.hxx"
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
+11
-2
@@ -41,6 +41,16 @@ void QtExpander::setContentWidget(QWidget* pWidget)
|
||||
|
||||
void QtExpander::setText(const QString& rText) { m_pButton->setText(rText); }
|
||||
|
||||
QString QtExpander::text() const { return m_pButton->text(); }
|
||||
|
||||
void QtExpander::setExpanded(bool bExpand)
|
||||
{
|
||||
m_bExpanded = bExpand;
|
||||
update();
|
||||
}
|
||||
|
||||
bool QtExpander::isExpanded() const { return m_bExpanded; }
|
||||
|
||||
void QtExpander::update()
|
||||
{
|
||||
const QString sIcon = m_bExpanded ? "go-down" : "go-next";
|
||||
@@ -53,8 +63,7 @@ void QtExpander::update()
|
||||
void QtExpander::handleButtonClick()
|
||||
{
|
||||
// toggle
|
||||
m_bExpanded = !m_bExpanded;
|
||||
update();
|
||||
setExpanded(!isExpanded());
|
||||
}
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <QtInstanceComboBox.hxx>
|
||||
#include <QtInstanceDrawingArea.hxx>
|
||||
#include <QtInstanceEntry.hxx>
|
||||
#include <QtInstanceExpander.hxx>
|
||||
#include <QtInstanceFrame.hxx>
|
||||
#include <QtInstanceImage.hxx>
|
||||
#include <QtInstanceLabel.hxx>
|
||||
@@ -329,10 +330,12 @@ std::unique_ptr<weld::TextView> QtInstanceBuilder::weld_text_view(const OUString
|
||||
return xRet;
|
||||
}
|
||||
|
||||
std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString&)
|
||||
std::unique_ptr<weld::Expander> QtInstanceBuilder::weld_expander(const OUString& rId)
|
||||
{
|
||||
assert(false && "Not implemented yet");
|
||||
return nullptr;
|
||||
QtExpander* pExpander = m_xBuilder->get<QtExpander>(rId);
|
||||
std::unique_ptr<weld::Expander> xRet(pExpander ? std::make_unique<QtInstanceExpander>(pExpander)
|
||||
: nullptr);
|
||||
return xRet;
|
||||
}
|
||||
|
||||
std::unique_ptr<weld::DrawingArea>
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* -*- 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);
|
||||
}
|
||||
|
||||
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: */
|
||||
@@ -0,0 +1,12 @@
|
||||
/* -*- 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 "../qt5/QtInstanceExpander.cxx"
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
Reference in New Issue
Block a user