Kaydet (Commit) 5fe23055 authored tarafından Michael Weghorn's avatar Michael Weghorn Kaydeden (comit) Katarina Behrens

kde5 fpicker: Reuse parent class member to store custom widgets

Directly access member 'm_pExtraControls' from parent class
Qt5FilePicker for managing custom widgets, rather than maintaining
an own one.

This is meant as an intermediate step, further refactoring will
follow.

Change-Id: I0568d3db68dc24042e198d36f4b5e49608f93a0e
Reviewed-on: https://gerrit.libreoffice.org/68055
Tested-by: Jenkins
Reviewed-by: 's avatarKatarina Behrens <Katarina.Behrens@cib.de>
(cherry picked from commit 2bd0400a)
Reviewed-on: https://gerrit.libreoffice.org/72652
üst e4a1c8ec
...@@ -54,9 +54,6 @@ protected: ...@@ -54,9 +54,6 @@ protected:
QHash<sal_Int16, QWidget*> _customWidgets; QHash<sal_Int16, QWidget*> _customWidgets;
QHash<sal_Int16, QWidget*> _customListboxes; QHash<sal_Int16, QWidget*> _customListboxes;
//widget to contain extra custom controls
QWidget* _extraControls;
//layout for extra custom controls //layout for extra custom controls
QGridLayout* _layout; QGridLayout* _layout;
...@@ -64,7 +61,6 @@ protected: ...@@ -64,7 +61,6 @@ protected:
public: public:
explicit KDE5FilePicker(QFileDialog::FileMode); explicit KDE5FilePicker(QFileDialog::FileMode);
virtual ~KDE5FilePicker() override;
// XExecutableDialog functions // XExecutableDialog functions
virtual sal_Int16 SAL_CALL execute() override; virtual sal_Int16 SAL_CALL execute() override;
......
...@@ -82,8 +82,7 @@ uno::Sequence<OUString> FilePicker_getSupportedServiceNames() ...@@ -82,8 +82,7 @@ uno::Sequence<OUString> FilePicker_getSupportedServiceNames()
KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode) KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
// Native kde5 filepicker does not add file extension automatically // Native kde5 filepicker does not add file extension automatically
: Qt5FilePicker(eMode, true) : Qt5FilePicker(eMode, true)
, _extraControls(new QWidget) , _layout(new QGridLayout(m_pExtraControls))
, _layout(new QGridLayout(_extraControls))
, allowRemoteUrls(false) , allowRemoteUrls(false)
{ {
// use native dialog // use native dialog
...@@ -118,8 +117,6 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode) ...@@ -118,8 +117,6 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
qApp->installEventFilter(this); qApp->installEventFilter(this);
} }
KDE5FilePicker::~KDE5FilePicker() { delete _extraControls; }
sal_Int16 SAL_CALL KDE5FilePicker::execute() sal_Int16 SAL_CALL KDE5FilePicker::execute()
{ {
if (qApp->thread() != QThread::currentThread()) if (qApp->thread() != QThread::currentThread())
...@@ -326,7 +323,7 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId) ...@@ -326,7 +323,7 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId)
// code, but the checkbox is hidden and ignored // code, but the checkbox is hidden and ignored
bool hidden = controlId == CHECKBOX_AUTOEXTENSION; bool hidden = controlId == CHECKBOX_AUTOEXTENSION;
auto widget = new QCheckBox(resString, _extraControls); auto widget = new QCheckBox(resString, m_pExtraControls);
widget->setHidden(hidden); widget->setHidden(hidden);
if (!hidden) if (!hidden)
{ {
...@@ -349,7 +346,7 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId) ...@@ -349,7 +346,7 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId)
case LISTBOX_TEMPLATE: case LISTBOX_TEMPLATE:
case LISTBOX_VERSION: case LISTBOX_VERSION:
{ {
auto widget = new QComboBox(_extraControls); auto widget = new QComboBox(m_pExtraControls);
QLabel* label = new QLabel(resString); QLabel* label = new QLabel(resString);
label->setBuddy(widget); label->setBuddy(widget);
...@@ -508,7 +505,7 @@ bool KDE5FilePicker::eventFilter(QObject* o, QEvent* e) ...@@ -508,7 +505,7 @@ bool KDE5FilePicker::eventFilter(QObject* o, QEvent* e)
{ {
if (auto* fileWidget = w->findChild<KFileWidget*>({}, Qt::FindDirectChildrenOnly)) if (auto* fileWidget = w->findChild<KFileWidget*>({}, Qt::FindDirectChildrenOnly))
{ {
fileWidget->setCustomWidget(_extraControls); fileWidget->setCustomWidget(m_pExtraControls);
// remove event filter again; the only purpose was to set the custom widget here // remove event filter again; the only purpose was to set the custom widget here
qApp->removeEventFilter(this); qApp->removeEventFilter(this);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment