Ejemplo n.º 1
0
void OBSPropertiesView::RefreshProperties()
{
	children.clear();
	if (widget)
		widget->deleteLater();

	widget = new QWidget();

	QFormLayout *layout = new QFormLayout;
	layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
	widget->setLayout(layout);

	QSizePolicy mainPolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred);
	//widget->setSizePolicy(policy);
	layout->setSizeConstraint(QLayout::SetMaximumSize);
	layout->setLabelAlignment(Qt::AlignRight);

	obs_property_t property = obs_properties_first(properties);

	while (property) {
		AddProperty(property, layout);
		obs_property_next(&property);
	}

	setWidgetResizable(true);
	setWidget(widget);
	setSizePolicy(mainPolicy);

	lastFocused.clear();
	if (lastWidget) {
		lastWidget->setFocus(Qt::OtherFocusReason);
		lastWidget = nullptr;
	}
}
Ejemplo n.º 2
0
LoginDialog::LoginDialog(validator_f validator, bool loopMode, QWidget* parent)
	: QDialog(parent)
	, m_validator(validator)
    , m_loopMode(loopMode)
	, m_loginOk(false)
{
	this->setModal(true);
	this->setWindowTitle(QSTRING_FROM_CHARARRAY(_Tr("Login")));

	m_pass = new PasswordInput(this);
    m_pass->setMinimumWidth(200);

    m_buttonBox = new QDialogButtonBox(this);
    m_buttonBox->setOrientation(Qt::Horizontal);
    m_buttonBox->setStandardButtons(/*QDialogButtonBox::Cancel|*/QDialogButtonBox::Ok);

    m_warnImg = new QLabel(this);
    m_warnImg->setPixmap(QPixmap(":/images/exclam.png"));
    m_warnText = new QPlainTextEdit(this);
    m_warnText->setMaximumHeight(100);
    m_warnText->setFrameStyle(QFrame::NoFrame);
    m_warnText->setReadOnly(true);

    // I could not get results by changing the background color in this way (Qt v4.7)
    //
    //m_warnText->setBackgroundRole(QPalette::Window);
    //
    // and this
    //
    //QPalette pal = m_warnText->palette();
    //pal.setColor(m_warnText->foregroundRole(), Qt::blue);
    //m_warnText->setPalette(pal);
    //
    // but works only this way
    QColor bg = this->palette().window().color();
    m_warnText->setStyleSheet(QString("background-color: %1;").arg(bg.name()));

    m_warnText->hide();
    m_warnImg->hide();

	QFormLayout *formLayout = new QFormLayout;
	formLayout->addRow("You are:", new QLabel("anonymous", this));
	formLayout->addRow("Password:", m_pass);
	formLayout->addRow(m_warnImg, m_warnText);
	formLayout->addRow(m_buttonBox);

	formLayout->setSizeConstraint(QLayout::SetFixedSize);
    this->setLayout(formLayout);

	connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
	connect(m_pass, SIGNAL(gotFocus()), this, SLOT(clearLoginFailedWarning()));

	this->resize(sizeHint());
}
Ejemplo n.º 3
0
GridSetupDialog::GridSetupDialog(QWidget * parent) :
    KDialog(parent)
{
    PLEConfigSkeleton * skeleton = PLEConfigSkeleton::self();

    this->setCaption(i18n("Setup grid lines"));
    this->setModal(true);

    centralWidget = new QWidget(this);
    setMainWidget(centralWidget);

    QFormLayout * layout = new QFormLayout();
    layout->setSizeConstraint( QLayout::SetFixedSize );

    x = new QDoubleSpinBox(centralWidget);
    KConfigSkeletonItem * hgi = skeleton->findItem("horizontalGrid");
    if (hgi)
    {
        x->setMinimum(hgi->minValue().toDouble());
        x->setMaximum(hgi->maxValue().toDouble());
    }
    x->setSingleStep(1.0);
    x->setValue(PLEConfigSkeleton::horizontalGrid());
    connect(skeleton, SIGNAL(horizontalGridChanged(double)), x, SLOT(setValue(double)));
    layout->addRow(i18n("Horizontal distance"), x);

    y = new QDoubleSpinBox(centralWidget);
    KConfigSkeletonItem * vgi = skeleton->findItem("verticalGrid");
    if (vgi)
    {
        y->setMinimum(hgi->minValue().toDouble());
        y->setMaximum(hgi->maxValue().toDouble());
    }
    y->setSingleStep(1.0);
    y->setValue(PLEConfigSkeleton::verticalGrid());
    connect(skeleton, SIGNAL(verticalGridChanged(double)), y, SLOT(setValue(double)));
    layout->addRow(i18n("Vertical distance"), y);

    centralWidget->setLayout(layout);

    this->setFixedSize( this->sizeHint() );
}
PropertyMultiValueWidget::PropertyMultiValueWidget(PartProperty* prop, QWidget* parent, QObject* keyEventFilter)
		: QWidget(parent), cat(prop->getPartCategory()), prop(prop), state(Enabled), flags(0)
{
	PartProperty::Type type = prop->getType();
	flags_t flags = prop->getFlags();


	QVBoxLayout* topLayout = new QVBoxLayout(this);
	setLayout(topLayout);

	QSplitter* splitter = new QSplitter(Qt::Horizontal, this);
	topLayout->addWidget(splitter);

	QWidget* listContWidget = new QWidget(splitter);
	splitter->addWidget(listContWidget);

	QVBoxLayout* listContLayout = new QVBoxLayout(listContWidget);
	listContWidget->setLayout(listContLayout);

	listWidget = new QListWidget(listContWidget);
	listWidget->installEventFilter(keyEventFilter);
	connect(listWidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
			this, SLOT(currentItemChanged(QListWidgetItem*, QListWidgetItem*)));
	listContLayout->addWidget(listWidget);


	QWidget* buttonWidget = new QWidget(listContWidget);
	listContLayout->addWidget(buttonWidget);

	QHBoxLayout* buttonLayout = new QHBoxLayout(buttonWidget);
	buttonWidget->setLayout(buttonLayout);

	buttonLayout->addStretch(1);

	listAddButton = new QPushButton("", buttonWidget);
	listAddButton->setIcon(QIcon::fromTheme("list-add", QIcon(":/icons/list-add.png")));
	connect(listAddButton, SIGNAL(clicked()), this, SLOT(addRequested()));
	buttonLayout->addWidget(listAddButton);

	listRemoveButton = new QPushButton("", buttonWidget);
	listRemoveButton->setIcon(QIcon::fromTheme("list-remove", QIcon(":/icons/list-remove.png")));
	connect(listRemoveButton, SIGNAL(clicked()), this, SLOT(removeRequested()));
	buttonLayout->addWidget(listRemoveButton);

	buttonLayout->addStretch(1);


	QWidget* detailWidget = new QWidget(splitter);
	splitter->addWidget(detailWidget);

	QVBoxLayout* detailLayout = new QVBoxLayout(detailWidget);
	detailWidget->setLayout(detailLayout);

	QWidget* detailFormWidget = new QWidget(detailWidget);
	detailLayout->addWidget(detailFormWidget);

	QFormLayout* detailFormLayout = new QFormLayout(detailFormWidget);
	detailFormLayout->setSizeConstraint(QFormLayout::SetMinimumSize);
	detailFormLayout->setHorizontalSpacing(20);
	detailFormLayout->setVerticalSpacing(10);
	detailFormWidget->setLayout(detailFormLayout);

	if (type != PartProperty::PartLink) {
		if (type == PartProperty::Boolean) {
			boolBox = new QCheckBox(prop->getUserReadableName(), detailFormWidget);
			boolBox->installEventFilter(keyEventFilter);
			connect(boolBox, SIGNAL(toggled(bool)), this, SLOT(boolFieldToggled(bool)));
			detailFormLayout->addRow(boolBox);
		} else if (type == PartProperty::File) {
Ejemplo n.º 5
0
void RandomImgOp::operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&) {
    QDialog* dialog = new QDialog(qApp->activeWindow());
    dialog->setWindowTitle(qApp->translate("RandomImgOp", "Parameters"));
    dialog->setMinimumWidth(180);
    QFormLayout* layout = new QFormLayout(dialog);

    QGroupBox* radioGroup = new QGroupBox(qApp->translate("RandomImgOp", "Image type"), dialog);
    QRadioButton* intButton = new QRadioButton(qApp->translate("RandomImgOp", "8-bit integer"));
    QRadioButton* floatButton = new QRadioButton(qApp->translate("RandomImgOp", "Floating point"));
    QHBoxLayout* radioLayout = new QHBoxLayout(radioGroup);
    radioLayout->addWidget(intButton);
    radioLayout->addWidget(floatButton);
    intButton->setChecked(true);
    layout->insertRow(0, radioGroup);

    QSpinBox* widthBox = new QSpinBox(dialog);
    widthBox->setRange(0, 65536);
    widthBox->setValue(512);
    layout->insertRow(1, qApp->translate("RandomImgOp", "Width : "), widthBox);

    QSpinBox* heightBox = new QSpinBox(dialog);
    heightBox->setRange(0, 65536);
    heightBox->setValue(512);
    layout->insertRow(2, qApp->translate("RandomImgOp", "Height : "), heightBox);

    QSpinBox* channelBox = new QSpinBox(dialog);
    channelBox->setRange(1, 4);
    channelBox->setValue(3);
    layout->insertRow(3, qApp->translate("RandomImgOp", "Number of channels : "), channelBox);

    QWidget* intRangeWidget = new QWidget(dialog);
    QHBoxLayout* intRangeLayout = new QHBoxLayout(intRangeWidget);
    QSpinBox* intMinBox = new QSpinBox(dialog);
    QSpinBox* intMaxBox = new QSpinBox(dialog);
    intMinBox->setRange(0, 255);
    intMaxBox->setRange(0, 255);
    intMinBox->setValue(0);
    intMaxBox->setValue(255);
    intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : ")));
    intRangeLayout->addWidget(intMinBox);
    intRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to ")));
    intRangeLayout->addWidget(intMaxBox);
    layout->insertRow(4, intRangeWidget);

    QWidget* floatRangeWidget = new QWidget(dialog);
    QHBoxLayout* floatRangeLayout = new QHBoxLayout(floatRangeWidget);
    QDoubleSpinBox* floatMinBox = new QDoubleSpinBox(dialog);
    QDoubleSpinBox* floatMaxBox = new QDoubleSpinBox(dialog);
    floatMinBox->setValue(0.0);
    floatMaxBox->setValue(1.0);
    floatMinBox->setRange(-65536, 65536);
    floatMaxBox->setRange(-65536, 65536);
    floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", "Range : ")));
    floatRangeLayout->addWidget(floatMinBox);
    floatRangeLayout->addWidget(new QLabel(qApp->translate("RandomImgOp", " to ")));
    floatRangeLayout->addWidget(floatMaxBox);
    layout->insertRow(5, floatRangeWidget);
    floatRangeWidget->hide();

    layout->setSizeConstraint(QLayout::SetFixedSize);

    QObject::connect(intButton, SIGNAL(toggled(bool)), intRangeWidget, SLOT(setVisible(bool)));
    QObject::connect(floatButton, SIGNAL(toggled(bool)), floatRangeWidget, SLOT(setVisible(bool)));

    QPushButton *okButton = new QPushButton(qApp->translate("Operations", "Validate"), dialog);
    okButton->setDefault(true);
    layout->addWidget(okButton);
    QObject::connect(okButton, SIGNAL(clicked()), dialog, SLOT(accept()));

    QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec());

    if(code!=QDialog::Accepted) {
        return;
    }

    if(intButton->isChecked()) {

        Image* resImg = new Image(widthBox->value(), heightBox->value(), channelBox->value());
        RandomLib::Random random;
        for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) {
            for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
                for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
                    Image::depth_t value = random.IntegerC<Image::depth_t>(intMinBox->value(), intMaxBox->value());
//                    Image::depth_t value = 256. * (rand() / (RAND_MAX + 1.));;
                    resImg->setPixel(i, j, c, value);
                }
            }
        }
        this->outImage(resImg, qApp->translate("Operations", "Random image").toStdString());

    }
    else if(floatButton->isChecked()) {

        Image_t<double>* resImg = new Image_t<double>(widthBox->value(), heightBox->value(), channelBox->value());
        RandomLib::Random random;
        for(unsigned int c = 0; c < resImg->getNbChannels(); ++c) {
            for(unsigned int j = 0; j < resImg->getHeight(); ++j) {
                for(unsigned int i = 0; i < resImg->getWidth(); ++i) {
                    double min = floatMinBox->value();
                    double max = floatMaxBox->value();
//                    double width = max - min;
//                    double value = min + (double)rand() * width / RAND_MAX;
                    double value = random.FixedN<double>();
                    value = value*(max-min) + min;
                    resImg->setPixel(i, j, c, value);
                }
            }
        }
        this->outDoubleImage(resImg, qApp->translate("Operations", "Random image").toStdString(), true);

    }
}