Commit be2e0479 authored by NICLAUSSE Nicolas's avatar NICLAUSSE Nicolas
Browse files

Merge branch 'issue_65_no_showing_doc' into 'develop'

Display doc and path in the tooltip for browse and save buttons.

See merge request !68
parents f0990ec4 d661e926
Pipeline #144155 passed with stage
in 0 seconds
......@@ -49,7 +49,7 @@
"file_browse": {
"label": "Open a file",
"doc": "Open a VTK file.",
"path": ".",
"path": "..",
"filters": [
"VTK (*.vtk)",
"VTI (*.vti)",
......@@ -58,6 +58,15 @@
],
"type": "dtk::d_path"
},
"file_save": {
"label": "Save in a file",
"doc": "Save in a file",
"path": "./output.txt",
"filters": [
"VTK (*.txt)"
],
"type": "dtk::d_path"
},
"slider_int": {
"type": "dtk::d_int",
"doc": "documentation",
......@@ -141,6 +150,18 @@
],
"type": "dtk::d_path"
},
"file_save_ro": {
"label": "Save a file (Read Only)",
"doc": "",
"path": ".",
"filters": [
"VTK (*.vtk)",
"VTI (*.vti)",
"VTU (*.vtu)",
"VTP (*.vtp)"
],
"type": "dtk::d_path"
},
"slider_int_ro": {
"type": "dtk::d_int",
"doc": "documentation",
......
......@@ -59,6 +59,14 @@
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterFileSave",
"uid": "file_save_ro",
"advanced": false,
"widget_read_only": true
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterIntSlider",
......@@ -155,6 +163,13 @@
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterFileSave",
"uid": "file_save",
"advanced": false
}
},
{
"parameter": {
"widget": "dtkWidgetsParameterIntSlider",
......
......@@ -15,6 +15,7 @@
#include "dtkWidgetsParameterFileBrowse.h"
#include <QtWidgets>
#include <QStringBuilder>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterFileBrowsePrivate declaration
......@@ -24,6 +25,20 @@ class dtkWidgetsParameterFileBrowsePrivate
{
public:
QPushButton *push_button = nullptr;
public:
void setToolTip(const QString& doc, const QString& path)
{
QString tooltip;
if (!doc.isEmpty()) {
tooltip += QString("Doc: %1").arg(doc);
}
if (!path.isEmpty()) {
if (!tooltip.isEmpty())
tooltip += "\n";
tooltip += QString("Path: %1").arg(path);
}
push_button->setToolTip( tooltip );
}
};
// ///////////////////////////////////////////////////////////////////
......@@ -74,11 +89,7 @@ bool dtkWidgetsParameterFileBrowse::connect(dtkCoreParameter *p)
}
d->push_button->setText(text);
QString path = m_parameter->path();
if(!path.isEmpty()) {
d->push_button->setToolTip(path);
}
d->setToolTip( m_parameter->documentation(), m_parameter->path() );
m_parameter->connect([=] (QVariant v) {
d->push_button->blockSignals(true);
......@@ -91,7 +102,7 @@ bool dtkWidgetsParameterFileBrowse::connect(dtkCoreParameter *p)
QString tip = v.value<dtk::d_path>().path();
if(!tip.isEmpty()) {
d->push_button->setToolTip(tip);
d->setToolTip( m_parameter->documentation(), tip );
}
});
......
......@@ -15,6 +15,7 @@
#include "dtkWidgetsParameterFileSave.h"
#include <QtWidgets>
#include <QStringBuilder>
// ///////////////////////////////////////////////////////////////////
// dtkWidgetsParameterFileSavePrivate declaration
......@@ -24,6 +25,20 @@ class dtkWidgetsParameterFileSavePrivate
{
public:
QPushButton *push_button = nullptr;
public:
void setToolTip(const QString& doc, const QString& path)
{
QString tooltip;
if (!doc.isEmpty()) {
tooltip += QString("Doc: %1").arg( doc );
}
if (!path.isEmpty()) {
if (!tooltip.isEmpty())
tooltip += "\n";
tooltip += QString("Path: %1").arg( path );
}
push_button->setToolTip( tooltip );
}
};
// ///////////////////////////////////////////////////////////////////
......@@ -45,6 +60,14 @@ dtkWidgetsParameterFileSave::~dtkWidgetsParameterFileSave(void)
delete d;
}
void dtkWidgetsParameterFileSave::setReadOnly(bool val)
{
this->dtkWidgetsParameter::m_readonly = val;
d->push_button->setEnabled(!this->dtkWidgetsParameter::m_readonly);
d->push_button->setFocusPolicy((this->dtkWidgetsParameter::m_readonly? Qt::NoFocus : Qt::WheelFocus));
}
bool dtkWidgetsParameterFileSave::connect(dtkCoreParameter *p)
{
if (!p) {
......@@ -59,7 +82,15 @@ bool dtkWidgetsParameterFileSave::connect(dtkCoreParameter *p)
return false;
}
d->push_button->setText("Save");
QString text = "Save";
QString base_name = m_parameter->baseName();
if(!base_name.isEmpty()) {
text = base_name;
}
d->push_button->setText(text);
d->setToolTip( m_parameter->documentation(), m_parameter->path() );
m_parameter->connect([=] (QVariant v) {
d->push_button->blockSignals(true);
......@@ -68,6 +99,7 @@ bool dtkWidgetsParameterFileSave::connect(dtkCoreParameter *p)
value = "Save";
}
d->push_button->setText(value);
d->setToolTip( m_parameter->documentation(), value );
d->push_button->blockSignals(false);
});
......
......@@ -30,6 +30,7 @@ public:
public:
bool connect(dtkCoreParameter *) override;
void setReadOnly(bool val) override;
private:
using dtkWidgetsParameterBase<dtk::d_path>::m_parameter;
......
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