コード例 #1
0
ファイル: bookmarkmanager.cpp プロジェクト: AlekSi/psi
void BookmarkManager::setIsAvailable(bool available)
{
	if (available != isAvailable_) {
		isAvailable_ = available;
		emit availabilityChanged();
	}
}
コード例 #2
0
void NetworkManager::connectToConnman(QString)
{
    disconnectFromConnman();
    m_manager = new Manager("net.connman", "/",
            QDBusConnection::systemBus(), this);

    if (!m_manager->isValid()) {

        pr_dbg() << "D-Bus net.connman.Manager object is invalid. Connman may not be running or is invalid.";

        delete m_manager;
        m_manager = NULL;

        // shouldn't happen but in this case service isn't available
        if(m_available)
            emit availabilityChanged(m_available = false);
    } else {
        QDBusPendingReply<QVariantMap> props_reply = m_manager->GetProperties();
        m_getPropertiesWatcher = new QDBusPendingCallWatcher(props_reply, m_manager);
        connect(m_getPropertiesWatcher,
                SIGNAL(finished(QDBusPendingCallWatcher*)),
                this,
                SLOT(getPropertiesReply(QDBusPendingCallWatcher*)));

        QDBusPendingReply<ConnmanObjectList> techs_reply = m_manager->GetTechnologies();
        m_getTechnologiesWatcher = new QDBusPendingCallWatcher(techs_reply, m_manager);
        connect(m_getTechnologiesWatcher,
                SIGNAL(finished(QDBusPendingCallWatcher*)),
                this,
                SLOT(getTechnologiesReply(QDBusPendingCallWatcher*)));

        QDBusPendingReply<ConnmanObjectList> services_reply = m_manager->GetServices();
        m_getServicesWatcher = new QDBusPendingCallWatcher(services_reply, m_manager);
        connect(m_getServicesWatcher,
                SIGNAL(finished(QDBusPendingCallWatcher*)),
                this,
                SLOT(getServicesReply(QDBusPendingCallWatcher*)));

        if(!m_available)
            emit availabilityChanged(m_available = true);

        pr_dbg() << "Connected";
    }
}
コード例 #3
0
void TechnologyModel::updateTechnologies()
{
    bool wasAvailable = m_manager->isAvailable() && m_tech;

    doUpdateTechnologies();

    bool isAvailable = m_manager->isAvailable() && m_tech;

    if (wasAvailable != isAvailable)
        Q_EMIT availabilityChanged(isAvailable);
}
コード例 #4
0
void ResourcePolicyInt::handleResourcesBecameAvailable(const QList<ResourcePolicy::ResourceType> &resources)
{
    bool available = false;

    for (int i = 0; i < resources.size(); ++i) {
        if (resources.at(i) == ResourcePolicy::AudioPlaybackType)
            available = true;
    }

    availabilityChanged(available);
}
コード例 #5
0
void NetworkManager::connectToConnman(QString)
{
    disconnectFromConnman();
    m_manager = new NetConnmanManagerInterface("net.connman", "/",
            QDBusConnection::systemBus(), this);

    if (!m_manager->isValid()) {

        delete m_manager;
        m_manager = NULL;

        // shouldn't happen but in this case service isn't available
        if(m_available)
            emit availabilityChanged(m_available = false);
    } else {

        QDBusPendingReply<QVariantMap> props_reply = m_manager->GetProperties();
        props_reply.waitForFinished();
        if (!props_reply.isError()) {
            m_propertiesCache = props_reply.value();

            emit stateChanged(m_propertiesCache[State].toString());

            connect(m_manager,
                    SIGNAL(PropertyChanged(const QString&, const QDBusVariant&)),
                    this,
                    SLOT(propertyChanged(const QString&, const QDBusVariant&)));
        }
        setupTechnologies();
        setupServices();

        if(!m_available)
            emit availabilityChanged(m_available = true);

        pr_dbg() << "Connected";
    }
コード例 #6
0
ファイル: griloquery.cpp プロジェクト: VDVsx/qtgrilo
void GriloQuery::availableSourcesChanged() {
  bool available = isAvailable();

  if (m_available != available) {
    m_available = available;

    emit availabilityChanged();
  }

  if (!m_available && m_opId) {
    // A source has disappeared while an operation is already running.
    // Most grilo will crash soon but we will just reset the opId
    m_opId = 0;
  }
}
コード例 #7
0
void QDeclarativeRadioData::connectSignals()
{
    connect(m_radioData, SIGNAL(programTypeChanged(QRadioData::ProgramType)), this,
                                 SLOT(_q_programTypeChanged(QRadioData::ProgramType)));

    connect(m_radioData, SIGNAL(stationIdChanged(QString)), this, SIGNAL(stationIdChanged(QString)));
    connect(m_radioData, SIGNAL(programTypeNameChanged(QString)), this, SIGNAL(programTypeNameChanged(QString)));
    connect(m_radioData, SIGNAL(stationNameChanged(QString)), this, SIGNAL(stationNameChanged(QString)));
    connect(m_radioData, SIGNAL(radioTextChanged(QString)), this, SIGNAL(radioTextChanged(QString)));
    connect(m_radioData, SIGNAL(alternativeFrequenciesEnabledChanged(bool)), this,
                         SIGNAL(alternativeFrequenciesEnabledChanged(bool)));
    // Since the radio data type depends on the service for the tuner, the availability is also dictated from the tuner
    connect(m_radioTuner, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)), this, SLOT(_q_availabilityChanged(QMultimedia::AvailabilityStatus)));

    connect(m_radioData, SIGNAL(error(QRadioData::Error)), this, SLOT(_q_error(QRadioData::Error)));
}
コード例 #8
0
void QDeclarativeAudio::classBegin()
{
    m_player = new QMediaPlayer(this);

    connect(m_player, SIGNAL(stateChanged(QMediaPlayer::State)),
            this, SLOT(_q_statusChanged()));
    connect(m_player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)),
            this, SLOT(_q_statusChanged()));
    connect(m_player, SIGNAL(mediaChanged(QMediaContent)),
            this, SIGNAL(sourceChanged()));
    connect(m_player, SIGNAL(durationChanged(qint64)),
            this, SIGNAL(durationChanged()));
    connect(m_player, SIGNAL(positionChanged(qint64)),
            this, SIGNAL(positionChanged()));
    connect(m_player, SIGNAL(volumeChanged(int)),
            this, SIGNAL(volumeChanged()));
    connect(m_player, SIGNAL(mutedChanged(bool)),
            this, SIGNAL(mutedChanged()));
    connect(m_player, SIGNAL(bufferStatusChanged(int)),
            this, SIGNAL(bufferProgressChanged()));
    connect(m_player, SIGNAL(seekableChanged(bool)),
            this, SIGNAL(seekableChanged()));
    connect(m_player, SIGNAL(playbackRateChanged(qreal)),
            this, SIGNAL(playbackRateChanged()));
    connect(m_player, SIGNAL(error(QMediaPlayer::Error)),
            this, SLOT(_q_error(QMediaPlayer::Error)));
    connect(m_player, SIGNAL(audioAvailableChanged(bool)),
            this, SIGNAL(hasAudioChanged()));
    connect(m_player, SIGNAL(videoAvailableChanged(bool)),
            this, SIGNAL(hasVideoChanged()));

    m_error = m_player->availability() == QMultimedia::ServiceMissing ? QMediaPlayer::ServiceMissingError : QMediaPlayer::NoError;

    connect(m_player, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)),
                     this, SLOT(_q_availabilityChanged(QMultimedia::AvailabilityStatus)));

    m_metaData.reset(new QDeclarativeMediaMetaData(m_player));

    connect(m_player, SIGNAL(metaDataChanged()),
            m_metaData.data(), SIGNAL(metaDataChanged()));

    emit mediaObjectChanged();
}
コード例 #9
0
/*!
    Construct a declarative camera object using \a parent object.
 */
QDeclarativeCamera::QDeclarativeCamera(QObject *parent) :
    QObject(parent),
    m_camera(0),
    m_metaData(0),
    m_viewfinder(0),
    m_pendingState(ActiveState),
    m_componentComplete(false)
{
    m_camera = new QCamera;
    m_currentCameraInfo = QCameraInfo(*m_camera);

    m_imageCapture = new QDeclarativeCameraCapture(m_camera);
    m_videoRecorder = new QDeclarativeCameraRecorder(m_camera);
    m_exposure = new QDeclarativeCameraExposure(m_camera);
    m_flash = new QDeclarativeCameraFlash(m_camera);
    m_focus = new QDeclarativeCameraFocus(m_camera);
    m_imageProcessing = new QDeclarativeCameraImageProcessing(m_camera);

    connect(m_camera, SIGNAL(captureModeChanged(QCamera::CaptureModes)),
            this, SIGNAL(captureModeChanged()));
    connect(m_camera, SIGNAL(lockStatusChanged(QCamera::LockStatus,QCamera::LockChangeReason)),
            this, SIGNAL(lockStatusChanged()));
    connect(m_camera, &QCamera::stateChanged, this, &QDeclarativeCamera::_q_updateState);
    connect(m_camera, SIGNAL(statusChanged(QCamera::Status)), this, SIGNAL(cameraStatusChanged()));
    connect(m_camera, SIGNAL(error(QCamera::Error)), this, SLOT(_q_error(QCamera::Error)));
    connect(m_camera, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)),
            this, SLOT(_q_availabilityChanged(QMultimedia::AvailabilityStatus)));

    connect(m_camera->focus(), &QCameraFocus::opticalZoomChanged,
            this, &QDeclarativeCamera::opticalZoomChanged);
    connect(m_camera->focus(), &QCameraFocus::digitalZoomChanged,
            this, &QDeclarativeCamera::digitalZoomChanged);
    connect(m_camera->focus(), &QCameraFocus::maximumOpticalZoomChanged,
            this, &QDeclarativeCamera::maximumOpticalZoomChanged);
    connect(m_camera->focus(), &QCameraFocus::maximumDigitalZoomChanged,
            this, &QDeclarativeCamera::maximumDigitalZoomChanged);
}
コード例 #10
0
void QDeclarativeAudio::_q_availabilityChanged(QMultimedia::AvailabilityStatus)
{
    emit availabilityChanged(availability());
}
コード例 #11
0
void QDeclarativeCamera::_q_availabilityChanged(QMultimedia::AvailabilityStatus availability)
{
    emit availabilityChanged(Availability(availability));
}
コード例 #12
0
ファイル: fsmonitor.cpp プロジェクト: ballock/cameraplus
void FSMonitor::setAvailable(bool available) {
  if (m_available != available) {
    m_available = available;
    emit availabilityChanged();
  }
}
コード例 #13
0
void StelVideoMgr::loadVideo(const QString& filename, const QString& id, const float x, const float y, const bool show, const float alpha)
{
	if (videoObjects.contains(id))
	{
		qWarning() << "[StelVideoMgr] Video object with ID" << id << "already exists, dropping it";
		dropVideo(id);
	}

	videoObjects[id] = new VideoPlayer;
	videoObjects[id]->videoItem= new QGraphicsVideoItem();
	// This sets a tiny size so that if window should appear before proper resize, it should not disturb.
	videoObjects[id]->videoItem->setSize(QSizeF(1,1));

	videoObjects[id]->player = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
	videoObjects[id]->duration=-1; // -1 to signal "unknown".
	videoObjects[id]->resolution=QSize(); // initialize with "invalid" empty resolution, we must detect this when player is starting!
	videoObjects[id]->keepVisible=false;
	videoObjects[id]->needResize=true; // resolution and target frame not yet known.
	videoObjects[id]->simplePlay=true;
	videoObjects[id]->targetFrameSize=QSizeF(); // start with invalid, depends on parameters given in playVideo(), playPopoutVideo() and resolution detected only after playing started.
	videoObjects[id]->popupOrigin=QPointF();
	videoObjects[id]->popupTargetCenter=QPointF();
	videoObjects[id]->player->setProperty("Stel_id", id); // allow tracking of log messages and access of members.
	videoObjects[id]->player->setVideoOutput(videoObjects[id]->videoItem);
	videoObjects[id]->videoItem->setOpacity(alpha);
#ifndef Q_OS_WIN
	// There is a notable difference: on Windows this causes a crash. On Linux, it is required, else the movie frame is visible before proper resize.
	videoObjects[id]->videoItem->setVisible(show);
#endif
	videoObjects[id]->lastPos=-1;

	// A few connections are not really needed, they are signals we don't use. TBD: Remove or keep commented out?
	connect(videoObjects[id]->player, SIGNAL(bufferStatusChanged(int)), this, SLOT(handleBufferStatusChanged(int)));
	connect(videoObjects[id]->player, SIGNAL(durationChanged(qint64)), this, SLOT(handleDurationChanged(qint64))); // (CRITICALLY IMPORTANT!)
	connect(videoObjects[id]->player, SIGNAL(error(QMediaPlayer::Error)), this, SLOT(handleError(QMediaPlayer::Error)));
	connect(videoObjects[id]->player, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(handleMediaStatusChanged(QMediaPlayer::MediaStatus)));
	//connect(videoObjects[id]->player, SIGNAL(positionChanged(qint64)), this, SLOT(handlePositionChanged(qint64)));
	// we test isSeekable() where needed, so only debug log entry. --> And we may use the signal however now during blocking load below!
	connect(videoObjects[id]->player, SIGNAL(seekableChanged(bool)), this, SLOT(handleSeekableChanged(bool)));
	connect(videoObjects[id]->player, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(handleStateChanged(QMediaPlayer::State)));
	connect(videoObjects[id]->player, SIGNAL(videoAvailableChanged(bool)), this, SLOT(handleVideoAvailableChanged(bool)));
	connect(videoObjects[id]->player, SIGNAL(audioAvailableChanged(bool)), this, SLOT(handleAudioAvailableChanged(bool)));
	connect(videoObjects[id]->player, SIGNAL(mutedChanged(bool)), this, SLOT(handleMutedChanged(bool)));
	connect(videoObjects[id]->player, SIGNAL(volumeChanged(int)), this, SLOT(handleVolumeChanged(int)));
	connect(videoObjects[id]->player, SIGNAL(availabilityChanged(bool)), this, SLOT(handleAvailabilityChanged(bool)));
	connect(videoObjects[id]->player, SIGNAL(availabilityChanged(QMultimedia::AvailabilityStatus)), this, SLOT(handleAvailabilityChanged(QMultimedia::AvailabilityStatus)));

	// Only this is triggered also on Windows. Lets us read resolution etc. (CRITICALLY IMPORTANT!)
	connect(videoObjects[id]->player, SIGNAL(metaDataChanged()), this, SLOT(handleMetaDataChanged()));
	// That signal would require less overhead, but is not triggered under Windows and apparently also not on MacOS X. (QTBUG-42034.)
	// If this becomes available/bugfixed, it should be preferred as being more elegant.
	// connect(videoObjects[id]->player, SIGNAL(metaDataChanged(QString,QVariant)), this, SLOT(handleMetaDataChanged(QString,QVariant)));

	// We need an absolute pathname here.
	QMediaContent content(QUrl::fromLocalFile(QFileInfo(filename).absoluteFilePath()));
	videoObjects[id]->player->setMedia(content);
	if (verbose)
	{
		qDebug() << "Loading " << content.canonicalUrl();
		qDebug() << "Media Resources queried from player:";
		qDebug() << "\tSTATUS:        " << videoObjects[id]->player->mediaStatus();
		qDebug() << "\tFile:          " << videoObjects[id]->player->currentMedia().canonicalUrl();
	}
//	qDebug() << "scene->addItem...";
	StelMainView::getInstance().scene()->addItem(videoObjects[id]->videoItem);
//	qDebug() << "scene->addItem OK";

	videoObjects[id]->videoItem->setPos(x, y);
	// DEFAULT SIZE: show a tiny frame. This gets updated to native resolution as soon as resolution becomes known. Needed?
	//videoObjects[id]->videoItem->setSize(QSizeF(1, 1));

	// after many troubles with incompletely loaded files we attempt a blocking load from https://wiki.qt.io/Seek_in_Sound_File
	// This may be no longer required. But please keep the block here for testing/reactivation if necessary.
//	if (! videoObjects[id]->player->isSeekable())
//	{
//		qDebug() << "Not Seekable!";
//		if (verbose)
//			qDebug() << "Blocking load ...";
//		QEventLoop loop;
//		QTimer timer;
//		qDebug() << "Not Seekable: setSingleShot";
//		timer.setSingleShot(true);
//		timer.setInterval(5000); // 5 seconds, may be too long?
//		qDebug() << "Not Seekable: connect...";
//		loop.connect(&timer, SIGNAL (timeout()), &loop, SLOT (quit()) );
//		loop.connect(videoObjects[id]->player, SIGNAL (seekableChanged(bool)), &loop, SLOT (quit()));
//		qDebug() << "Not Seekable: loop...";
//		loop.exec();
//		if (verbose)
//			qDebug() << "Blocking load finished, should be seekable now or 5s are over.";
//	}

	if (verbose)
		qDebug() << "Loaded video" << id << "for pos " << x << "/" << y << "Size" << videoObjects[id]->videoItem->size();
	videoObjects[id]->player->setPosition(0); // This should force triggering a metadataAvailable() with resolution update.
	if (show)
		videoObjects[id]->player->play();
	else
		videoObjects[id]->player->pause();
}
コード例 #14
0
void QGStreamerAvailabilityControl::handleAvailabilityChanged()
{
    emit availabilityChanged(this->availability());
}