Implement setValue of fpicker checkboxes, signal+slot

Change-Id: I0d75ef9f5584935d05a0526a626145e00761efd9
This commit is contained in:
Katarina Behrens
2018-06-08 22:40:45 +02:00
parent d61f5db212
commit c38e49e869
3 changed files with 25 additions and 13 deletions

View File

@@ -91,18 +91,6 @@ QString KDE5FilePicker::getCurrentFilter() const
return filter;
}
void KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction, bool value)
{
if (_customWidgets.contains(controlId))
{
QCheckBox* cb = dynamic_cast<QCheckBox*>(_customWidgets.value(controlId));
if (cb)
cb->setChecked(value);
}
else
qWarning() << "set value on unknown control" << controlId;
}
bool KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction) const
{
bool ret = false;

View File

@@ -174,10 +174,16 @@ protected:
Q_SIGNALS:
void setTitleSignal(const OUString& rTitle);
void setDisplayDirectorySignal(const OUString& rDir);
void setValueSignal(sal_Int16 nControlId, sal_Int16 nControlAction,
const css::uno::Any& rValue);
private Q_SLOTS:
void setTitleSlot(const OUString& rTitle) { return setTitle(rTitle); }
void setDisplayDirectorySlot(const OUString& rDir) { return setDisplayDirectory(rDir); }
void setValueSlot(sal_Int16 nControlId, sal_Int16 nControlAction, const css::uno::Any& rValue)
{
return setValue(nControlAction, nControlAction, rValue);
}
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -105,6 +105,8 @@ KDE5FilePicker::KDE5FilePicker(QFileDialog::FileMode eMode)
connect(this, &KDE5FilePicker::setDisplayDirectorySignal /*(const OUString&)*/, this,
&KDE5FilePicker::setDisplayDirectorySlot /*(const OUString&)*/,
Qt::BlockingQueuedConnection);
connect(this, &KDE5FilePicker::setValueSignal, this, &KDE5FilePicker::setValueSlot,
Qt::BlockingQueuedConnection);
qApp->installEventFilter(this);
setMultiSelectionMode(false);
@@ -205,6 +207,23 @@ void SAL_CALL KDE5FilePicker::appendFilterGroup(const OUString& /*rGroupTitle*/,
void SAL_CALL KDE5FilePicker::setValue(sal_Int16 controlId, sal_Int16 nControlAction,
const uno::Any& value)
{
if (qApp->thread() != QThread::currentThread())
{
SolarMutexReleaser aReleaser;
return Q_EMIT setValueSignal(controlId, nControlAction, value);
}
if (_customWidgets.contains(controlId))
{
bool bChecked = false;
value >>= bChecked;
QCheckBox* cb = dynamic_cast<QCheckBox*>(_customWidgets.value(controlId));
if (cb)
cb->setChecked(bChecked);
}
else
SAL_WARN("vcl.kde5", "set value on unknown control " << controlId);
}
uno::Any SAL_CALL KDE5FilePicker::getValue(sal_Int16 controlId, sal_Int16 nControlAction)
@@ -433,7 +452,6 @@ void SAL_CALL KDE5FilePicker::initialize(const uno::Sequence<uno::Any>& args)
OSL_TRACE("Unknown templates %d", templateId);
return;
}
setTitle(VclResId(saveDialog ? STR_FPICKER_SAVE : STR_FPICKER_OPEN));
}