instancemanager.h \
settings.h \
trackmodel.h \
- chaptermodel.h
+ chaptermodel.h \
+ include/aniplayer/playerfeatureplugininterface.h
include(qtsingleapplication/qtsingleapplication.pri)
#include <QObject>
+#include "aniplayer/playerfeatureplugininterface.h"
+
+class FeaturePluginInstance {
+public:
+ virtual ~FeaturePluginInstance() = default;
+
+ FeaturePluginInstance(QObject *player,
+ PlayerFeaturePlauginInterface *interface)
+ : m_player{player}, m_playerInterface{interface} {}
+
+protected:
+ QObject *m_player;
+ PlayerFeaturePlauginInterface *m_playerInterface;
+};
+
class FeaturePluginBase {
public:
virtual ~FeaturePluginBase() = default;
- virtual void instanceCreated(QObject *instance) = 0;
- virtual void instanceDestroyed(QObject *instance) = 0;
+ virtual FeaturePluginInstance *
+ createInstance(QObject *instance, PlayerFeaturePlauginInterface *) = 0;
};
-#define ANIPLAYER_FEATURE_PLUGIN_INTERFACE_IID \
+#define ANIPLAYER_FEATURE_PLUGIN_INTERFACE_IID \
"org.aptx.aniplayer.FeaturePluginInterface"
Q_DECLARE_INTERFACE(FeaturePluginBase, ANIPLAYER_FEATURE_PLUGIN_INTERFACE_IID)
--- /dev/null
+#ifndef PLAYERFEATUREPLUGININTERFACE_H
+#define PLAYERFEATUREPLUGININTERFACE_H
+
+#include <QString>
+
+class PlayerFeaturePlauginInterface {
+public:
+ virtual ~PlayerFeaturePlauginInterface() = default;
+
+ virtual void featureShowStatusMessage(const QString &message) = 0;
+};
+
+#endif // PLAYERFEATUREPLUGININTERFACE_H
auto player = new Player{instance, this};
Q_CHECK_PTR(player);
- m_featurePluginManager->forEach<FeaturePluginBase>(
- [player](FeaturePluginBase *plugin) { plugin->instanceCreated(player); });
+ m_featurePluginManager->forEach<FeaturePluginBase>([player](
+ FeaturePluginBase *plugin) { plugin->createInstance(player, player); });
return player;
}
emit currentSubtitleTrackChanged(track);
}
+void Player::featureShowStatusMessage(const QString &message)
+{
+ emit statusMessageRequested(message);
+}
+
void Player::reqisterQmlTypes() {
qRegisterMetaType<TimeStamp>("TimeStamp");
qRegisterMetaType<TrackIndex>("StreamIndex");
#include <QUrl>
#include "aniplayer/backendpluginbase.h"
+#include "aniplayer/playerfeatureplugininterface.h"
#include "chaptermodel.h"
#include "trackmodel.h"
class Player : public QObject,
public PlayerPluginInterface,
- public PlayerRendererInterface {
+ public PlayerRendererInterface,
+ public PlayerFeaturePlauginInterface {
Q_OBJECT
Q_PROPERTY(QUrl currentSource READ currentSource WRITE load NOTIFY
currentSourceChanged)
void subtitleTrackModelChanged(QAbstractItemModel *subtitleTrackModel);
void chapterModelChanged(QAbstractItemModel *chapterModel);
+ void statusMessageRequested(const QString &message);
+
public slots:
// Basic Play state
void load(const QUrl &resource);
void backendCurrentAudioTrackChanged(TrackIndex) override;
void backendCurrentSubtitleTrackChanged(TrackIndex) override;
+ void featureShowStatusMessage(const QString &message) override;
+
public:
static void reqisterQmlTypes();
qCWarning(lmlCategory) << "Init failed";
}
-void FeatureLocalMyList::instanceCreated(QObject *instance) {
- qCDebug(lmlCategory) << "Registering with instance" << instance;
- connect(instance, SIGNAL(currentSourceChanged(QUrl)), this,
- SLOT(sourceChanged(QUrl)));
- connect(instance, SIGNAL(positionChanged(double)), this,
- SLOT(positionChanged(double)));
- connect(instance, SIGNAL(durationChanged(double)), this,
- SLOT(durationChanged(double)));
+FeaturePluginInstance *
+FeatureLocalMyList::createInstance(QObject *instance,
+ PlayerFeaturePlauginInterface *interface) {
+ return new FeatureLocalMyListInstance(instance, interface);
}
-void FeatureLocalMyList::instanceDestroyed(QObject *instance) {
- qCDebug(lmlCategory) << "Unregistering from instance" << instance;
- m_instanceMap.remove(instance);
-}
-
-void FeatureLocalMyList::sourceChanged(const QUrl &source) {
+void FeatureLocalMyListInstance::sourceChanged(const QUrl &source) {
if (!source.isLocalFile())
return;
const auto path = source.toLocalFile();
qCInfo(lmlCategory) << "File" << path
<< "found in LocalMyList, fid =" << file.fid;
- auto &data = m_instanceMap[sender()];
- data.duration = readDuration(sender());
- data.fid = file.fid;
- data.path = path;
+ m_duration = readDuration(sender());
+ m_fid = file.fid;
+ m_path = path;
}
-void FeatureLocalMyList::durationChanged(double duration)
-{
+void FeatureLocalMyListInstance::durationChanged(double duration) {
qCDebug(lmlCategory) << "Duration changed for " << sender();
- const auto it = m_instanceMap.find(sender());
- if (it == m_instanceMap.cend())
- return;
- auto &data = it.value();
-
- data.duration = duration;
+ m_duration = duration;
}
-void FeatureLocalMyList::positionChanged(double position) {
- {
- const auto it = m_instanceMap.find(sender());
- if (it == m_instanceMap.cend())
- return;
-
- const auto &data = it.value();
-
- if (data.duration < 1.0)
- return;
+void FeatureLocalMyListInstance::positionChanged(double position) {
+ if (m_duration < 1.0)
+ return;
- if (!data.fid)
- return;
+ if (!m_fid)
+ return;
- if (position / data.duration * 100.0 < PERCENT)
- return;
+ if (position / m_duration * 100.0 < PERCENT)
+ return;
- qCInfo(lmlCategory) << "Marking file" << data.path << "watched";
- LocalMyList::instance()->markWatchedIfUnwatched(data.fid);
- }
- m_instanceMap.remove(sender());
+ qCInfo(lmlCategory) << "Marking file" << m_path << "watched";
+ LocalMyList::instance()->markWatchedIfUnwatched(m_fid);
}
-double FeatureLocalMyList::readDuration(QObject *obj)
-{
+double FeatureLocalMyListInstance::readDuration(QObject *obj) {
const auto mo = obj->metaObject();
const auto durationIdx = mo->indexOfProperty("duration");
qCDebug(lmlCategory) << "duration propert index" << durationIdx;
qCDebug(lmlCategory) << "File duration read" << duration;
return duration;
}
+
+FeatureLocalMyListInstance::FeatureLocalMyListInstance(
+ QObject *instance, PlayerFeaturePlauginInterface *player, QObject *parent)
+ : FeaturePluginInstance{instance, player} {
+ qCDebug(lmlCategory) << "Registering with instance" << instance;
+ connect(instance, SIGNAL(currentSourceChanged(QUrl)), this,
+ SLOT(sourceChanged(QUrl)));
+ connect(instance, SIGNAL(positionChanged(double)), this,
+ SLOT(positionChanged(double)));
+ connect(instance, SIGNAL(durationChanged(double)), this,
+ SLOT(durationChanged(double)));
+}
#include <QtPlugin>
#include "aniplayer/featurepluginbase.h"
+#include "aniplayer/playerfeatureplugininterface.h"
#include "feature_localmylist_global.h"
class FEATURE_LOCALMYLISTSHARED_EXPORT FeatureLocalMyList
public:
FeatureLocalMyList(QObject *parent = nullptr);
- void instanceCreated(QObject *instance) override;
- void instanceDestroyed(QObject *instance) override;
+ FeaturePluginInstance *
+ createInstance(QObject *instance, PlayerFeaturePlauginInterface *) override;
+};
+
+class FeatureLocalMyListInstance : public QObject, public FeaturePluginInstance {
+ Q_OBJECT
+public:
+ FeatureLocalMyListInstance(QObject *instance, PlayerFeaturePlauginInterface *, QObject *parent = nullptr);
private slots:
void sourceChanged(const QUrl &source);
private:
static double readDuration(QObject *obj);
- struct FileData {
- int fid;
- QString path;
- double duration;
- };
- QHash<QObject *, FileData> m_instanceMap;
+ QObject m_player;
+ PlayerFeaturePlauginInterface *m_playerInterface;
+ int m_fid;
+ QString m_path;
+ double m_duration;
};
#endif // FEATURELOCALMYLIST_H
<file>qml/SeekSlider.qml</file>
<file>qml/PlaybackPosition.qml</file>
<file>qml/VolumeSlider.qml</file>
+ <file>qml/TextWithBackground.qml</file>
</qresource>
</RCC>
--- /dev/null
+import QtQuick 2.0
+
+Rectangle {
+ property alias text: message.text
+
+ color: "#000000"
+ width: childrenRect.width + 5
+ height: childrenRect.height + 5
+ Text {
+ id: message
+ color: "red"
+ x: 0
+ y: 0
+ width: contentWidth
+ height: contentHeight
+ }
+}
controlsVisible = !controlsVisible;
}
}
+
+ TextWithBackground {
+ anchors.top: parent.top
+ anchors.left: parent.left
+
+ text: "This is a text message"
+
+ visible: controls.visible
+
+ Connections {
+ target: player
+ onStatusMessageRequested: text = message
+ }
+ }
}