void FilePropertyWidgetQt::generateWidget() {
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);
    setLayout(hLayout);

    label_ = new EditableLabelQt(this, property_);
    hLayout->addWidget(label_);

    QHBoxLayout* hWidgetLayout = new QHBoxLayout();
    hWidgetLayout->setContentsMargins(0,0,0,0);
    QWidget* widget = new QWidget();
    widget->setLayout(hWidgetLayout);

    lineEdit_ = new QLineEdit(this);
    lineEdit_->setReadOnly(true);
    
    QSizePolicy sp = lineEdit_->sizePolicy();
    sp.setHorizontalStretch(3);
    lineEdit_->setSizePolicy(sp);
    
    openButton_ = new QToolButton(this);
    openButton_->setIcon(QIcon(":/icons/open.png"));
    hWidgetLayout->addWidget(lineEdit_);
    hWidgetLayout->addWidget(openButton_);
    
    sp = widget->sizePolicy();
    sp.setHorizontalStretch(3);
    widget->setSizePolicy(sp);
    
    hLayout->addWidget(widget);
    connect(openButton_, SIGNAL(pressed()), this, SLOT(setPropertyValue()));
}
void StringMultilinePropertyWidgetQt::generateWidget() {
    QHBoxLayout *hLayout = new QHBoxLayout;
    setSpacingAndMargins(hLayout);

    // QVBoxLayout* vLayout = new QVBoxLayout;
    // vLayout->setContentsMargins(0, 0, 0, 0);
    // vLayout->setSpacing(0);

    label_ = new EditableLabelQt(this, property_);
    // vLayout->addWidget(label_);
    // vLayout->addStretch();
    // hLayout->addLayout(vLayout);

    hLayout->addWidget(label_);

    textEdit_ = new MultilineTextEdit;
    // if(property_->getSemantics().getString() == "Password"){
    //    textEdit_->setEchoMode(QLineEdit::PasswordEchoOnEdit);
    //}

    QSizePolicy sp = textEdit_->sizePolicy();
    sp.setHorizontalStretch(3);
    sp.setVerticalPolicy(QSizePolicy::Preferred);
    textEdit_->setSizePolicy(sp);

    hLayout->addWidget(textEdit_);

    setLayout(hLayout);
    connect(textEdit_, SIGNAL(editingFinished()), this, SLOT(setPropertyValue()));
}
void inviwo::EventPropertyWidgetQt::generateWidget() {
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);

    label_ = new EditableLabelQt(this, eventproperty_);

    button_ = new IvwPushButton(this);
    connect(button_, SIGNAL(clicked()), this, SLOT(clickedSlot()));
    hLayout->addWidget(label_);

    {
        QWidget* widget = new QWidget(this);
        QSizePolicy sliderPol = widget->sizePolicy();
        sliderPol.setHorizontalStretch(3);
        widget->setSizePolicy(sliderPol);
        QGridLayout* vLayout = new QGridLayout();
        widget->setLayout(vLayout);
        vLayout->setContentsMargins(0, 0, 0, 0);
        vLayout->setSpacing(0);

        vLayout->addWidget(button_);
        hLayout->addWidget(widget);
    }

    setLayout(hLayout);

    setButtonText();
}
void BaseOrdinalMinMaxPropertyWidgetQt::generateWidget() {
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);
    label_ = new EditableLabelQt(this, property_);
    hLayout->addWidget(label_);
    
    QHBoxLayout* hSliderLayout = new QHBoxLayout();
    QWidget* sliderWidget = new QWidget();
    sliderWidget->setLayout(hSliderLayout);
    hSliderLayout->setContentsMargins(0,0,0,0);
    
    spinBoxMin_ = new CustomDoubleSpinBoxQt(this);
    spinBoxMin_->setKeyboardTracking(false); // don't emit the valueChanged() signal while typing
    spinBoxMin_->setFixedWidth(50);
    hSliderLayout->addWidget(spinBoxMin_);
    
    slider_ = new RangeSliderQt(Qt::Horizontal, this);
    hSliderLayout->addWidget(slider_);
    
    spinBoxMax_ = new CustomDoubleSpinBoxQt(this);
    spinBoxMax_->setKeyboardTracking(false); // don't emit the valueChanged() signal while typing
    spinBoxMax_->setFixedWidth(50);
    hSliderLayout->addWidget(spinBoxMax_);
    
    hLayout->addWidget(sliderWidget);
    setLayout(hLayout);
    
    QSizePolicy slidersPol = sliderWidget->sizePolicy();
    slidersPol.setHorizontalStretch(3);
    sliderWidget->setSizePolicy(slidersPol);
    
    connect(slider_, SIGNAL(valuesChanged(int,int)), this, SLOT(updateFromSlider(int,int)));
    connect(spinBoxMin_, SIGNAL(valueChanged(double)), this, SLOT(updateFromSpinBoxMin(double)));
    connect(spinBoxMax_, SIGNAL(valueChanged(double)), this, SLOT(updateFromSpinBoxMax(double)));
}
void FilePropertyWidgetQt::generateWidget() {
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);
    setLayout(hLayout);
    setAcceptDrops(true);

    label_ = new EditableLabelQt(this, property_);
    hLayout->addWidget(label_);

    QHBoxLayout* hWidgetLayout = new QHBoxLayout();
    hWidgetLayout->setContentsMargins(0, 0, 0, 0);
    QWidget* widget = new QWidget();
    widget->setLayout(hWidgetLayout);

    lineEdit_ = new FilePathLineEditQt(this);

    connect(lineEdit_, &QLineEdit::editingFinished, [&]() {
        // editing is done, sync property with contents
        property_->set(lineEdit_->getPath());
    });
#if defined(IVW_DEBUG)
    QObject::connect(lineEdit_, &LineEditQt::editingCanceled, [this]() {
        // undo textual changes by resetting the contents of the line edit
        ivwAssert(lineEdit_->getPath() == property_->get(), "FilePropertyWidgetQt: paths not equal after canceling edit");
    });
#endif // IVW_DEBUG

    QSizePolicy sp = lineEdit_->sizePolicy();
    sp.setHorizontalStretch(3);
    lineEdit_->setSizePolicy(sp);
    hWidgetLayout->addWidget(lineEdit_);

    auto revealButton = new QToolButton(this);
    revealButton->setIcon(QIcon(":/icons/reveal.png"));
    hWidgetLayout->addWidget(revealButton);
    connect(revealButton, &QToolButton::pressed, [&]() {
        auto dir = filesystem::directoryExists(property_->get())
                       ? property_->get()
                       : filesystem::getFileDirectory(property_->get());

        QDesktopServices::openUrl(
            QUrl(QString::fromStdString("file:///" + dir), QUrl::TolerantMode));
    });

    openButton_ = new QToolButton(this);
    openButton_->setIcon(QIcon(":/icons/open.png"));
    hWidgetLayout->addWidget(openButton_);
    connect(openButton_, SIGNAL(pressed()), this, SLOT(setPropertyValue()));

    sp = widget->sizePolicy();
    sp.setHorizontalStretch(3);
    widget->setSizePolicy(sp);
    hLayout->addWidget(widget);
}
void BoolPropertyWidgetQt::generateWidget() {
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);

    label_ = new EditableLabelQt(this, property_, false);
    hLayout->addWidget(label_);

    checkBox_ = new QCheckBox();
    checkBox_->setEnabled(!property_->getReadOnly());
    checkBox_->setFixedSize(QSize(15,15));
   
    connect(checkBox_, SIGNAL(clicked()), this, SLOT(setPropertyValue()));

    hLayout->addWidget(checkBox_);
    setLayout(hLayout);
}
void BaseOrdinalMinMaxTextPropertyWidgetQt::generateWidget() {
    makeEditorWidgets();
    
    QHBoxLayout* hLayout = new QHBoxLayout();
    setSpacingAndMargins(hLayout);
    label_ = new EditableLabelQt(this, property_);
    hLayout->addWidget(label_);
    
    QHBoxLayout* textLayout = new QHBoxLayout();
    QWidget* textWidget = new QWidget();
    textWidget->setLayout(textLayout);
    textLayout->setContentsMargins(0,0,0,0);
    
    QSizePolicy sp = QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);
    sp.setHorizontalStretch(3);

    QLabel* minLabel = new QLabel("Min:");
    textLayout->addWidget(minLabel);
    textLayout->addWidget(min_);
    min_->setSizePolicy(sp);

    QLabel* maxLabel = new QLabel("Max:");
    textLayout->addWidget(maxLabel);
    textLayout->addWidget(max_);
    max_->setSizePolicy(sp);
    
    hLayout->addWidget(textWidget);
    setLayout(hLayout);
    
    QSizePolicy textsp = textWidget->sizePolicy();
    textsp.setHorizontalStretch(3);
    textWidget->setSizePolicy(textsp);
    
    connect(min_, SIGNAL(valueChanged()), this, SLOT(updateFromMin()));
    connect(max_, SIGNAL(valueChanged()), this, SLOT(updateFromMax()));
    
    setFixedHeight(sizeHint().height());
    sp = sizePolicy();
    sp.setVerticalPolicy(QSizePolicy::Fixed);
    setSizePolicy(sp);
}