Kaydet (Commit) c41adbca authored tarafından Katarina Behrens's avatar Katarina Behrens Kaydeden (comit) Samuel Mehrbrodt

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: 's avatarThorsten Behrens <Thorsten.Behrens@CIB.de>
(cherry picked from commit 2d33c7cb)
Reviewed-on: https://gerrit.libreoffice.org/66758Reviewed-by: 's avatarSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
üst 617998e9
......@@ -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
......
......@@ -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()
......
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