summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarina Behrens <Katarina.Behrens@cib.de>2019-01-21 22:12:15 +0100
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2019-01-22 00:41:14 +0100
commit2d33c7cb4b4835de77194650124a1cf046920f66 (patch)
tree5e3919455dfcf866d26bbd8803c1eef4917266d0
parent1e38d5b976dacd8b42b8330b4b9635a058ffe20b (diff)
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.Behrens@CIB.de>
-rw-r--r--vcl/unx/kde5/KDE5FilePicker.hxx4
-rw-r--r--vcl/unx/kde5/KDE5FilePicker2.cxx91
2 files changed, 94 insertions, 1 deletions
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 dc87f90c84ce..67f0f56401ca 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>
@@ -378,6 +379,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);
}
@@ -405,6 +412,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);
@@ -561,7 +574,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:
@@ -569,7 +581,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()