Skip to content
Snippets Groups Projects
Commit 985eb865 authored by MelanieCarriere's avatar MelanieCarriere Committed by MelanieCarriere
Browse files

[ui] display information messages to the user

This commit add some messages to the user :
- An instruction message
- If an empty json file is saved.
- If there is no property to display (if the json file loaded is empty for exemple)
parent b243e49e
1 merge request!164Fix crash analysis and save load reaction
Pipeline #205907 passed
Pipeline: LidarView

#205908

    ......@@ -7,10 +7,12 @@
    //-----------------------------------------------------------------------------
    lqLidarStateDialog::lqLidarStateDialog(QWidget *parent,
    std::vector<propertyInfo>& propertiesVector) :
    std::vector<propertyInfo>& propertiesVector,
    const std::string& instruction) :
    QDialog(parent)
    {
    this->properties = propertiesVector;
    this->instructions = QString(instruction.c_str());
    QVBoxLayout* vbox = new QVBoxLayout;
    ......@@ -26,6 +28,22 @@ lqLidarStateDialog::lqLidarStateDialog(QWidget *parent,
    //-----------------------------------------------------------------------------
    void lqLidarStateDialog::CreateDialog(QVBoxLayout *vbox)
    {
    // Display an information message if there is no property to display
    if(this->properties.empty())
    {
    QLabel * label = new QLabel(QString("No property available"));
    vbox->addWidget(label, 0, Qt::AlignCenter);
    return;
    }
    // Display a message to give a tip to the user :
    if(!this->instructions.isEmpty())
    {
    QLabel * label = new QLabel(this->instructions);
    label->setStyleSheet("font: italic;font-size: 12px ; color: grey");
    vbox->addWidget(label, 0, Qt::AlignLeft);
    }
    for(unsigned int i = 0; i < this->properties.size(); i++)
    {
    propertyInfo currentProperty = this->properties[i];
    ......
    ......@@ -63,13 +63,17 @@ class lqLidarStateDialog : public QDialog
    Q_OBJECT
    public:
    explicit lqLidarStateDialog(QWidget *parent, std::vector<propertyInfo>& propertiesVector);
    explicit lqLidarStateDialog(QWidget *parent,
    std::vector<propertyInfo>& propertiesVector,
    const std::string& instruction = "");
    ~lqLidarStateDialog(){}
    void CreateDialog(QVBoxLayout * vbox);
    std::vector<propertyInfo> properties;
    QString instructions;
    };
    #endif // LQLIDARSTATEDIALOG_H
    ......
    ......@@ -80,7 +80,7 @@ void lqLoadLidarStateReaction::onTriggered()
    return;
    }
    lqLidarStateDialog dialog(nullptr, propertyInfo);
    lqLidarStateDialog dialog(nullptr, propertyInfo, "Please select the parameters to load");
    if(dialog.exec())
    {
    for(const auto & currentProp : dialog.properties)
    ......
    ......@@ -70,7 +70,7 @@ void lqSaveLidarStateReaction::onTriggered()
    std::vector<propertyInfo> propertiesInfo;
    constructPropertiesInfo(lidarProxy, propertiesInfo);
    lqLidarStateDialog dialog(nullptr, propertiesInfo);
    lqLidarStateDialog dialog(nullptr, propertiesInfo, "Please select the parameters to save");
    if(dialog.exec())
    {
    Json::StyledStreamWriter writer;
    ......@@ -108,6 +108,10 @@ void lqSaveLidarStateReaction::onTriggered()
    }
    }
    }
    if(data.empty())
    {
    QMessageBox::information(nullptr, QObject::tr(""), QObject::tr("Saved json file is empty (no parameter selected)"));
    }
    writer.write(configFile, data);
    }
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment