Commit 051fe512 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas

remove unused file

parent 470a669e
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsParameterStringBrowseFile.h"
#include <dtkLog>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterStringBrowseFilePrivate declaration
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsParameterStringBrowseFilePrivate
{
public:
QPushButton *push_button = nullptr;
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterStringBrowseFile implementation
// ///////////////////////////////////////////////////////////////////
dtkWidgetsParameterStringBrowseFile::dtkWidgetsParameterStringBrowseFile(QWidget* parent) : dtkWidgetsParameterBase<dtk::d_file>(parent), d(new dtkWidgetsParameterStringBrowseFilePrivate)
{
d->push_button = new QPushButton;
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(d->push_button);
this->setLayout(layout);
}
dtkWidgetsParameterStringBrowseFile::~dtkWidgetsParameterStringBrowseFile(void)
{
delete d;
}
bool dtkWidgetsParameterStringBrowseFile::connect(dtkCoreParameter *p)
{
if (!p) {
qWarning() << Q_FUNC_INFO << "The input parameter is null. Nothing is done.";
return false;
}
m_parameter = dynamic_cast<dtk::d_file *>(p);
if(!m_parameter) {
qWarning() << Q_FUNC_INFO << "The type of the parameter is not compatible with the widget dtkWidgetsParameterStringBrowseFile.";
return false;
}
d->push_button->setText("Browse");
m_parameter->connect([=] (QVariant v) {
d->push_button->blockSignals(true);
QString value = v.value<dtk::d_file>().fileName();
if (value.isEmpty()) {
value = "Browse";
}
d->push_button->setText(value);
d->push_button->blockSignals(false);
});
QObject::connect(d->push_button, &QPushButton::clicked, [=] ()
{
QString file_name = QFileDialog::getOpenFileName(this, "Open file", m_parameter->dir(), m_parameter->filters().join("; "));
m_parameter->setValue(file_name);
});
return true;
}
//
// dtkWidgetsParameterStringBrowseFile.cpp ends here
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