vcl/unx/kde5/KDE5FilePicker.hxx | 4 + vcl/unx/kde5/KDE5FilePicker2.cxx | 91 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 94 insertions(+), 1 deletion(-)
New commits: commit c41adbca85969efd8442abf3b593118e1256efb6 Author: Katarina Behrens <katarina.behr...@cib.de> AuthorDate: Mon Jan 21 22:12:15 2019 +0100 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Mon Jan 28 16:05:09 2019 +0100 tdf#121129: custom listboxes in kde5 fpicker, first stab for FILESAVE_AUTOEXTENSION_TEMPLATE only so far (e.g. menu Insert > Image) Change-Id: I5674025788ce9bab4094f717e2b940e7cd6891e3 Reviewed-on: https://gerrit.libreoffice.org/66705 Tested-by: Jenkins Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de> (cherry picked from commit 2d33c7cb4b4835de77194650124a1cf046920f66) Reviewed-on: https://gerrit.libreoffice.org/66758 Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/vcl/unx/kde5/KDE5FilePicker.hxx b/vcl/unx/kde5/KDE5FilePicker.hxx index 8179170e831d..b3293b32a1b7 100644 --- a/vcl/unx/kde5/KDE5FilePicker.hxx +++ b/vcl/unx/kde5/KDE5FilePicker.hxx @@ -43,6 +43,7 @@ class QFileDialog; class QGridLayout; class QWidget; +class QComboBox; typedef ::cppu::WeakComponentImplHelper<css::ui::dialogs::XFilePicker3, css::ui::dialogs::XFilePickerControlAccess, @@ -71,6 +72,7 @@ protected: //mapping of SAL control ID's to created custom controls QHash<sal_Int16, QWidget*> _customWidgets; + QHash<sal_Int16, QWidget*> _customListboxes; //widget to contain extra custom controls QWidget* _extraControls; @@ -157,6 +159,8 @@ public: private: //add a custom control widget to the file dialog void addCustomControl(sal_Int16 controlId); + void handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction, const css::uno::Any& rValue); + css::uno::Any handleGetListValue(QComboBox* pQComboBox, sal_Int16 nAction); OUString implGetDirectory(); // emit XFilePickerListener controlStateChanged event diff --git a/vcl/unx/kde5/KDE5FilePicker2.cxx b/vcl/unx/kde5/KDE5FilePicker2.cxx index 553ed8500c84..81ed9d0a8e0b 100644 --- a/vcl/unx/kde5/KDE5FilePicker2.cxx +++ b/vcl/unx/kde5/KDE5FilePicker2.cxx @@ -44,6 +44,7 @@ #include <QtGui/QClipboard> #include <QtGui/QWindow> #include <QtWidgets/QCheckBox> +#include <QtWidgets/QComboBox> #include <QtWidgets/QFileDialog> #include <QtWidgets/QGridLayout> #include <QtWidgets/QWidget> @@ -377,6 +378,12 @@ void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAc if (cb) cb->setChecked(bChecked); } + else if (_customListboxes.contains(controlId)) + { + QComboBox* cb = dynamic_cast<QComboBox*>(_customListboxes.value(controlId)); + if (cb) + handleSetListValue(cb, nControlAction, value); + } else SAL_WARN("vcl.kde5", "set value on unknown control " << controlId); } @@ -404,6 +411,12 @@ uno::Any SAL_CALL KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nContr if (cb) value = cb->isChecked(); } + else if (_customListboxes.contains(controlId)) + { + QComboBox* cb = dynamic_cast<QComboBox*>(_customListboxes.value(controlId)); + if (cb) + return handleGetListValue(cb, nControlAction); + } else SAL_WARN("vcl.kde5", "get value on unknown control" << controlId); @@ -560,7 +573,6 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId) case PUSHBUTTON_PLAY: case LISTBOX_VERSION: case LISTBOX_TEMPLATE: - case LISTBOX_IMAGE_TEMPLATE: case LISTBOX_IMAGE_ANCHOR: case LISTBOX_VERSION_LABEL: case LISTBOX_TEMPLATE_LABEL: @@ -568,7 +580,84 @@ void KDE5FilePicker::addCustomControl(sal_Int16 controlId) case LISTBOX_IMAGE_ANCHOR_LABEL: case LISTBOX_FILTER_SELECTOR: break; + + case LISTBOX_IMAGE_TEMPLATE: + auto widget = new QComboBox(_extraControls); + _layout->addWidget(widget); + _customListboxes.insert(controlId, widget); + break; + } +} + +void KDE5FilePicker::handleSetListValue(QComboBox* pQComboBox, sal_Int16 nAction, + const css::uno::Any& rValue) +{ + switch (nAction) + { + case ControlActions::ADD_ITEM: + { + OUString sItem; + rValue >>= sItem; + pQComboBox->addItem(toQString(sItem)); + } + break; + case ControlActions::ADD_ITEMS: + { + Sequence<OUString> aStringList; + rValue >>= aStringList; + sal_Int32 nItemCount = aStringList.getLength(); + for (sal_Int32 i = 0; i < nItemCount; ++i) + { + pQComboBox->addItem(toQString(aStringList[i])); + } + } + break; + case ControlActions::SET_SELECT_ITEM: + { + sal_Int32 nPos = 0; + rValue >>= nPos; + pQComboBox->setCurrentIndex(nPos); + } + break; + default: + //FIXME: insert warning here + break; + } +} + +uno::Any KDE5FilePicker::handleGetListValue(QComboBox* pQComboBox, sal_Int16 nAction) +{ + uno::Any aAny; + switch (nAction) + { + case ControlActions::GET_ITEMS: + { + uno::Sequence<OUString> aItemList; + + for (int i = 0; i < pQComboBox->count(); ++i) + { + aItemList[i] = toOUString(pQComboBox->itemText(i)); + } + aAny <<= aItemList; + } + break; + case ControlActions::GET_SELECTED_ITEM: + { + OUString sItem = toOUString(pQComboBox->currentText()); + aAny <<= sItem; + } + break; + case ControlActions::GET_SELECTED_ITEM_INDEX: + { + int nCurrent = pQComboBox->currentIndex(); + aAny <<= nCurrent; + } + break; + default: + //FIXME: insert warning here + break; } + return aAny; } OUString KDE5FilePicker::implGetDirectory() _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits