void Qt_widget_standard_toolbar::group_clicked(int i) { static int id = 0; // This id is here to keep track of the button from the group that // is on (if all toolbuttons are down, nolayer is on. At the // beginning, it is set to 0, because // button_group.id(nolayerBt)==0. if( i == id ) { if( i == 0) return; // nolayer is on and cannot be set off like that. QToolButton* tBt = static_cast<QToolButton*>(button_group->find(i)); if( tBt != 0) tBt->setOn(false); nolayerBt->setOn(true); id = 0; } else id = i; }
void stepsequencerWidget::stepModeGroup_clicked(int mode) { //we are in step mode (arg is 0 - on./off, 1 - note - 2- length 3 -velocity) stepMode=mode; patternStepSong=1; if (stepMode==0) { sequenceGroup->setExclusive(FALSE); dataDisplay->setText("qTribe"); //now we need to go through our steps and set them on or off depending on our underlying step model. QToolButton* myButton; step* myStep; stepPattern* myPattern=mySequencerThread->getCurrentPattern(); stepSequence* mySequence=myPattern->getActiveSequence(); for (int i=0;i< 16;i++) { myButton=(QToolButton*) sequenceGroup->find(i); //fprintf(stderr,"BUTTON: %s\n",myButton->className()); myStep=mySequence->getStep(i+(selectedMeasure*16)); if (myStep->isOn) { myButton->setOn(TRUE); pal.setColor( QPalette::Active, QColorGroup::Button, buttonOnColor); myButton ->setPalette( pal ); } else { myButton->setOn(FALSE); pal.setColor( QPalette::Active, QColorGroup::Button, buttonOffColor); myButton ->setPalette( pal ); } } } else if (stepMode==1 || stepMode==2 || stepMode==3 || stepMode==4) { sequenceGroup->setExclusive(TRUE); dataDisplay->setText("---"); step* myStep; stepPattern* myPattern=mySequencerThread->getCurrentPattern(); stepSequence* mySequence=myPattern->getActiveSequence(); for (int i=0;i< 16;i++) { QToolButton* myButton=(QToolButton*) sequenceGroup->find(i); myButton->setOn(FALSE); } if (selectedStep) { int step_array_index=selectedStep-1; sequenceGroup->setButton(step_array_index); myStep=mySequence->getStep(step_array_index+(selectedMeasure*16)); if (stepMode==1) { dataDisplay->setText(QString("%1").arg(noteNames[myStep->noteNumber])); } if (stepMode==2) { dataDisplay->setText(QString("%1").arg(myStep->noteLength)); } if (stepMode==3) { dataDisplay->setText(QString("%1").arg(myStep->noteVelocity)); } if (stepMode==4) { dataDisplay->setText(QString("%1").arg(myStep->noteTonality)); } } if (mySequence->drumSequence==1) { //drum part if (stepMode==1) { dataDisplay->setText(QString("%1").arg(noteNames[mySequence->drumNote])); } } } else { sequenceGroup->setExclusive(TRUE); } }
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent) { d_plot = new Plot(this); setCentralWidget(d_plot); QToolBar *toolBar = new QToolBar(this); QToolButton *btnSpectrogram = new QToolButton(toolBar); QToolButton *btnContour = new QToolButton(toolBar); QToolButton *btnPrint = new QToolButton(toolBar); #if QT_VERSION >= 0x040000 btnSpectrogram->setText("Spectrogram"); //btnSpectrogram->setIcon(QIcon()); btnSpectrogram->setCheckable(true); btnSpectrogram->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolBar->addWidget(btnSpectrogram); btnContour->setText("Contour"); //btnContour->setIcon(QIcon()); btnContour->setCheckable(true); btnContour->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolBar->addWidget(btnContour); btnPrint->setText("Print"); btnPrint->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); toolBar->addWidget(btnPrint); #else btnSpectrogram->setTextLabel("Spectrogram"); //btnSpectrogram->setPixmap(zoom_xpm); btnSpectrogram->setToggleButton(true); btnSpectrogram->setUsesTextLabel(true); btnContour->setTextLabel("Contour"); //btnContour->setPixmap(zoom_xpm); btnContour->setToggleButton(true); btnContour->setUsesTextLabel(true); btnPrint->setTextLabel("Print"); btnPrint->setUsesTextLabel(true); #endif addToolBar(toolBar); connect(btnSpectrogram, SIGNAL(toggled(bool)), d_plot, SLOT(showSpectrogram(bool))); connect(btnContour, SIGNAL(toggled(bool)), d_plot, SLOT(showContour(bool))); connect(btnPrint, SIGNAL(clicked()), d_plot, SLOT(printPlot()) ); #if QT_VERSION >= 0x040000 btnSpectrogram->setChecked(true); btnContour->setChecked(false); #else btnSpectrogram->setOn(true); btnContour->setOn(false); #endif }