示例#1
0
PicasawebLogin::PicasawebLogin(QWidget* parent, const QString& header,
                               const QString& _name, const QString& _passwd)
              : QDialog(parent)
{
    setSizeGripEnabled(false);

    QVBoxLayout* vbox = new QVBoxLayout(this);

    m_headerLabel = new QLabel(this);
    m_headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
    m_headerLabel->setText(header);

    QFrame* hline = new QFrame(this);
    hline->setObjectName("hline");
    hline->setFrameShape( QFrame::HLine );
    hline->setFrameShadow( QFrame::Sunken );
    hline->setFrameShape( QFrame::HLine );

    QGridLayout* centerLayout = new QGridLayout();

    m_nameEdit   = new KLineEdit(this);
    m_passwdEdit = new KLineEdit(this);
    m_passwdEdit->setEchoMode(KLineEdit::Password);

    QLabel* nameLabel = new QLabel(this);
    nameLabel->setText(i18n( "Google Login:"******"Password:"******"&OK"));

    QPushButton *cancelBtn = new QPushButton(this);
    cancelBtn->setText(i18n("&Cancel"));

    btnLayout->addItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum));
    btnLayout->addWidget(okBtn);
    btnLayout->addWidget(cancelBtn);
    btnLayout->setMargin(0);
    btnLayout->setSpacing(5);

    vbox->setMargin(5);
    vbox->setSpacing(5);
    vbox->setObjectName("vbox");
    vbox->addWidget(m_headerLabel);
    vbox->addWidget(hline);
    vbox->addLayout(centerLayout);
    vbox->addLayout(btnLayout);

    resize(QSize(300, 150).expandedTo(minimumSizeHint()));

    //TODO: KDE4PORT
    //clearWState( WState_Polished );

    m_nameEdit->setText(_name);
    m_passwdEdit->setText(_passwd);

    // signals and slots connections

    connect(okBtn, SIGNAL(clicked()),
            this, SLOT(accept()));

    connect(cancelBtn, SIGNAL(clicked()),
            this, SLOT(reject()));
}
void
QvisHistogramPlotWindow::CreateWindowContents()
{
    QGridLayout *mainLayout = new QGridLayout();
    topLayout->addLayout(mainLayout);

    basedOnLabel = new QLabel(tr("Histogram based on"), central);
    mainLayout->addWidget(basedOnLabel,0,0);

    QWidget *basedOnWidget = new QWidget(central);
    QHBoxLayout *basedOnLayout = new QHBoxLayout(basedOnWidget);
    
    QRadioButton *basedOnBasedOnManyVarsForSingleZone =
      new QRadioButton(tr("Array of variables (one zone)"), basedOnWidget);
    QRadioButton *basedOnBasedOnManyZonesForSingleVar =
      new QRadioButton(tr("Many zones"), basedOnWidget);

    basedOnLayout->addWidget(basedOnBasedOnManyVarsForSingleZone);
    basedOnLayout->addWidget(basedOnBasedOnManyZonesForSingleVar);
    
    basedOnGroup = new QButtonGroup(basedOnWidget);
    basedOnGroup->addButton(basedOnBasedOnManyVarsForSingleZone,0);
    basedOnGroup->addButton(basedOnBasedOnManyZonesForSingleVar,1);
    
    
    connect(basedOnGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(basedOnChanged(int)));
    mainLayout->addWidget(basedOnWidget, 0,1);
    basedOnLabel->setEnabled(false);
    basedOnWidget->setEnabled(false);
    
    // Histogram Style Group Box
    histGroupBox =new QGroupBox(central); 
    histGroupBox->setTitle(tr("Histogram Options"));
    mainLayout->addWidget(histGroupBox, 1, 0, 1, 2);
    QVBoxLayout *hgTopLayout = new QVBoxLayout(histGroupBox);
    QGridLayout *hgLayout = new QGridLayout();
    hgTopLayout->addLayout(hgLayout);
    hgLayout->setColumnStretch(1,10);

    // Number of bins
    numBinsLabel = new QLabel(tr("Number of Bins"), histGroupBox);
    hgLayout->addWidget(numBinsLabel, 0, 0);

    numBins = new QSpinBox(central);
    numBins->setMinimum(2);
    numBins->setMaximum(1000);
    numBins->setSingleStep(1);
    connect(numBins, SIGNAL(valueChanged(int)),
            this, SLOT(numBinsChanged(int)));

    hgLayout->addWidget(numBins, 0, 1, 1, 1);

    // Bin scale
    QLabel *binScaleLabel = new QLabel(tr("Bin Scale"), histGroupBox);
    hgLayout->addWidget(binScaleLabel, 1, 0);

    QWidget     *binScaleWidget = new QWidget(histGroupBox);
    QHBoxLayout *binScaleLayout = new QHBoxLayout(binScaleWidget);    
    binScaleLayout->setMargin(0);

    QRadioButton *binLinearScale = new QRadioButton(tr("Linear"), binScaleWidget);
    QRadioButton *binLogScale = new QRadioButton(tr("Log"), binScaleWidget);
    QRadioButton *binSqrtScale = new QRadioButton(tr("Square root"), binScaleWidget);
    
    binScaleGroup = new QButtonGroup(binScaleWidget);
    binScaleGroup->addButton(binLinearScale,0);
    binScaleGroup->addButton(binLogScale,1);
    binScaleGroup->addButton(binSqrtScale,2);
    
    binScaleLayout->addWidget(binLinearScale);
    binScaleLayout->addWidget(binLogScale);
    binScaleLayout->addWidget(binSqrtScale);
    
    connect(binScaleGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(binScaleChanged(int)));    

    hgLayout->addWidget(binScaleWidget, 1, 1, 1, 2);

    // Bin contribution
    histogramTypeLabel = new QLabel(tr("Bin contribution"), histGroupBox);
    hgLayout->addWidget(histogramTypeLabel, 2, 0);


    histogramTypeWidget = new QWidget(central);
    QHBoxLayout *histogramTypeLayout = new QHBoxLayout(histogramTypeWidget);
    histogramTypeLayout->setMargin(0);
    
    QRadioButton *histogramTypeBinContributionFrequency =
      new QRadioButton(tr("Frequency"), histogramTypeWidget);
    QRadioButton *histogramTypeBinContributionWeighted =
      new QRadioButton(tr("Weighted"), histogramTypeWidget);

    histogramTypeGroup = new QButtonGroup(histogramTypeWidget);
    histogramTypeGroup->addButton(histogramTypeBinContributionFrequency,0);
    histogramTypeGroup->addButton(histogramTypeBinContributionWeighted,1);
    
    histogramTypeLayout->addWidget(histogramTypeBinContributionFrequency);
    histogramTypeLayout->addWidget(histogramTypeBinContributionWeighted);
    
    connect(histogramTypeGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(histogramTypeChanged(int)));

    hgLayout->addWidget(histogramTypeWidget, 2, 1, 1, 2);

    
    // Add weighting
    QGroupBox * weightingGroup = new QGroupBox(central);
    weightingGroup->setTitle(tr("Weighting"));
    hgLayout->addWidget(weightingGroup, 3, 0, 3, 5);

    QGridLayout *weightingLayout = new QGridLayout(weightingGroup);
    weightingLayout->setMargin(5);
    weightingLayout->setSpacing(10);


    weightTypeLabel = new QLabel(tr("Weighted by"), histGroupBox);
    weightingLayout->addWidget(weightTypeLabel,1,0);
    
    weightTypeWidget = new QWidget(histGroupBox);
    QHBoxLayout *weightTypeLayout = new QHBoxLayout(weightTypeWidget);
    weightTypeLayout->setMargin(0);
    
    QRadioButton *weightTypeVolumeArea =
      new QRadioButton(tr("Area (2D) / Volume (3D)"), weightTypeWidget);
    QRadioButton *weightTypeVariable = new QRadioButton(tr("Variable"),
                                                        weightTypeWidget);
    weightTypeGroup = new QButtonGroup(weightTypeWidget);
    weightTypeGroup->addButton(weightTypeVolumeArea,0);
    weightTypeGroup->addButton(weightTypeVariable,1);
    
    weightTypeLayout->addWidget(weightTypeVolumeArea);
    weightTypeLayout->addWidget(weightTypeVariable);
    
    connect(weightTypeGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(weightTypeChanged(int)));
    weightingLayout->addWidget(weightTypeWidget, 1,1);

    weightVariableLabel = new QLabel(tr("Variable to Weight By"), histGroupBox);
    weightingLayout->addWidget(weightVariableLabel,2,0);
    int weightVariableMask = QvisVariableButton::Scalars;
    weightVariable =
      new QvisVariableButton(true, true, true, weightVariableMask, histGroupBox);
    weightVariable->setDefaultVariable("default");
    connect(weightVariable, SIGNAL(activated(const QString&)),
            this, SLOT(weightVariableChanged(const QString&)));
    weightingLayout->addWidget(weightVariable, 2,1);

    //
    // Statistics options
    //
    QGroupBox* statisticsGroupBox = new QGroupBox(histGroupBox);
    statisticsGroupBox->setTitle(tr("Statistical Options"));
    hgTopLayout->addWidget(statisticsGroupBox);

    QHBoxLayout* statsLayout = new QHBoxLayout(statisticsGroupBox);
    statisticsGroupBox->setLayout(statsLayout);

    // Normalization
    normalizeHistogram = 
      new QCheckBox(tr("Normalize Histogram"), statisticsGroupBox);
    statsLayout->addWidget(normalizeHistogram);
    
    connect(normalizeHistogram, SIGNAL(toggled(bool)),
            this, SLOT(normalizeChanged(bool)));
   
    computeCDF = 
      new QCheckBox(tr("Compute the CDF"), statisticsGroupBox);
    statsLayout->addWidget(computeCDF);

    connect(computeCDF, SIGNAL(toggled(bool)),
            this, SLOT(computeCdfChanged(bool)));

    // Add data scale
    QGroupBox * dataGroup = new QGroupBox(central);
    dataGroup->setTitle(tr("Data"));
    hgLayout->addWidget(dataGroup, 6, 0, 3, 5);

    QGridLayout *dataLayout = new QGridLayout(dataGroup);
    dataLayout->setMargin(5);
    dataLayout->setSpacing(10);

    //
    // Create the scale radio buttons
    //
    dataLayout->addWidget( new QLabel(tr("Scale"), central), 0, 0);
    
    // Create the radio buttons
    dataScaleGroup = new QButtonGroup(central);

    QRadioButton * rb = new QRadioButton(tr("Linear"), central);
    rb->setChecked(true);
    dataScaleGroup->addButton(rb, 0);
    dataLayout->addWidget(rb, 0, 1);
    rb = new QRadioButton(tr("Log"), central);
    dataScaleGroup->addButton(rb, 1);
    dataLayout->addWidget(rb, 0, 2);
    rb = new QRadioButton(tr("Square Root"), central);
    dataScaleGroup->addButton(rb, 2);
    dataLayout->addWidget(rb, 0, 3);

    // Each time a radio button is clicked, call the scale clicked slot.
    connect(dataScaleGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(dataScaleChanged(int)));

    //
    // Create the Limits stuff
    //
    QGroupBox * limitsGroup = new QGroupBox(central);
    dataLayout->addWidget(limitsGroup, 1, 0, 2, 5);

    QGridLayout *limitsLayout = new QGridLayout(limitsGroup);
    limitsLayout->setMargin(5);
    limitsLayout->setSpacing(10);

    limitsLayout->addWidget( new QLabel(tr("Limits"), central), 0, 0);

    limitsSelect = new QComboBox(central);
    limitsSelect->addItem(tr("Use Original Data"));
    limitsSelect->addItem(tr("Use Current Plot"));
    connect(limitsSelect, SIGNAL(activated(int)),
            this, SLOT(limitsSelectChanged(int))); 
    limitsLayout->addWidget(limitsSelect, 0, 1, 1, 2, Qt::AlignLeft);

    // Create the min toggle and line edit
    minToggle = new QCheckBox(tr("Minimum"), central);
    limitsLayout->addWidget(minToggle, 1, 0);
    connect(minToggle, SIGNAL(toggled(bool)),
            this, SLOT(minToggled(bool)));
    minLineEdit = new QLineEdit(central);
    connect(minLineEdit, SIGNAL(returnPressed()),
            this, SLOT(minProcessText())); 
    limitsLayout->addWidget(minLineEdit, 1, 1);

    // Create the max toggle and line edit
    maxToggle = new QCheckBox(tr("Maximum"), central);
    limitsLayout->addWidget(maxToggle, 1, 2);
    connect(maxToggle, SIGNAL(toggled(bool)),
            this, SLOT(maxToggled(bool)));
    maxLineEdit = new QLineEdit(central);
    connect(maxLineEdit, SIGNAL(returnPressed()),
            this, SLOT(maxProcessText())); 
    limitsLayout->addWidget(maxLineEdit, 1, 3);



    // Bar Plot Group Box
    barGroupBox =new QGroupBox(central); 
    barGroupBox->setTitle(tr("Single Zone Plot Options"));
    mainLayout->addWidget(barGroupBox, 2, 0, 1, 2);
    QVBoxLayout *bgTopLayout = new QVBoxLayout(barGroupBox);

    QGridLayout *bgLayout = new QGridLayout();
    bgTopLayout->addLayout(bgLayout);
    bgLayout->setColumnStretch(1,10);

    domainLabel = new QLabel(tr("domain"), barGroupBox);
    bgLayout->addWidget(domainLabel,0,0);

    domain = new QLineEdit(barGroupBox);
    connect(domain, SIGNAL(returnPressed()),
            this, SLOT(domainProcessText()));
    bgLayout->addWidget(domain, 0,1);

    zoneLabel = new QLabel(tr("zone"), barGroupBox);
    bgLayout->addWidget(zoneLabel,1,0);

    zone = new QLineEdit(barGroupBox);
    connect(zone, SIGNAL(returnPressed()),
            this, SLOT(zoneProcessText()));
    bgLayout->addWidget(zone, 1,1);

    useBinWidths = new QCheckBox(tr("Use bin widths"), barGroupBox);
    connect(useBinWidths, SIGNAL(toggled(bool)),
            this, SLOT(useBinWidthsChanged(bool)));
    bgLayout->addWidget(useBinWidths, 2,0);


    // Plot Syle Group Box

    // Bar Plot Group Box
    styleGroupBox =new QGroupBox(central); 
    styleGroupBox->setTitle(tr("Plot Style"));
    mainLayout->addWidget(styleGroupBox, 3, 0, 1, 2);
    QVBoxLayout *sgTopLayout = new QVBoxLayout(styleGroupBox);
    QGridLayout *sgLayout= new QGridLayout();
    sgTopLayout->addLayout(sgLayout);
    sgLayout->setColumnStretch(2,10);
    
    // Add output type

    QWidget     *outputTypeWidget = new QWidget(styleGroupBox);
    QHBoxLayout *outputTypeLayout = new QHBoxLayout(outputTypeWidget);
    outputTypeLayout->setMargin(0);
    
    QRadioButton *outputTypeOutputTypeCurve = new QRadioButton(tr("Curve"), outputTypeWidget);
    QRadioButton *outputTypeOutputTypeBlock = new QRadioButton(tr("Block"), outputTypeWidget);
    
    outputTypeGroup = new QButtonGroup(outputTypeWidget);
    outputTypeGroup->addButton(outputTypeOutputTypeCurve,0);
    outputTypeGroup->addButton(outputTypeOutputTypeBlock,1);
    
    outputTypeLayout->addWidget(outputTypeOutputTypeCurve);
    outputTypeLayout->addWidget(outputTypeOutputTypeBlock,1);
    
    connect(outputTypeGroup, SIGNAL(buttonClicked(int)),
            this, SLOT(outputTypeChanged(int)));

    sgLayout->addWidget(outputTypeWidget, 0,1,1,2);

    outputTypeLabel = new QLabel(tr("Type of Output"), styleGroupBox);
    sgLayout->addWidget(outputTypeLabel,0,0, Qt::AlignRight | Qt::AlignVCenter);

    // Add Line Style
    lineStyleLabel = new QLabel(tr("Line Style"), styleGroupBox);
    sgLayout->addWidget(lineStyleLabel,1,0,Qt::AlignRight | Qt::AlignVCenter);

    lineStyle = new QvisLineStyleWidget(0, styleGroupBox);
    connect(lineStyle, SIGNAL(lineStyleChanged(int)),
            this, SLOT(lineStyleChanged(int)));
    sgLayout->addWidget(lineStyle, 1,1,1,2);

    // Add Line Width
    lineWidthLabel = new QLabel(tr("Line Width"), styleGroupBox);
    sgLayout->addWidget(lineWidthLabel,2,0,Qt::AlignRight | Qt::AlignVCenter);

    lineWidth = new QvisLineWidthWidget(0, styleGroupBox);
    connect(lineWidth, SIGNAL(lineWidthChanged(int)),
            this, SLOT(lineWidthChanged(int)));
    sgLayout->addWidget(lineWidth, 2,1,1,2);

    // Add Color Selector
    colorLabel = new QLabel(tr("Color"), styleGroupBox);
    sgLayout->addWidget(colorLabel,3,0,Qt::AlignRight | Qt::AlignVCenter);

    color = new QvisColorButton(styleGroupBox);
    connect(color, SIGNAL(selectedColor(const QColor&)),
            this, SLOT(colorChanged(const QColor&)));
    sgLayout->addWidget(color, 3,1);


    // Add normalization option.
}
示例#3
0
CollectionWidget::CollectionWidget( QWidget* parent ):
        QWidget(parent)
{
    p = new CollectionWidgetPrivate;

    QPushButton *pushRandom =new QPushButton();
    QPixmap pixmap2(":shuffle.png");
    pushRandom->setIcon(QIcon(pixmap2));
    pushRandom->setIconSize(QSize(27,27));
    pushRandom->setMaximumWidth(40);
    pushRandom->setStyleSheet("QPushButton { border: none; padding: 0px; margin-left: 10px;max-height: 20px; margin-right: 4px;}");
    pushRandom->setToolTip(tr( "Random Tracks" ));

    p->searchEdit = new SearchEdit();
    p->searchEdit->setToolTip(tr( "Enter space-separated terms to filter collection" ));

    QVBoxLayout *mainLayout = new QVBoxLayout;
    QWidget *headWidget = new QWidget(this);
    headWidget->setMaximumHeight(38);

    QHBoxLayout *headWidgetLayout = new QHBoxLayout;
    headWidgetLayout->setMargin(0);
    headWidgetLayout->setSpacing(1);

    headWidgetLayout->addSpacerItem(new QSpacerItem(10, 0, QSizePolicy::Fixed, QSizePolicy::Expanding));
    headWidgetLayout->addWidget(p->searchEdit);
    headWidgetLayout->addWidget(pushRandom);
    headWidget->setLayout(headWidgetLayout);

    p->updater = new CollectionUpdater();

    p->timer = new QTimer( this );
    p->timer->setInterval(300);
    p->timer->setSingleShot(true);

    p->collectiontree = new CollectionTree(this);
    p->modeSelect = new ModeSelector(p->collectiontree);

    headWidget->raise();
    mainLayout->addWidget(headWidget);

    mainLayout->setMargin(0);
    mainLayout->setSpacing(0);
 
    connect(pushRandom,SIGNAL(clicked()),
            p->collectiontree,SLOT(triggerRandomSelection()) );

    connect ( p->modeSelect , SIGNAL(modeChanged(ModeSelector::modeType)),
            this, SLOT(onModeSelected(ModeSelector::modeType)));

    connect( p->searchEdit, SIGNAL( textChanged( const QString& ) ),
             this,           SLOT( onSetFilterTimeout() ) );

    connect( p->searchEdit, SIGNAL( trackDropped(QString)),
             this,           SIGNAL( trackDropped(QString)) );

    connect( p->collectiontree, SIGNAL(selectionChanged(QList<Track*>)),
             this,           SIGNAL(selectionChanged(QList<Track*>)));

    connect( p->collectiontree, SIGNAL(wantLoad(QList<Track*>,QString)),
             this,           SIGNAL(wantLoad(QList<Track*>,QString)));

    connect( p->updater, SIGNAL(changesDone()), p->collectiontree, SLOT(createTrunk()));
    connect( p->collectiontree, SIGNAL(rescan()), p->updater, SLOT(scan()));

    connect( p->timer, SIGNAL(timeout()), SLOT(onSetFilter())  );

    setFocusProxy( p->collectiontree ); //default object to get focus
    setMaximumWidth(400);

    //Pogressbar for re-read collection
    p->progress = new ProgressBar(this);
    p->progress->setValue(0);
    p->progress->setStyleSheet("* { margin-bottom: 3px; }");

    mainLayout->addWidget(p->collectiontree);


    // Read config values
    QSettings settings;
    p->modeSelect->setMode( static_cast<ModeSelector::modeType>(settings.value("TreeMode",ModeSelector::MODENONE).toUInt()));


    p->collectiontree->createTrunk();
    setLayout(mainLayout);

    connect(p->updater, SIGNAL(progressChanged(int)), p->progress,SLOT(setValue(int)));
    connect(p->progress, SIGNAL(stopped()), p->updater,SLOT(stop()));
    p->modeSelect->show();
}
示例#4
0
/*****************************************************************************
* CameraExample
*/
CameraExample::CameraExample(QWidget *parent) :
    QMainWindow(parent)
{
    setWindowTitle("QCameraExample");

    // Opitimizations for screen update and drawing qwidget
    setAutoFillBackground(false);

    // Prevent to screensaver to activate
    m_systemScreenSaver = new QSystemScreenSaver(this);
    m_systemScreenSaver->setScreenSaverInhibit();

    m_myVideoSurface = 0;
    pictureCaptured = false;
    showViewFinder = false;
    m_focusing = false;

    // Black background
    QPalette palette = this->palette();
    palette.setColor(QPalette::Background, Qt::black);
    setPalette(palette);

    // Main widget & layout
    QWidget* mainWidget = new QWidget(this);
    mainWidget->setPalette(palette);

    QHBoxLayout* hboxl = new QHBoxLayout;
    hboxl->setSpacing(0);
    hboxl->setMargin(0);

    // UI stack
    m_stackedWidget = new QStackedWidget();
    m_stackedWidget->setPalette(palette);

    // First widget to stack
    m_videoWidget = new QWidget();
    m_videoWidget->setPalette(palette);
    m_stackedWidget->addWidget(m_videoWidget);

    // Second widget to stack
    QWidget* secondWidget = new QWidget(this);
    secondWidget->setPalette(palette);
    m_stackedWidget->addWidget(secondWidget);
    m_stackedWidget->setCurrentIndex(0);

    hboxl->addWidget(m_stackedWidget);

    // Buttons
    QSize iconSize(80, 80);
    QVBoxLayout* vboxl = new QVBoxLayout;
    vboxl->setSpacing(0);
    vboxl->setMargin(0);

    // Camera button
    m_cameraBtn = new Button(this);
    QObject::connect(m_cameraBtn, SIGNAL(pressed()), this, SLOT(searchAndLock()));
    QPixmap p = QPixmap(":/images/camera.png");
    m_cameraBtn->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    vboxl->addWidget(m_cameraBtn);
    vboxl->setAlignment(m_cameraBtn, Qt::AlignCenter);

    // Exit button
    m_exit = new Button(this);
    QObject::connect(m_exit, SIGNAL(pressed()), qApp, SLOT(quit()));
    p = QPixmap(":/images/exit.png");
    m_exit->setPixmap(p.scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation));
    vboxl->addWidget(m_exit);
    vboxl->setAlignment(m_exit, Qt::AlignHCenter | Qt::AlignTop);

    hboxl->addLayout(vboxl);
    mainWidget->setLayout(hboxl);

    setCentralWidget(mainWidget);

    // Enable camera after 1s, so that the application is started
    // and widget is created to landscape orientation
    QTimer::singleShot(1000,this,SLOT(enableCamera()));
}
示例#5
0
SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
                          bool b_shiny, bool b_special )
                         : QWidget( _parent ), p_intf( _p_intf),
                           b_is_muted( false ), b_ignore_valuechanged( false )
{
    /* We need a layout for this widget */
    QHBoxLayout *layout = new QHBoxLayout( this );
    layout->setSpacing( 0 ); layout->setMargin( 0 );

    /* We need a Label for the pix */
    volMuteLabel = new QLabel;
    volMuteLabel->setPixmap( QIcon( ":/toolbar/volume-medium" ).pixmap( 16, 16 ) );

    /* We might need a subLayout too */
    QVBoxLayout *subLayout;

    volMuteLabel->installEventFilter( this );

    /* Normal View, click on icon mutes */
    if( !b_special )
    {
        volumeMenu = NULL; subLayout = NULL;
        volumeControlWidget = NULL;

        /* And add the label */
        layout->addWidget( volMuteLabel, 0, b_shiny? Qt::AlignBottom : Qt::AlignCenter );
    }
    else
    {
        /* Special view, click on button shows the slider */
        b_shiny = false;

        volumeControlWidget = new QFrame( this );
        subLayout = new QVBoxLayout( volumeControlWidget );
        subLayout->setContentsMargins( 4, 4, 4, 4 );
        volumeMenu = new QMenu( this );

        QWidgetAction *widgetAction = new QWidgetAction( volumeControlWidget );
        widgetAction->setDefaultWidget( volumeControlWidget );
        volumeMenu->addAction( widgetAction );

        /* And add the label */
        layout->addWidget( volMuteLabel );
    }

    /* Slider creation: shiny or clean */
    if( b_shiny )
    {
        volumeSlider = new SoundSlider( this,
            config_GetFloat( p_intf, "volume-step" ),
            var_InheritString( p_intf, "qt-slider-colours" ),
            var_InheritInteger( p_intf, "qt-max-volume") );
    }
    else
    {
        volumeSlider = new QSlider( NULL );
        volumeSlider->setAttribute( Qt::WA_MacSmallSize);
        volumeSlider->setOrientation( b_special ? Qt::Vertical
                                                : Qt::Horizontal );
        volumeSlider->setMaximum( 200 );
    }

    volumeSlider->setFocusPolicy( Qt::NoFocus );
    if( b_special )
        subLayout->addWidget( volumeSlider );
    else
        layout->addWidget( volumeSlider, 0, b_shiny? Qt::AlignBottom : Qt::AlignCenter );

    /* Set the volume from the config */
    float volume = playlist_VolumeGet( THEPL );
    libUpdateVolume( (volume >= 0.f) ? volume : 1.f );
    /* Sync mute status */
    if( playlist_MuteGet( THEPL ) > 0 )
        updateMuteStatus( true );

    /* Volume control connection */
    volumeSlider->setTracking( true );
    CONNECT( volumeSlider, valueChanged( int ), this, valueChangedFilter( int ) );
    CONNECT( this, valueReallyChanged( int ), this, userUpdateVolume( int ) );
    CONNECT( THEMIM, volumeChanged( float ), this, libUpdateVolume( float ) );
    CONNECT( THEMIM, soundMuteChanged( bool ), this, updateMuteStatus( bool ) );
}
QScriptDebuggerCodeFinderWidget::QScriptDebuggerCodeFinderWidget(QWidget *parent)
    : QScriptDebuggerCodeFinderWidgetInterface(
        *new QScriptDebuggerCodeFinderWidgetPrivate, parent, 0)
{
    Q_D(QScriptDebuggerCodeFinderWidget);
    QString system = QLatin1String("win");
    QHBoxLayout *hboxLayout = new QHBoxLayout(this);
#ifdef Q_OS_MAC
    system = QLatin1String("mac");
#else
    hboxLayout->setSpacing(6);
    hboxLayout->setMargin(0);
#endif

    d->toolClose = new QToolButton(this);
    d->toolClose->setIcon(QIcon(QString::fromUtf8(":/qt/scripttools/debugging/images/%1/closetab.png").arg(system)));
    d->toolClose->setAutoRaise(true);
    d->toolClose->setText(tr("Close"));
    hboxLayout->addWidget(d->toolClose);

    d->editFind = new QLineEdit(this);
    d->editFind->setMinimumSize(QSize(150, 0));
    connect(d->editFind, SIGNAL(textChanged(QString)),
            this, SLOT(_q_updateButtons()));
    connect(d->editFind, SIGNAL(returnPressed()),
            this, SLOT(_q_next()));
    hboxLayout->addWidget(d->editFind);

    d->toolPrevious = new QToolButton(this);
    d->toolPrevious->setAutoRaise(true);
    d->toolPrevious->setText(tr("Previous"));
    d->toolPrevious->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    d->toolPrevious->setIcon(QIcon(QString::fromUtf8(":/qt/scripttools/debugging/images/%1/previous.png").arg(system)));
    hboxLayout->addWidget(d->toolPrevious);

    d->toolNext = new QToolButton(this);
    d->toolNext->setAutoRaise(true);
    d->toolNext->setText(tr("Next"));
    d->toolNext->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    d->toolNext->setIcon(QIcon(QString::fromUtf8(":/qt/scripttools/debugging/images/%1/next.png").arg(system)));
    hboxLayout->addWidget(d->toolNext);

    d->checkCase = new QCheckBox(tr("Case Sensitive"), this);
    hboxLayout->addWidget(d->checkCase);

    d->checkWholeWords = new QCheckBox(tr("Whole words"), this);
    hboxLayout->addWidget(d->checkWholeWords);

    d->labelWrapped = new QLabel(this);
    d->labelWrapped->setMinimumSize(QSize(0, 20));
    d->labelWrapped->setMaximumSize(QSize(115, 20));
    d->labelWrapped->setTextFormat(Qt::RichText);
    d->labelWrapped->setScaledContents(true);
    d->labelWrapped->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
    d->labelWrapped->setText(tr("<img src=\":/qt/scripttools/debugging/images/wrap.png\">&nbsp;Search wrapped"));
    hboxLayout->addWidget(d->labelWrapped);

    QSpacerItem *spacerItem = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    hboxLayout->addItem(spacerItem);
    setMinimumWidth(minimumSizeHint().width());
    d->labelWrapped->hide();

    d->_q_updateButtons();

    setFocusProxy(d->editFind);
    QObject::connect(d->toolClose, SIGNAL(clicked()), this, SLOT(hide()));
    QObject::connect(d->editFind, SIGNAL(textChanged(QString)),
                     this, SLOT(_q_onTextChanged(QString)));
    QObject::connect(d->toolNext, SIGNAL(clicked()), this, SLOT(_q_next()));
    QObject::connect(d->toolPrevious, SIGNAL(clicked()), this, SLOT(_q_previous()));
}
示例#7
0
QHBoxLayout* StatusViewer::initializeLayout() {
    QHBoxLayout* mainLayout = new QHBoxLayout();
    mainLayout->setSpacing(0);
    mainLayout->setMargin(0);
    mainLayout->addStretch(0);
    
    //Initialize the mag and qval fields
    magLabel_ = new QLabel;
    qvalLabel_ = new QLabel;
    
    QFormLayout* rtlayout = new QFormLayout();
    rtlayout->setMargin(0);
    rtlayout->addRow("Calculated Mag: ", magLabel_);
    rtlayout->addRow("Last QVAL: ", qvalLabel_);
    
    phaseResLabel_ = new QLabel;
    numSpotsLabel_ = new QLabel;
    
    QFormLayout* ltlayout = new QFormLayout();
    ltlayout->setMargin(0);
    ltlayout->addRow("Sym. PhaRes: ", phaseResLabel_);
    ltlayout->addRow("# of spots: ", numSpotsLabel_);
    
    QHBoxLayout* layout = new QHBoxLayout();
    layout->setSpacing(5);
    layout->setMargin(0);
    layout->addLayout(rtlayout);
    layout->addLayout(ltlayout);
    
    //Initialize the bins table
    binsTable_ = prepareTable(2, 6);
    binsTable_->horizontalHeader()->hide();
    binsTable_->setVerticalHeaderLabels(QStringList() << "Resolution [A]" << "#");
    
    //Initialize the qval table
    qvalTable_ = prepareTable(4, 7);

    QStringList labels;
    labels << tr("IQ1") << tr("IQ2") << tr("IQ3") << tr("IQ4") << tr("IQ5") << tr("IQ6") << tr("QVAL");
    qvalTable_->setHorizontalHeaderLabels(labels);
    qvalTable_->setVerticalHeaderLabels(QStringList() << "Unbend I" << "Unbend II" << "Movie A" << "Movie B");
    
    //Initialize the tilt table
    tiltTable_ = prepareTable(4, 4);
    tiltTable_->setVerticalHeaderLabels(QStringList() << tr("Defocus") << tr("Lattice") << tr("Spot Split") << tr("Merge"));
    tiltTable_->setHorizontalHeaderLabels(QStringList() << "Grid TAxis" << "Grid TAngle" << "Xtal TAxis" << "Xtal TAngle");
    
    //Arrange everything in a layout
    QVBoxLayout* firstColLayout = new QVBoxLayout();
    firstColLayout->setMargin(0);
    firstColLayout->setSpacing(2);
    firstColLayout->addLayout(layout);
    firstColLayout->addStretch(1);
    firstColLayout->addWidget(new QLabel("Power Bins:"));
    firstColLayout->addWidget(binsTable_);
    QWidget* firstCol = new QWidget;
    firstCol->setLayout(firstColLayout);
    
    mainLayout->addWidget(firstCol, 1);
    mainLayout->addWidget(qvalTable_, 1);
    mainLayout->addWidget(tiltTable_, 1);
    
    return mainLayout;
}
void EditorConfigDialog::setupSpeedWidgets(QWidget* parent)
{
	QIntValidator* allInts = new QIntValidator(this);

	QHBoxLayout* hboxLayout = new QHBoxLayout(parent);
	hboxLayout->setSpacing(4);
	hboxLayout->setMargin(4);

	hboxLayout->addItem(
		new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Ignored));

	QGridLayout* gridLayout = new QGridLayout;
	gridLayout->setSpacing(1);
	gridLayout->setMargin(0);

	gridLayout->addItem(new QSpacerItem(
		0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding),
		0, 0);

	QLabel* label;
#define ADDSPEEDLABEL(text, row) \
	label = new QLabel(tr(text), parent); \
	label->setAlignment(Qt::AlignTrailing|Qt::AlignVCenter); \
	gridLayout->addWidget(label, row, 0, 1, 1); \

	ADDSPEEDLABEL("Scrolling Speeds:", 1);
	ADDSPEEDLABEL("Keyboard Scroll:", 2);
	ADDSPEEDLABEL("Mouse Scroll:", 3);
	ADDSPEEDLABEL("Tile Edit Window Scroll:", 4);
#undef ADDSPEEDLABEL

	label = new QLabel(tr("X"), parent);
	label->setMinimumSize(QSize(30, 0));
	label->setAlignment(Qt::AlignCenter);
	gridLayout->addWidget(label, 1, 1, 1, 1);

	label = new QLabel(tr("Y"), parent);
	label->setMinimumSize(QSize(30, 0));
	label->setAlignment(Qt::AlignCenter);
	gridLayout->addWidget(label, 1, 2, 1, 1);

#define ADDSPEEDLINEEDIT(var, row, col) \
	var = new QLineEdit(parent); \
	var ->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); \
	var ->setValidator(allInts); \
	gridLayout->addWidget( var , row , col , 1, 1); \

#define ADDSPEEDXYPAIR(enum, row) \
	ADDSPEEDLINEEDIT(scrollSpeeds[ enum ][0], row , 1) \
	ADDSPEEDLINEEDIT(scrollSpeeds[ enum ][1], row , 2) \

	ADDSPEEDXYPAIR(keyboardScroll, 2);
	ADDSPEEDXYPAIR(mouseScroll, 3);
	ADDSPEEDXYPAIR(tileeditScroll, 4);
#undef ADDSPEEDXYPAIR
#undef ADDSPEEDLINEEDIT

	gridLayout->addItem(new QSpacerItem(
		0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding),
		5, 0);

	hboxLayout->addLayout(gridLayout);

	hboxLayout->addItem(
		new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Ignored));

	QVBoxLayout* vboxLayout = new QVBoxLayout;

	vboxLayout->addItem(
		new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding));

	label = new QLabel(tr("Object Edit Scroll:"), parent);
	label->setAlignment(Qt::AlignCenter);
	vboxLayout->addWidget(label);

	editScrollSpeed = new QLineEdit(parent);
	editScrollSpeed->setValidator(allInts);
	vboxLayout->addWidget(editScrollSpeed);

	vboxLayout->addItem(
		new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding));

	lowZoomedScrollSpeed = new QCheckBox(tr("Low scroll speed\nwhile zoomed out"), parent);
	vboxLayout->addWidget(lowZoomedScrollSpeed);

	vboxLayout->addItem(
		new QSpacerItem(20, 40, QSizePolicy::Expanding, QSizePolicy::Expanding));

	hboxLayout->addLayout(vboxLayout);

	hboxLayout->addItem(
		new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Ignored));

	vboxLayout = new QVBoxLayout;

	vboxLayout->addItem(
		new QSpacerItem(20, 40, QSizePolicy::Ignored, QSizePolicy::Preferred));

	label = new QLabel(tr("Mouse Speed:"), parent);
	label->setAlignment(Qt::AlignCenter);
	vboxLayout->addWidget(label);

	QHBoxLayout* hboxLayout2;
#define ADDMOUSESPEED(text, index) \
	hboxLayout2 = new QHBoxLayout; \
	label = new QLabel(tr(text), parent); \
	label->setAlignment(Qt::AlignRight|Qt::AlignVCenter); \
	label->setMaximumWidth(20); \
	hboxLayout2->addWidget(label); \
	mouseSpeeds[index] = new QLineEdit(parent); \
	mouseSpeeds[index]->setValidator(allInts); \
	mouseSpeeds[index]->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed); \
	hboxLayout2->addWidget(mouseSpeeds[index]); \
	vboxLayout->addLayout(hboxLayout2); \

	ADDMOUSESPEED("X:", 0);
	ADDMOUSESPEED("Y:", 1);
#undef ADDMOUSESPEED

	vboxLayout->addItem(
		new QSpacerItem(20, 40, QSizePolicy::Ignored, QSizePolicy::Preferred));

	hboxLayout->addLayout(vboxLayout);

	hboxLayout->addItem(
		new QSpacerItem(20, 20, QSizePolicy::Preferred, QSizePolicy::Ignored));
}
void EditorConfigDialog::setupMiscWidgets(QWidget* parent)
{
	QIntValidator* allInts = new QIntValidator(this);

	QHBoxLayout* hboxLayout = new QHBoxLayout(parent);
	hboxLayout->setSpacing(6);
	hboxLayout->setMargin(2);

	QVBoxLayout* vboxLayout = new QVBoxLayout;
	vboxLayout->setSpacing(4);
	vboxLayout->setMargin(0);

#define ADDMISCCHECK(var, text) \
	var = new QCheckBox(tr( text ), parent); \
	vboxLayout->addWidget( var ); \

	ADDMISCCHECK(enableWorkspace, "Enable workspaces");
	ADDMISCCHECK(allowHigherType2, "Allow type 2 objects of higher Acts");
	ADDMISCCHECK(alwaysMaxLayerCount, "Always maximize layer count");
	ADDMISCCHECK(stretchSpritesOnZoom, "Stretch sprites when zooming");
	ADDMISCCHECK(minimizeSavedDs1, "Minimize file size of saved .ds1");
#undef ADDMISCCHECK

	QHBoxLayout* hboxLayout2 = new QHBoxLayout;
	QLabel* label = new QLabel(tr("Zoom after centering:"), parent);
	label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
	hboxLayout2->addWidget(label);
	zoomAfterCentering = new QComboBox(parent);
	zoomAfterCentering->addItems(QStringList()
		<<"NO_CHANGE"<<"1:1"<<"1:2"<<"1:4"<<"1:8"<<"1:16");
	hboxLayout2->addWidget(zoomAfterCentering);
	vboxLayout->addLayout(hboxLayout2);

	hboxLayout->addLayout(vboxLayout);

	vboxLayout = new QVBoxLayout;
	vboxLayout->setSpacing(4);
	vboxLayout->setMargin(0);

	label = new QLabel(tr("When objects editing window is open:"), parent);
	vboxLayout->addWidget(label);

	mouseScrollsMain = new QCheckBox(tr("Mouse scrolls main screen"), parent);
	vboxLayout->addWidget(mouseScrollsMain);

	keybScrollsMain = new QCheckBox(tr("Keyboard scrolls main screen"), parent);
	vboxLayout->addWidget(keybScrollsMain);

	vboxLayout->addItem(
		new QSpacerItem(20, 16, QSizePolicy::Ignored, QSizePolicy::Expanding));

	QGridLayout* gridLayout = new QGridLayout;
	label = new QLabel(tr("type 1 objects:"), parent);
	gridLayout->addWidget(label, 0, 0, 1, 1);
	label = new QLabel(tr("type 2 objects:"), parent);
	gridLayout->addWidget(label, 1, 0, 1, 1);
	type1TableSize = new QLineEdit(parent);
	type1TableSize->setValidator(allInts);
	gridLayout->addWidget(type1TableSize, 0, 1, 1, 1);
	type2TableSize = new QLineEdit(parent);
	type2TableSize->setValidator(allInts);
	gridLayout->addWidget(type2TableSize, 1, 1, 1, 1);
	QPushButton* pushButton = new QPushButton(tr("Revert"), parent);
	gridLayout->addWidget(pushButton, 0, 2, 2, 1);
	connect(pushButton, SIGNAL(clicked()), SLOT(revertTableSizes()));

	vboxLayout->addLayout(gridLayout);

	hboxLayout->addLayout(vboxLayout);
}
示例#10
0
OptionsGeneral::OptionsGeneral() :
   QWidget(NULL)
{
   // MRU files
   QLabel* pMruFilesLabel = new QLabel("MRU File Entries:", this);

   mpMruFilesSpin = new QSpinBox(this);
   mpMruFilesSpin->setMinimum(0);
   mpMruFilesSpin->setMaximum(16);
   mpMruFilesSpin->setSingleStep(1);

   QWidget* pMruFilesWidget = new QWidget(this);
   QHBoxLayout* pMruFilesLayout = new QHBoxLayout(pMruFilesWidget);
   pMruFilesLayout->setMargin(0);
   pMruFilesLayout->setSpacing(5);
   pMruFilesLayout->addWidget(pMruFilesLabel);
   pMruFilesLayout->addWidget(mpMruFilesSpin);
   pMruFilesLayout->addStretch(10);

   LabeledSection* pMruFilesSection = new LabeledSection(pMruFilesWidget, "Most Recently Used (MRU) Files", this);

   // Undo/redo
   QLabel* pBufferLabel = new QLabel("Buffer Size:", this);
   mpBufferSpin = new QSpinBox(this);
   mpBufferSpin->setRange(1, 3000);
   mpBufferSpin->setSingleStep(1);
   mpBufferSpin->setSuffix(" Actions");
   mpBufferSpin->setToolTip("Maximum number of undo actions per view");

   QWidget* pBufferLayoutWidget = new QWidget();
   QHBoxLayout* pUndoLayout = new QHBoxLayout(pBufferLayoutWidget);
   pUndoLayout->setMargin(0);
   pUndoLayout->setSpacing(5);
   pUndoLayout->addWidget(pBufferLabel);
   pUndoLayout->addWidget(mpBufferSpin);
   pUndoLayout->addStretch(10);
   LabeledSection* pUndoSection = new LabeledSection(pBufferLayoutWidget, "Undo/Redo", this);

   // Threading
   QLabel* pThreadCountLabel = new QLabel("Worker Threads:", this);
   unsigned int maxThreadCount = Service<UtilityServices>()->getNumProcessors();
   mpThreadSpin = new QSpinBox(this);
   mpThreadSpin->setMinimum(1);
   mpThreadSpin->setMaximum(maxThreadCount);
   mpThreadSpin->setSingleStep(1);
   QWidget* pThreadingLayoutWidget = new QWidget(this);
   QHBoxLayout* pThreadingLayout = new QHBoxLayout(pThreadingLayoutWidget);
   pThreadingLayout->setMargin(0);
   pThreadingLayout->setSpacing(5);
   pThreadingLayout->addWidget(pThreadCountLabel);
   pThreadingLayout->addWidget(mpThreadSpin);
   pThreadingLayout->addStretch(10);
   LabeledSection* pThreadingSection = new LabeledSection(pThreadingLayoutWidget, "Multi-threading", this);

   // Progress Dialog
   mpProgressClose = new QCheckBox("Automatically close on process completion", this);
   LabeledSection* pProgressSection = new LabeledSection(mpProgressClose, "Progress Dialog", this);

   // Mouse Wheel Zoom Dialog
   mpMouseWheelZoom = new QCheckBox("Alternate mouse wheel zoom direction", this);
   LabeledSection* pMouseWheelZoomSection = new LabeledSection(mpMouseWheelZoom, "Mouse Wheel Zoom Direction", this);

   // Dialog layout
   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(0);
   pLayout->setSpacing(10);
   pLayout->addWidget(pMruFilesSection);
   pLayout->addWidget(pUndoSection);
   pLayout->addWidget(pThreadingSection);
   pLayout->addWidget(pProgressSection);
   pLayout->addWidget(pMouseWheelZoomSection);
   pLayout->addStretch(10);

   // Initialization
   mpMruFilesSpin->setValue(static_cast<int>(ConfigurationSettings::getSettingNumberOfMruFiles()));
   mpBufferSpin->setValue(static_cast<int>(ConfigurationSettings::getSettingUndoBufferSize()));
   mpThreadSpin->setValue(static_cast<int>(ConfigurationSettings::getSettingThreadCount()));
   mpProgressClose->setChecked(Progress::getSettingAutoClose());
   mpMouseWheelZoom->setChecked(ConfigurationSettings::getSettingAlternateMouseWheelZoom());
}
示例#11
0
QgsLocatorWidget::QgsLocatorWidget( QWidget *parent )
  : QWidget( parent )
  , mModelBridge( new QgsLocatorModelBridge( this ) )
  , mLineEdit( new QgsFilterLineEdit() )
  , mResultsView( new QgsLocatorResultsView() )
{
  mLineEdit->setShowClearButton( true );
#ifdef Q_OS_MACX
  mLineEdit->setPlaceholderText( tr( "Type to locate (⌘K)" ) );
#else
  mLineEdit->setPlaceholderText( tr( "Type to locate (Ctrl+K)" ) );
#endif

  int placeholderMinWidth = mLineEdit->fontMetrics().width( mLineEdit->placeholderText() );
  int minWidth = std::max( 200, static_cast< int >( placeholderMinWidth * 1.8 ) );
  resize( minWidth, 30 );
  QSizePolicy sizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
  sizePolicy.setHorizontalStretch( 0 );
  sizePolicy.setVerticalStretch( 0 );
  setSizePolicy( sizePolicy );
  setMinimumSize( QSize( minWidth, 0 ) );

  QHBoxLayout *layout = new QHBoxLayout();
  layout->setMargin( 0 );
  layout->setContentsMargins( 0, 0, 0, 0 );
  layout->addWidget( mLineEdit );
  setLayout( layout );

  setFocusProxy( mLineEdit );

  // setup floating container widget
  mResultsContainer = new QgsFloatingWidget( parent ? parent->window() : nullptr );
  mResultsContainer->setAnchorWidget( mLineEdit );
  mResultsContainer->setAnchorPoint( QgsFloatingWidget::BottomLeft );
  mResultsContainer->setAnchorWidgetPoint( QgsFloatingWidget::TopLeft );

  QHBoxLayout *containerLayout = new QHBoxLayout();
  containerLayout->setMargin( 0 );
  containerLayout->setContentsMargins( 0, 0, 0, 0 );
  containerLayout->addWidget( mResultsView );
  mResultsContainer->setLayout( containerLayout );
  mResultsContainer->hide();

  mResultsView->setModel( mModelBridge->proxyModel() );
  mResultsView->setUniformRowHeights( true );
  mResultsView->setIconSize( QSize( 16, 16 ) );
  mResultsView->recalculateSize();
  mResultsView->setContextMenuPolicy( Qt::CustomContextMenu );

  connect( mLineEdit, &QLineEdit::textChanged, this, &QgsLocatorWidget::scheduleDelayedPopup );
  connect( mResultsView, &QAbstractItemView::activated, this, &QgsLocatorWidget::acceptCurrentEntry );
  connect( mResultsView, &QAbstractItemView::customContextMenuRequested, this, &QgsLocatorWidget::showContextMenu );

  connect( mModelBridge, &QgsLocatorModelBridge::resultAdded, this, &QgsLocatorWidget::resultAdded );
  connect( mModelBridge, &QgsLocatorModelBridge::isRunningChanged, this, [ = ]() {mLineEdit->setShowSpinner( mModelBridge->isRunning() );} );
  connect( mModelBridge, & QgsLocatorModelBridge::resultsCleared, this, [ = ]() {mHasSelectedResult = false;} );

  // have a tiny delay between typing text in line edit and showing the window
  mPopupTimer.setInterval( 100 );
  mPopupTimer.setSingleShot( true );
  connect( &mPopupTimer, &QTimer::timeout, this, &QgsLocatorWidget::performSearch );
  mFocusTimer.setInterval( 110 );
  mFocusTimer.setSingleShot( true );
  connect( &mFocusTimer, &QTimer::timeout, this, &QgsLocatorWidget::triggerSearchAndShowList );

  mLineEdit->installEventFilter( this );
  mResultsContainer->installEventFilter( this );
  mResultsView->installEventFilter( this );
  installEventFilter( this );
  window()->installEventFilter( this );

  mModelBridge->locator()->registerFilter( new QgsLocatorFilterFilter( this, this ) );

  mMenu = new QMenu( this );
  QAction *menuAction = mLineEdit->addAction( QgsApplication::getThemeIcon( QStringLiteral( "/search.svg" ) ), QLineEdit::LeadingPosition );
  connect( menuAction, &QAction::triggered, this, [ = ]
  {
    mFocusTimer.stop();
    mResultsContainer->hide();
    mMenu->exec( QCursor::pos() );
  } );
  connect( mMenu, &QMenu::aboutToShow, this, &QgsLocatorWidget::configMenuAboutToShow );

}
示例#12
0
int KMessageBox::createKMessageBox(KDialog *dialog, const QIcon &icon,
                             const QString &text, const QStringList &strlist,
                             const QString &ask, bool *checkboxReturn, Options options,
                             const QString &details, QMessageBox::Icon notifyType)
{
    QWidget *mainWidget = new QWidget(dialog);
    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget);
    mainLayout->setSpacing(KDialog::spacingHint() * 2); // provide extra spacing
    mainLayout->setMargin(0);

    QHBoxLayout *hLayout = new QHBoxLayout();
    hLayout->setMargin(0);
    hLayout->setSpacing(-1); // use default spacing
    mainLayout->addLayout(hLayout,5);

    QLabel *iconLabel = new QLabel(mainWidget);

    if (!icon.isNull()) {
        QStyleOption option;
        option.initFrom(mainWidget);
        iconLabel->setPixmap(icon.pixmap(mainWidget->style()->pixelMetric(QStyle::PM_MessageBoxIconSize, &option, mainWidget)));
    }

    QVBoxLayout *iconLayout = new QVBoxLayout();
    iconLayout->addStretch(1);
    iconLayout->addWidget(iconLabel);
    iconLayout->addStretch(5);

    hLayout->addLayout(iconLayout,0);
    hLayout->addSpacing(KDialog::spacingHint());

    QLabel *messageLabel = new QLabel(text, mainWidget);
    messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
    Qt::TextInteractionFlags flags = Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard;
    if (options & KMessageBox::AllowLink) {
        flags |= Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard;
    }
    messageLabel->setTextInteractionFlags(flags);

    QRect desktop = KGlobalSettings::desktopGeometry(dialog);
    bool usingSqueezedTextLabel = false;
    if (messageLabel->sizeHint().width() > desktop.width() * 0.5) {
        // enable automatic wrapping of messages which are longer than 50% of screen width
        messageLabel->setWordWrap(true);
        // display a text widget with scrollbar if still too wide
        usingSqueezedTextLabel = messageLabel->sizeHint().width() > desktop.width() * 0.85;
        if (usingSqueezedTextLabel)
        {
            delete messageLabel;
            messageLabel = new KSqueezedTextLabel(text, mainWidget);
            messageLabel->setOpenExternalLinks(options & KMessageBox::AllowLink);
            messageLabel->setTextInteractionFlags(flags);
        }
    }

    QPalette messagePal(messageLabel->palette());
    messagePal.setColor(QPalette::Window, Qt::transparent);
    messageLabel->setPalette(messagePal);


    bool usingScrollArea=desktop.height() / 3 < messageLabel->sizeHint().height();
    if (usingScrollArea)
    {
        QScrollArea* messageScrollArea = new QScrollArea(mainWidget);
        messageScrollArea->setWidget(messageLabel);
        messageScrollArea->setFrameShape(QFrame::NoFrame);
        messageScrollArea->setWidgetResizable(true);
        QPalette scrollPal(messageScrollArea->palette());
        scrollPal.setColor(QPalette::Window, Qt::transparent);
        messageScrollArea->viewport()->setPalette(scrollPal);
        hLayout->addWidget(messageScrollArea,5);
    }
    else
        hLayout->addWidget(messageLabel,5);


    const bool usingListWidget=!strlist.isEmpty();
    if (usingListWidget) {
        // enable automatic wrapping since the listwidget has already a good initial width
        messageLabel->setWordWrap(true);
        QListWidget *listWidget = new QListWidget(mainWidget);
        listWidget->addItems(strlist);

        QStyleOptionViewItem styleOption;
        styleOption.initFrom(listWidget);
        QFontMetrics fm(styleOption.font);
        int w = listWidget->width();
        Q_FOREACH(const QString &str, strlist) {
            w = qMax(w, fm.width(str));
        }
        const int borderWidth = listWidget->width() - listWidget->viewport()->width() + listWidget->verticalScrollBar()->height();
        w += borderWidth;
        if (w > desktop.width() * 0.85) { // limit listWidget size to 85% of screen width
            w = qRound(desktop.width() * 0.85);
        }
        listWidget->setMinimumWidth(w);

        mainLayout->addWidget(listWidget,usingScrollArea?10:50);
        listWidget->setSelectionMode(QListWidget::NoSelection);
        messageLabel->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Minimum);
    }
示例#13
0
/*!	\fn void PaletteViewer::updateToolBar()
                Update button bar.
                */
PaletteViewer::PaletteViewer(QWidget *parent, PaletteViewType viewType,
                             bool hasSaveToolBar, bool hasPageCommand,
                             bool hasPasteColors)
    : QFrame(parent)
    , m_tabBarContainer(0)
    , m_pagesBar(0)
    , m_paletteToolBar(0)
    , m_savePaletteToolBar(0)
    , m_pageViewer(0)
    , m_pageViewerScrollArea(0)
    , m_indexPageToDelete(-1)
    , m_viewType(viewType)
    , m_frameHandle(0)
    , m_paletteHandle(0)
    , m_changeStyleCommand(0)
    , m_xsheetHandle(0)
    , m_hasSavePaletteToolbar(hasSaveToolBar)
    , m_hasPageCommand(hasPageCommand)
    , m_isSaveActionEnabled(true)
    , m_lockPaletteAction(0)
    , m_lockPaletteToolButton(0) {
  setObjectName("OnePixelMarginFrame");
  setFrameStyle(QFrame::StyledPanel);

  createTabBar();

  // Create pageView
  m_pageViewerScrollArea = new QScrollArea();
  m_pageViewerScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  m_pageViewerScrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  m_pageViewerScrollArea->setWidgetResizable(true);

  m_pageViewer =
      new PageViewer(m_pageViewerScrollArea, m_viewType, hasPasteColors);
  m_pageViewerScrollArea->setWidget(m_pageViewer);
  m_pagesBar->setPageViewer(m_pageViewer);

  // Create toolbar. It is an horizontal layout with three internal toolbar.
  DvScrollWidget *toolbarScrollWidget = new DvScrollWidget;

  toolbarScrollWidget->setObjectName(
      "ToolBarContainer");  // Toonz's qss files are instructed to leave a
  // 1px grey margin on top for scroll buttons
  QWidget *toolBarWidget = new QWidget;  // children of this parent name.
  toolbarScrollWidget->setWidget(toolBarWidget);
  toolBarWidget->setSizePolicy(QSizePolicy::MinimumExpanding,
                               QSizePolicy::Fixed);
  toolBarWidget->setFixedHeight(22);

  m_paletteToolBar     = new QToolBar(toolBarWidget);
  m_savePaletteToolBar = new QToolBar(toolBarWidget);
  createToolBar();

  QHBoxLayout *toolBarLayout = new QHBoxLayout(toolBarWidget);
  toolBarLayout->setMargin(0);
  toolBarLayout->setSpacing(0);
  {
    toolBarLayout->addWidget(m_savePaletteToolBar, 0, Qt::AlignRight);
    toolBarLayout->addWidget(m_paletteToolBar, 0, Qt::AlignRight);
  }
  toolBarWidget->setLayout(toolBarLayout);

  // This widget is used to set the background color of the tabBar
  // using the styleSheet.
  // It is also used to take 6px on the left before the tabBar
  // and to draw the two lines on the bottom size
  m_tabBarContainer = new TabBarContainter(this);

  QVBoxLayout *mainLayout = new QVBoxLayout(this);
  mainLayout->setMargin(0);
  mainLayout->setSpacing(0);
  {
    // To add 6px (on the left) before the TabBar
    QHBoxLayout *hLayout = new QHBoxLayout;
    hLayout->setMargin(0);
    // hLayout->setAlignment(Qt::AlignLeft);
    // hLayout->addSpacing(6);
    {
      hLayout->addWidget(m_pagesBar, 0);
      hLayout->addStretch(1);
      hLayout->addWidget(toolbarScrollWidget, 0);
    }
    m_tabBarContainer->setLayout(hLayout);

    // To align this panel with the style Editor
    mainLayout->addWidget(m_tabBarContainer, 0);
    mainLayout->addWidget(m_pageViewerScrollArea, 1);
  }
  setLayout(mainLayout);

  connect(m_pagesBar, SIGNAL(currentChanged(int)), this,
          SLOT(setPageView(int)));
  connect(m_pagesBar, SIGNAL(movePage(int, int)), this,
          SLOT(movePage(int, int)));
  connect(m_pageViewer, SIGNAL(changeWindowTitleSignal()), this,
          SLOT(changeWindowTitle()));

  changeWindowTitle();

  setAcceptDrops(true);
}
ManageMetronomeDialog::ManageMetronomeDialog(QWidget *parent,
        RosegardenDocument *doc) :
        QDialog(parent),
        m_doc(doc),
        m_buttonBox(new QDialogButtonBox(QDialogButtonBox::Ok | 
                                         QDialogButtonBox::Close))
{
    setModal(true);
    setWindowTitle(tr("Metronome"));

    QGridLayout *metagrid = new QGridLayout;
    setLayout(metagrid);
    QWidget *hbox = new QWidget(this);
    QHBoxLayout *hboxLayout = new QHBoxLayout;
    hboxLayout->setMargin(0);
    metagrid->addWidget(hbox, 0, 0);

    QWidget *vbox = new QWidget(hbox);
    QVBoxLayout *vboxLayout = new QVBoxLayout;
    vboxLayout->setMargin(0);
    hboxLayout->addWidget(vbox);

    QGroupBox *deviceBox = new QGroupBox( tr("Metronome Instrument"), vbox );
    deviceBox->setContentsMargins(10, 10, 10, 10);
    QGridLayout *deviceBoxLayout = new QGridLayout(deviceBox);
    deviceBoxLayout->setSpacing(5);
    vboxLayout->addWidget(deviceBox);

    deviceBoxLayout->addWidget(new QLabel(tr("Device"), deviceBox), 0, 0);
    m_metronomeDevice = new QComboBox(deviceBox);
    m_metronomeDevice->setToolTip(tr("<qt>Choose the device you want to use to play the metronome</qt>"));
    deviceBoxLayout->addWidget(m_metronomeDevice, 0, 1);

    DeviceList *devices = doc->getStudio().getDevices();
    DeviceListConstIterator it;

    Studio &studio = m_doc->getStudio();
    DeviceId deviceId = studio.getMetronomeDevice();

    for (it = devices->begin(); it != devices->end(); it++) {

        Device *dev = *it;
        bool hasConnection = false;
        if (!isSuitable(dev, &hasConnection)) continue;

        QString label = QObject::tr(dev->getName().c_str());
        // connections imply some untranslatable external string
        QString connection = RosegardenSequencer::getInstance()->getConnection
            (dev->getId());

        if (hasConnection && connection != "") {
            label = tr("%1 - %2").arg(label).arg(connection);
        } else if (!hasConnection) {
            label = tr("%1 - No connection").arg(label);
        }
        m_metronomeDevice->addItem(label);
        if (dev->getId() == deviceId) {
            m_metronomeDevice->setCurrentIndex(m_metronomeDevice->count() - 1);
        }
    }

    deviceBoxLayout->addWidget(new QLabel(tr("Instrument"), deviceBox), 1, 0);
    m_metronomeInstrument = new QComboBox(deviceBox);
    m_metronomeInstrument->setToolTip(tr("<qt>Choose the instrument you want to use to play the metronome (typically #10)</qt>"));
    connect(m_metronomeInstrument, SIGNAL(activated(int)), this, SLOT(slotSetModified()));
    deviceBoxLayout->addWidget(m_metronomeInstrument, 1, 1);
    deviceBox->setLayout(deviceBoxLayout);

    QGroupBox *beatBox = new QGroupBox( tr("Beats"), vbox );
    beatBox->setContentsMargins(10, 10, 10, 10);
    QGridLayout *beatBoxLayout = new QGridLayout(beatBox);
    beatBoxLayout->setSpacing(5);
    vboxLayout->addWidget(beatBox);

    beatBoxLayout->addWidget(new QLabel(tr("Resolution"), beatBox), 0, 0);
    m_metronomeResolution = new QComboBox(beatBox);
    m_metronomeResolution->setToolTip(tr("<qt>The metronome can sound bars only, bars and beats, or bars, beats and sub-beats.  The latter mode can be particularly useful for playing in compound time signatures like 12/8.</qt>"));
    m_metronomeResolution->addItem(tr("None"));
    m_metronomeResolution->addItem(tr("Bars only"));
    m_metronomeResolution->addItem(tr("Bars and beats"));
    m_metronomeResolution->addItem(tr("Bars, beats, and sub-beats"));
    connect(m_metronomeResolution, SIGNAL(activated(int)), this, SLOT(slotResolutionChanged(int)));
    beatBoxLayout->addWidget(m_metronomeResolution, 0, 1);

    beatBoxLayout->addWidget(new QLabel(tr("Bar velocity"), beatBox), 1, 0);
    m_metronomeBarVely = new QSpinBox(beatBox);
    m_metronomeBarVely->setToolTip(tr("<qt>Controls how forcefully the bar division notes will be struck.  (These are typically the loudest of all.)</qt>"));
    m_metronomeBarVely->setMinimum(0);
    m_metronomeBarVely->setMaximum(127);
    connect(m_metronomeBarVely, SIGNAL(valueChanged(int)), this, SLOT(slotSetModified()));
    beatBoxLayout->addWidget(m_metronomeBarVely, 1, 1);

    beatBoxLayout->addWidget(new QLabel(tr("Beat velocity"), beatBox), 2, 0);
    m_metronomeBeatVely = new QSpinBox(beatBox);
    m_metronomeBeatVely->setToolTip(tr("<qt>Controls how forcefully the beat division notes will be struck.  (These are typically more quiet than beat division notes.)</qt>"));
    m_metronomeBeatVely->setMinimum(0);
    m_metronomeBeatVely->setMaximum(127);
    connect(m_metronomeBeatVely, SIGNAL(valueChanged(int)), this, SLOT(slotSetModified()));
    beatBoxLayout->addWidget(m_metronomeBeatVely, 2, 1);

    beatBoxLayout->addWidget(new QLabel(tr("Sub-beat velocity"), beatBox), 3, 0);
    m_metronomeSubBeatVely = new QSpinBox(beatBox);
    m_metronomeSubBeatVely->setToolTip(tr("<qt>Controls how forcefully the sub-beat division notes will be struck.  (These are typically the most quiet of all, and are not heard unless you are working in compound time.)</qt>"));
    m_metronomeSubBeatVely->setMinimum(0);
    m_metronomeSubBeatVely->setMaximum(127);
    connect(m_metronomeSubBeatVely, SIGNAL(valueChanged(int)), this, SLOT(slotSetModified()));
    beatBoxLayout->addWidget(m_metronomeSubBeatVely, 3, 1);
    beatBox->setLayout(beatBoxLayout);

    vbox->setLayout(vboxLayout);

    vbox = new QWidget(hbox);
    vboxLayout = new QVBoxLayout;
    vboxLayout->setMargin(0);
    hboxLayout->addWidget(vbox);
    hbox->setLayout(hboxLayout);

    m_metronomePitch = new PitchChooser(tr("Pitch"), vbox , 60);
    m_metronomePitch->setToolTip(tr("<qt>It is typical to use a percussion instrument for the metronome, so the pitch normally controls which sort of drum will sound for each tick.  You may configure a different pitch for each of the bar, beat, and sub-beat ticks.</qt>"));
    vboxLayout->addWidget(m_metronomePitch);
    connect(m_metronomePitch, SIGNAL(pitchChanged(int)), this, SLOT(slotPitchChanged(int)));
    connect(m_metronomePitch, SIGNAL(preview(int)), this, SLOT(slotPreviewPitch(int)));

    m_metronomePitchSelector = new QComboBox();
    m_metronomePitchSelector->addItem(tr("for Bar"));
    m_metronomePitchSelector->addItem(tr("for Beat"));
    m_metronomePitchSelector->addItem(tr("for Sub-beat"));
    m_metronomePitch->addWidgetToLayout(m_metronomePitchSelector);
    connect(m_metronomePitchSelector, SIGNAL(activated(int)), this, SLOT(slotPitchSelectorChanged(int)));

    QGroupBox *enableBox = new QGroupBox( tr("Metronome Activated"), vbox );
    QVBoxLayout *enableBoxLayout = new QVBoxLayout;
    vboxLayout->addWidget(enableBox);
    m_playEnabled = new QCheckBox(tr("Playing"), enableBox);
    enableBoxLayout->addWidget(m_playEnabled);
    m_recordEnabled = new QCheckBox(tr("Recording"), enableBox);
    enableBoxLayout->addWidget(m_recordEnabled);
    connect(m_playEnabled, SIGNAL(clicked()), this, SLOT(slotSetModified()));
    connect(m_recordEnabled, SIGNAL(clicked()), this, SLOT(slotSetModified()));
    enableBox->setLayout(enableBoxLayout);

    vbox->setLayout(vboxLayout);

    // populate the dialog
    populate(m_metronomeDevice->currentIndex());

    // connect up the device list
    connect(m_metronomeDevice, SIGNAL(activated(int)),
            this, SLOT(populate(int)));
    // connect up the device list
    connect(m_metronomeDevice, SIGNAL(activated(int)),
            this, SLOT(slotSetModified()));

    metagrid->addWidget(m_buttonBox, 1, 0);
    metagrid->setRowStretch(0, 10);
    connect(m_buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
    connect(m_buttonBox, SIGNAL(rejected()), this, SLOT(reject()));

    setModified(false);
}
示例#15
0
EditorView::EditorView(EditorModel *model, QWidget *parent) :
    QWidget(parent),
    m_toolBar(new QWidget),
    m_container(new QStackedWidget(this)),
    m_editorList(new QComboBox),
    m_closeButton(new QToolButton),
    m_lockButton(new QToolButton),
    m_defaultToolBar(new QToolBar(this)),
    m_infoWidget(new QFrame(this)),
    m_editorForInfoWidget(0),
    m_statusHLine(new QFrame(this)),
    m_statusWidget(new QFrame(this))
{
    QVBoxLayout *tl = new QVBoxLayout(this);
    tl->setSpacing(0);
    tl->setMargin(0);
    {
        m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
        m_editorList->setMinimumContentsLength(20);
        m_editorList->setModel(model);
        m_editorList->setMaxVisibleItems(40);

        QToolBar *editorListToolBar = new QToolBar;

        editorListToolBar->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
        editorListToolBar->addWidget(m_editorList);

        m_defaultToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        m_activeToolBar = m_defaultToolBar;

        QHBoxLayout *toolBarLayout = new QHBoxLayout;
        toolBarLayout->setMargin(0);
        toolBarLayout->setSpacing(0);
        toolBarLayout->addWidget(m_defaultToolBar);
        m_toolBar->setLayout(toolBarLayout);

        m_lockButton->setAutoRaise(true);
        m_lockButton->setProperty("type", QLatin1String("dockbutton"));

        m_closeButton->setAutoRaise(true);
        m_closeButton->setIcon(QIcon(":/core/images/closebutton.png"));
        m_closeButton->setProperty("type", QLatin1String("dockbutton"));

        QToolBar *rightToolBar = new QToolBar;
        rightToolBar->setLayoutDirection(Qt::RightToLeft);
        rightToolBar->addWidget(m_closeButton);
        rightToolBar->addWidget(m_lockButton);

        QHBoxLayout *toplayout = new QHBoxLayout;
        toplayout->setSpacing(0);
        toplayout->setMargin(0);
        toplayout->addWidget(editorListToolBar);
        toplayout->addWidget(m_toolBar, 1); // Custom toolbar stretches
        toplayout->addWidget(rightToolBar);

        QWidget *top = new QWidget;
        QVBoxLayout *vlayout = new QVBoxLayout(top);
        vlayout->setSpacing(0);
        vlayout->setMargin(0);
        vlayout->addLayout(toplayout);
        tl->addWidget(top);

        connect(m_editorList, SIGNAL(activated(int)), this, SLOT(listSelectionActivated(int)));
        connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable()));
        connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection);
    }
    {
        m_infoWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
        m_infoWidget->setLineWidth(1);
        m_infoWidget->setForegroundRole(QPalette::ToolTipText);
        m_infoWidget->setBackgroundRole(QPalette::ToolTipBase);
        m_infoWidget->setAutoFillBackground(true);

        QHBoxLayout *hbox = new QHBoxLayout(m_infoWidget);
        hbox->setMargin(2);
        m_infoWidgetLabel = new QLabel("Placeholder");
        m_infoWidgetLabel->setForegroundRole(QPalette::ToolTipText);
        hbox->addWidget(m_infoWidgetLabel);
        hbox->addStretch(1);

        m_infoWidgetButton = new QToolButton;
        m_infoWidgetButton->setText(tr("Placeholder"));
        hbox->addWidget(m_infoWidgetButton);

        QToolButton *closeButton = new QToolButton;
        closeButton->setAutoRaise(true);
        closeButton->setIcon(QIcon(":/core/images/clear.png"));
        closeButton->setToolTip(tr("Close"));
        connect(closeButton, SIGNAL(clicked()), m_infoWidget, SLOT(hide()));

        hbox->addWidget(closeButton);

        m_infoWidget->setVisible(false);
        tl->addWidget(m_infoWidget);
    }

    tl->addWidget(m_container);

    {
        m_statusHLine->setFrameStyle(QFrame::HLine);

        m_statusWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
        m_statusWidget->setLineWidth(1);
        //m_statusWidget->setForegroundRole(QPalette::ToolTipText);
        //m_statusWidget->setBackgroundRole(QPalette::ToolTipBase);
        m_statusWidget->setAutoFillBackground(true);


        QHBoxLayout *hbox = new QHBoxLayout(m_statusWidget);
        hbox->setMargin(2);
        m_statusWidgetLabel = new QLabel("Placeholder");
        m_statusWidgetLabel->setForegroundRole(QPalette::ToolTipText);
        hbox->addWidget(m_statusWidgetLabel);
        hbox->addStretch(1);

        m_statusWidgetButton = new QToolButton;
        m_statusWidgetButton->setText(tr("Placeholder"));
        hbox->addWidget(m_statusWidgetButton);

        m_statusHLine->setVisible(false);
        m_statusWidget->setVisible(false);
        tl->addWidget(m_statusHLine);
        tl->addWidget(m_statusWidget);
    }
}
示例#16
0
NetStatus::NetStatus(QWidget *parent)
	: QWidget(parent), _sentbytes(0), _recvbytes(0), _lag(0)
{
	setMinimumHeight(16+2);

	QHBoxLayout *layout = new QHBoxLayout(this);
	layout->setMargin(1);
	layout->setSpacing(4);

	// Download progress bar
	m_download = new QProgressBar(this);
	m_download->setMaximumWidth(120);
	m_download->setSizePolicy(QSizePolicy());
	m_download->setTextVisible(false);
	m_download->setMaximum(100);
	m_download->hide();
	layout->addWidget(m_download);

	// Host address label
	_label = new QLabel(tr("not connected"), this);
	_label->setTextInteractionFlags(
			Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard
			);
	_label->setCursor(Qt::IBeamCursor);
	_label->setContextMenuPolicy(Qt::ActionsContextMenu);
	layout->addWidget(_label);

	// Action to copy address to clipboard
	_copyaction = new QAction(tr("Copy address to clipboard"), this);
	_copyaction->setEnabled(false);
	_label->addAction(_copyaction);
	connect(_copyaction,SIGNAL(triggered()),this,SLOT(copyAddress()));

	// Action to copy the full session URL to clipboard
	_urlaction = new QAction(tr("Copy session URL to clipboard"), this);
	_urlaction->setEnabled(false);
	_label->addAction(_urlaction);
	connect(_urlaction, SIGNAL(triggered()), this, SLOT(copyUrl()));

	// Discover local IP address
	_discoverIp = new QAction(tr("Get externally visible IP address"), this);
	_discoverIp->setVisible(false);
	_label->addAction(_discoverIp);
	connect(_discoverIp, SIGNAL(triggered()), this, SLOT(discoverAddress()));
	connect(WhatIsMyIp::instance(), SIGNAL(myAddressIs(QString)), this, SLOT(externalIpDiscovered(QString)));

#ifdef HAVE_UPNP
	connect(net::UPnPClient::instance(), SIGNAL(externalIp(QString)), this, SLOT(externalIpDiscovered(QString)));
#endif

	// Show network statistics
	QAction *sep = new QAction(this);
	sep->setSeparator(true);
	_label->addAction(sep);

	QAction *showNetStats = new QAction(tr("Statistics"), this);
	_label->addAction(showNetStats);
	connect(showNetStats, SIGNAL(triggered()), this, SLOT(showNetStats()));

	// Security level icon
	_security = new QLabel(QString(), this);
	_security->setFixedSize(QSize(16, 16));
	_security->hide();
	layout->addWidget(_security);

	_security->setContextMenuPolicy(Qt::ActionsContextMenu);

	QAction *showcert = new QAction(tr("Show certificate"), this);
	_security->addAction(showcert);
	connect(showcert, SIGNAL(triggered()), this, SLOT(showCertificate()));

	// Low space alert
	m_lowspace = new QLabel(tr("Low space!"), this);
	m_lowspace->setToolTip(tr("Server is almost out of space for session history! Reset the session to free some up."));
	QPalette lowSpacePalette = m_lowspace->palette();
	lowSpacePalette.setColor(QPalette::WindowText, Qt::red);
	m_lowspace->setPalette(lowSpacePalette);
	m_lowspace->setVisible(false);
	layout->addWidget(m_lowspace);

	// Popup label
	m_popup = new PopupMessage(this);

	// Some styles are buggy and have bad tooltip colors, so we force the colors here.
	QPalette popupPalette;
	popupPalette.setColor(QPalette::ToolTipBase, Qt::black);
	popupPalette.setColor(QPalette::ToolTipText, Qt::white);
	m_popup->setPalette(popupPalette);
}
示例#17
0
文件: toolbar.cpp 项目: AsamQi/vlc
/************************************************
 *  Widget Listing:
 * Creation of the list of drawed lovely buttons
 ************************************************/
WidgetListing::WidgetListing( intf_thread_t *p_intf, QWidget *_parent )
              : QListWidget( _parent )
{
    /* We need the parent to know the options checked */
    parent = qobject_cast<ToolbarEditDialog *>(_parent);
    assert( parent );

    /* Normal options */
    setViewMode( QListView::IconMode );
    setSpacing( 8 );
    setGridSize( QSize(90, 50) );
    setWrapping( true );
    setWordWrap( true );
    setTextElideMode( Qt::ElideNone );
    setDragEnabled( true );

    /* All the buttons do not need a special rendering */
    for( int i = 0; i < BUTTON_MAX; i++ )
    {
        QListWidgetItem *widgetItem = new QListWidgetItem( this );
        widgetItem->setText( qtr( nameL[i] ) );
        QPixmap pix( iconL[i] );
        widgetItem->setIcon( pix.scaled( 16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
        widgetItem->setData( Qt::UserRole, QVariant( i ) );
        widgetItem->setToolTip( widgetItem->text() );
        addItem( widgetItem );
    }

    /* Spacers are yet again a different thing */
    QListWidgetItem *widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ),
            qtr( "Spacer" ), this );
    widgetItem->setData( Qt::UserRole, WIDGET_SPACER );
    widgetItem->setToolTip( widgetItem->text() );
    addItem( widgetItem );

    widgetItem = new QListWidgetItem( QIcon( ":/toolbar/space" ),
            qtr( "Expanding Spacer" ), this );
    widgetItem->setData( Qt::UserRole, WIDGET_SPACER_EXTEND );
    widgetItem->setToolTip( widgetItem->text() );
    addItem( widgetItem );

    /**
     * For all other widgets, we create then, do a pseudo rendering in
     * a pixmaps for the view, and delete the object
     *
     * A lot of code is retaken from the Abstract, but not exactly...
     * So, rewrite.
     * They are better ways to deal with this, but I doubt that this is
     * necessary. If you feel like you have the time, be my guest.
     * --
     * jb
     **/
    for( int i = SPLITTER; i < SPECIAL_MAX; i++ )
    {
        QWidget *widget = NULL;
        QListWidgetItem *widgetItem = new QListWidgetItem( this );
        switch( i )
        {
        case SPLITTER:
            {
                QFrame *line = new QFrame( this );
                line->setFrameShape( QFrame::VLine );
                line->setFrameShadow( QFrame::Raised );
                line->setLineWidth( 0 ); line->setMidLineWidth( 1 );
                widget = line;
            }
            widgetItem->setText( qtr("Splitter") );
            break;
        case INPUT_SLIDER:
            {
                SeekSlider *slider = new SeekSlider( Qt::Horizontal, this );
                widget = slider;
            }
            widgetItem->setText( qtr("Time Slider") );
            break;
        case VOLUME:
            {
                SoundWidget *snd = new SoundWidget( this, p_intf,
                        parent->getOptions() & WIDGET_SHINY );
                widget = snd;
            }
            widgetItem->setText( qtr("Volume") );
            break;
        case VOLUME_SPECIAL:
            {
                QListWidgetItem *widgetItem = new QListWidgetItem( this );
                widgetItem->setText( qtr("Small Volume") );
                widgetItem->setIcon( QIcon( ":/toolbar/volume-medium" ) );
                widgetItem->setData( Qt::UserRole, QVariant( i ) );
                addItem( widgetItem );
            }
            continue;
        case TIME_LABEL:
            {
                QLabel *timeLabel = new QLabel( "12:42/2:12:42", this );
                widget = timeLabel;
            }
            widgetItem->setText( qtr("Time") );
            break;
        case MENU_BUTTONS:
            {
                QWidget *discFrame = new QWidget( this );
                //discFrame->setLineWidth( 1 );
                QHBoxLayout *discLayout = new QHBoxLayout( discFrame );
                discLayout->setSpacing( 0 ); discLayout->setMargin( 0 );

                QToolButton *prevSectionButton = new QToolButton( discFrame );
                prevSectionButton->setIcon( QIcon( ":/toolbar/dvd_prev" ) );
                prevSectionButton->setToolTip( qtr("Previous chapter") );
                discLayout->addWidget( prevSectionButton );

                QToolButton *menuButton = new QToolButton( discFrame );
                menuButton->setIcon( QIcon( ":/toolbar/dvd_menu" ) );
                menuButton->setToolTip( qtr("Go to the DVD menu") );
                discLayout->addWidget( menuButton );

                QToolButton *nextButton = new QToolButton( discFrame );
                nextButton->setIcon( QIcon( ":/toolbar/dvd_next" ) );
                nextButton->setToolTip( qtr("Next chapter") );
                discLayout->addWidget( nextButton );

                widget = discFrame;
            }
            widgetItem->setText( qtr("DVD menus") );
            break;
        case TELETEXT_BUTTONS:
            {
                QWidget *telexFrame = new QWidget( this );
                QHBoxLayout *telexLayout = new QHBoxLayout( telexFrame );
                telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );

                QToolButton *telexOn = new QToolButton( telexFrame );
                telexOn->setIcon( QIcon( ":/toolbar/tv" ) );
                telexLayout->addWidget( telexOn );

                QToolButton *telexTransparent = new QToolButton;
                telexTransparent->setIcon( QIcon( ":/toolbar/tvtelx" ) );
                telexTransparent->setToolTip( qtr("Teletext transparency") );
                telexLayout->addWidget( telexTransparent );

                QSpinBox *telexPage = new QSpinBox;
                telexLayout->addWidget( telexPage );

                widget = telexFrame;
            }
            widgetItem->setText( qtr("Teletext") );
            break;
        case ADVANCED_CONTROLLER:
            {
                AdvControlsWidget *advControls = new AdvControlsWidget( p_intf, this );
                widget = advControls;
            }
            widgetItem->setText( qtr("Advanced Buttons") );
            break;
        case PLAYBACK_BUTTONS:
            {
                widget = new QWidget;
                DeckButtonsLayout *layout = new DeckButtonsLayout( widget );
                BrowseButton *prev = new BrowseButton( widget, BrowseButton::Backward );
                BrowseButton *next = new BrowseButton( widget );
                RoundButton *play = new RoundButton( widget );
                layout->setBackwardButton( prev );
                layout->setForwardButton( next );
                layout->setRoundButton( play );
            }
            widgetItem->setText( qtr("Playback Buttons") );
            break;
        case ASPECT_RATIO_COMBOBOX:
            widget = new AspectRatioComboBox( p_intf );
            widgetItem->setText( qtr("Aspect ratio selector") );
            break;
        case SPEED_LABEL:
            widget = new SpeedLabel( p_intf, this );
            widgetItem->setText( qtr("Speed selector") );
            break;
        case TIME_LABEL_ELAPSED:
            widget = new QLabel( "2:42", this );
            widgetItem->setText( qtr("Elapsed time") );
            break;
        case TIME_LABEL_REMAINING:
            widget = new QLabel( "-2:42", this );
            widgetItem->setText( qtr("Total/Remaining time") );
            break;
        default:
            msg_Warn( p_intf, "This should not happen %i", i );
            break;
        }

        if( widget == NULL ) continue;


        widgetItem->setIcon( QIcon( QPixmap::grabWidget( widget ) ) );
        widgetItem->setToolTip( widgetItem->text() );
        widget->hide();
        widgetItem->setData( Qt::UserRole, QVariant( i ) );

        addItem( widgetItem );
        delete widget;
    }
}
   // -------------------------------------------------------------
   TRasterMapsDialog::TRasterMapsDialog(IMapAdapterInterfaces MapInterfaces_,
                                        QString Organization_, QString Application_, QWidget *Parent_)
      : QDialog(Parent_), PI(acos(-1.0)), m_Organization(Organization_), m_Application(Application_),
        m_Mode(Consts::ListMode), m_KeyControlPressed(false)
   {
   setWindowTitle(QNetMapTranslator::tr("Raster map list" /* Russian: Список растровых карт */));
   QPalette palette/*(palette())*/;
   palette.setColor(backgroundRole(), Qt::white);
   setPalette(palette);
   setAutoFillBackground(true);

   setMinimumSize(800, 600);
   // карта
   w_MapWidget = new TMapWidget(MapInterfaces_, "", 12, QPointF(0,0), Organization_, Application_);
   // Лайаут основной
   setLayout(&m_MainVerticalLayout);
   m_MainVerticalLayout.setSpacing(8);
   m_MainVerticalLayout.setMargin(8);

   // Лайаут для размещения элементов верхней строки с подсказкой
   QHBoxLayout *TopLayout = new QHBoxLayout;
   m_MainVerticalLayout.addLayout(TopLayout);
   TopLayout->addWidget(&m_TextHint);
   hint(QNetMapTranslator::tr("Select the map or action" /* Russian: Выберите карту или действие */));
   TopLayout->addStretch();
   // Лайаут для списка, кнопок и карты
   QHBoxLayout *MiddleLayout = new QHBoxLayout;
   m_MainVerticalLayout.addLayout(MiddleLayout);
   // Лайаут для списка и кнопок
   QVBoxLayout *ListLayout = new QVBoxLayout;
   // Лайаут для карты
   QVBoxLayout *MapLayout = new QVBoxLayout;

   // Путь к карте
   MapLayout->addWidget(&m_MapPath);
   // Рамка для виджета карты
   QFrame *MapWidgetFrame = new QFrame;
   MapWidgetFrame->setFrameStyle(QFrame::Box | QFrame::Plain);
   QHBoxLayout *MapWidgetFrameLayout = new QHBoxLayout(MapWidgetFrame);
   MapWidgetFrameLayout->setMargin(0);
   MapWidgetFrameLayout->addWidget(w_MapWidget);
   MapLayout->addWidget(MapWidgetFrame);
   // лайоут для списка точек привязки
   w_MapAnchors = new QVBoxLayout;
   w_MapAnchors->setMargin(0);
   MapLayout->addLayout(w_MapAnchors);

   // Список карт
   QStringList ListMaps;
   IMapAdapterInterfaces RasterMapInterfaces = w_MapWidget->rasterMapInterfaces();
   foreach(IMapAdapterInterface* Interface, RasterMapInterfaces) {
      ListMaps << Interface->pluginName();
      }
   m_Model.setStringList(ListMaps);
   m_MapsListView.setModel(&m_Model);
   ListLayout->addWidget(&m_MapsListView);
   QGroupBox *ListGroup = new QGroupBox(QNetMapTranslator::tr("Raster maps" /* Russian: Растровые карты */));
   ListGroup->setMaximumWidth(200);
   ListGroup->setLayout(ListLayout);
   
   // кнопки
   m_CenterMapButton.setText(QNetMapTranslator::tr("Map's center" /* Russian: Центр карты */));
   m_LinkingButton.setText(QNetMapTranslator::tr("Add reference points..." /* Russian: Привязать... */));
   m_DeleteLinkingButton.setText(QNetMapTranslator::tr("Delete reference points" /* Russian: Удалить привязку */));
   m_AddButton.setText(QNetMapTranslator::tr("Add to list..." /* Russian: Добавить в список... */));
   m_DeleteButton.setText(QNetMapTranslator::tr("Delete from list" /* Ru: Удалить из списка */));
   m_ExitDialogButton.setText(QNetMapTranslator::tr("OK"));
   ListLayout->addWidget(&m_CenterMapButton);
   ListLayout->addWidget(&m_LinkingButton);
   ListLayout->addWidget(&m_DeleteLinkingButton);
   ListLayout->addWidget(&m_AddButton);
   ListLayout->addWidget(&m_DeleteButton);
   ListLayout->addItem(new QSpacerItem(0, 7));
   ListLayout->addWidget(&m_ExitDialogButton);

   // Кнопки подтверждения / отмены
   m_ButtonBox.setMinimumSize(QSize(0, 30));
   m_ButtonBox.setOrientation(Qt::Horizontal);
   m_ButtonBox.setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
   // находим кнопку ОК и делаем ее недоступной
   QList<QAbstractButton*> ListButtons = m_ButtonBox.buttons();
   foreach(QAbstractButton* Button, ListButtons) {
      if(m_ButtonBox.buttonRole(Button) == QDialogButtonBox::AcceptRole) {
         w_ButtonOK = Button;
         w_ButtonOK->setEnabled(false);
         break;
         }
      }
   MapLayout->addWidget(&m_ButtonBox);
   m_ButtonBox.setVisible(false);   

   MiddleLayout->addWidget(ListGroup);
   MiddleLayout->addLayout(MapLayout);
   // устанавливаем текущей первую карту в списке
   if(m_Model.rowCount()) mapNameClicked(m_Model.index(0, 0));

   // сигналы
   QNM_DEBUG_CHECK(connect(&m_MapsListView,     SIGNAL(clicked(const QModelIndex&)),   
                  this,                SLOT(mapNameClicked(const QModelIndex&))));
   QNM_DEBUG_CHECK(connect(&m_MapsListView,     SIGNAL(activated(const QModelIndex&)), 
                  this,                SLOT(mapNameClicked(const QModelIndex&))));
   QNM_DEBUG_CHECK(connect(&m_ButtonBox,        SIGNAL(accepted()), this, SLOT(acceptLinking())));
   QNM_DEBUG_CHECK(connect(&m_ButtonBox,        SIGNAL(rejected()), this, SLOT(rejectLinking())));
   QNM_DEBUG_CHECK(connect(&m_AddButton,        SIGNAL(clicked()),  this, SLOT(addMap())));
   QNM_DEBUG_CHECK(connect(&m_DeleteButton,     SIGNAL(clicked()),  this, SLOT(deleteMap())));
   QNM_DEBUG_CHECK(connect(&m_LinkingButton,    SIGNAL(clicked()),  this, SLOT(viewMap())));
   QNM_DEBUG_CHECK(connect(&m_DeleteLinkingButton, SIGNAL(clicked()), this, SLOT(deleteLinking())));
   QNM_DEBUG_CHECK(connect(&m_CenterMapButton,  SIGNAL(clicked()),  this, SLOT(viewCenterMap())));
   QNM_DEBUG_CHECK(connect(&m_ExitDialogButton, SIGNAL(clicked()),  this, SLOT(accept())));
   //
   widgetsEnabling();
   }
示例#19
0
QFrame * ProgramTab::createFooter() {
    QFrame * footerFrame = new QFrame();
    footerFrame->setObjectName("footer"); // Used for styling
	footerFrame->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);

    QLabel * languageLabel = new QLabel(tr("Language:"), this);

	m_languageComboBox = new QComboBox();
	m_languageComboBox->setEditable(false);
    m_languageComboBox->setEnabled(true);
    m_languageComboBox->addItems(m_programWindow->getAvailableLanguages());
	QSettings settings;
	QString currentLanguage = settings.value("programwindow/language", "").toString();
	if (currentLanguage.isEmpty()) {
		currentLanguage = m_languageComboBox->currentText();
	}
    setLanguage(currentLanguage, false);

	QPushButton * addButton = new QPushButton(tr("New"));
	//addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	connect(addButton, SIGNAL(clicked()), m_programWindow, SLOT(addTab()));

    QPushButton * loadButton = new QPushButton(tr("Open..."));
	//loadButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadProgramFile()));

    m_saveButton = new QPushButton(tr("Save"));
	//m_saveButton->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
    connect(m_saveButton, SIGNAL(clicked()), this, SLOT(save()));

    QLabel * portLabel = new QLabel(tr("Port:"), this);

    m_portComboBox = new SerialPortComboBox();
    m_portComboBox->setEditable(false);
    m_portComboBox->setEnabled(true);
	QStringList ports = m_programWindow->getSerialPorts();
    m_portComboBox->addItems(ports);

	QString currentPort = settings.value("programwindow/port", "").toString();
	if (currentPort.isEmpty()) {
		currentPort = m_portComboBox->currentText();
	}
	else if (!ports.contains(currentPort)) {
		currentPort = m_portComboBox->currentText();
	}
    setPort(currentPort);

	m_programButton = new QPushButton(tr("Program"));
	m_programButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    connect(m_programButton, SIGNAL(clicked()), this, SLOT(sendProgram()));
	m_programButton->setEnabled(false);

	QLabel * programmerLabel = new QLabel(tr("Programmer:"), this);

	m_programmerComboBox = new QComboBox();
	m_programmerComboBox->setEditable(false);
    m_programmerComboBox->setEnabled(true);
	updateProgrammers();
	QString currentProgrammer = ProgramWindow::LocateName;
	QString temp = settings.value("programwindow/programmer", "").toString();
	if (!temp.isEmpty()) {
		QFileInfo fileInfo(temp);
		if (fileInfo.exists()) {
			currentProgrammer = temp;
		}
	}
	chooseProgrammerAux(currentProgrammer, false);

	QHBoxLayout *footerLayout = new QHBoxLayout;

	footerLayout->setMargin(0);
	footerLayout->setSpacing(5);
    footerLayout->addWidget(addButton);
    footerLayout->addWidget(loadButton);
    footerLayout->addWidget(m_saveButton);

    footerLayout->addSpacerItem(new QSpacerItem(5,0,QSizePolicy::Expanding,QSizePolicy::Minimum));

    footerLayout->addWidget(languageLabel);
    footerLayout->addWidget(m_languageComboBox);
    footerLayout->addWidget(portLabel);
    footerLayout->addWidget(m_portComboBox);
	footerLayout->addWidget(programmerLabel);
	footerLayout->addWidget(m_programmerComboBox);
	footerLayout->addWidget(m_programButton);

	footerFrame->setLayout(footerLayout);

	// connect last so these signals aren't triggered during initialization
    connect(m_languageComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setLanguage(const QString &)));
    connect(m_portComboBox, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(setPort(const QString &)));
	connect(m_portComboBox, SIGNAL(aboutToShow()), this, SLOT(updateSerialPorts()), Qt::DirectConnection);
    connect(m_programmerComboBox, SIGNAL(activated(int)), this, SLOT(chooseProgrammerTimed(int)));	

	return footerFrame;
}
示例#20
0
ParameterGroup::ParameterGroup(QWidget *pParent, const char *pName) :
    QGroupBox(pParent)
{
    if(pName)
        setObjectName(pName);

    _type = AdhocGroup;

    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));

    QWidget *selectedGroup = new QWidget(this);
    QWidget *patternGroup = new QWidget(this);

    _all= new QRadioButton(QObject::tr("All"), this, "_all");
    _all->setChecked(TRUE);

    _selected = new QRadioButton(tr("Selected:"), selectedGroup, "_selected");

    _items = new XComboBox(FALSE, selectedGroup, "_items");
    _items->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    _items->setEnabled(FALSE);

    QHBoxLayout * hLayout = new QHBoxLayout(selectedGroup);
    hLayout->setSpacing(5);
    hLayout->setMargin(0);
    hLayout->addWidget(_selected);
    hLayout->addWidget(_items);
    selectedGroup->setLayout(hLayout);

    _usePattern = new QRadioButton(tr("Pattern:"), patternGroup, "_usePattern");

    _pattern = new QLineEdit(patternGroup, "_pattern");
    _pattern->setEnabled(FALSE);

    hLayout = new QHBoxLayout(patternGroup);
    hLayout->setSpacing(5);
    hLayout->setMargin(0);
    hLayout->addWidget(_usePattern);
    hLayout->addWidget(_pattern);
    patternGroup->setLayout(hLayout);

    QVBoxLayout * vLayout = new QVBoxLayout(this);
    vLayout->setSpacing(0);
    vLayout->setMargin(5);
    vLayout->addWidget(_all);
    vLayout->addWidget(selectedGroup);
    vLayout->addWidget(patternGroup);
    setLayout(vLayout);

    QButtonGroup * buttonGroup = new QButtonGroup(this);
    buttonGroup->addButton(_all);
    buttonGroup->addButton(_selected);
    buttonGroup->addButton(_usePattern);

    connect(_selected, SIGNAL(toggled(bool)), _items, SLOT(setEnabled(bool)));
    connect(_usePattern, SIGNAL(toggled(bool)), _pattern, SLOT(setEnabled(bool)));
    connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SIGNAL(updated()));
    connect(_items, SIGNAL(newID(int)), this, SIGNAL(updated()));
    connect(_pattern, SIGNAL(lostFocus()), this, SIGNAL(updated()));

    setFocusProxy(_all);
}
示例#21
0
SettingsWidget::SettingsWidget(int page, const QString &moduleName, QWidget *videoEq) :
	videoEq(videoEq), videoEqOriginalParent(videoEq->parentWidget()),
	wasShow(false),
	moduleIndex(0)
{
	setWindowFlags(Qt::Window);
	setWindowTitle(tr("Settings"));
	setAttribute(Qt::WA_DeleteOnClose);

	Settings &QMPSettings = QMPlay2Core.getSettings();

	tabW = new QTabWidget;

	QPushButton *applyB = new QPushButton;
	applyB->setText(tr("Apply"));
	connect(applyB, SIGNAL(clicked()), this, SLOT(apply()));

	QPushButton *closeB = new QPushButton;
	closeB->setText(tr("Close"));
	closeB->setShortcut(QKeySequence("Escape"));
	connect(closeB, SIGNAL(clicked()), this, SLOT(close()));

	QGridLayout *layout = new QGridLayout(this);
	layout->addWidget(tabW, 0, 0, 1, 3);
	layout->addWidget(applyB, 1, 1, 1, 1);
	layout->addWidget(closeB, 1, 2, 1, 1);
	layout->setMargin(2);

	/* Page 1 */
	{
		QWidget *page1Widget = new QWidget;
		page1 = new Ui::GeneralSettings;
		page1->setupUi(page1Widget);

		appendColon(page1->langL);
		appendColon(page1->styleL);
		appendColon(page1->encodingL);
		appendColon(page1->audioLangL);
		appendColon(page1->subsLangL);
		appendColon(page1->screenshotL);
		appendColon(page1->profileL);

		tabW->addTab(page1Widget, tr("General settings"));

		int idx;

		page1->langBox->addItem("English", "en");
		page1->langBox->setCurrentIndex(0);
		const QStringList langs = QMPlay2Core.getLanguages();
		for (int i = 0; i < langs.count(); i++)
		{
			page1->langBox->addItem(QMPlay2Core.getLongFromShortLanguage(langs[i]), langs[i]);
			if (QMPlay2Core.getLanguage() == langs[i])
				page1->langBox->setCurrentIndex(i + 1);
		}

		page1->styleBox->addItems(QStyleFactory::keys());
		idx = page1->styleBox->findText(QApplication::style()->objectName(), Qt::MatchFixedString);
		if (idx > -1 && idx < page1->styleBox->count())
			page1->styleBox->setCurrentIndex(idx);
		connect(page1->styleBox, SIGNAL(currentIndexChanged(int)), this, SLOT(chStyle()));

		QStringList encodings;
		for (const QByteArray &item : QTextCodec::availableCodecs())
			encodings += QTextCodec::codecForName(item)->name();
		encodings.removeDuplicates();
		page1->encodingB->addItems(encodings);
		idx = page1->encodingB->findText(QMPSettings.getByteArray("FallbackSubtitlesEncoding"));
		if (idx > -1)
			page1->encodingB->setCurrentIndex(idx);

		const QString audioLang = QMPSettings.getString("AudioLanguage");
		const QString subsLang = QMPSettings.getString("SubtitlesLanguage");
		page1->audioLangB->addItem(tr("Default or first stream"));
		page1->subsLangB->addItem(tr("Default or first stream"));
		for (const QString &lang : QMPlay2Core.getLanguagesMap())
		{
			page1->audioLangB->addItem(lang);
			page1->subsLangB->addItem(lang);
			if (lang == audioLang)
				page1->audioLangB->setCurrentIndex(page1->audioLangB->count() - 1);
			if (lang == subsLang)
				page1->subsLangB->setCurrentIndex(page1->subsLangB->count() - 1);
		}
		{
			const QString currentProfile = QSettings(QMPlay2Core.getSettingsDir() + "Profile.ini", QSettings::IniFormat).value("Profile").toString();
			page1->profileB->addItem(tr("Default"));
			for (const QString &profile : QDir(QMPlay2Core.getSettingsDir() + "Profiles/").entryList(QDir::Dirs | QDir::NoDotAndDotDot))
			{
				page1->profileB->addItem(profile);
				if (profile == currentProfile)
					page1->profileB->setCurrentIndex(page1->profileB->count() - 1);
			}
			connect(page1->profileB, SIGNAL(currentIndexChanged(int)), this, SLOT(profileListIndexChanged(int)));

			page1->profileRemoveB->setIcon(QMPlay2Core.getIconFromTheme("list-remove"));
			page1->profileRemoveB->setEnabled(page1->profileB->currentIndex() != 0);
			connect(page1->profileRemoveB, SIGNAL(clicked()), this, SLOT(removeProfile()));
		}

		page1->screenshotE->setText(QMPSettings.getString("screenshotPth"));
		page1->screenshotFormatB->setCurrentIndex(page1->screenshotFormatB->findText(QMPSettings.getString("screenshotFormat")));
		page1->screenshotB->setIcon(QMPlay2Core.getIconFromTheme("folder-open"));
		connect(page1->screenshotB, SIGNAL(clicked()), this, SLOT(chooseScreenshotDir()));

		connect(page1->setAppearanceB, SIGNAL(clicked()), this, SLOT(setAppearance()));
		connect(page1->setKeyBindingsB, SIGNAL(clicked()), this, SLOT(setKeyBindings()));

#ifdef ICONS_FROM_THEME
		page1->iconsFromTheme->setChecked(QMPSettings.getBool("IconsFromTheme"));
#else
		delete page1->iconsFromTheme;
		page1->iconsFromTheme = nullptr;
#endif

		page1->showCoversGB->setChecked(QMPSettings.getBool("ShowCovers"));
		page1->blurCoversB->setChecked(QMPSettings.getBool("BlurCovers"));
		page1->showDirCoversB->setChecked(QMPSettings.getBool("ShowDirCovers"));

		page1->autoOpenVideoWindowB->setChecked(QMPSettings.getBool("AutoOpenVideoWindow"));
		page1->autoRestoreMainWindowOnVideoB->setChecked(QMPSettings.getBool("AutoRestoreMainWindowOnVideo"));

		page1->autoUpdatesB->setChecked(QMPSettings.getBool("AutoUpdates"));
#ifndef UPDATER
		page1->autoUpdatesB->setText(tr("Automatically check for updates"));
#endif

		if (Notifies::hasBoth())
			page1->trayNotifiesDefault->setChecked(QMPSettings.getBool("TrayNotifiesDefault"));
		else
		{
			delete page1->trayNotifiesDefault;
			page1->trayNotifiesDefault = nullptr;
		}

		page1->autoDelNonGroupEntries->setChecked(QMPSettings.getBool("AutoDelNonGroupEntries"));

		page1->tabsNorths->setChecked(QMPSettings.getBool("MainWidget/TabPositionNorth"));

#ifdef QMPLAY2_ALLOW_ONLY_ONE_INSTANCE
		page1->allowOnlyOneInstance->setChecked(QMPSettings.getBool("AllowOnlyOneInstance"));
#else
		delete page1->allowOnlyOneInstance;
		page1->allowOnlyOneInstance = nullptr;
#endif

		page1->hideArtistMetadata->setChecked(QMPSettings.getBool("HideArtistMetadata"));
		page1->displayOnlyFileName->setChecked(QMPSettings.getBool("DisplayOnlyFileName"));
		page1->restoreRepeatMode->setChecked(QMPSettings.getBool("RestoreRepeatMode"));
		page1->stillImages->setChecked(QMPSettings.getBool("StillImages"));

		page1->proxyB->setChecked(QMPSettings.getBool("Proxy/Use"));
		page1->proxyHostE->setText(QMPSettings.getString("Proxy/Host"));
		page1->proxyPortB->setValue(QMPSettings.getInt("Proxy/Port"));
		page1->proxyLoginB->setChecked(QMPSettings.getBool("Proxy/Login"));
		page1->proxyUserE->setText(QMPSettings.getString("Proxy/User"));
		page1->proxyPasswordE->setText(QByteArray::fromBase64(QMPSettings.getByteArray("Proxy/Password")));

		const QIcon viewRefresh = QMPlay2Core.getIconFromTheme("view-refresh");
		page1->clearCoversCache->setIcon(viewRefresh);
		connect(page1->clearCoversCache, SIGNAL(clicked()), this, SLOT(clearCoversCache()));
		page1->removeYtDlB->setIcon(QMPlay2Core.getIconFromTheme("list-remove"));
		connect(page1->removeYtDlB, SIGNAL(clicked()), this, SLOT(removeYouTubeDl()));
		page1->resetSettingsB->setIcon(viewRefresh);
		connect(page1->resetSettingsB, SIGNAL(clicked()), this, SLOT(resetSettings()));
	}

	/* Page 2 */
	{
		QWidget *page2Widget = new QWidget;
		page2 = new Ui::PlaybackSettings;
		page2->setupUi(page2Widget);

		appendColon(page2->shortSeekL);
		appendColon(page2->longSeekL);
		appendColon(page2->bufferLocalL);
		appendColon(page2->bufferNetworkL);
		appendColon(page2->backwardBufferNetworkL);
		appendColon(page2->playIfBufferedL);
		appendColon(page2->maxVolL);
		appendColon(page2->forceSamplerate);
		appendColon(page2->forceChannels);

		page2->shortSeekB->setSuffix(" " + page2->shortSeekB->suffix());
		page2->longSeekB->setSuffix(" " + page2->longSeekB->suffix());
		page2->playIfBufferedB->setSuffix(" " + page2->playIfBufferedB->suffix());
		page2->replayGainPreamp->setPrefix(page2->replayGainPreamp->prefix() + ": ");

		tabW->addTab(page2Widget, tr("Playback settings"));

		page2->shortSeekB->setValue(QMPSettings.getInt("ShortSeek"));
		page2->longSeekB->setValue(QMPSettings.getInt("LongSeek"));
		page2->bufferLocalB->setValue(QMPSettings.getInt("AVBufferLocal"));
		page2->bufferNetworkB->setValue(QMPSettings.getInt("AVBufferNetwork"));
		page2->backwardBufferNetworkB->setCurrentIndex(QMPSettings.getUInt("BackwardBuffer"));
		page2->playIfBufferedB->setValue(QMPSettings.getDouble("PlayIfBuffered"));
		page2->maxVolB->setValue(QMPSettings.getInt("MaxVol"));

		page2->forceSamplerate->setChecked(QMPSettings.getBool("ForceSamplerate"));
		page2->samplerateB->setValue(QMPSettings.getInt("Samplerate"));
		connect(page2->forceSamplerate, SIGNAL(toggled(bool)), page2->samplerateB, SLOT(setEnabled(bool)));
		page2->samplerateB->setEnabled(page2->forceSamplerate->isChecked());

		page2->forceChannels->setChecked(QMPSettings.getBool("ForceChannels"));
		page2->channelsB->setValue(QMPSettings.getInt("Channels"));
		connect(page2->forceChannels, SIGNAL(toggled(bool)), page2->channelsB, SLOT(setEnabled(bool)));
		page2->channelsB->setEnabled(page2->forceChannels->isChecked());

		page2->replayGain->setChecked(QMPSettings.getBool("ReplayGain/Enabled"));
		page2->replayGainAlbum->setChecked(QMPSettings.getBool("ReplayGain/Album"));
		page2->replayGainPreventClipping->setChecked(QMPSettings.getBool("ReplayGain/PreventClipping"));
		page2->replayGainPreamp->setValue(QMPSettings.getDouble("ReplayGain/Preamp"));

		page2->wheelActionB->setChecked(QMPSettings.getBool("WheelAction"));
		page2->wheelSeekB->setChecked(QMPSettings.getBool("WheelSeek"));
		page2->wheelVolumeB->setChecked(QMPSettings.getBool("WheelVolume"));

		page2->storeARatioAndZoomB->setChecked(QMPSettings.getBool("StoreARatioAndZoom"));
		connect(page2->storeARatioAndZoomB, &QCheckBox::toggled, this, [this](bool checked) {
			if (checked)
			{
				page2->keepZoom->setChecked(true);
				page2->keepARatio->setChecked(true);
			}
		});

		page2->keepZoom->setChecked(QMPSettings.getBool("KeepZoom"));
		connect(page2->keepZoom, &QCheckBox::toggled, this, [this](bool checked) {
			if (!checked && !page2->keepARatio->isChecked())
			{
				page2->storeARatioAndZoomB->setChecked(false);
			}
		});

		page2->keepARatio->setChecked(QMPSettings.getBool("KeepARatio"));
		connect(page2->keepARatio, &QCheckBox::toggled, this, [this](bool checked) {
			if (!checked && !page2->keepZoom->isChecked())
			{
				page2->storeARatioAndZoomB->setChecked(false);
			}
		});

		page2->showBufferedTimeOnSlider->setChecked(QMPSettings.getBool("ShowBufferedTimeOnSlider"));
		page2->savePos->setChecked(QMPSettings.getBool("SavePos"));
		page2->keepSubtitlesDelay->setChecked(QMPSettings.getBool("KeepSubtitlesDelay"));
		page2->keepSubtitlesScale->setChecked(QMPSettings.getBool("KeepSubtitlesScale"));
		page2->keepVideoDelay->setChecked(QMPSettings.getBool("KeepVideoDelay"));
		page2->keepSpeed->setChecked(QMPSettings.getBool("KeepSpeed"));
		page2->syncVtoA->setChecked(QMPSettings.getBool("SyncVtoA"));
		page2->silence->setChecked(QMPSettings.getBool("Silence"));
		page2->restoreVideoEq->setChecked(QMPSettings.getBool("RestoreVideoEqualizer"));
		page2->ignorePlaybackError->setChecked(QMPSettings.getBool("IgnorePlaybackError"));
		page2->leftMouseTogglePlay->setCheckState((Qt::CheckState)qBound(0, QMPSettings.getInt("LeftMouseTogglePlay"), 2));

		page2->accurateSeekB->setCheckState((Qt::CheckState)QMPSettings.getInt("AccurateSeek"));
		page2->accurateSeekB->setToolTip(tr("Slower, but more accurate seeking.\nPartially checked doesn't affect seeking on slider."));

		page2->unpauseWhenSeekingB->setChecked(QMPSettings.getBool("UnpauseWhenSeeking"));

		const QString modulesListTitle[3] = {
			tr("Video output priority"),
			tr("Audio output priority"),
			tr("Decoders priority")
		};
		for (int m = 0; m < 3; ++m)
		{
			QGroupBox *groupB = new QGroupBox(modulesListTitle[m]);
			Ui::ModulesList *ml = new Ui::ModulesList;
			ml->setupUi(groupB);
			connect(ml->list, SIGNAL(itemDoubleClicked (QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			connect(ml->moveUp, SIGNAL(clicked()), this, SLOT(moveModule()));
			connect(ml->moveDown, SIGNAL(clicked()), this, SLOT(moveModule()));
			ml->moveUp->setProperty("idx", m);
			ml->moveDown->setProperty("idx", m);
			page2->modulesListLayout->addWidget(groupB);
			page2ModulesList[m] = ml;
		}
	}

	/* Page 3 */
	{
		page3 = new Page3;
		tabW->addTab(page3, tr("Modules"));

		page3->listW = new QListWidget;
		page3->listW->setIconSize({32, 32});
		page3->listW->setMinimumSize(200, 0);
		page3->listW->setMaximumSize(200, 16777215);
		for (Module *module : QMPlay2Core.getPluginsInstance())
		{
			QListWidgetItem *tWI = new QListWidgetItem(module->name());
			tWI->setData(Qt::UserRole, qVariantFromValue((void *)module));
			QString toolTip = "<html>" + tr("Contains") + ":";
			for (const Module::Info &mod : module->getModulesInfo(true))
			{
				const QPixmap moduleIcon = Functions::getPixmapFromIcon(mod.icon, QSize(22, 22), this);
				toolTip += "<p>&nbsp;&nbsp;&nbsp;&nbsp;";
				bool hasIcon = false;
				if (!moduleIcon.isNull())
				{
					QBuffer buffer;
					if (buffer.open(QBuffer::WriteOnly) && moduleIcon.save(&buffer, "PNG"))
					{
						toolTip += "<img width='22' height='22' src='data:image/png;base64, " + buffer.data().toBase64() + "'/> ";
						hasIcon = true;
					}
				}
				if (!hasIcon)
					toolTip += "- ";
				toolTip += mod.name + "</p>";
			}
			toolTip += "</html>";
			tWI->setToolTip(toolTip);
			tWI->setIcon(QMPlay2GUI.getIcon(module->icon()));
			page3->listW->addItem(tWI);
			if (page == 2 && !moduleName.isEmpty() && module->name() == moduleName)
				moduleIndex = page3->listW->count() - 1;
		}

		page3->scrollA = new QScrollArea;
		page3->scrollA->setWidgetResizable(true);
		page3->scrollA->setFrameShape(QFrame::NoFrame);

		QHBoxLayout *layout = new QHBoxLayout(page3);
		layout->setMargin(0);
		layout->setSpacing(1);
		layout->addWidget(page3->listW);
		layout->addWidget(page3->scrollA);
		connect(page3->listW, SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)), this, SLOT(chModule(QListWidgetItem *)));
	}

	/* Page 4 */
	{
		page4 = new Page4;
		tabW->addTab(page4, tr("Subtitles"));

		page4->colorsAndBordersB = new QCheckBox(tr("Colors and borders"));
		page4->colorsAndBordersB->setChecked(QMPSettings.getBool("ApplyToASS/ColorsAndBorders"));

		page4->marginsAndAlignmentB = new QCheckBox(tr("Margins and alignment"));
		page4->marginsAndAlignmentB->setChecked(QMPSettings.getBool("ApplyToASS/MarginsAndAlignment"));

		page4->fontsB = new QCheckBox(tr("Fonts and spacing"));
		page4->fontsB->setChecked(QMPSettings.getBool("ApplyToASS/FontsAndSpacing"));

		page4->overridePlayResB = new QCheckBox(tr("Use the same size"));
		page4->overridePlayResB->setChecked(QMPSettings.getBool("ApplyToASS/OverridePlayRes"));

		page4->toAssGB = new QGroupBox(tr("Apply for ASS/SSA subtitles"));
		page4->toAssGB->setCheckable(true);
		page4->toAssGB->setChecked(QMPSettings.getBool("ApplyToASS/ApplyToASS"));

		QGridLayout *page4ToAssLayout = new QGridLayout(page4->toAssGB);
		page4ToAssLayout->addWidget(page4->colorsAndBordersB, 0, 0, 1, 1);
		page4ToAssLayout->addWidget(page4->marginsAndAlignmentB, 1, 0, 1, 1);
		page4ToAssLayout->addWidget(page4->fontsB, 0, 1, 1, 1);
		page4ToAssLayout->addWidget(page4->overridePlayResB, 1, 1, 1, 1);

		page4->addWidget(page4->toAssGB);
	}

	/* Page 5 */
	{
		page5 = new Page5;
		tabW->addTab(page5, tr("OSD"));

		page5->enabledB = new QCheckBox(tr("OSD enabled"));
		page5->enabledB->setChecked(QMPSettings.getBool("OSD/Enabled"));
		page5->addWidget(page5->enabledB);
	}

	/* Page 6 */
	{
		page6 = new Page6;
		tabW->addTab(page6, tr("Video filters"));

		QWidget *widget = new QWidget;

		QGridLayout *layout = new QGridLayout(widget);
		layout->setMargin(0);

		page6->deintSettingsW = new DeintSettingsW;
		layout->addWidget(page6->deintSettingsW, 0, 0, 1, 2);

		page6->videoEqContainer = new QGroupBox(videoEq->objectName());
		layout->addWidget(page6->videoEqContainer, 1, 0, 2, 1);

		page6->otherVFiltersW = new OtherVFiltersW(false);
		if (!page6->otherVFiltersW->count())
		{
			delete page6->otherVFiltersW;
			page6->otherVFiltersW = nullptr;
		}
		else
		{
			QGroupBox *otherVFiltersContainer = new QGroupBox(tr("Software video filters"));
			QGridLayout *otherVFiltersLayout = new QGridLayout(otherVFiltersContainer);
			otherVFiltersLayout->addWidget(page6->otherVFiltersW);
			connect(page6->otherVFiltersW, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			layout->addWidget(otherVFiltersContainer, 1, 1, 1, 1);
		}

		OtherVFiltersW *otherHWVFiltersW = new OtherVFiltersW(true);
		if (!otherHWVFiltersW->count())
			delete otherHWVFiltersW;
		else
		{
			QGroupBox *otherHWVFiltersContainer = new QGroupBox(tr("Hardware accelerated video outputs"));
			QGridLayout *otherHWVFiltersLayout = new QGridLayout(otherHWVFiltersContainer);
			otherHWVFiltersLayout->addWidget(otherHWVFiltersW);
			connect(otherHWVFiltersW, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(openModuleSettings(QListWidgetItem *)));
			layout->addWidget(otherHWVFiltersContainer, 2, 1, 1, 1);
		}

		page6->setWidget(widget);
	}

	connect(tabW, SIGNAL(currentChanged(int)), this, SLOT(tabCh(int)));
	tabW->setCurrentIndex(page);

	show();
}
OutputPaneManager::OutputPaneManager(QWidget *parent) :
    QWidget(parent),
    m_titleLabel(new QLabel),
    m_manageButton(new OutputPaneManageButton),
    m_closeButton(new QToolButton),
    m_minMaxAction(0),
    m_minMaxButton(new QToolButton),
    m_nextAction(0),
    m_prevAction(0),
    m_outputWidgetPane(new QStackedWidget),
    m_opToolBarWidgets(new QStackedWidget),
    m_minimizeIcon(QLatin1String(":/core/images/arrowdown.png")),
    m_maximizeIcon(QLatin1String(":/core/images/arrowup.png")),
    m_maximised(false),
    m_outputPaneHeight(0)
{
    setWindowTitle(tr("Output"));

    m_titleLabel->setContentsMargins(5, 0, 5, 0);

    m_clearAction = new QAction(this);
    m_clearAction->setIcon(QIcon(QLatin1String(Constants::ICON_CLEAN_PANE)));
    m_clearAction->setText(tr("Clear"));
    connect(m_clearAction, SIGNAL(triggered()), this, SLOT(clearPage()));

    m_nextAction = new QAction(this);
    m_nextAction->setIcon(QIcon(QLatin1String(Constants::ICON_NEXT)));
    m_nextAction->setText(tr("Next Item"));
    connect(m_nextAction, SIGNAL(triggered()), this, SLOT(slotNext()));

    m_prevAction = new QAction(this);
    m_prevAction->setIcon(QIcon(QLatin1String(Constants::ICON_PREV)));
    m_prevAction->setText(tr("Previous Item"));
    connect(m_prevAction, SIGNAL(triggered()), this, SLOT(slotPrev()));

    m_minMaxAction = new QAction(this);
    m_minMaxAction->setIcon(m_maximizeIcon);
    m_minMaxAction->setText(tr("Maximize Output Pane"));

    m_closeButton->setIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_DOCUMENT)));
    connect(m_closeButton, SIGNAL(clicked()), this, SLOT(slotHide()));

    connect(ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(saveSettings()));

    QVBoxLayout *mainlayout = new QVBoxLayout;
    mainlayout->setSpacing(0);
    mainlayout->setMargin(0);
    m_toolBar = new Utils::StyledBar;
    QHBoxLayout *toolLayout = new QHBoxLayout(m_toolBar);
    toolLayout->setMargin(0);
    toolLayout->setSpacing(0);
    toolLayout->addWidget(m_titleLabel);
    toolLayout->addWidget(new Utils::StyledSeparator);
    m_clearButton = new QToolButton;
    toolLayout->addWidget(m_clearButton);
    m_prevToolButton = new QToolButton;
    toolLayout->addWidget(m_prevToolButton);
    m_nextToolButton = new QToolButton;
    toolLayout->addWidget(m_nextToolButton);
    toolLayout->addWidget(m_opToolBarWidgets);
    toolLayout->addWidget(m_minMaxButton);
    toolLayout->addWidget(m_closeButton);
    mainlayout->addWidget(m_toolBar);
    mainlayout->addWidget(m_outputWidgetPane, 10);
    mainlayout->addWidget(new Core::FindToolBarPlaceHolder(this));
    setLayout(mainlayout);

    m_buttonsWidget = new QWidget;
    m_buttonsWidget->setLayout(new QHBoxLayout);
    m_buttonsWidget->layout()->setContentsMargins(5,0,0,0);
    m_buttonsWidget->layout()->setSpacing(4);
}
示例#23
0
KoPageNavigator::KoPageNavigator(KoPAView *view)
  : QStackedWidget(view)
  , d(new Private(view))
{
    const bool isSlideType = (d->view->kopaDocument()->pageType() == KoPageApp::Slide);

#ifdef Q_WS_MAC
    setAttribute(Qt::WA_MacMiniSize, true);
#endif
    // normal display
    d->displayLabel = new QLabel(this);
    d->displayLabel->setAlignment(Qt::AlignCenter | Qt::AlignVCenter);
    addWidget(d->displayLabel);

    // add interactive variant
    QWidget* controlWidget = new QWidget(this);
    QHBoxLayout* layout = new QHBoxLayout(controlWidget);
    layout->setSpacing(0);
    layout->setMargin(0);

    // the original go-*-view-page icons as set for the actions are not reused,
    // because they look too complex, at least with the Oxygen icons
    // also installing an event filter for all buttons, to get wheel events even
    // for disabled buttons
    d->gotoFirstPageButton = new KoPageNavigatorButton(koIconNameCStr("go-first-view"), this);
    d->gotoFirstPageButton->installEventFilter(this);
    d->gotoPreviousPageButton = new KoPageNavigatorButton(koIconNameCStr("go-previous-view"), this);
    d->gotoPreviousPageButton->installEventFilter(this);
    d->gotoNextPageButton = new KoPageNavigatorButton(koIconNameCStr("go-next-view"), this);
    d->gotoNextPageButton->installEventFilter(this);
    d->gotoLastPageButton = new KoPageNavigatorButton(koIconNameCStr("go-last-view"), this);
    d->gotoLastPageButton->installEventFilter(this);

    d->pageNumberEdit = new QLineEdit(this);
    d->pageNumberEdit->installEventFilter(this);
    d->pageNumberEditValidator = new QIntValidator(d->pageNumberEdit);
    d->pageNumberEditValidator->setBottom(1);
    d->pageNumberEdit->setValidator(d->pageNumberEditValidator);
    d->pageNumberEdit->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    connect(d->pageNumberEdit, SIGNAL(returnPressed()), SLOT(onPageNumberEntered()));

    layout->addWidget(d->gotoFirstPageButton);
    layout->addWidget(d->gotoPreviousPageButton);
    layout->addWidget(d->pageNumberEdit);
    layout->addWidget(d->gotoNextPageButton);
    layout->addWidget(d->gotoLastPageButton);

    addWidget(controlWidget);

    KoPADocument *const kopaDocument = d->view->kopaDocument();
    connect(kopaDocument, SIGNAL(pageAdded(KoPAPageBase*)), SLOT(updateDisplayLabel()));
    connect(kopaDocument, SIGNAL(pageRemoved(KoPAPageBase*)), SLOT(updateDisplayLabel()));
    connect(d->view->proxyObject, SIGNAL(activePageChanged()), SLOT(updateDisplayLabel()));

    // Fix width by the largest needed
    QFontMetrics fontMetrics(font());
    d->pageNumberEdit->setMinimumWidth(fontMetrics.width(QString::number(maxPageCountPattern*10))); //one more
    const int editWidth = widget(Edit)->minimumWidth();
    const int normalWidth = fontMetrics.width(displayText(false, isSlideType, maxPageCountPattern, maxPageCountPattern));
    const int masterWidth = fontMetrics.width(displayText(true, isSlideType, maxPageCountPattern, maxPageCountPattern));
    setFixedWidth(qMax(editWidth, qMax(normalWidth, masterWidth)));

    updateDisplayLabel();
}
void OutputPaneManager::init()
{
    ActionContainer *mwindow = ActionManager::actionContainer(Constants::M_WINDOW);
    const Context globalContext(Constants::C_GLOBAL);

    // Window->Output Panes
    ActionContainer *mpanes = ActionManager::createMenu(Constants::M_WINDOW_PANES);
    mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
    mpanes->menu()->setTitle(tr("Output &Panes"));
    mpanes->appendGroup("Coreplugin.OutputPane.ActionsGroup");
    mpanes->appendGroup("Coreplugin.OutputPane.PanesGroup");

    Command *cmd;

    cmd = ActionManager::registerAction(m_clearAction, "Coreplugin.OutputPane.clear", globalContext);
    m_clearButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_prevAction, "Coreplugin.OutputPane.previtem", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Shift+F6")));
    m_prevToolButton->setDefaultAction(cmd->action());
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_nextAction, "Coreplugin.OutputPane.nextitem", globalContext);
    m_nextToolButton->setDefaultAction(cmd->action());
    cmd->setDefaultKeySequence(QKeySequence(tr("F6")));
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");

    cmd = ActionManager::registerAction(m_minMaxAction, "Coreplugin.OutputPane.minmax", globalContext);
    cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+9") : tr("Alt+9")));
    cmd->setAttribute(Command::CA_UpdateText);
    cmd->setAttribute(Command::CA_UpdateIcon);
    mpanes->addAction(cmd, "Coreplugin.OutputPane.ActionsGroup");
    connect(m_minMaxAction, SIGNAL(triggered()), this, SLOT(slotMinMax()));
    m_minMaxButton->setDefaultAction(cmd->action());

    mpanes->addSeparator(globalContext, "Coreplugin.OutputPane.ActionsGroup");

    QFontMetrics titleFm = m_titleLabel->fontMetrics();
    int minTitleWidth = 0;

    m_panes = ExtensionSystem::PluginManager::getObjects<IOutputPane>();
    qSort(m_panes.begin(), m_panes.end(), &comparePanes);
    const int n = m_panes.size();

    int shortcutNumber = 1;
    const Id baseId = "QtCreator.Pane.";
    for (int i = 0; i != n; ++i) {
        IOutputPane *outPane = m_panes.at(i);
        const int idx = m_outputWidgetPane->addWidget(outPane->outputWidget(this));
        QTC_CHECK(idx == i);

        connect(outPane, SIGNAL(showPage(int)), this, SLOT(showPage(int)));
        connect(outPane, SIGNAL(hidePage()), this, SLOT(slotHide()));
        connect(outPane, SIGNAL(togglePage(int)), this, SLOT(togglePage(int)));
        connect(outPane, SIGNAL(navigateStateUpdate()), this, SLOT(updateNavigateState()));
        connect(outPane, SIGNAL(flashButton()), this, SLOT(flashButton()));
        connect(outPane, SIGNAL(setBadgeNumber(int)), this, SLOT(setBadgeNumber(int)));

        QWidget *toolButtonsContainer = new QWidget(m_opToolBarWidgets);
        QHBoxLayout *toolButtonsLayout = new QHBoxLayout;
        toolButtonsLayout->setMargin(0);
        toolButtonsLayout->setSpacing(0);
        foreach (QWidget *toolButton, outPane->toolBarWidgets())
            toolButtonsLayout->addWidget(toolButton);
        toolButtonsLayout->addStretch(5);
        toolButtonsContainer->setLayout(toolButtonsLayout);

        m_opToolBarWidgets->addWidget(toolButtonsContainer);

        minTitleWidth = qMax(minTitleWidth, titleFm.width(outPane->displayName()));

        QString suffix = outPane->displayName().simplified();
        suffix.remove(QLatin1Char(' '));
        const Id id = baseId.withSuffix(suffix);
        QAction *action = new QAction(outPane->displayName(), this);
        Command *cmd = ActionManager::registerAction(action, id, globalContext);

        mpanes->addAction(cmd, "Coreplugin.OutputPane.PanesGroup");
        m_actions.append(action);
        m_ids.append(id);

        cmd->setDefaultKeySequence(QKeySequence(paneShortCut(shortcutNumber)));
        OutputPaneToggleButton *button = new OutputPaneToggleButton(shortcutNumber, outPane->displayName(),
                                                                    cmd->action());
        ++shortcutNumber;
        m_buttonsWidget->layout()->addWidget(button);
        m_buttons.append(button);
        connect(button, SIGNAL(clicked()), this, SLOT(buttonTriggered()));

        bool visible = outPane->priorityInStatusBar() != -1;
        button->setVisible(visible);

        connect(action, SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
    }

    m_titleLabel->setMinimumWidth(minTitleWidth + m_titleLabel->contentsMargins().left()
                                  + m_titleLabel->contentsMargins().right());
    m_buttonsWidget->layout()->addWidget(m_manageButton);
    connect(m_manageButton, SIGNAL(clicked()), this, SLOT(popupMenu()));

    readSettings();
}
示例#25
0
ItemCluster::ItemCluster(QWidget *pParent, const char *name) : QWidget(pParent)
{
  setObjectName(name);

//  Create the component Widgets
  QVBoxLayout *mainLayout  = new QVBoxLayout(); 
  mainLayout->setMargin(0); mainLayout->setSpacing(2);
  QHBoxLayout *itemLayout  = new QHBoxLayout(); 
  itemLayout->setMargin(0); itemLayout->setSpacing(5);
  QHBoxLayout *uomLayout   = new QHBoxLayout(); 
  uomLayout->setMargin(0); uomLayout->setSpacing(5);
  QHBoxLayout *line1Layout = new QHBoxLayout(); 
  line1Layout->setMargin(0); line1Layout->setSpacing(7);

  QLabel *_itemNumberLit = new QLabel(tr("Item Number:"), this, "_itemNumberLit");
  _itemNumberLit->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
  itemLayout->addWidget(_itemNumberLit);

  _itemNumber = new ItemLineEdit(this, "_itemNumber");
  _itemNumber->setMinimumWidth(100);
  itemLayout->addWidget(_itemNumber);

  _itemList = new QPushButton(tr("..."), this, "_itemList");
#ifndef Q_WS_MAC
  _itemList->setMaximumWidth(25);
#else
  _itemList->setMinimumWidth(60);
  _itemList->setMinimumHeight(32);
#endif
  _itemList->setFocusPolicy(Qt::NoFocus);
  itemLayout->addWidget(_itemList);
  line1Layout->addLayout(itemLayout);

  QLabel *_uomLit = new QLabel(tr("UOM:"), this, "_uomLit");
  _uomLit->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
  uomLayout->addWidget(_uomLit);

  _uom = new QLabel(this, "_uom");
  _uom->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
  _uom->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
  _uom->setMinimumWidth(50);
  uomLayout->addWidget(_uom);
  line1Layout->addLayout(uomLayout);
  mainLayout->addLayout(line1Layout);

  _descrip1 = new QLabel(this, "_descrip1");
  _descrip1->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
  mainLayout->addWidget(_descrip1);

  _descrip2 = new QLabel(this, "_descrip2");
  _descrip2->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
  mainLayout->addWidget(_descrip2);
  setLayout(mainLayout);

//  Make some internal connections
  connect(_itemNumber, SIGNAL(aliasChanged(const QString &)), this, SIGNAL(aliasChanged(const QString &)));
  connect(_itemNumber, SIGNAL(privateIdChanged(int)), this, SIGNAL(privateIdChanged(int)));
  connect(_itemNumber, SIGNAL(newId(int)), this, SIGNAL(newId(int)));
  connect(_itemNumber, SIGNAL(valid(bool)), this, SIGNAL(valid(bool)));
  connect(_itemNumber, SIGNAL(warehouseIdChanged(int)), this, SIGNAL(warehouseIdChanged(int)));
  connect(_itemNumber, SIGNAL(typeChanged(const QString &)), this, SIGNAL(typeChanged(const QString &)));
  connect(_itemNumber, SIGNAL(configured(bool)), this, SIGNAL(configured(bool)));

  connect(_itemNumber, SIGNAL(uomChanged(const QString &)), _uom, SLOT(setText(const QString &)));
  connect(_itemNumber, SIGNAL(descrip1Changed(const QString &)), _descrip1, SLOT(setText(const QString &)));
  connect(_itemNumber, SIGNAL(descrip2Changed(const QString &)), _descrip2, SLOT(setText(const QString &)));

  connect(_itemList, SIGNAL(clicked()), _itemNumber, SLOT(sEllipses()));

  setFocusProxy(_itemNumber);
}
示例#26
0
QHBoxLayout* ProjectWindow::setupTitleContainer() {
    QHBoxLayout* mainLayout = new QHBoxLayout;
    mainLayout->setMargin(5);
    mainLayout->setSpacing(10);
    mainLayout->addStretch(0);
    
    GraphicalButton* modeIcon = new GraphicalButton(projectData.projectMode().getIconWithLogo());
    modeIcon->setFixedSize(78, 78);
    mainLayout->addWidget(modeIcon, 0);
    
    QVBoxLayout* titleLayout = new QVBoxLayout();
    titleLayout->setMargin(0);
    titleLayout->setSpacing(5);
    titleLayout->addStretch(0);
    
    projectNameLabel_ = new QLabel;
    QFont nameFont = projectNameLabel_->font();
    nameFont.setPointSize(16);
    projectNameLabel_->setFont(nameFont);
    setProjectTitle(projectData.projectName());
    titleLayout->addWidget(projectNameLabel_, 0);

    projectPathLabel_ = new QLabel;
    projectPathLabel_->setTextInteractionFlags(Qt::TextSelectableByMouse);
    setProjectPath(projectData.projectDir().canonicalPath());
    titleLayout->addWidget(projectPathLabel_, 0);
    
    QHBoxLayout* titleButtonsLayout = new QHBoxLayout;
    titleButtonsLayout->addStretch(0);
    
    QPushButton* changeNameButton = new QPushButton(ApplicationData::icon("rename"), "Rename Project");
    connect(changeNameButton, &QPushButton::clicked, &projectData, &ProjectData::changeProjectName);
    titleButtonsLayout->addWidget(changeNameButton, 0);
    
    QPushButton* changeModeButton = new QPushButton(ApplicationData::icon("change_mode"), "Change Project Mode");
    connect(changeModeButton, &QPushButton::clicked, &projectData, &ProjectData::changeProjectMode);
    titleButtonsLayout->addWidget(changeModeButton, 0);
    
    QPushButton* repiarLinksButton = new QPushButton(ApplicationData::icon("repair"), "Repair Project Links");
    connect(repiarLinksButton, &QPushButton::clicked, &projectData, &ProjectData::repairLinks);
    titleButtonsLayout->addWidget(repiarLinksButton, 0);
    
    titleButtonsLayout->addStretch(1);
    
    titleLayout->addLayout(titleButtonsLayout, 0);
    titleLayout->addStretch(1);
    
    QVBoxLayout* imagesLayout = new QVBoxLayout();
    imagesLayout->setMargin(5);
    imagesLayout->setSpacing(5);
    imagesLayout->addStretch(0);
    
    imagesCountLabel_ = new QLabel;
    imagesLayout->setAlignment(Qt::AlignRight);
    setImagesCount(projectData.projectImageList().count());
    
    imagesLayout->addWidget(imagesCountLabel_, 0, Qt::AlignRight);
    imagesLayout->addLayout(setupImageActions());
    
    imagesLayout->addStretch(1);
    
    QFrame* imagesFrame = new QFrame;
    imagesFrame->setFrameShadow(QFrame::Raised);
    imagesFrame->setFrameShape(QFrame::StyledPanel);
    imagesFrame->setLayout(imagesLayout);
    
    mainLayout->addLayout(titleLayout);
    mainLayout->addStretch(1);
    mainLayout->addWidget(imagesFrame);

    return mainLayout;
}
示例#27
0
void MythWizard::layOut()
{
    delete d->v;
    d->v = new QVBoxLayout( this);
    d->v->setMargin(6);
    d->v->setSpacing(0);
    d->v->setObjectName("top-level layout");

    QHBoxLayout * l;
    l = new QHBoxLayout();
    l->setMargin(6);
    d->v->addLayout( l, 0 );
    layOutTitleRow( l, d->current ? d->current->t : QString() );

    if ( ! d->hbar1 ) {
        d->hbar1 = new QFrame(this, nullptr);
        d->hbar1->setObjectName("MythWizard - hbar1");
        d->hbar1->setFrameStyle(QFrame::Sunken | QFrame::HLine);
        d->hbar1->setFixedHeight( 12 );
    }

    d->v->addWidget( d->hbar1 );

    d->v->addWidget( d->ws, 10 );

    if (!d->helpgroup)
    {
        d->helpgroup = new MythGroupBox(this);
        d->helpgroup->setObjectName("MythWizard -- help group box");

        d->help = new MythLabel(d->helpgroup);
        d->help->setObjectName("MythWizard -- help text");

        d->help->setAlignment(Qt::AlignLeft | Qt::AlignTop);
        d->help->setWordWrap(true);

        d->help->setMinimumWidth(screenwidth - (int)(40 * wmult));
        d->help->setMaximumHeight((int)(80 * hmult));
        d->help->setMinimumHeight((int)(80 * hmult));

        QVBoxLayout *helplayout = new QVBoxLayout(d->helpgroup);
        helplayout->setMargin(10);
        helplayout->addWidget(d->help);
    }
    else
    {
        d->help->setText("");
    }

    d->v->addWidget(d->helpgroup);

    if ( ! d->hbar2 ) {
        d->hbar2 = new QFrame( this, nullptr );
        d->hbar2->setObjectName("MythWizard - hbar2");
        d->hbar2->setFrameStyle(QFrame::Sunken | QFrame::HLine);
        d->hbar2->setFixedHeight( 12 );
    }
    d->v->addWidget( d->hbar2 );

    l = new QHBoxLayout();
    l->setMargin(6);
    d->v->addLayout( l );
    layOutButtonRow( l );
    d->v->activate();
}
示例#28
0
文件: pmquery.cpp 项目: DundalkIT/pcp
PmQuery::PmQuery(bool inputflag, bool printflag, bool noframeflag,
		 bool nosliderflag, bool usesliderflag, bool exclusiveflag)
    : QDialog()
{
    QHBoxLayout *hboxLayout;
    QVBoxLayout *vboxLayout;
    QSpacerItem *spacerItem;
    QSpacerItem *spacerItem1;
    QVBoxLayout *vboxLayout1;
    QHBoxLayout *hboxLayout1;
    QSpacerItem *spacerItem2;

    QString filename;
    if (iconic == HOST_ICON)
	filename = tr(":images/dialog-host.png");
    else if (iconic == ERROR_ICON)
	filename = tr(":images/dialog-error.png");
    else if (iconic == WARNING_ICON)
	filename = tr(":images/dialog-warning.png");
    else if (iconic == ARCHIVE_ICON)
	filename = tr(":images/dialog-archive.png");
    else if (iconic == QUESTION_ICON)
	filename = tr(":images/dialog-question.png");
    else // (iconic == INFO_ICON)
	filename = tr(":images/dialog-information.png");

    QIcon	icon(filename);
    QPixmap	pixmap(filename);
    setWindowIcon(icon);
    setWindowTitle(tr(title));

    QGridLayout *gridLayout = new QGridLayout(this);
    gridLayout->setSpacing(6);
    gridLayout->setMargin(9);
    hboxLayout = new QHBoxLayout();
    hboxLayout->setSpacing(6);
    hboxLayout->setMargin(0);
    vboxLayout = new QVBoxLayout();
    vboxLayout->setSpacing(6);
    vboxLayout->setMargin(0);
    spacerItem = new QSpacerItem(20, 2, QSizePolicy::Minimum,
					QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem);

    QLabel *imageLabel = new QLabel(this);
    imageLabel->setPixmap(pixmap);

    vboxLayout->addWidget(imageLabel);

    spacerItem1 = new QSpacerItem(20, 20, QSizePolicy::Minimum,
					  QSizePolicy::Expanding);

    vboxLayout->addItem(spacerItem1);
    hboxLayout->addLayout(vboxLayout);
    vboxLayout1 = new QVBoxLayout();
    vboxLayout1->setSpacing(6);
    vboxLayout1->setMargin(0);

    int height;
    int width = DEFAULT_EDIT_WIDTH; 

    QLineEdit* lineEdit = NULL;
    QTextEdit* textEdit = NULL;
    if (inputflag && messagecount <= 1) {
	lineEdit = new QLineEdit(this);
	if (messagecount == 1)
	    lineEdit->setText(tr(messages[0]));
	height = lineEdit->font().pointSize() + 4;
	if (height < 0)
	    height = lineEdit->font().pixelSize() + 4;
	if (height < 0)
	    height = lineEdit->heightForWidth(width) + 4;
	lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::Fixed);
	lineEdit->setMinimumSize(QSize(width, height));
	lineEdit->setGeometry(QRect(0, 0, width, height));
	vboxLayout1->addWidget(lineEdit);
    }
    else {
	QFont	fixed("monospace");
	fixed.setStyleHint(QFont::TypeWriter);

	textEdit = new QTextEdit(this);
	textEdit->setFont(fixed);
	textEdit->setLineWrapMode(QTextEdit::FixedColumnWidth);
	textEdit->setLineWrapColumnOrWidth(80);
	textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	if (nosliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	else if (usesliderflag)
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	else
	    textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	for (int m = 0; m < messagecount; m++)
	    textEdit->append(tr(messages[m]));
	if (inputflag)
	    textEdit->setReadOnly(false);
	else {
	    textEdit->setLineWidth(1);
	    textEdit->setFrameStyle(noframeflag ? QFrame::NoFrame :
				    QFrame::Box | QFrame::Sunken);
	    textEdit->setReadOnly(true);
	}
	if (usesliderflag)
	    height = DEFAULT_EDIT_HEIGHT;
	else {
	    height = textEdit->font().pointSize() + 4;
	    if (height < 0)
		height = textEdit->font().pixelSize() + 4;
	    if (height < 0)
	        height = textEdit->heightForWidth(width) + 4;
	    height *= messagecount;
	}
	textEdit->setMinimumSize(QSize(width, height));
	textEdit->setSizePolicy(QSizePolicy::MinimumExpanding,
				QSizePolicy::MinimumExpanding);
	textEdit->moveCursor(QTextCursor::Start);
	textEdit->ensureCursorVisible();
	vboxLayout1->addWidget(textEdit);
    }

    hboxLayout1 = new QHBoxLayout();
    hboxLayout1->setSpacing(6);
    hboxLayout1->setMargin(0);
    spacerItem2 = new QSpacerItem(40, 20, QSizePolicy::Expanding,
					  QSizePolicy::Minimum);
    hboxLayout1->addItem(spacerItem2);

    for (int i = 0; i < buttoncount; i++) {
	QueryButton *button = new QueryButton(printflag, this);
	button->setMinimumSize(QSize(72, 32));
	button->setDefault(buttons[i] == defaultbutton);
	button->setQuery(this);
	button->setText(tr(buttons[i]));
	button->setStatus(statusi[i]);
	if (inputflag && buttons[i] == defaultbutton) {
	    if (textEdit) 
		button->setEditor(textEdit);
	    else if (lineEdit) {
		button->setEditor(lineEdit);
		if (buttons[i] == defaultbutton)
		    connect(lineEdit, SIGNAL(returnPressed()),
			    button, SLOT(click()));
	    }
	}
	connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
	hboxLayout1->addWidget(button);
    }

    vboxLayout1->addLayout(hboxLayout1);
    hboxLayout->addLayout(vboxLayout1);
    gridLayout->addLayout(hboxLayout, 0, 0, 1, 1);
    gridLayout->setSizeConstraint(QLayout::SetFixedSize);

    if (inputflag && messagecount <= 1)
	resize(QSize(320, 83));
    else
	resize(QSize(320, 132));

    if (timeout)
	startTimer(timeout * 1000);

    if (exclusiveflag)
	setWindowModality(Qt::WindowModal);
}
示例#29
0
PickerPopup::PickerPopup(DatePicker *picker)
        : QFrame(NULL, "calendar", WType_Popup | WStyle_Customize | WStyle_Tool | WDestructiveClose)
{
    m_picker = picker;

    setFrameShape(PopupPanel);
    setFrameShadow(Sunken);
    setLineWidth(1);

    QDate d = QDate::currentDate();
    QLabel *lbl = new QLabel(this);
    lbl->setBackgroundMode(PaletteBase);
    QVBoxLayout *l = new QVBoxLayout(this);
    QHBoxLayout *hLay = new QHBoxLayout(l);
    hLay->setMargin(0);
    hLay->setSpacing(4);

    m_monthBox = new MonthSpinBox(this);
    hLay->addWidget(m_monthBox);
    m_yearBox = new QSpinBox(this);
    m_yearBox->setMaxValue(d.year());
    m_yearBox->setMinValue(d.year() - 200);
    m_monthBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
    hLay->addWidget(m_yearBox);
    connect(m_monthBox, SIGNAL(valueChanged(int)), this, SLOT(monthChanged(int)));
    connect(m_yearBox, SIGNAL(valueChanged(int)), this, SLOT(yearChanged(int)));
    l->addWidget(lbl);
    l->setMargin(6);
    l->setSpacing(4);

    QPalette pal(palette());
    pal.setColor(QColorGroup::Text, QColor(127, 0, 0));
    pal.setColor(QColorGroup::Foreground, QColor(255, 0, 0));
    QFont f(font());
    f.setBold(true);

    m_labels = new QLabel*[7 * 6];
    QGridLayout *lay = new QGridLayout(lbl, 7, 7);
    lay->setMargin(6);
    lay->setSpacing(4);
    unsigned n = 0;
    for (unsigned j = 0; j < 6; j++){
        for (unsigned i = 0; i < 7; i++){
            QLabel *l = new PickerLabel(lbl);
            l->setFont(f);
            l->setAlignment(AlignRight);
            l->setText("99");
            l->setMinimumSize(l->sizeHint());
            l->setText(QString::number(n));
            l->setBackgroundMode(PaletteBase);
            lay->addWidget(l, i, j + 1);
            m_labels[n++] = l;
            if (i >= 5)
                l->setPalette(pal);
            connect(l, SIGNAL(clicked(PickerLabel*)), this, SLOT(dayClick(PickerLabel*)));
        }
    }
    for (unsigned i = 0; i < 7; i++){
        QLabel *l = new QLabel(lbl);
        l->setFont(f);
        l->setText(i18n(day_name[i]));
        l->setBackgroundMode(PaletteBase);
        lay->addWidget(l, i, 0);
        if (i >= 5)
            l->setPalette(pal);
    }
    int day, month, year;
    m_picker->getDate(day, month, year);
    if ((month == 0) || (year == 0)){
        month = d.month();
        year  = d.year();
    }
    m_monthBox->setValue(month - 1);
    m_yearBox->setValue(year);
    monthChanged(month - 1);
    yearChanged(year);
}
示例#30
0
SourceView::SourceView(QWidget *parent,QFont & efont,bool line, QList<QColor> edcolors, QList<QColor> hicolors ) : QWidget(parent)
{
  
splitter=new MiniSplitter(this);
splitter->setOrientation(Qt::Vertical);

QFrame *framebis=new QFrame(splitter);
framebis->setLineWidth(0);
framebis->setFrameShape(QFrame::NoFrame);
framebis->setFrameShadow(QFrame::Plain);
framebis->setFrameStyle(QFrame::NoFrame);


QVBoxLayout* mainlay = new QVBoxLayout(framebis );
mainlay->setSpacing(0);
mainlay->setMargin(0);

centralToolBar=new QToolBar("ToolBar",framebis);
centralToolBar->setFloatable(false);
centralToolBar->setOrientation(Qt::Horizontal);
centralToolBar->setMovable(false);
centralToolBar->setIconSize(QSize(16,16 ));
centralToolBar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
mainlay->addWidget(centralToolBar);
QAction *Act = new QAction(getIcon(":/images/fileopen16.png"), tr("Open"), this);
connect(Act, SIGNAL(triggered()), this, SLOT(fileOpen()));
centralToolBar->addAction(Act);
centralToolBar->addSeparator();
titleLabel=new QLabel("(read only)",centralToolBar);
centralToolBar->addWidget(titleLabel);
centralToolBar->addSeparator();
Act = new QAction(getIcon(":/images/diff.png"), tr("Check differences"), this);
connect(Act, SIGNAL(triggered()), this, SLOT(checkDiff()));
centralToolBar->addAction(Act);


QFrame *frame=new QFrame(framebis);
frame->setLineWidth(0);
frame->setFrameShape(QFrame::NoFrame);
frame->setFrameShadow(QFrame::Plain);
frame->setFrameStyle(QFrame::NoFrame);
mainlay->addWidget(frame);

lastdocument="";
editor=new LightLatexEditor(frame,efont,edcolors,hicolors,"");
connect(editor, SIGNAL(requestFind()), this, SLOT(showFind()));
connect(editor, SIGNAL(requestGotoLine()), this, SLOT(showGoto()));
m_lineNumberWidget = new LightLineNumberWidget( editor, frame);
m_lineNumberWidget->setFont(efont);
QFontMetrics fm( efont );
m_lineNumberWidget->setFixedWidth( fm.width( "00000" ) + 22 );
QHBoxLayout* lay = new QHBoxLayout( frame );
lay->setSpacing(0);
lay->setMargin(0);
lay->addWidget( m_lineNumberWidget );
lay->addWidget( editor );
setFocusProxy( editor );
setLineNumberWidgetVisible(line);

Stack=new QStackedWidget(this);
Stack->setLineWidth(0);
Stack->setFrameShape(QFrame::NoFrame);
Stack->setFrameShadow(QFrame::Plain);

findwidget=new LightFindWidget(Stack);
Stack->addWidget(findwidget);
findwidget->SetEditor(editor);
connect(findwidget, SIGNAL( requestHide() ), Stack, SLOT( hide() ) );
connect(findwidget, SIGNAL( requestExtension() ), this, SLOT( showFind() ) );

gotolinewidget=new LightGotoLineWidget(Stack);
Stack->addWidget(gotolinewidget);
gotolinewidget->SetEditor(editor);
connect(gotolinewidget, SIGNAL( requestHide() ), Stack, SLOT( hide() ) );

Stack->hide();

splitter->addWidget(framebis);
splitter->addWidget(Stack);

QVBoxLayout *mainlayout= new QVBoxLayout(this);
mainlayout->setSpacing(0);
mainlayout->setMargin(0);
mainlayout->addWidget(splitter);
}