Unverified Commit 206a00f9 authored by Nicolas Fella's avatar Nicolas Fella Committed by David Rosca
Browse files

Move availability property from Port to Profile

Differential Revision: https://phabricator.kde.org/D9671
parent fc013c7a
......@@ -25,7 +25,6 @@ namespace QPulseAudio
Port::Port(QObject *parent)
: Profile(parent)
, m_availability(Unknown)
{
}
......@@ -33,9 +32,4 @@ Port::~Port()
{
}
Port::Availability Port::availability() const
{
return m_availability;
}
} // QPulseAudio
......@@ -31,14 +31,8 @@ namespace QPulseAudio
class Port : public Profile
{
Q_OBJECT
Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
public:
enum Availability {
Unknown,
Available,
Unavailable
};
Q_ENUM(Availability)
Port(QObject *parent);
virtual ~Port();
......@@ -47,31 +41,7 @@ public:
void setInfo(const PAInfo *info)
{
Profile::setInfo(info);
Availability newAvailability;
switch (info->available) {
case PA_PORT_AVAILABLE_NO:
newAvailability = Unavailable;
break;
case PA_PORT_AVAILABLE_YES:
newAvailability = Available;
break;
default:
newAvailability = Unknown;
}
if (m_availability != newAvailability) {
m_availability = newAvailability;
emit availabilityChanged();
}
}
Availability availability() const;
signals:
void availabilityChanged();
private:
Availability m_availability;
};
} // QPulseAudio
......
......@@ -28,6 +28,7 @@ Profile::Profile(QObject *parent)
, m_name()
, m_description()
, m_priority(0)
, m_availability(Unknown)
{
}
......@@ -50,4 +51,9 @@ quint32 Profile::priority() const
return m_priority;
}
Profile::Availability Profile::availability() const
{
return m_availability;
}
} // QPulseAudio
......@@ -33,7 +33,16 @@ class Profile : public QObject
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(quint32 priority READ priority NOTIFY priorityChanged)
Q_PROPERTY(Availability availability READ availability NOTIFY availabilityChanged)
public:
enum Availability {
Unknown,
Available,
Unavailable
};
Q_ENUM(Availability)
Profile(QObject *parent);
virtual ~Profile();
......@@ -58,21 +67,30 @@ public:
m_priority = info->priority;
emit priorityChanged();
}
Availability newAvailability = info->available ? Available : Unavailable;
if (m_availability != newAvailability) {
m_availability = newAvailability;
emit availabilityChanged();
}
}
QString name() const;
QString description() const;
quint32 priority() const;
Availability availability() const;
signals:
void nameChanged();
void descriptionChanged();
void priorityChanged();
void availabilityChanged();
private:
QString m_name;
QString m_description;
quint32 m_priority;
Availability m_availability;
};
} // QPulseAudio
......
......@@ -28,7 +28,7 @@
#include "source.h"
#include "context.h"
#include "modulemanager.h"
#include "port.h"
#include "profile.h"
#include "globalactioncollection.h"
#include "volumeosd.h"
......@@ -55,7 +55,7 @@ void Plugin::registerTypes(const char* uri)
qmlRegisterType<QPulseAudio::SourceOutputModel>(uri, 0, 1, "SourceOutputModel");
qmlRegisterType<QPulseAudio::StreamRestoreModel>(uri, 0, 1, "StreamRestoreModel");
qmlRegisterType<QPulseAudio::ModuleModel>(uri, 0, 1, "ModuleModel");
qmlRegisterUncreatableType<QPulseAudio::Port>(uri, 0, 1, "Port", QString());
qmlRegisterUncreatableType<QPulseAudio::Profile>(uri, 0, 1, "Profile", QString());
qmlRegisterType<GlobalAction>(uri, 0, 1, "GlobalAction");
qmlRegisterType<GlobalActionCollection>(uri, 0, 1, "GlobalActionCollection");
qmlRegisterType<VolumeOSD>(uri, 0, 1, "VolumeOSD");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment