コード例 #1
0
AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
                        PrefsItemData * data ) :
                        QWidget( _parent ), p_intf( _p_intf )
{
    /* Find our module */
    module_t *p_module = NULL;
    if( data->i_type == TYPE_CATEGORY )
        return;
    else if( data->i_type == TYPE_MODULE )
        p_module = module_find( data->psz_name );
    else
    {
        p_module = module_get_main();
        assert( p_module );
    }

    unsigned confsize;
    module_config_t *const p_config = module_config_get (p_module, &confsize),
                    *p_item = p_config,
                    *p_end = p_config + confsize;

    if( data->i_type == TYPE_SUBCATEGORY || data->i_type ==  TYPE_CATSUBCAT )
    {
        while (p_item < p_end)
        {
            if(  p_item->i_type == CONFIG_SUBCATEGORY &&
                            ( ( data->i_type == TYPE_SUBCATEGORY &&
                              p_item->value.i == data->i_object_id ) ||
                            ( data->i_type == TYPE_CATSUBCAT &&
                              p_item->value.i == data->i_subcat_id ) ) )
                break;
            p_item++;
        }
    }

    /* Widgets now */
    global_layout = new QVBoxLayout();
    global_layout->setMargin( 2 );
    QString head;
    QString help;

    help = QString( data->help );

    if( data->i_type == TYPE_SUBCATEGORY || data->i_type ==  TYPE_CATSUBCAT )
    {
        head = QString( data->name );
        p_item++; // Why that ?
    }
    else
    {
        head = QString( qtr( module_GetLongName( p_module ) ) );
    }

    QLabel *titleLabel = new QLabel( head );
    QFont titleFont = QApplication::font();
    titleFont.setPointSize( titleFont.pointSize() + 6 );
    titleLabel->setFont( titleFont );

    // Title <hr>
    QFrame *title_line = new QFrame;
    title_line->setFrameShape(QFrame::HLine);
    title_line->setFrameShadow(QFrame::Sunken);

    QLabel *helpLabel = new QLabel( help, this );
    helpLabel->setWordWrap( true );

    global_layout->addWidget( titleLabel );
    global_layout->addWidget( title_line );
    global_layout->addWidget( helpLabel );

    QGroupBox *box = NULL;
    QGridLayout *boxlayout = NULL;

    QScrollArea *scroller= new QScrollArea;
    scroller->setFrameStyle( QFrame::NoFrame );
    QWidget *scrolled_area = new QWidget;

    QGridLayout *layout = new QGridLayout();
    int i_line = 0, i_boxline = 0;
    bool has_hotkey = false;

    if( p_item ) do
    {
        if( ( ( data->i_type == TYPE_SUBCATEGORY &&
                p_item->value.i != data->i_object_id ) ||
              ( data->i_type == TYPE_CATSUBCAT  &&
                p_item->value.i != data->i_subcat_id ) ) &&
            ( p_item->i_type == CONFIG_CATEGORY ||
              p_item->i_type == CONFIG_SUBCATEGORY ) )
            break;
        if( p_item->b_internal ) continue;

        if( p_item->i_type == CONFIG_SECTION )
        {
            if( box )
            {
                box->setLayout( boxlayout );
                box->show();
                layout->addWidget( box, i_line, 0, 1, -1 );
                i_line++;
            }
            box = new QGroupBox( qtr( p_item->psz_text ), this );
            box->hide();
            boxlayout = new QGridLayout();
        }
        /* Only one hotkey control */
        if( p_item->i_type == CONFIG_ITEM_KEY )
        {
            if( has_hotkey )
                continue;
            has_hotkey = true;
        }

        ConfigControl *control;
        if( ! box )
            control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
                                        p_item, this, layout, i_line );
        else
            control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
                                    p_item, this, boxlayout, i_boxline );
        if( !control )
            continue;

        if( box ) i_boxline++;
        else i_line++;
        controls.append( control );
    }
    while( !( ( data->i_type == TYPE_SUBCATEGORY ||
               data->i_type == TYPE_CATSUBCAT ) &&
             ( p_item->i_type == CONFIG_CATEGORY ||
               p_item->i_type == CONFIG_SUBCATEGORY ) )
        && ( ++p_item < p_end ) );

    if( box && i_boxline > 0 )
    {
        box->setLayout( boxlayout );
        box->show();
        layout->addWidget( box, i_line, 0, 1, -1 );
    }

    scrolled_area->setSizePolicy( QSizePolicy::Preferred,QSizePolicy::Fixed );
    scrolled_area->setLayout( layout );
    scroller->setWidget( scrolled_area );
    scroller->setWidgetResizable( true );
    global_layout->addWidget( scroller );
    setLayout( global_layout );
}
コード例 #2
0
ファイル: qt4.cpp プロジェクト: m8a/uim
void GroupPageWidget::setupWidgets()
{
    if ( m_widget_created )
        return;

    QVBoxLayout *vLayout = new QVBoxLayout( this );
    vLayout->setMargin( 6 );
    vLayout->setSpacing( 3 );
    
    struct uim_custom_group *group
        = uim_custom_group_get( m_group_sym.toLatin1().constData() );
    if( group == 0 )
        return;

    QLabel *groupLabel = new QLabel( _FU8(group->label), this );
    groupLabel->setAlignment( Qt::AlignLeft );
    vLayout->addWidget( groupLabel );
    
    QFrame *separator = new QFrame( this );
    separator->setFrameShape( QFrame::HLine );
    separator->setFrameShadow( QFrame::Sunken );
    vLayout->addWidget( separator );

    /* default QVGroupBox */
    QGroupBox *defaultGroupVBox = new QGroupBox( this );
    vLayout->addWidget( defaultGroupVBox );    
    defaultGroupVBox->hide();
#if 0
    SubgroupData *sd = new SubgroupData( this, group_name );

    /* add various widgets to the vbox */
    char **custom_syms = uim_custom_collect_by_group( group_name );
    if( custom_syms )
    {
        for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ )
        {
            QGroupBox *vbox = sd->searchGroupVBoxByCustomSym( *custom_sym );
            if( vbox == 0 )
            {
                vbox = defaultGroupVBox;
                vbox->show();
            }
            
            UimCustomItemIface *iface = addCustom( vbox, *custom_sym );
            if( iface )
                m_customIfaceList.append( iface );
        }

        uim_custom_symbol_list_free( custom_syms );
    }
#else
    char **sub_groups
        = uim_custom_group_subgroups( m_group_sym.toLatin1().constData() );
    char **sgrp;
    for( sgrp = sub_groups; *sgrp; sgrp++ )
    {
        struct uim_custom_group *sgroup_custom =  uim_custom_group_get( *sgrp );
        QGroupBox *vbox;
        if( QString::compare( *sgrp, "main" ) == 0 )
        {
            vbox = defaultGroupVBox;
            vbox->show();
        }
        else
        {
            vbox = new QGroupBox( _FU8(sgroup_custom->label), this );
            vLayout->addWidget( vbox );
        }
        QVBoxLayout *layout = new QVBoxLayout;
        vbox->setLayout( layout );

        /* XXX quick hack to use AND expression of groups */
        QString groups( m_group_sym );
        groups += " '";
        groups += *sgrp;
        char **custom_syms
            = uim_custom_collect_by_group( groups.toLatin1().constData() );
        if( !custom_syms )
            continue;

        for( char **custom_sym = custom_syms; *custom_sym; custom_sym++ )
        {
            UimCustomItemIface *iface = addCustom( vbox, *custom_sym );
            if( iface )
                m_customIfaceList.append( iface );
        }
        uim_custom_symbol_list_free( custom_syms );


        uim_custom_group_free( sgroup_custom );
    }
    uim_custom_symbol_list_free( sub_groups );
#endif

    /* free */
    //delete sd;
    uim_custom_group_free( group );

    /* bottom up */
    vLayout->addStretch();    

    setLayout( vLayout );

    m_widget_created = true;
}
コード例 #3
0
void XXPortSelectDialog::initGUI()
{
  QWidget *page = new QWidget( this );
  setMainWidget( page );

  QVBoxLayout *topLayout = new QVBoxLayout( page );
  topLayout->setSpacing( KDialog::spacingHint() );
  topLayout->setMargin( 0 );

  QLabel *label = new QLabel( i18n( "Which contacts do you want to export?" ), page );
  topLayout->addWidget( label );

  mButtonGroup = new QGroupBox( i18nc( "@title:group Selection of contacts that must be exported", "Selection" ), page );
  QGridLayout *groupLayout = new QGridLayout();
  groupLayout->setSpacing( KDialog::spacingHint() );
  groupLayout->setMargin( KDialog::marginHint() );
  groupLayout->setAlignment( Qt::AlignTop );
  mButtonGroup->setLayout( groupLayout );

  mUseWholeBook = new QRadioButton( i18n( "&All contacts" ), mButtonGroup );
  mUseWholeBook->setChecked( true );
  mUseWholeBook->setWhatsThis( i18n( "Export the entire address book" ) );
  groupLayout->addWidget( mUseWholeBook, 0, 0 );
  mUseSelection = new QRadioButton( i18np( "&Selected contact", "&Selected contacts (%1 selected)", mCore->selectedUIDs().count() ), mButtonGroup );
  mUseSelection->setWhatsThis( i18n( "Only export contacts selected in KAddressBook.\n"
                                        "This option is disabled if no contacts are selected." ) );
  groupLayout->addWidget( mUseSelection, 1, 0 );

  mUseFilters = new QRadioButton( i18n( "Contacts matching &filter" ), mButtonGroup );
  mUseFilters->setWhatsThis( i18n( "Only export contacts matching the selected filter.\n"
                                     "This option is disabled if you have not defined any filters" ) );
  groupLayout->addWidget( mUseFilters, 2, 0 );

  mUseCategories = new QRadioButton( i18n( "Category &members" ), mButtonGroup );
  mUseCategories->setWhatsThis( i18n( "Only export contacts who are members of a category that is checked on the list to the left.\n"
                                       "This option is disabled if you have no categories." ) );
  groupLayout->addWidget( mUseCategories, 3, 0, Qt::AlignTop );

  mFiltersCombo = new KComboBox( mButtonGroup );
  mFiltersCombo->setEditable( false );
  mFiltersCombo->setWhatsThis( i18n( "Select a filter to decide which contacts to export." ) );
  groupLayout->addWidget( mFiltersCombo, 2, 1 );

  mCategoriesView = new KPIM::CategorySelectWidget( mButtonGroup, KABPrefs::instance() );
  mCategoriesView->hideButton();
  mCategoriesView->layout()->setMargin( 0 );
  mCategoriesView->setWhatsThis( i18n( "Check the categories whose members you want to print." ) );
  groupLayout->addWidget( mCategoriesView, 3, 1 );
  connect( mCategoriesView->listView(),
           SIGNAL( itemClicked( QTreeWidgetItem *, int ) ),
           this, SLOT( categoryClicked() ) );

  topLayout->addWidget( mButtonGroup );

  QGroupBox *sortingGroup = new QGroupBox( i18n( "Sorting" ), page );
  QGridLayout *sortLayout = new QGridLayout();
  sortLayout->setSpacing( KDialog::spacingHint() );
  sortLayout->setAlignment( Qt::AlignTop );
  sortingGroup->setLayout( sortLayout );

  label = new QLabel( i18n( "Criterion:" ), sortingGroup );
  sortLayout->addWidget( label, 0, 0 );

  mFieldCombo = new KComboBox( false, sortingGroup );
  sortLayout->addWidget( mFieldCombo, 0, 1 );

  label = new QLabel( i18n( "Order:" ), sortingGroup );
  sortLayout->addWidget( label, 1, 0 );

  mSortTypeCombo = new KComboBox( false, sortingGroup );
  sortLayout->addWidget( mSortTypeCombo, 1, 1 );

  topLayout->addWidget( sortingGroup );

  if ( !mUseSorting )
    sortingGroup->hide();
}
コード例 #4
0
ファイル: current-clamp.cpp プロジェクト: RTXI/current-clamp
void Clamp::customizeGUI(void) {

	QGridLayout *customlayout = DefaultGUIModel::getLayout(); 
	customlayout->setColumnStretch(1,1);

	//overall GUI layout with a "horizontal box" copied from DefaultGUIModel
	QGroupBox *plotBox = new QGroupBox("FI Plot");
	QHBoxLayout *plotBoxLayout = new QHBoxLayout;
	plotBox->setLayout(plotBoxLayout);

	QPushButton *clearButton = new QPushButton("&Clear");
	QPushButton *linearfitButton = new QPushButton("Linear &Fit");
	QPushButton *savePlotButton = new QPushButton("Screenshot");
	QPushButton *printButton = new QPushButton("Print");
	QPushButton *saveDataButton = new QPushButton("Save Data");
	plotBoxLayout->addWidget(clearButton);
	plotBoxLayout->addWidget(linearfitButton);
	plotBoxLayout->addWidget(printButton);
	plotBoxLayout->addWidget(savePlotButton);
	plotBoxLayout->addWidget(saveDataButton);
	QLineEdit *eqnLine = new QLineEdit("Linear Equation");
	eqnLine->setText("Y = c0 + c1 * X");
	eqnLine->setFrame(false);
	splot = new ScatterPlot(this);

	// Connect buttons to functions
	QObject::connect(clearButton, SIGNAL(clicked()), splot, SLOT(clear()));
	QObject::connect(clearButton, SIGNAL(clicked()), this, SLOT(clearData()));
	QObject::connect(savePlotButton, SIGNAL(clicked()), this, SLOT(exportSVG()));
	QObject::connect(printButton, SIGNAL(clicked()), this, SLOT(print()));
	QObject::connect(saveDataButton, SIGNAL(clicked()), this, SLOT(saveFIData()));
	QObject::connect(linearfitButton, SIGNAL(clicked()), this, SLOT(fitData()));
	clearButton->setToolTip("Clear");
	savePlotButton->setToolTip("Save screenshot");
	saveDataButton->setToolTip("Save data");
	linearfitButton->setToolTip("Perform linear least-squares regression");
	printButton->setToolTip("Print plot");

	plotBox->hide();
	eqnLine->hide();
//	splot->setMinimumSize(450, 270);
	splot->hide();
	customlayout->addWidget(plotBox, 0, 1, 1, 1);
	customlayout->addWidget(eqnLine, 10, 1, 1, 1);
	customlayout->addWidget(splot, 1, 1, 3, 1);

	QGroupBox *modeBox = new QGroupBox("Clamp Mode");
	QHBoxLayout *modeBoxLayout = new QHBoxLayout;
	modeBox->setLayout(modeBoxLayout);
	QButtonGroup *modeButtons = new QButtonGroup;
	modeButtons->setExclusive(true);
	QRadioButton *stepButton = new QRadioButton("Step");
	modeBoxLayout->addWidget(stepButton);
	modeButtons->addButton(stepButton);
	stepButton->setEnabled(true);
	QRadioButton *rampButton = new QRadioButton("Ramp"); 
	modeBoxLayout->addWidget(rampButton);
	modeButtons->addButton(rampButton);
	stepButton->setChecked(true);
	QObject::connect(modeButtons,SIGNAL(buttonClicked(int)),this,SLOT(updateClampMode(int)));
	stepButton->setToolTip("Set mode to current steps");
	rampButton->setToolTip("Set mode to triangular current ramps");
	customlayout->addWidget(modeBox, 0, 0);

	QHBoxLayout *optionBoxLayout = new QHBoxLayout;
	QGroupBox *optionBoxGroup = new QGroupBox;
	QCheckBox *randomCheckBox = new QCheckBox("Randomize");
	optionBoxLayout->addWidget(randomCheckBox);
	QCheckBox *plotFICheckBox = new QCheckBox("Plot FI Curve");
	optionBoxLayout->addWidget(plotFICheckBox);
	QObject::connect(randomCheckBox,SIGNAL(toggled(bool)),this,SLOT(togglerandom(bool)));
	QObject::connect(plotFICheckBox,SIGNAL(toggled(bool)),eqnLine,SLOT(setVisible(bool)));
	QObject::connect(plotFICheckBox,SIGNAL(toggled(bool)),splot,SLOT(setVisible(bool)));
	QObject::connect(plotFICheckBox,SIGNAL(toggled(bool)),plotBox,SLOT(setVisible(bool)));
	QObject::connect(plotFICheckBox,SIGNAL(toggled(bool)),this,SLOT(toggleFIplot(bool)));
	QObject::connect(plotFICheckBox,SIGNAL(toggled(bool)),this,SLOT(resizeMe()));
	randomCheckBox->setToolTip("Randomize input amplitudes within a cycle");
	plotFICheckBox->setToolTip("Show/Hide FI plot area");
	optionBoxGroup->setLayout(optionBoxLayout);
	customlayout->addWidget(optionBoxGroup, 3, 0);

	QObject::connect(DefaultGUIModel::pauseButton,SIGNAL(toggled(bool)),savePlotButton,SLOT(setEnabled(bool)));
	QObject::connect(DefaultGUIModel::pauseButton,SIGNAL(toggled(bool)),printButton,SLOT(setEnabled(bool)));
	QObject::connect(DefaultGUIModel::pauseButton,SIGNAL(toggled(bool)),saveDataButton,SLOT(setEnabled(bool)));
	QObject::connect(DefaultGUIModel::pauseButton,SIGNAL(toggled(bool)),linearfitButton,SLOT(setEnabled(bool)));
	QObject::connect(DefaultGUIModel::pauseButton,SIGNAL(toggled(bool)),DefaultGUIModel::modifyButton,SLOT(setEnabled(bool)));
	DefaultGUIModel::pauseButton->setToolTip("Start/Stop current clamp protocol");
	DefaultGUIModel::modifyButton->setToolTip("Commit changes to parameter values");
	DefaultGUIModel::unloadButton->setToolTip("Close module");

	QObject::connect(this,SIGNAL(newDataPoint(double,double)),splot,SLOT(appendPoint(double,double)));
	QObject::connect(this,SIGNAL(setFIRange(double, double, double, double)),splot,SLOT(setAxes(double, double, double, double)));
	QObject::connect(this,SIGNAL(setPlotMode(bool)),plotFICheckBox,SLOT(setChecked(bool)));
	QObject::connect(this,SIGNAL(setStepMode(bool)),plotFICheckBox,SLOT(setEnabled(bool)));
	QObject::connect(this,SIGNAL(setStepMode(bool)),plotBox,SLOT(setEnabled(bool)));
	QObject::connect(this,SIGNAL(drawFit(double*, double*, int)),splot,SLOT(appendLine(double*, double*, int)));
	QObject::connect(this,SIGNAL(setEqnMsg(const QString &)), eqnLine,SLOT(setText(const QString &)));

	setLayout(customlayout);
}