XYPenPlotterController::XYPenPlotterController(QObject *parent) : QObject(parent) { setCurrentState("STOPPED"); timer = new QTimer(this); timer->setInterval(100); connect(timer, SIGNAL(timeout()), this, SLOT(setStoppedState())); }
void TvrUiWidget::on_actionSaveAs_triggered(){ if(getRecordingState() || getRecordingPausedState() || getPlayingState() || getPlayingPausedState()){ stopMedia(); } if(isLRAvailable()){ checkFileAndSave(); } showSaveMessageDlg(); setStoppedState(false); setButtonStatus(true, false, false, false, false, true); }
void TvrUiWidget::showSaveFileDlg(){ int ret = QMessageBox::question (this, "Save Recording", "Do you want to save last recording", QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save); if (ret == QMessageBox::Save){ saveMedia(); showSaveMessageDlg(); } else { setButtonStatus(true, false, false, false, true, true); } setStoppedState(false); }
void LabelsApplet::init() { DEBUG_BLOCK // Call the base implementation. Context::Applet::init(); setBackgroundHints( Plasma::Applet::NoBackground ); // properly set the size, asking for the whole cv size. resize( 500, -1 ); // this applet has to be on top of the applet below, otherwise the completion list of the combobox will shine through the other applet setZValue( zValue() + 100 ); // Create the title label enableHeader( true ); setHeaderText( i18n( "Labels" ) ); setCollapseHeight( m_header->height() ); setMinimumHeight( collapseHeight() ); // reload icon QAction *reloadAction = new QAction( this ); reloadAction->setIcon( KIcon( "view-refresh" ) ); reloadAction->setVisible( true ); reloadAction->setEnabled( true ); reloadAction->setText( i18n( "Reload" ) ); m_reloadIcon = addLeftHeaderAction( reloadAction ); m_reloadIcon.data()->setEnabled( false ); connect( m_reloadIcon.data(), SIGNAL( clicked() ), this, SLOT( reload() ) ); // settings icon QAction *settingsAction = new QAction( this ); settingsAction->setIcon( KIcon( "preferences-system" ) ); settingsAction->setVisible( true ); settingsAction->setEnabled( true ); settingsAction->setText( i18n( "Settings" ) ); m_settingsIcon = addRightHeaderAction( settingsAction ); connect( m_settingsIcon.data(), SIGNAL( clicked() ), this, SLOT( showConfigurationInterface() ) ); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this ); layout->addItem( m_header ); m_addLabelProxy = new QGraphicsProxyWidget( this ); m_addLabelProxy.data()->setAttribute( Qt::WA_NoSystemBackground ); m_addLabel = new KComboBox( this ); m_addLabel.data()->setAttribute( Qt::WA_NoSystemBackground ); m_addLabel.data()->setAutoFillBackground( false ); QPalette p = m_addLabel.data()->palette(); QColor c = p.color( QPalette::Base ); c.setAlphaF( 0.4 ); p.setColor( QPalette::Base, c ); m_addLabel.data()->setPalette( p ); m_addLabel.data()->completionObject()->setIgnoreCase( true ); m_addLabel.data()->setCompletionMode( KGlobalSettings::CompletionPopup ); connect( m_addLabel.data(), SIGNAL( returnPressed() ), this, SLOT( addLabelPressed() ) ); m_addLabelProxy.data()->setWidget( m_addLabel.data() ); // Read config KConfigGroup config = Amarok::config("Labels Applet"); m_minCount = config.readEntry( "MinCount", 30 ); m_numLabels = config.readEntry( "NumLabels", 10 ); m_personalCount = config.readEntry( "PersonalCount", 70 ); m_autoAdd = config.readEntry( "AutoAdd", false ); m_minAutoAddCount = config.readEntry( "MinAutoAddCount", 60 ); m_selectedColor = config.readEntry( "SelectedColor", PaletteHandler::highlightColor( 2.0, 0.7 ) ); const QPalette pal; m_backgroundColor = config.readEntry( "BackgroundColor", pal.color( QPalette::Base ) ); m_matchArtist = config.readEntry( "MatchArtist", true ); m_matchTitle = config.readEntry( "MatchTitle", true ); m_matchAlbum = config.readEntry( "MatchAlbum", true ); m_blacklist = config.readEntry( "Blacklist", QStringList() ); const QStringList replacementList = config.readEntry( "ReplacementList", QStringList() ); foreach( const QString replacement, replacementList ) { const QStringList parts = replacement.split( "|" ); QString label = parts.at(0); label = label.replace( "%s", "|" ); label = label.replace( "%p", "%" ); QString replacementValue = parts.at(1); replacementValue = replacementValue.replace( "%s", "|" ); replacementValue = replacementValue.replace( "%p", "%" ); m_replacementMap.insert( label, replacementValue ); } m_stoppedstate = false; // force an update setStoppedState( true ); connectSource( "labels" ); connect( dataEngine( "amarok-labels" ), SIGNAL( sourceAdded( const QString & ) ), this, SLOT( connectSource( const QString & ) ) ); }
SettingsWidget::SettingsWidget(MandelbrotWidget *mandelbrot, QWidget *parent) : QDockWidget(parent), m_mandelbrot(mandelbrot), m_started(false) { setWindowTitle(tr("Settings")); m_renderTimer = new QTime; QVBoxLayout *layout = new QVBoxLayout; QWidget *widget = new QWidget(this); widget->setLayout(layout); setWidget(widget); QGroupBox *areaGroupBox = new QGroupBox(tr("Area")); QGroupBox *outputGroupBox = new QGroupBox(tr("Output settings")); QGroupBox *threadsGroupBox = new QGroupBox(tr("Threads")); QGroupBox *iterationsGroupBox = new QGroupBox(tr("Iterations")); layout->addWidget(areaGroupBox); layout->addWidget(outputGroupBox); layout->addWidget(threadsGroupBox); layout->addWidget(iterationsGroupBox); m_leftSpinBox = new QDoubleSpinBox; m_leftSpinBox->setDecimals(SpinBoxDecimals); m_leftSpinBox->setRange(-10, 10); m_leftSpinBox->setValue(m_defaultLeft); m_topSpinBox = new QDoubleSpinBox; m_topSpinBox->setDecimals(SpinBoxDecimals); m_topSpinBox->setRange(-10, 10); m_topSpinBox->setValue(m_defaultTop); m_widthSpinBox = new QDoubleSpinBox; m_widthSpinBox->setDecimals(SpinBoxDecimals); m_widthSpinBox->setRange(0.00000001, 10); m_widthSpinBox->setValue(m_defaultWidth); m_heightSpinBox = new QDoubleSpinBox; m_heightSpinBox->setDecimals(SpinBoxDecimals); m_heightSpinBox->setRange(0.00000001, 10); m_heightSpinBox->setValue(m_defaultHeight); QFormLayout *areaLayout = new QFormLayout; areaGroupBox->setLayout(areaLayout); areaLayout->addRow(tr("&Left"), m_leftSpinBox); areaLayout->addRow(tr("&Top"), m_topSpinBox); areaLayout->addRow(tr("&Width"), m_widthSpinBox); areaLayout->addRow(tr("&Height"), m_heightSpinBox); m_renderWidthSpinBox = new QSpinBox; m_renderWidthSpinBox->setRange(1, 8192); m_renderWidthSpinBox->setValue(m_defaultRenderWidth); m_renderHeightSpinBox = new QSpinBox; m_renderHeightSpinBox->setRange(1, 8192); m_renderHeightSpinBox->setValue(m_defaultRenderHeight); QFormLayout *outputLayout = new QFormLayout; outputGroupBox->setLayout(outputLayout); outputLayout->addRow(tr("W&idth"), m_renderWidthSpinBox); outputLayout->addRow(tr("H&eight"), m_renderHeightSpinBox); m_threadSpinBox = new QSpinBox; m_threadSpinBox->setRange(1, 255); m_threadSpinBox->setValue(m_defaultThreadCount); m_segmentWidthSpinBox = new QSpinBox; m_segmentWidthSpinBox->setRange(1, 8192); m_segmentWidthSpinBox->setValue(m_defaultSegmentWidth); m_segmentHeightSpinBox = new QSpinBox; m_segmentHeightSpinBox->setRange(1, 8192); m_segmentHeightSpinBox->setValue(m_defaultSegmentHeight); QFormLayout *threadsLayout = new QFormLayout; threadsGroupBox->setLayout(threadsLayout); threadsLayout->addRow(tr("&Number of threads"), m_threadSpinBox); threadsLayout->addRow(tr("&Segment width"), m_segmentWidthSpinBox); threadsLayout->addRow(tr("Se&gment height"), m_segmentHeightSpinBox); m_iterationsSpinBox = new QSpinBox; m_iterationsSpinBox->setRange(1, 8192); m_iterationsSpinBox->setValue(1000); QFormLayout *iterationsLayout = new QFormLayout; iterationsGroupBox->setLayout(iterationsLayout); iterationsLayout->addRow(tr("&Max iterations"), m_iterationsSpinBox); m_useGmp = new QPushButton(tr("&Use GMP")); m_useGmp->setCheckable(true); m_useGmp->setChecked(true); layout->addWidget(m_useGmp); layout->addStretch(); m_timeLabel = new QLabel; m_timeLabel->setFrameShape(QFrame::StyledPanel); m_timeLabel->setFrameShadow(QFrame::Plain); layout->addWidget(m_timeLabel); QHBoxLayout *btnLayout = new QHBoxLayout(); layout->addLayout(btnLayout); m_startBtn = new QPushButton(tr("Start")); m_stopBtn = new QPushButton(tr("Stop")); btnLayout->addWidget(m_startBtn); btnLayout->addWidget(m_stopBtn); connect(m_startBtn, SIGNAL(clicked()), SLOT(start())); connect(m_stopBtn, SIGNAL(clicked()), SLOT(stop())); connect(m_mandelbrot, SIGNAL(renderingStarted()), SLOT(setRunningState())); connect(m_mandelbrot, SIGNAL(renderingStopped()), SLOT(setStoppedState())); setState(Finished); }
void AudioPlayerLoaders::loadData(AudioMsgId audio, qint64 position) { SetupError err = SetupNoErrorStarted; auto type = audio.type(); AudioPlayerLoader *l = setupLoader(audio, err, position); if (!l) { if (err == SetupErrorAtStart) { emitError(type); } return; } bool started = (err == SetupNoErrorStarted); bool finished = false; bool waiting = false; bool errAtStart = started; QByteArray samples; int64 samplesCount = 0; if (l->holdsSavedDecodedSamples()) { l->takeSavedDecodedSamples(&samples, &samplesCount); } while (samples.size() < AudioVoiceMsgBufferSize) { auto res = l->readMore(samples, samplesCount); using Result = AudioPlayerLoader::ReadResult; if (res == Result::Error) { if (errAtStart) { { QMutexLocker lock(internal::audioPlayerMutex()); AudioPlayer::AudioMsg *m = checkLoader(type); if (m) m->playbackState.state = AudioPlayerStoppedAtStart; } emitError(type); return; } finished = true; break; } else if (res == Result::EndOfFile) { finished = true; break; } else if (res == Result::Ok) { errAtStart = false; } else if (res == Result::Wait) { waiting = (samples.size() < AudioVoiceMsgBufferSize); if (waiting) { l->saveDecodedSamples(&samples, &samplesCount); } break; } QMutexLocker lock(internal::audioPlayerMutex()); if (!checkLoader(type)) { clear(type); return; } } QMutexLocker lock(internal::audioPlayerMutex()); AudioPlayer::AudioMsg *m = checkLoader(type); if (!m) { clear(type); return; } if (started) { if (m->source) { alSourceStop(m->source); for (int32 i = 0; i < 3; ++i) { if (m->samplesCount[i]) { ALuint buffer = 0; alSourceUnqueueBuffers(m->source, 1, &buffer); m->samplesCount[i] = 0; } } m->nextBuffer = 0; } m->skipStart = position; m->skipEnd = m->playbackState.duration - position; m->playbackState.position = position; m->started = 0; } if (samplesCount) { if (!m->source) { alGenSources(1, &m->source); alSourcef(m->source, AL_PITCH, 1.f); alSource3f(m->source, AL_POSITION, 0, 0, 0); alSource3f(m->source, AL_VELOCITY, 0, 0, 0); alSourcei(m->source, AL_LOOPING, 0); } if (!m->buffers[m->nextBuffer]) { alGenBuffers(3, m->buffers); } // If this buffer is queued, try to unqueue some buffer. if (m->samplesCount[m->nextBuffer]) { ALint processed = 0; alGetSourcei(m->source, AL_BUFFERS_PROCESSED, &processed); if (processed < 1) { // No processed buffers, wait. l->saveDecodedSamples(&samples, &samplesCount); return; } // Unqueue some processed buffer. ALuint buffer = 0; alSourceUnqueueBuffers(m->source, 1, &buffer); if (!internal::audioCheckError()) { setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); return; } // Find it in the list and make it the nextBuffer. bool found = false; for (int i = 0; i < 3; ++i) { if (m->buffers[i] == buffer) { found = true; m->nextBuffer = i; break; } } if (!found) { LOG(("Audio Error: Could not find the unqueued buffer! Buffer %1 in source %2 with processed count %3").arg(buffer).arg(m->source).arg(processed)); setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); return; } if (m->samplesCount[m->nextBuffer]) { m->skipStart += m->samplesCount[m->nextBuffer]; m->samplesCount[m->nextBuffer] = 0; } } auto frequency = l->frequency(); auto format = l->format(); m->samplesCount[m->nextBuffer] = samplesCount; alBufferData(m->buffers[m->nextBuffer], format, samples.constData(), samples.size(), frequency); alSourceQueueBuffers(m->source, 1, m->buffers + m->nextBuffer); m->skipEnd -= samplesCount; m->nextBuffer = (m->nextBuffer + 1) % 3; if (!internal::audioCheckError()) { setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); return; } } else { if (waiting) { return; } finished = true; } if (finished) { m->skipEnd = 0; m->playbackState.duration = m->skipStart + m->samplesCount[0] + m->samplesCount[1] + m->samplesCount[2]; clear(type); } m->loading = false; if (m->playbackState.state == AudioPlayerResuming || m->playbackState.state == AudioPlayerPlaying || m->playbackState.state == AudioPlayerStarting) { ALint state = AL_INITIAL; alGetSourcei(m->source, AL_SOURCE_STATE, &state); if (internal::audioCheckError()) { if (state != AL_PLAYING) { audioPlayer()->resumeDevice(); switch (type) { case AudioMsgId::Type::Voice: alSourcef(m->source, AL_GAIN, internal::audioSuppressGain()); break; case AudioMsgId::Type::Song: alSourcef(m->source, AL_GAIN, internal::audioSuppressSongGain() * Global::SongVolume()); break; case AudioMsgId::Type::Video: alSourcef(m->source, AL_GAIN, internal::audioSuppressSongGain() * Global::VideoVolume()); break; } if (!internal::audioCheckError()) { setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); return; } alSourcePlay(m->source); if (!internal::audioCheckError()) { setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); return; } emit needToCheck(); } } else { setStoppedState(m, AudioPlayerStoppedAtError); emitError(type); } } }