Example #1
0
void ShaderSelector::addUniform(QGridLayout* settings, const QString& section, const QString& name, int* value, int min, int max, int y, int x) {
	QSpinBox* i = new QSpinBox;
	if (min < max) {
		i->setMinimum(min);
		i->setMaximum(max);
	}
	int def = *value;
	bool ok = false;
	int v = m_config->getQtOption(name, section).toInt(&ok);
	if (ok) {
		*value = v;
	}
	i->setValue(*value);
	i->setSingleStep(1);
	i->setAccelerated(true);
	settings->addWidget(i, y, x);
	connect(i, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [value](int v) {
		*value = v;
	});
	connect(this, &ShaderSelector::saved, [this, section, name, i]() {
		m_config->setQtOption(name, i->value(), section);
	});
	connect(this, &ShaderSelector::reset, [this, section, name, i]() {
		bool ok = false;
		int v = m_config->getQtOption(name, section).toInt(&ok);
		if (ok) {
			i->setValue(v);
		}
	});
	connect(this, &ShaderSelector::resetToDefault, [def, section, name, i]() {
		i->setValue(def);
	});
}
Example #2
0
QWidget* Sis3350UI::createTriggerThresholdControls()
{
    // Trigger Threshold Controls
    QWidget *box = new QWidget(this);
    QSignalMapper *mapper = new QSignalMapper();
    QHBoxLayout *l = new QHBoxLayout();
    l->setMargin(0);

    thresholds = new QList<QSpinBox*>();
    QLabel *label = new QLabel(tr("Thr:"),this);

    l->addWidget(label);

    for(int i=0; i<4; i++)
    {
        QSpinBox *thr = new QSpinBox(this);
        thr->setMinimum(0);
        thr->setMaximum(0xFFF);
        thr->setAccelerated(true);
        thr->setSingleStep(10);
        thr->setValue(module->conf.trigger_threshold[i]);
        thresholds->append(thr);
        connect(thr,SIGNAL(valueChanged(int)),mapper,SLOT(map()));
        mapper->setMapping(thr,i);
        l->addWidget(thr);
    }
    connect(mapper,SIGNAL(mapped(int)),this,SLOT(thrChanged(int)));
    box->setLayout(l);
    return box;
}
Example #3
0
QWidget* Sis3350UI::createTriggerGateControls()
{
    // Trigger Gate spinners
    QWidget *box = new QWidget(this);
    QSignalMapper *mapper = new QSignalMapper();
    QHBoxLayout *l = new QHBoxLayout();
    l->setMargin(0);

    gates = new QList<QSpinBox*>();
    QLabel *label = new QLabel(tr("Gap width:"),this);

    l->addWidget(label);

    for(int i=0; i<4; i++)
    {
        QSpinBox *gate = new QSpinBox(this);
        gate->setMinimum(0);
        gate->setMaximum(0x1F);
        gate->setAccelerated(true);
        gate->setSingleStep(1);
        gate->setValue(module->conf.trigger_gap_length[i]);
        gates->append(gate);
        connect(gate,SIGNAL(valueChanged(int)),mapper,SLOT(map()));
        mapper->setMapping(gate,i);
        l->addWidget(gate);
    }
    connect(mapper,SIGNAL(mapped(int)),this,SLOT(gateChanged(int)));
    box->setLayout(l);
    return box;
}
Example #4
0
QWidget* Sis3350UI::createInputOffsetControls()
{
    // Trigger Offset spinners
    QWidget *box = new QWidget(this);
    QSignalMapper *mapper = new QSignalMapper();
    QHBoxLayout *l = new QHBoxLayout();
    l->setMargin(0);

    offsets = new QList<QSpinBox*>();
    QLabel *label = new QLabel(tr("Offset:"),this);

    l->addWidget(label);

    for(int i=0; i<4; i++)
    {
        QSpinBox *off = new QSpinBox(this);
        off->setMinimum(0);
        off->setMaximum(65535);
        off->setAccelerated(true);
        off->setSingleStep(10);
        off->setValue(module->conf.adc_offset[i]);
        connect(off,SIGNAL(valueChanged(int)),mapper,SLOT(map()));
        mapper->setMapping(off,i);
        l->addWidget(off);
        offsets->append(off);
    }
    connect(mapper,SIGNAL(mapped(int)),this,SLOT(offChanged(int)));
    box->setLayout(l);
    return box;
}
Example #5
0
QFrame *AbstractController::telexFrame()
{
    /**
     * Telextext QFrame
     **/
    QFrame *telexFrame = new QFrame( this );
    QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
    telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexFrame, setVisible( bool ) );

    /* On/Off button */
    QToolButton *telexOn = new QToolButton;
    setupButton( telexOn );
    BUTTON_SET_BAR2( telexOn, toolbar/tv, qtr( "Teletext Activation" ) );
    telexOn->setEnabled( false );
    telexOn->setCheckable( true );

    telexLayout->addWidget( telexOn );

    /* Teletext Activation and set */
    CONNECT( telexOn, clicked( bool ),
             THEMIM->getIM(), activateTeletext( bool ) );
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexOn, setEnabled( bool ) );

    /* Transparency button */
    QToolButton *telexTransparent = new QToolButton;
    setupButton( telexTransparent );
    BUTTON_SET_BAR2( telexTransparent, toolbar/tvtelx,
                     qtr( "Toggle Transparency " ) );
    telexTransparent->setEnabled( false );
    telexTransparent->setCheckable( true );
    telexLayout->addWidget( telexTransparent );

    /* Transparency change and set */
    CONNECT( telexTransparent, clicked( bool ),
            THEMIM->getIM(), telexSetTransparency( bool ) );
    CONNECT( THEMIM->getIM(), teletextTransparencyActivated( bool ),
             telexTransparent, setChecked( bool ) );


    /* Page setting */
    QSpinBox *telexPage = new QSpinBox( telexFrame );
    telexPage->setRange( 100, 899 );
    telexPage->setValue( 100 );
    telexPage->setAccelerated( true );
    telexPage->setWrapping( true );
    telexPage->setAlignment( Qt::AlignRight );
    telexPage->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
    telexPage->setEnabled( false );
    telexLayout->addWidget( telexPage );

    /* Contextual & Index Buttons */
    QSignalMapper *contextButtonMapper = new QSignalMapper( this );
    QToolButton *contextButton = NULL;
    int i_iconminsize = __MAX( 16, telexOn->minimumHeight() );
    QPixmap iconPixmap( i_iconminsize, i_iconminsize );
    iconPixmap.fill( Qt::transparent );
    QPainter iconPixmapPainter( &iconPixmap );
    QLinearGradient iconPixmapPainterGradient( iconPixmap.rect().center() / 2,
                                               iconPixmap.rect().center() );

#define CREATE_CONTEXT_BUTTON(color, key) \
    iconPixmapPainterGradient.setColorAt( 0, QColor( color ).lighter(150) );\
    iconPixmapPainterGradient.setColorAt( 1.0, QColor( color ) );\
    iconPixmapPainter.setBrush( iconPixmapPainterGradient );\
    iconPixmapPainter.drawEllipse( iconPixmap.rect().adjusted( 4, 4, -5, -5 ) );\
    contextButton = new QToolButton();\
    setupButton( contextButton );\
    contextButton->setIcon( iconPixmap );\
    contextButton->setEnabled( false );\
    contextButtonMapper->setMapping( contextButton, key << 16 );\
    CONNECT( contextButton, clicked(), contextButtonMapper, map() );\
    CONNECT( contextButtonMapper, mapped( int ),\
             THEMIM->getIM(), telexSetPage( int ) );\
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), contextButton, setEnabled( bool ) );\
    telexLayout->addWidget( contextButton )

    CREATE_CONTEXT_BUTTON("grey", 'i'); /* index */
    CREATE_CONTEXT_BUTTON("red", 'r');
    CREATE_CONTEXT_BUTTON("green", 'g');
    CREATE_CONTEXT_BUTTON("yellow", 'y');
    CREATE_CONTEXT_BUTTON("blue", 'b');

#undef CREATE_CONTEXT_BUTTON

    /* Page change and set */
    CONNECT( telexPage, valueChanged( int ),
            THEMIM->getIM(), telexSetPage( int ) );
    CONNECT( THEMIM->getIM(), newTelexPageSet( int ),
            telexPage, setValue( int ) );

    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexPage, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexTransparent, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexOn, setChecked( bool ) );
    return telexFrame;
}
Example #6
0
QFrame *AbstractController::telexFrame()
{
    /**
     * Telextext QFrame
     **/
    QFrame *telexFrame = new QFrame( this );
    QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
    telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexFrame, setVisible( bool ) );

    /* On/Off button */
    QToolButton *telexOn = new QToolButton;
    setupButton( telexOn );
    BUTTON_SET_BAR2( telexOn, toolbar/tv, qtr( "Teletext Activation" ) );
    telexOn->setEnabled( false );
    telexOn->setCheckable( true );

    telexLayout->addWidget( telexOn );

    /* Teletext Activation and set */
    CONNECT( telexOn, clicked( bool ),
             THEMIM->getIM(), activateTeletext( bool ) );
    CONNECT( THEMIM->getIM(), teletextPossible( bool ),
             telexOn, setEnabled( bool ) );

    /* Transparency button */
    QToolButton *telexTransparent = new QToolButton;
    setupButton( telexTransparent );
    BUTTON_SET_BAR2( telexTransparent, toolbar/tvtelx,
                     qtr( "Toggle Transparency " ) );
    telexTransparent->setEnabled( false );
    telexTransparent->setCheckable( true );
    telexLayout->addWidget( telexTransparent );

    /* Transparency change and set */
    CONNECT( telexTransparent, clicked( bool ),
            THEMIM->getIM(), telexSetTransparency( bool ) );
    CONNECT( THEMIM->getIM(), teletextTransparencyActivated( bool ),
             telexTransparent, setChecked( bool ) );


    /* Page setting */
    QSpinBox *telexPage = new QSpinBox( telexFrame );
    telexPage->setRange( 0, 999 );
    telexPage->setValue( 100 );
    telexPage->setAccelerated( true );
    telexPage->setWrapping( true );
    telexPage->setAlignment( Qt::AlignRight );
    telexPage->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
    telexPage->setEnabled( false );
    telexLayout->addWidget( telexPage );

    /* Page change and set */
    CONNECT( telexPage, valueChanged( int ),
            THEMIM->getIM(), telexSetPage( int ) );
    CONNECT( THEMIM->getIM(), newTelexPageSet( int ),
            telexPage, setValue( int ) );

    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexPage, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexTransparent, setEnabled( bool ) );
    CONNECT( THEMIM->getIM(), teletextActivated( bool ), telexOn, setChecked( bool ) );
    return telexFrame;
}
Example #7
0
QWidget *HopDelegate::createEditor(QWidget *parent,
                                     const QStyleOptionViewItem &/*option*/,
                                     const QModelIndex &index) const
{
    QComboBox *combo;
    QSpinBox *spin;
    QDoubleSpinBox *dspin;
    QString suffix;
    // can only edit name on blank row
    bool blank = index.row() >= index.model()->rowCount();


    // different kind of editor for each column
    switch (index.column()) {
      case HopModel::NAME:
          combo = new QComboBox(parent);
          combo->setEditable(true);
          combo->addItem(QString());
          combo->addItems(Data::instance()->hopsList());
          combo->installEventFilter(const_cast<HopDelegate*>(this));
          return combo;

      case HopModel::WEIGHT:
          if (blank) return 0;
          dspin = new QDoubleSpinBox(parent);
          dspin->setDecimals(3);
          dspin->setRange(0.00, 1000.00);
          dspin->setSingleStep(0.25);
          suffix = " " + Data::instance()->defaultHopUnit().symbol();
          dspin->setSuffix(suffix);
          dspin->setAccelerated(true);
          dspin->installEventFilter(const_cast<HopDelegate*>(this));
          return dspin;

      case HopModel::ALPHA:
          if (blank) return 0;
          dspin = new QDoubleSpinBox(parent);
          dspin->setDecimals(1);
          dspin->setRange(0.0, 50.0);
          dspin->setSingleStep(0.1);
          dspin->setSuffix("%");
          dspin->setAccelerated(true);
          dspin->installEventFilter(const_cast<HopDelegate*>(this));
          return dspin;

      case HopModel::TIME:
          if (blank) return 0;
          spin = new QSpinBox(parent);
          spin->setRange(0, 120);
          spin->setSingleStep(5);
          spin->setSuffix(tr(" min", "minutes"));
          spin->setAccelerated(true);
          spin->installEventFilter(const_cast<HopDelegate*>(this));
          return spin;

      case HopModel::TYPE:
          if (blank) return 0;
          combo = new QComboBox(parent);
          combo->setEditable(true);
          combo->addItems(Hop::typeStringList());
          combo->installEventFilter(const_cast<HopDelegate*>(this));
          return combo;

      default:
          return 0;
    }
}
Example #8
0
void GradientDialog::Private::init()
{
    ui->setupUi( q );
    QStringList list; list << tr( "stop1" ) << tr( "stop2" );
    ui->stopSelector->addItems( list );
    QHBoxLayout *redLayout = new QHBoxLayout;
    dynamic_cast< QVBoxLayout* >( ui->gradientStopBox->layout() )->addLayout( redLayout );
    QLabel *redLabel = new QLabel( "R" );
    QFont redFont( redLabel->font() );
    redFont.setUnderline( true );
    redLabel->setFont( redFont );
    redLayout->addWidget( redLabel );
    redSlider = new ColorSlider( q );
    redSlider->setStartColor( Qt::black );
    redSlider->setEndColor( Qt::red );
    QSpinBox *redSpin = new QSpinBox( q );
    redSpin->setMinimum( 0 );
    redSpin->setMaximum( 255 );
    redSpin->setAccelerated( true );
    redSpin->setValue( redSlider->value() );
    connect( redSpin, SIGNAL( valueChanged( int ) ), redSlider, SLOT( setValue( int ) ) );
    connect( redSlider, SIGNAL( valueChanged( int ) ), redSpin, SLOT( setValue( int ) ) );
    redLayout->addWidget( redSlider );
    redLayout->addWidget( redSpin );

    QHBoxLayout *greenLayout = new QHBoxLayout;
    dynamic_cast< QVBoxLayout* >( ui->gradientStopBox->layout() )->addLayout( greenLayout );
    QLabel *greenLabel = new QLabel( "G" );
    QFont greenFont( greenLabel->font() );
    greenFont.setUnderline( true );
    greenLabel->setFont( greenFont );
    greenLayout->addWidget( greenLabel );
    greenSlider = new ColorSlider( q );
    greenSlider->setStartColor( Qt::black );
    greenSlider->setEndColor( Qt::green );
    QSpinBox *greenSpin = new QSpinBox( q );
    greenSpin->setMinimum( 0 );
    greenSpin->setMaximum( 255 );
    greenSpin->setAccelerated( true );
    greenSpin->setValue( greenSlider->value() );
    connect( greenSpin, SIGNAL( valueChanged( int ) ), greenSlider, SLOT( setValue( int ) ) );
    connect( greenSlider, SIGNAL( valueChanged( int ) ), greenSpin, SLOT( setValue( int ) ) );
    greenLayout->addWidget( greenSlider );
    greenLayout->addWidget( greenSpin );

    QHBoxLayout *blueLayout = new QHBoxLayout;
    dynamic_cast< QVBoxLayout* >( ui->gradientStopBox->layout() )->addLayout( blueLayout );
    QLabel *blueLabel = new QLabel( "B" );
    QFont blueFont( blueLabel->font() );
    blueFont.setUnderline( true );
    blueLabel->setFont( blueFont );
    blueLayout->addWidget( blueLabel );
    blueSlider = new ColorSlider( q );
    blueSlider->setStartColor( Qt::black );
    blueSlider->setEndColor( Qt::blue );
    QSpinBox *blueSpin = new QSpinBox( q );
    blueSpin->setMinimum( 0 );
    blueSpin->setMaximum( 255 );
    blueSpin->setAccelerated( true );
    blueSpin->setValue( blueSlider->value() );
    connect( blueSpin, SIGNAL( valueChanged( int ) ), blueSlider, SLOT( setValue( int ) ) );
    connect( blueSlider, SIGNAL( valueChanged( int ) ), blueSpin, SLOT( setValue( int ) ) );
    blueLayout->addWidget( blueSlider );
    blueLayout->addWidget( blueSpin );

    updateGradientDisplay();

    connect( redSlider, SIGNAL( valueChanged( int ) ), this, SLOT( resetColors() ) );
    connect( greenSlider, SIGNAL( valueChanged( int ) ), this, SLOT( resetColors() ) );
    connect( blueSlider, SIGNAL( valueChanged( int ) ), this, SLOT( resetColors() ) );

    connect( ui->newStop, SIGNAL( clicked() ), this, SLOT( insertItem() ) );
    connect( ui->deleteStop, SIGNAL( clicked() ), this, SLOT( deleteItem() ) );
    connect( ui->stopSelector, SIGNAL( currentIndexChanged( int ) ), this, SLOT( changedIndex( int ) ) );

    connect( ui->stopPosition, SIGNAL( valueChanged( double ) ), this, SLOT( changeStopPosition( double ) ) );
}