Mpris2DBusHandler::Mpris2DBusHandler()
        : QObject( kapp )
    {
        new Mpris2RootAdaptor( this );
        new Mpris2PlayerAdaptor( this );
        // amarok extensions:
        new Mpris2AmarokAppAdaptor( this );
        new Mpris2AmarokPlayerAdaptor( this );
        QDBusConnection::sessionBus().registerObject( MPRIS2_OBJECT_PATH, this );

        connect( The::playlistActions(), SIGNAL( navigatorChanged() ),
            SLOT( updateTrackProgressionProperties() ) );
        // changing the navigator may also affect whether there is a
        // next or previous track
        connect( The::playlistActions(), SIGNAL( navigatorChanged() ),
            SLOT( updatePlaylistProperties() ) );

        connect( The::playlist()->qaim(), SIGNAL( rowsInserted(QModelIndex,int,int) ),
            SLOT( updatePlaylistProperties() ) );
        connect( The::playlist()->qaim(), SIGNAL( rowsMoved(QModelIndex,int,int,QModelIndex,int) ),
            SLOT( updatePlaylistProperties() ) );
        connect( The::playlist()->qaim(), SIGNAL( rowsRemoved(QModelIndex,int,int) ),
            SLOT( updatePlaylistProperties() ) );
        connect( qobject_cast<Playlist::ProxyBase*>(The::playlist()->qaim()), SIGNAL( activeTrackChanged(const quint64) ),
                 this, SLOT( playlistActiveTrackChanged(quint64) ) );

        EngineController *engine = The::engineController();

        connect( engine, SIGNAL( playbackStateChanged() ),
                 this, SLOT( updatePlaybackStatusProperty() ) );

        connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ),
                 this, SLOT( updatePlaylistProperties() ) );

        connect( engine, SIGNAL( trackChanged( Meta::TrackPtr ) ),
                 this, SLOT( updateTrackProperties() ) );

        connect( engine, SIGNAL( trackPositionChanged( qint64, bool ) ),
                 this, SLOT( trackPositionChanged( qint64, bool ) ) );
        connect( engine, SIGNAL( seekableChanged( bool ) ),
                 this, SLOT( seekableChanged( bool ) ) );
        connect( engine, SIGNAL( volumeChanged( int ) ),
                 this, SLOT( volumeChanged( int ) ) );

        updateTrackProgressionProperties();
        updatePlaybackStatusProperty();
        updatePlaylistProperties();
        updateTrackProperties();
        setPropertyInternal( "Volume", static_cast<double>(The::engineController()->volume()) / 100.0 );
        setPropertyInternal( "CanSeek", The::engineController()->phononMediaObject()->isSeekable() );
    }
Beispiel #2
0
void CSSMutableStyleDeclaration::setImageProperty(int propertyId, const String& url, bool important)
{
    ASSERT(!m_iteratorCount);

    setPropertyInternal(CSSProperty(propertyId, CSSImageValue::create(url), important));
    setNeedsStyleRecalc();
}
Beispiel #3
0
void CSSMutableStyleDeclaration::setStringProperty(int propertyId, const String &value, CSSPrimitiveValue::UnitTypes type, bool important)
{
    ASSERT(!m_iteratorCount);

    setPropertyInternal(CSSProperty(propertyId, CSSPrimitiveValue::create(value, type), important));
    setNeedsStyleRecalc();
}
Beispiel #4
0
bool CSSMutableStyleDeclaration::setProperty(int propertyID, double value, CSSPrimitiveValue::UnitTypes unit, bool important, bool notifyChanged)
{
    CSSProperty property(propertyID, CSSPrimitiveValue::create(value, unit), important);
    setPropertyInternal(property);
    if (notifyChanged)
        setNeedsStyleRecalc();
    return true;
}
Beispiel #5
0
bool CSSMutableStyleDeclaration::setProperty(int propertyID, int value, bool important, bool notifyChanged)
{
    CSSProperty property(propertyID, CSSPrimitiveValue::createIdentifier(value), important);
    setPropertyInternal(property);
    if (notifyChanged)
        setNeedsStyleRecalc();
    return true;
}
    void Mpris2DBusHandler::playlistActiveTrackChanged( quint64 newTrackId )
    {
        // the rest of the metadata should be set in updateTrackProperties when the
        // engine controller says the track has changed
        QVariantMap metaData = property( "Metadata" ).toMap();
        metaData["mpris:trackid"] = QVariant::fromValue<QDBusObjectPath>( mprisTrackId( newTrackId ) );
        setPropertyInternal( "Metadata", metaData );

        if ( AmarokConfig::trackProgression() != AmarokConfig::EnumTrackProgression::RepeatPlaylist )
        {
            int activeRow = The::playlist()->activeRow();
            bool canGoNext = activeRow < The::playlist()->qaim()->rowCount() - 1;
            bool canGoPrevious = activeRow > 0;
            debug() << "Active track changed; can go next:" << canGoNext << "; can go previous:" << canGoPrevious;
            setPropertyInternal( "CanGoNext", canGoNext );
            setPropertyInternal( "CanGoPrevious", canGoPrevious );
        }
    }
Beispiel #7
0
void ModulatorSamplerSound::setPreloadPropertyInternal(Property p, int newValue)
{
	auto firstSampler = ProcessorHelpers::getFirstProcessorWithType<ModulatorSampler>(getMainController()->getMainSynthChain());

	auto f = [this, p, newValue](Processor*)->bool {
		setPropertyInternal(p, newValue);
		return true;
	};

	firstSampler->killAllVoicesAndCall(f);
}
void AbstractPropertySetCSSStyleDeclaration::setProperty(const String& propertyName, const String& value, const String& priority, ExceptionState& exceptionState)
{
    CSSPropertyID propertyID = cssPropertyID(propertyName);
    if (!propertyID)
        return;

    bool important = equalIgnoringCase(priority, "important");
    if (!important && !priority.isEmpty())
        return;

    setPropertyInternal(propertyID, value, important, exceptionState);
}
    void Mpris2DBusHandler::updateTrackProperties()
    {
        DEBUG_BLOCK

        Meta::TrackPtr currentTrack = The::engineController()->currentTrack();
        if ( !currentTrack )
        {
            int rowCount = The::playlist()->qaim()->rowCount();
            setPropertyInternal( "Metadata", QVariantMap() );
            setPropertyInternal( "CanPlay", rowCount > 0 );
            setPropertyInternal( "CanPause", false );
            //setPropertyInternal( "CanSeek", false );
        }
        else
        {
            QVariantMap metaData = Meta::Field::mpris20MapFromTrack( currentTrack );
            if ( currentTrack == The::playlist()->activeTrack() )
                metaData["mpris:trackid"] = QVariant::fromValue<QDBusObjectPath>(activeMprisTrackId());
            else {
                // we should be updated shortly
                QString path = QString( "%1/PendingTrack" ).arg( MPRIS2_OBJECT_PATH );
                metaData["mpris:trackid"] = QVariant::fromValue<QDBusObjectPath>( QDBusObjectPath( path ) );
            }

            setPropertyInternal( "CanPlay", true );
            // Phonon doesn't actually tell us whether the media is pausable,
            // so we always claim it is
            setPropertyInternal( "CanPause", true );
            //setPropertyInternal( "CanSeek", The::engineController()->phononMediaObject()->isSeekable() );
            setPropertyInternal( "Metadata", metaData );
        }
    }
    void Mpris2DBusHandler::updateTrackProgressionProperties()
    {
        QString loopStatus;
        // Trying to match with AmarokConfig::EnumTrack
        switch( AmarokConfig::trackProgression() )
        {
            case AmarokConfig::EnumTrackProgression::Normal:
            case AmarokConfig::EnumTrackProgression::OnlyQueue:
            case AmarokConfig::EnumTrackProgression::RandomTrack:
            case AmarokConfig::EnumTrackProgression::RandomAlbum:
                loopStatus = "None";
                break;
            case AmarokConfig::EnumTrackProgression::RepeatTrack:
                loopStatus = "Track";
                break;
            case AmarokConfig::EnumTrackProgression::RepeatAlbum:
            case AmarokConfig::EnumTrackProgression::RepeatPlaylist:
                loopStatus = "Playlist";
                break;
            default:
                Q_ASSERT( false );
                loopStatus = "None";
                break;
        }
        setPropertyInternal( "LoopStatus", loopStatus );

        bool shuffle;
        switch( AmarokConfig::trackProgression() )
        {
            case AmarokConfig::EnumTrackProgression::RandomAlbum:
            case AmarokConfig::EnumTrackProgression::RandomTrack:
                shuffle = true;
                break;
            default:
                shuffle = false;
                break;
        }
        setPropertyInternal( "Shuffle", shuffle );
    }
 void Mpris2DBusHandler::updatePlaylistProperties()
 {
     // FIXME: we should really be able to ask the active navigator
     // whether it can produce a next/previous track, rather than
     // depending on this enum.
     //
     // However, likelyLastTrack() and likelyNextTrack() don't do quite what we want
     if ( AmarokConfig::trackProgression() == AmarokConfig::EnumTrackProgression::RepeatPlaylist )
     {
         int rowCount = The::playlist()->qaim()->rowCount();
         setPropertyInternal( "CanGoNext", rowCount > 0 );
         setPropertyInternal( "CanGoPrevious", rowCount > 0 );
     }
     else
     {
         int activeRow = The::playlist()->activeRow();
         bool canGoNext = activeRow < The::playlist()->qaim()->rowCount() - 1;
         bool canGoPrevious = activeRow > 0;
         debug() << "Playlist properties changed; can go next:" << canGoNext << "; can go previous:" << canGoPrevious;
         setPropertyInternal( "CanGoNext", canGoNext );
         setPropertyInternal( "CanGoPrevious", canGoPrevious );
     }
 }
 void Mpris2DBusHandler::updatePlaybackStatusProperty()
 {
     QString status;
     switch( getStatus() )
     {
         case Playing:
             status = "Playing";
             break;
         case Paused:
             status = "Paused";
             break;
         case Stopped:
             status = "Stopped";
             break;
     }
     setPropertyInternal( "PlaybackStatus", status );
 }
Beispiel #13
0
void CSSMutableStyleDeclaration::merge(const CSSMutableStyleDeclaration* other, bool argOverridesOnConflict)
{
    ASSERT(!m_iteratorCount);

    unsigned size = other->m_properties.size();
    for (unsigned n = 0; n < size; ++n) {
        const CSSProperty& toMerge = other->m_properties[n];
        CSSProperty* old = findPropertyWithId(toMerge.id());
        if (old) {
            if (!argOverridesOnConflict && old->value())
                continue;
            setPropertyInternal(toMerge, old);
        } else
            m_properties.append(toMerge);
    }
    // FIXME: This probably should have a call to setNeedsStyleRecalc() if something changed. We may also wish to add
    // a notifyChanged argument to this function to follow the model of other functions in this class.
}
 void Mpris2DBusHandler::volumeChanged( int percent )
 {
     setPropertyInternal( "Volume", static_cast<double>(percent) / 100.0 );
 }
 void Mpris2DBusHandler::seekableChanged( bool seekable )
 {
     setPropertyInternal( "CanSeek", seekable );
 }
void CSSMutableStyleDeclaration::addParsedProperty(const CSSProperty& property)
{
    ASSERT(!m_iteratorCount);

    setPropertyInternal(property);
}