tdf#130857 qt weld: Introduce QtInstanceScrollbar
Add new class QtInstanceScrollbar as the weld::Scrollbar implementation using a native QScrollBar. QtInstanceScrolledWindow already contains similar logic to what is needed for some of the methods. Extend QtBuilder to create a QScrollBar for "GtkScrollbar" objects. Change-Id: Iccb08659852f216df143e2d4293eead2bc9215f5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182401 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
This commit is contained in:
@@ -40,6 +40,7 @@ $(call gb_CustomTarget_get_target,vcl/qt5) : \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceProgressBar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceRadioButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceScale.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceScrollbar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceScrolledWindow.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceSpinButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt5/QtInstanceTextView.moc \
|
||||
|
||||
@@ -40,6 +40,7 @@ $(call gb_CustomTarget_get_target,vcl/qt6) : \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceProgressBar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceRadioButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceScale.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceScrollbar.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceScrolledWindow.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceSpinButton.moc \
|
||||
$(gb_CustomTarget_workdir)/vcl/qt6/QtInstanceTextView.moc \
|
||||
|
||||
@@ -126,6 +126,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt5,\
|
||||
vcl/qt5/QtInstanceProgressBar \
|
||||
vcl/qt5/QtInstanceRadioButton \
|
||||
vcl/qt5/QtInstanceScale \
|
||||
vcl/qt5/QtInstanceScrollbar \
|
||||
vcl/qt5/QtInstanceScrolledWindow \
|
||||
vcl/qt5/QtInstanceSpinButton \
|
||||
vcl/qt5/QtInstanceTextView \
|
||||
|
||||
@@ -125,6 +125,7 @@ $(eval $(call gb_Library_add_exception_objects,vclplug_qt6,\
|
||||
vcl/qt6/QtInstanceProgressBar \
|
||||
vcl/qt6/QtInstanceRadioButton \
|
||||
vcl/qt6/QtInstanceScale \
|
||||
vcl/qt6/QtInstanceScrollbar \
|
||||
vcl/qt6/QtInstanceScrolledWindow \
|
||||
vcl/qt6/QtInstanceSpinButton \
|
||||
vcl/qt6/QtInstanceTextView \
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
virtual std::unique_ptr<weld::Menu> weld_menu(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::Popover> weld_popover(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::Toolbar> weld_toolbar(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::Scrollbar> weld_scrollbar(const OUString&) override;
|
||||
virtual std::unique_ptr<weld::Scrollbar> weld_scrollbar(const OUString& rId) override;
|
||||
virtual std::unique_ptr<weld::SizeGroup> create_size_group() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -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/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "QtInstanceWidget.hxx"
|
||||
|
||||
#include <QtWidgets/QScrollBar>
|
||||
|
||||
class QtInstanceScrollbar : public QtInstanceWidget, public virtual weld::Scrollbar
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QScrollBar* m_pScrollBar;
|
||||
|
||||
public:
|
||||
QtInstanceScrollbar(QScrollBar* pScrollBar);
|
||||
|
||||
virtual void adjustment_configure(int nValue, int nLower, int nUpper, int nStepIncrement,
|
||||
int nPageIncrement, int nPageSize) override;
|
||||
virtual int adjustment_get_value() const override;
|
||||
virtual void adjustment_set_value(int nValue) override;
|
||||
virtual int adjustment_get_upper() const override;
|
||||
virtual void adjustment_set_upper(int nUpper) override;
|
||||
virtual int adjustment_get_page_size() const override;
|
||||
virtual void adjustment_set_page_size(int nSize) override;
|
||||
virtual int adjustment_get_page_increment() const override;
|
||||
virtual void adjustment_set_page_increment(int nSize) override;
|
||||
virtual int adjustment_get_step_increment() const override;
|
||||
virtual void adjustment_set_step_increment(int nSize) override;
|
||||
virtual int adjustment_get_lower() const override;
|
||||
virtual void adjustment_set_lower(int nLower) override;
|
||||
|
||||
virtual int get_scroll_thickness() const override;
|
||||
virtual void set_scroll_thickness(int nThickness) override;
|
||||
virtual void set_scroll_swap_arrows(bool bSwap) override;
|
||||
|
||||
virtual ScrollType get_scroll_type() const override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void signalValueChanged();
|
||||
};
|
||||
|
||||
/* 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/QtInstanceScrollbar.hxx"
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QtWidgets/QRadioButton>
|
||||
#include <QtWidgets/QScrollArea>
|
||||
#include <QtWidgets/QScrollBar>
|
||||
#include <QtWidgets/QSlider>
|
||||
#include <QtWidgets/QSplitter>
|
||||
#include <QtWidgets/QTabWidget>
|
||||
@@ -314,6 +315,10 @@ QObject* QtBuilder::makeObject(QObject* pParent, std::u16string_view sName, std:
|
||||
extractRadioButtonGroup(sID, rMap);
|
||||
pObject = pRadioButton;
|
||||
}
|
||||
else if (sName == u"GtkScrollbar")
|
||||
{
|
||||
pObject = new QScrollBar(pParentWidget);
|
||||
}
|
||||
else if (sName == u"GtkScrolledWindow")
|
||||
{
|
||||
pObject = new QScrollArea(pParentWidget);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QtInstanceProgressBar.hxx>
|
||||
#include <QtInstanceRadioButton.hxx>
|
||||
#include <QtInstanceScale.hxx>
|
||||
#include <QtInstanceScrollbar.hxx>
|
||||
#include <QtInstanceScrolledWindow.hxx>
|
||||
#include <QtInstanceSpinButton.hxx>
|
||||
#include <QtInstanceTextView.hxx>
|
||||
@@ -456,10 +457,12 @@ std::unique_ptr<weld::Toolbar> QtInstanceBuilder::weld_toolbar(const OUString& r
|
||||
return xRet;
|
||||
}
|
||||
|
||||
std::unique_ptr<weld::Scrollbar> QtInstanceBuilder::weld_scrollbar(const OUString&)
|
||||
std::unique_ptr<weld::Scrollbar> QtInstanceBuilder::weld_scrollbar(const OUString& rId)
|
||||
{
|
||||
assert(false && "Not implemented yet");
|
||||
return nullptr;
|
||||
QScrollBar* pScrollBar = m_xBuilder->get<QScrollBar>(rId);
|
||||
std::unique_ptr<weld::Scrollbar> xRet(
|
||||
pScrollBar ? std::make_unique<QtInstanceScrollbar>(pScrollBar) : nullptr);
|
||||
return xRet;
|
||||
}
|
||||
|
||||
std::unique_ptr<weld::SizeGroup> QtInstanceBuilder::create_size_group()
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
/* -*- 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 <QtInstanceScrollbar.hxx>
|
||||
#include <QtInstanceScrollbar.moc>
|
||||
|
||||
QtInstanceScrollbar::QtInstanceScrollbar(QScrollBar* pScrollBar)
|
||||
: QtInstanceWidget(pScrollBar)
|
||||
, m_pScrollBar(pScrollBar)
|
||||
{
|
||||
assert(m_pScrollBar);
|
||||
|
||||
connect(m_pScrollBar, &QScrollBar::valueChanged, this,
|
||||
&QtInstanceScrollbar::signalValueChanged);
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_configure(int, int, int, int, int, int)
|
||||
{
|
||||
assert(false && "not implemented yet");
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_value() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nValue = 0;
|
||||
GetQtInstance().RunInMainThread([&] { nValue = m_pScrollBar->value(); });
|
||||
|
||||
return nValue;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_value(int nValue)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] { m_pScrollBar->setValue(nValue); });
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_upper() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nMax = 0;
|
||||
GetQtInstance().RunInMainThread([&] { nMax = m_pScrollBar->maximum(); });
|
||||
|
||||
return nMax;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_upper(int nUpper)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] { m_pScrollBar->setMaximum(nUpper); });
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_page_size() const
|
||||
{
|
||||
assert(false && "Not implemented yet");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_page_size(int) { assert(false && "not implemented yet"); }
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_page_increment() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nPageStep = 0;
|
||||
GetQtInstance().RunInMainThread([&] { nPageStep = m_pScrollBar->pageStep(); });
|
||||
|
||||
return nPageStep;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_page_increment(int nSize)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] { m_pScrollBar->setPageStep(nSize); });
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_step_increment() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nSingleStep = 0;
|
||||
GetQtInstance().RunInMainThread([&] { nSingleStep = m_pScrollBar->singleStep(); });
|
||||
|
||||
return nSingleStep;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_step_increment(int nSize)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] { m_pScrollBar->setSingleStep(nSize); });
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::adjustment_get_lower() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nMin = 0;
|
||||
GetQtInstance().RunInMainThread([&] { nMin = m_pScrollBar->minimum(); });
|
||||
|
||||
return nMin;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::adjustment_set_lower(int nLower)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] { m_pScrollBar->setMinimum(nLower); });
|
||||
}
|
||||
|
||||
int QtInstanceScrollbar::get_scroll_thickness() const
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
int nThickness = 0;
|
||||
GetQtInstance().RunInMainThread([&] {
|
||||
if (m_pScrollBar->orientation() == Qt::Horizontal)
|
||||
nThickness = m_pScrollBar->height();
|
||||
else
|
||||
nThickness = m_pScrollBar->width();
|
||||
});
|
||||
|
||||
return nThickness;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::set_scroll_thickness(int nThickness)
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
|
||||
GetQtInstance().RunInMainThread([&] {
|
||||
if (m_pScrollBar->orientation() == Qt::Horizontal)
|
||||
m_pScrollBar->resize(m_pScrollBar->width(), nThickness);
|
||||
else
|
||||
m_pScrollBar->resize(nThickness, m_pScrollBar->height());
|
||||
});
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::set_scroll_swap_arrows(bool) { assert(false && "not implemented yet"); }
|
||||
|
||||
ScrollType QtInstanceScrollbar::get_scroll_type() const
|
||||
{
|
||||
assert(false && "not implemented yet");
|
||||
return ScrollType::DontKnow;
|
||||
}
|
||||
|
||||
void QtInstanceScrollbar::signalValueChanged()
|
||||
{
|
||||
SolarMutexGuard g;
|
||||
signal_adjustment_value_changed();
|
||||
}
|
||||
|
||||
/* 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/QtInstanceScrollbar.cxx"
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
|
||||
Reference in New Issue
Block a user