Пример #1
0
void Player::handleEvent()
{
	if ((MainWind::trackStatus->value(e->track(), true) == false) && e->isNoteEvent()) {
		return;
	}

	if (e->type() == QMidiEvent::SysEx) {
		// TODO: sysex
	} else {
		qint32 message = e->message();
		MainWind::midiOut->sendMsg(message);
	}

	// Update the piano, pianoroll, and slider
	if (e->type() == QMidiEvent::NoteOn) {
		emit addTrackColor(e->note(), e->track());
		emit tickChanged(e->tick());
	} else if (e->type() == QMidiEvent::NoteOff) {
		emit removeTrackColor(e->note(), e->track());
	} else if (e->type() == QMidiEvent::ControlChange) {
		emit clearTrackColors(e->track());
	}
}
Пример #2
0
void MainWindow::initializeQMLComponent()
{
    QDeclarativeContext *context = m_view->rootContext();

#if defined(Q_WS_MAEMO_5) || defined(QT_NO_OPENGL)
    // Set UI to low performance mode for Maemo5 and Symbian^1. This mainly
    // disables antialiasing on some performance costly elements.
    context->setContextProperty("lowPerf", true);
#else
    context->setContextProperty("lowPerf", false);
#endif

#ifdef Q_OS_SYMBIAN
    context->setContextProperty("sampleFolder", "file:");
#else
    context->setContextProperty("sampleFolder", QString("file:/") +
                                QDir::currentPath());
#endif

#ifdef Q_WS_MAEMO_6
    // Hide the exit button in Harmattan
    context->setContextProperty("exitButtonVisible", false);
#else
    context->setContextProperty("exitButtonVisible", true);
#endif

    m_view->setSource(QUrl("qrc:/qml/Main.qml"));

    // Create Qt settings object to load / store app settings
    m_settings = new QSettings("Nokia", "DJTurntable");

    // Create Qt objects to handle Turntable and Drum machine
    m_turntable = new Turntable(m_settings, this);
    m_drumMachine = new DrumMachine(m_settings, this);
    m_turntable->addAudioSource(m_drumMachine);

    // Find out the interesting Qt objects of the QML elements
    QObject *turntableQML = dynamic_cast<QObject*>(m_view->rootObject());
    QObject *sampleSelectorQML =
            m_view->rootObject()->findChild<QObject*>("sampleSelector");
    QObject *drumMachineQML =
            m_view->rootObject()->findChild<QObject*>("drumMachine");

    // If there are errors in QML code and the elements does not exist,
    // they won't be found Qt side either, check existance of the elements.
    if (!turntableQML || !sampleSelectorQML || !drumMachineQML) {
        QMessageBox::warning(NULL, "Warning",
                             "Failed to resolve QML elements in main.cpp");
        return;
    }

    // Turntable connections
    connect(turntableQML, SIGNAL(start()),
            m_turntable, SLOT(start()));
    connect(turntableQML, SIGNAL(stop()),
            m_turntable, SLOT(stop()));
    connect(turntableQML, SIGNAL(diskAimSpeed(QVariant)),
            m_turntable, SLOT(setDiscAimSpeed(QVariant)));
    connect(turntableQML, SIGNAL(diskSpeed(QVariant)),
            m_turntable, SLOT(setDiscSpeed(QVariant)));
    connect(turntableQML, SIGNAL(cutOff(QVariant)),
            m_turntable, SLOT(setCutOff(QVariant)));
    connect(turntableQML, SIGNAL(resonance(QVariant)),
            m_turntable, SLOT(setResonance(QVariant)));
    connect(turntableQML, SIGNAL(seekToPosition(QVariant)),
            m_turntable, SLOT(seekToPosition(QVariant)));
    connect(m_turntable, SIGNAL(audioPosition(QVariant)),
            turntableQML, SLOT(audioPosition(QVariant)));
    connect(m_turntable, SIGNAL(powerOff()),
            turntableQML, SLOT(powerOff()));

    // SampleSelector connections
    connect(sampleSelectorQML, SIGNAL(sampleSelected(QVariant)),
            m_turntable, SLOT(setSample(QVariant)));
    connect(sampleSelectorQML, SIGNAL(defaultSample()),
            m_turntable, SLOT(openDefaultSample()));
    connect(m_turntable, SIGNAL(sampleOpened(QVariant)),
            sampleSelectorQML, SLOT(setCurrentSample(QVariant)));
    connect(m_turntable, SIGNAL(error(QVariant, QVariant)),
            sampleSelectorQML, SLOT(showError(QVariant, QVariant)));

    // DrumMachine connections
    connect(drumMachineQML, SIGNAL(startBeat()),
            m_drumMachine, SLOT(startBeat()));
    connect(drumMachineQML, SIGNAL(stopBeat()),
            m_drumMachine, SLOT(stopBeat()));
    connect(drumMachineQML, SIGNAL(setBeat(QVariant)),
            m_drumMachine, SLOT(setBeat(QVariant)));
    connect(drumMachineQML,
            SIGNAL(drumButtonToggled(QVariant, QVariant, QVariant)),
            m_drumMachine,
            SLOT(drumButtonToggled(QVariant, QVariant, QVariant)));
    connect(drumMachineQML, SIGNAL(drumMachineSpeed(QVariant)),
            m_drumMachine, SLOT(setBeatSpeed(QVariant)));
    connect(m_drumMachine,
            SIGNAL(drumButtonState(QVariant, QVariant, QVariant)),
            drumMachineQML,
            SLOT(setDrumButton(QVariant, QVariant, QVariant)));
    connect(m_drumMachine, SIGNAL(tickChanged(QVariant)),
            drumMachineQML, SLOT(highlightTick(QVariant)));

    // Framework connections
    connect((QObject*)m_view->engine(), SIGNAL(quit()), qApp, SLOT(quit()));

#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
#ifndef QT_NO_OPENGL
    // Create Qt accelerometer objects
    m_accelerometer = new QAccelerometer(this);
    m_accelerometerFilter = new AccelerometerFilter;
    // Does not take the ownership of the filter
    m_accelerometer->addFilter(m_accelerometerFilter);

    m_accelerometer->setDataRate(50);

    // Create Qt objects for accessing profile information
    m_deviceInfo = new QSystemDeviceInfo(this);
    m_turntable->profile(m_deviceInfo->currentProfile());

    connect(m_accelerometerFilter, SIGNAL(rotationChanged(QVariant)),
            turntableQML, SLOT(inclination(QVariant)));
    connect(m_deviceInfo,
            SIGNAL(currentProfileChanged(QSystemDeviceInfo::Profile)),
            m_turntable,
            SLOT(profile(QSystemDeviceInfo::Profile)));

    // Begin the measuring of the accelerometer sensor
    m_accelerometer->start();
#endif
#endif

    m_turntable->openLastSample();
    m_drumMachine->setBeat(0);
}
Пример #3
0
PlotControlWidget::PlotControlWidget(QWidget *parent) :
    ControlWidget(parent),
    ui(new Ui::PlotControlWidget)
{
    ui->setupUi(this);

    ui->gridLayout->setSpacing(0);
    ui->gridLayout->setMargin(0);
    ui->verticalLayout->setSpacing(0);
    ui->verticalLayout->setMargin(0);
    ui->verticalLayout_3->setSpacing(0);
    ui->verticalLayout_3->setMargin(0);
    ui->verticalLayout_4->setSpacing(0);
    ui->verticalLayout_4->setMargin(0);
    ui->verticalLayout_5->setSpacing(0);
    ui->verticalLayout_5->setMargin(0);
    ui->verticalLayout_6->setSpacing(0);
    ui->verticalLayout_6->setMargin(0);
    ui->verticalLayout_8->setSpacing(0);
    ui->verticalLayout_8->setMargin(0);


    layout()->setSpacing(0);
    layout()->setMargin(0);



    mFastenToolButtonVector << ui->fastenToolButton_0;
    mFastenToolButtonVector << ui->fastenToolButton_1;
    mFastenToolButtonVector << ui->fastenToolButton_2;
    mFastenToolButtonVector << ui->fastenToolButton_3;
    mFastenToolButtonVector << ui->fastenToolButton_4;
    mFastenToolButtonVector << ui->fastenToolButton_5;
    mFastenToolButtonVector << ui->fastenToolButton_6;
    mFastenToolButtonVector << ui->fastenToolButton_7;
    mFastenToolButtonVector << ui->fastenToolButton_8;
    mFastenToolButtonVector << ui->fastenToolButton_9;
    mFastenToolButtonVector << ui->fastenToolButton_10;
    mFastenToolButtonVector << ui->fastenToolButton_11;
    mFastenToolButtonVector << ui->fastenToolButton_12;
    for (int i = 0; i < mFastenToolButtonVector.size(); ++i) {
        mFastenToolButtonVector[i]->setChecked(sTabVisibilityVector[i]);
        connect(mFastenToolButtonVector[i], SIGNAL(toggled(bool)),
                this, SLOT(treatFastenToolButtonPressed()));
    }
    mTabsVector << ui->tab_0;
    mTabsVector << ui->tab_1;
    mTabsVector << ui->tab_2;
    mTabsVector << ui->tab_3;
    mTabsVector << ui->tab_4;
    mTabsVector << ui->tab_5;
    mTabsVector << ui->tab_6;
    mTabsVector << ui->tab_7;
    mTabsVector << ui->tab_8;
    mTabsVector << ui->tab_9;
    mTabsVector << ui->tab_10;
    mTabsVector << ui->tab_11;
    mTabsVector << ui->tab_12;

    for (auto tab : mTabsVector) {
        tab->layout()->setSpacing(0);
        tab->layout()->setMargin(0);
    }


    ui->xGridWidget->setHead("X grid");
    ui->yGridWidget->setHead("Y grid");
    ui->xSubGridWidget->setHead("X sub grid");
    ui->ySubGridWidget->setHead("Y sub grid");

    ui->scaleTypeComboBox->addItem("Linear", PlotLayoutModel::ScaleType::Linear);
    ui->scaleTypeComboBox->addItem("Logarithmic", PlotLayoutModel::ScaleType::Logarithmic);

    ui->timeFormatComboBox->addItem("Number", QCPAxis::ltNumber);
    ui->timeFormatComboBox->addItem("DateTime", QCPAxis::ltDateTime);

    ui->subTickEditingWidget->setSubTickCountVisibility(false);

    connect(ui->xLowMarginLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXLowLimitRequest()));
    connect(ui->xHighMarginLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXHighLimitRequest()));
    connect(ui->xLabelLineEdit, SIGNAL(editingFinished()),
            this, SLOT(treatXLabelChanging()));
    connect(ui->titleEditingWidget, SIGNAL(titleChanged()),
            this, SLOT(treatTitleChanging()));
    connect(ui->titleEditingWidget, SIGNAL(titlePropertiesChanged()),
            this, SLOT(treatTitlePropertiesChanging()));

    connect(ui->scaleTypeComboBox, SIGNAL(valueActivated(boost::any)),
            this, SLOT(treatScaleTypeChanging()));
    connect(ui->timeFormatComboBox, SIGNAL(valueActivated(boost::any)),
            this, SLOT(treatTimeAxisTypeChanging()));
    connect(ui->xTickRotationDoubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(treatXTickRotationChanging()));
    connect(ui->eventLabelRotationDoubleSpinBox, SIGNAL(valueChanged(double)),
            this, SLOT(treatCommandLabelRotationChanging()));

    connect(ui->legendLayoutComboBox, SIGNAL(currentLegendLocationChanged(style::LegendLocation)),
            this, SLOT(treatLegendLayoutChanging()));

    connect(ui->legendFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatLegendFontSizeChanging()));
    connect(ui->yLabelFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatUnitsFontSizeChanging()));
    connect(ui->xLabelFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatXLabelFontSizeChanging()));
    connect(ui->xAxisFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatXAxisFontSizeChanging()));
    connect(ui->yAxisFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatYAxisFontSizeChanging()));
//    connect(ui->titleFontSizeSpinBox, SIGNAL(valueChanged(int)),
//            this, SLOT(treatTitleFontSizeChanging()));
    connect(ui->eventFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatEventFontSizeChanging()));
    connect(ui->arrowedTextFontSizeSpinBox, SIGNAL(valueChanged(int)),
            this, SLOT(treatArrowedTextFontSizeChanging()));

    connect(ui->legendFrameVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatLegendFrameVisibilityChanging()));
    connect(ui->legendVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatLegendVisibilityChanging()));
    connect(ui->unitsVisibilityCheckBox, SIGNAL(toggled ( bool )),
            this, SLOT(treatUnitsVisibilityChanging()));

    connect(ui->defaultPushButton, SIGNAL(clicked(bool)),
            this, SLOT(initiliazeLayoutPreferencesFromDefault()));


    connect(ui->xGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatXGridChanging()));
    connect(ui->yGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatYGridChanging()));
    connect(ui->xSubGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatXSubGridChanging()));
    connect(ui->ySubGridWidget, SIGNAL(gridChanged(style::Grid)),
            this, SLOT(treatYSubGridChanging()));
    connect(ui->axisRectEditingWidget, SIGNAL(axisRectPropertiesChanged()),
            this, SLOT(treatAxisRectChanging()));
    connect(ui->tickEditingWidget, SIGNAL(tickChanged()),
            this, SLOT(treatTickChanging()));
    connect(ui->subTickEditingWidget, SIGNAL(tickChanged()),
            this, SLOT(treatSubTickChanging()));
    connect(ui->colorSetEdititngWidget, SIGNAL(colorPrefChangedByUser()),
            this, SLOT(treatColorPrefChanging()));

    connect(ui->xAxisPrefWidget, SIGNAL(axisPrefChanged()),
            this, SLOT(treatXAxisPrefChanging()));
    connect(ui->yAxisPrefWidget, SIGNAL(axisPrefChanged()),
            this, SLOT(treatYAxisPrefChanging()));

    //NOTE: To avoid signal valueChanged emitting on each keyboard button pressing. ValueChanged signal will be emitted
    //only after Return is pressed or if widget loses focus.
    ui->xTickRotationDoubleSpinBox->setKeyboardTracking(false);
    ui->eventLabelRotationDoubleSpinBox->setKeyboardTracking(false);
    ui->legendFontSizeSpinBox->setKeyboardTracking(false);
    ui->yLabelFontSizeSpinBox->setKeyboardTracking(false);
    ui->xLabelFontSizeSpinBox->setKeyboardTracking(false);
    ui->xAxisFontSizeSpinBox->setKeyboardTracking(false);
//    ui->titleFontSizeSpinBox->setKeyboardTracking(false);
    ui->eventFontSizeSpinBox->setKeyboardTracking(false);
    ui->arrowedTextFontSizeSpinBox->setKeyboardTracking(false);

    QDoubleValidator *doubleValidator = new QDoubleValidator(this);
    ui->xLowMarginLineEdit->setValidator(doubleValidator);
    ui->xHighMarginLineEdit->setValidator(doubleValidator);

}