void TestMpVolumeSlider::testVolumeSliderChanged() { mTest->mEngineMuted = false; mTest->mEngineVolumeLevel = 20; mTest->mEngineVolumeMax = 100; mTest->initializeVolumeSliderPopup(); connect( this, SIGNAL( triggerValueChanged( int ) ), mTest->mVolumeSliderPopup, SIGNAL( valueChanged( int ) ) ); mTest->mEngineVolumeLevel = 60; mTest->mEngineMuted = false; // Same values slider and engine emit triggerValueChanged( 6 ); QTest::qWait(25); QCOMPARE( mTest->mMpEngine->iMediaCommandReceived, CmdNone ); QCOMPARE( mTest->mMpEngine->iCommandValue, -1 ); // Slider value smaller than engine mTest->mMpEngine->iMediaCommandReceived = CmdNone; mTest->mMpEngine->iCommandValue = -1; emit triggerValueChanged( 0 ); QTest::qWait(25); QCOMPARE( mTest->mMpEngine->iMediaCommandReceived, CmdSetVolumeLevel ); QCOMPARE( mTest->mMpEngine->iCommandValue, 0 ); // Slider value bigger than engine mTest->mMpEngine->iMediaCommandReceived = CmdNone; mTest->mMpEngine->iCommandValue = -1; emit triggerValueChanged( 7 ); QTest::qWait(25); QCOMPARE( mTest->mMpEngine->iMediaCommandReceived, CmdSetVolumeLevel ); QCOMPARE( mTest->mMpEngine->iCommandValue, 70 ); mTest->mEngineMuted = true; // Slider changes to 0 while engine in mute state. mTest->mMpEngine->iMediaCommandReceived = CmdNone; mTest->mMpEngine->iCommandValue = -1; emit triggerValueChanged( 0 ); QTest::qWait(25); QCOMPARE( mTest->mMpEngine->iMediaCommandReceived, CmdNone ); QCOMPARE( mTest->mMpEngine->iCommandValue, -1 ); // Slider changes other than 0 while engine in mute state. mTest->mMpEngine->iMediaCommandReceived = CmdNone; mTest->mMpEngine->iCommandValue = -1; emit triggerValueChanged( 8 ); QTest::qWait(25); QCOMPARE( mTest->mMpEngine->iMediaCommandReceived, CmdSetVolumeLevel ); QCOMPARE( mTest->mMpEngine->iCommandValue, 80 ); }
// ------------------------------------------------------------------------------------------------- ParameterBox::ParameterBox(QWidget* parent, const char* name) throw () : QFrame(parent, name), m_leftValue(-1.0), m_rightValue(-1.0) { QGridLayout* layout = new QGridLayout(this, 5 /* row */, 9 /* col */, 0 /* margin */, 5); // - create ------------------------------------------------------------------------------------ // settings Settings& set = Settings::set(); // widgets QLabel* timeLabel = new QLabel(tr("&Measuring Time:"), this); QLabel* sampleLabel = new QLabel(tr("&Sampling Rate:"), this); QLabel* triggerLabel = new QLabel(tr("&Triggering:"), this); QTimeEdit* timeedit = new QTimeEdit(this); timeedit->setRange(QTime(0, 0), QTime(0, 1)); QSlider* sampleSlider = new QSlider(0, MAX_SLIDER_VALUE, 1, 0, Qt::Horizontal, this); TriggerWidget* triggering = new TriggerWidget(this); // labels for the markers QLabel* leftMarkerLabel = new QLabel(tr("Left Button Marker:"), this); QLabel* rightMarkerLabel = new QLabel(tr("Right Button Marker:"), this); QLabel* diffLabel = new QLabel(tr("Difference:"), this); m_leftMarker = new QLabel(this); m_rightMarker = new QLabel(this); m_diff = new QLabel("zdddd", this); // set the font for the labels QFont font = qApp->font(this); font.setPixelSize(15); font.setBold(true); m_leftMarker->setFont(font); m_rightMarker->setFont(font); m_diff->setFont(font); // buddys timeLabel->setBuddy(timeedit); triggerLabel->setBuddy(triggering); sampleLabel->setBuddy(sampleSlider); // load value triggering->setValue(set.readNumEntry("Measuring/Triggering/Value"), set.readNumEntry("Measuring/Triggering/Mask")); timeedit->setTime(QTime(0, set.readNumEntry("Measuring/Triggering/Minutes"), set.readNumEntry("Measuring/Triggering/Seconds"))); sampleSlider->setValue(MAX_SLIDER_VALUE - set.readNumEntry("Measuring/Number_Of_Skips")); // - layout the stuff -------------------------------------------------------------------------- // row, col layout->addWidget(timeLabel, 0, 1); layout->addWidget(sampleLabel, 1, 1); layout->addWidget(triggerLabel, 2, 1, Qt::AlignTop); layout->addWidget(timeedit, 0, 3); layout->addWidget(sampleSlider, 1, 3); layout->addMultiCellWidget(triggering, 2, 3, 3, 3); layout->addWidget(leftMarkerLabel, 0, 5); layout->addWidget(rightMarkerLabel, 1, 5); layout->addWidget(diffLabel, 2, 5); layout->addWidget(m_leftMarker, 0, 7, Qt::AlignRight); layout->addWidget(m_rightMarker, 1, 7, Qt::AlignRight); layout->addWidget(m_diff, 2, 7, Qt::AlignRight); layout->setColStretch(0, 2); layout->setColSpacing(2, 20); layout->setColStretch(4, 4); layout->setColSpacing(6, 20); layout->setColSpacing(7, 150); layout->setColStretch(8, 2); connect(timeedit, SIGNAL(valueChanged(const QTime&)), this, SLOT(timeValueChanged(const QTime&))); connect(triggering, SIGNAL(valueChanged(byte, byte)), this, SLOT(triggerValueChanged(byte, byte))); connect(sampleSlider, SIGNAL(valueChanged(int)), this, SLOT(sliderValueChanged(int))); // - initial values ---------------------------------------------------------------------------- updateValues(); }