Commit 3777d23e authored by LE BRETON Come's avatar LE BRETON Come

Merge branch 'feature/adapt_menu_parameter_generator_to_menubar' of...

Merge branch 'feature/adapt_menu_parameter_generator_to_menubar' of gitlab.inria.fr:dtk/dtk-widgets into feature/adapt_menu_parameter_generator_to_menubar
parents 5d7e336b 48ad7820
......@@ -71,18 +71,20 @@ set(${PROJECT_NAME}_HEADERS
dtkWidgetsParameterBoolCheckBox.h
dtkWidgetsParameterBoolPushButton
dtkWidgetsParameterBoolPushButton.h
dtkWidgetsParameterDirBrowse
dtkWidgetsParameterDirBrowse.h
dtkWidgetsParameterDoubleSpinBox
dtkWidgetsParameterDoubleSpinBox.h
dtkWidgetsParameterFactory
dtkWidgetsParameterFactory.h
dtkWidgetsParameterFileBrowse
dtkWidgetsParameterFileBrowse.h
dtkWidgetsParameterIntSlider
dtkWidgetsParameterIntSlider.h
dtkWidgetsParameterIntSpinBox
dtkWidgetsParameterIntSpinBox.h
dtkWidgetsParameterMenuBarGenerator
dtkWidgetsParameterMenuBarGenerator.h
dtkWidgetsParameterStringBrowseFile
dtkWidgetsParameterStringBrowseFile.h
dtkWidgetsParameterStringListComboBox
dtkWidgetsParameterStringListComboBox.h
dtkWidgetsSettings
......@@ -117,12 +119,13 @@ set(${PROJECT_NAME}_SOURCES
dtkWidgetsParameter.cpp
dtkWidgetsParameterBoolCheckBox.cpp
dtkWidgetsParameterBoolPushButton.cpp
dtkWidgetsParameterDirBrowse.cpp
dtkWidgetsParameterDoubleSpinBox.cpp
dtkWidgetsParameterIntSlider.cpp
dtkWidgetsParameterIntSpinBox.cpp
dtkWidgetsParameterFactory.cpp
dtkWidgetsParameterFileBrowse.cpp
dtkWidgetsParameterMenuBarGenerator.cpp
dtkWidgetsParameterStringBrowseFile.cpp
dtkWidgetsParameterStringListComboBox.cpp
dtkWidgetsSettings.cpp
dtkWidgetsWidget.cpp)
......
......@@ -23,9 +23,10 @@
#include "dtkWidgetsParameterBoolCheckBox.h"
#include "dtkWidgetsParameterBoolPushButton.h"
#include "dtkWidgetsParameterDoubleSpinBox.h"
#include "dtkWidgetsParameterDirBrowse.h"
#include "dtkWidgetsParameterFileBrowse.h"
#include "dtkWidgetsParameterIntSlider.h"
#include "dtkWidgetsParameterIntSpinBox.h"
#include "dtkWidgetsParameterStringBrowseFile.h"
#include "dtkWidgetsParameterStringListComboBox.h"
#include "dtkWidgetsParameterFactory.h"
......@@ -67,10 +68,11 @@ namespace dtk {
// ///////////////////////////////////////////////////////////////////
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterBoolCheckBox", dtkWidgetsParameterBoolCheckBoxCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterBoolPushButton", dtkWidgetsParameterBoolPushButtonCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterDirBrowse", dtkWidgetsParameterDirBrowseCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterDoubleSpinBox", dtkWidgetsParameterDoubleSpinBoxCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterIntSlider", dtkWidgetsParameterIntSliderCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterIntSpinBox", dtkWidgetsParameterIntSpinBoxCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterStringBrowseFile", dtkWidgetsParameterStringBrowseFileCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterFileBrowse", dtkWidgetsParameterFileBrowseCreator);
dtk::widgets::parameters::pluginFactory().record("dtkWidgetsParameterStringListComboBox", dtkWidgetsParameterStringListComboBoxCreator);
}
void setVerboseLoading(bool b)
......
#include "dtkWidgetsParameterFileBrowse.h"
\ No newline at end of file
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsParameterDirBrowse.h"
#include <dtkLog>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterDirBrowsePrivate declaration
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsParameterDirBrowsePrivate
{
public:
QPushButton *push_button = nullptr;
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterDirBrowse implementation
// ///////////////////////////////////////////////////////////////////
dtkWidgetsParameterDirBrowse::dtkWidgetsParameterDirBrowse(QWidget* parent) : dtkWidgetsParameterBase<dtk::d_path>(parent), d(new dtkWidgetsParameterDirBrowsePrivate)
{
d->push_button = new QPushButton;
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(d->push_button);
this->setLayout(layout);
}
dtkWidgetsParameterDirBrowse::~dtkWidgetsParameterDirBrowse(void)
{
delete d;
}
bool dtkWidgetsParameterDirBrowse::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_path *>(p);
if(!m_parameter) {
qWarning() << Q_FUNC_INFO << "The type of the parameter is not compatible with the widget dtkWidgetsParameterDirBrowse.";
return false;
}
d->push_button->setText("Browse");
m_parameter->connect([=] (QVariant v) {
d->push_button->blockSignals(true);
QString value = v.value<dtk::d_path>().baseName();
if (value.isEmpty()) {
value = "Browse";
}
d->push_button->setText(value);
d->push_button->blockSignals(false);
});
QObject::connect(d->push_button, &QPushButton::clicked, [=] ()
{
m_parameter->setValue(QFileDialog::getExistingDirectory(this, "Open Directory", m_parameter->dirName()));
});
return true;
}
//
// dtkWidgetsParameterDirBrowse.cpp ends here
......@@ -21,30 +21,30 @@
#include "dtkWidgetsParameter.h"
#include <dtkCore/dtkCoreParameter>
#include <dtkCore/dtkCoreParameterFile>
#include <dtkCore/dtkCoreParameterPath>
class DTKWIDGETS_EXPORT dtkWidgetsParameterStringBrowseFile : public dtkWidgetsParameterBase<dtk::d_file>
class DTKWIDGETS_EXPORT dtkWidgetsParameterDirBrowse : public dtkWidgetsParameterBase<dtk::d_path>
{
Q_OBJECT
public:
dtkWidgetsParameterStringBrowseFile(QWidget* parent = 0);
~dtkWidgetsParameterStringBrowseFile(void);
dtkWidgetsParameterDirBrowse(QWidget* parent = 0);
~dtkWidgetsParameterDirBrowse(void);
public:
bool connect(dtkCoreParameter *) override;
private:
using dtkWidgetsParameterBase<dtk::d_file>::m_parameter;
using dtkWidgetsParameterBase<dtk::d_path>::m_parameter;
class dtkWidgetsParameterStringBrowseFilePrivate *d;
class dtkWidgetsParameterDirBrowsePrivate *d;
};
// ///////////////////////////////////////////////////////////////////
inline dtkWidgetsParameter *dtkWidgetsParameterStringBrowseFileCreator(void)
inline dtkWidgetsParameter *dtkWidgetsParameterDirBrowseCreator(void)
{
return new dtkWidgetsParameterStringBrowseFile();
return new dtkWidgetsParameterDirBrowse();
}
//
// dtkWidgetsParameterStringBrowseFile.h ends here
// dtkWidgetsParameterDirBrowse.h ends here
#include "dtkWidgetsParameterFileBrowse.h"
\ No newline at end of file
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#include "dtkWidgetsParameterFileBrowse.h"
#include <dtkLog>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterFileBrowsePrivate declaration
// ///////////////////////////////////////////////////////////////////
class dtkWidgetsParameterFileBrowsePrivate
{
public:
QPushButton *push_button = nullptr;
};
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterFileBrowse implementation
// ///////////////////////////////////////////////////////////////////
dtkWidgetsParameterFileBrowse::dtkWidgetsParameterFileBrowse(QWidget* parent) : dtkWidgetsParameterBase<dtk::d_path>(parent), d(new dtkWidgetsParameterFileBrowsePrivate)
{
d->push_button = new QPushButton;
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(d->push_button);
this->setLayout(layout);
}
dtkWidgetsParameterFileBrowse::~dtkWidgetsParameterFileBrowse(void)
{
delete d;
}
bool dtkWidgetsParameterFileBrowse::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_path *>(p);
if(!m_parameter) {
qWarning() << Q_FUNC_INFO << "The type of the parameter is not compatible with the widget dtkWidgetsParameterFileBrowse.";
return false;
}
d->push_button->setText("Browse");
m_parameter->connect([=] (QVariant v) {
d->push_button->blockSignals(true);
QString value = v.value<dtk::d_path>().baseName();
if (value.isEmpty()) {
value = "Browse";
}
d->push_button->setText(value);
d->push_button->blockSignals(false);
});
QObject::connect(d->push_button, &QPushButton::clicked, [=] ()
{
m_parameter->setValue(QFileDialog::getOpenFileName(this, "Open file", m_parameter->dirName(), m_parameter->filters().join("; ")));
});
return true;
}
//
// dtkWidgetsParameterFileBrowse.cpp ends here
// Version: $Id$
//
//
// Commentary:
//
//
// Change Log:
//
//
// Code:
#pragma once
#include <dtkWidgetsExport>
#include <QtWidgets>
#include "dtkWidgetsParameter.h"
#include <dtkCore/dtkCoreParameter>
#include <dtkCore/dtkCoreParameterPath>
class DTKWIDGETS_EXPORT dtkWidgetsParameterFileBrowse : public dtkWidgetsParameterBase<dtk::d_path>
{
Q_OBJECT
public:
dtkWidgetsParameterFileBrowse(QWidget* parent = 0);
~dtkWidgetsParameterFileBrowse(void);
public:
bool connect(dtkCoreParameter *) override;
private:
using dtkWidgetsParameterBase<dtk::d_path>::m_parameter;
class dtkWidgetsParameterFileBrowsePrivate *d;
};
// ///////////////////////////////////////////////////////////////////
inline dtkWidgetsParameter *dtkWidgetsParameterFileBrowseCreator(void)
{
return new dtkWidgetsParameterFileBrowse();
}
//
// dtkWidgetsParameterFileBrowse.h ends here
#include "dtkWidgetsParameterStringBrowseFile.h"
\ No newline at end of file
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