Code cleanup

Use GNU formatter from Eclipse.
This commit is contained in:
Stéphane Cerveau 2017-05-31 21:35:10 +02:00
parent 606b1bb3eb
commit 2d75a32dd0
21 changed files with 2718 additions and 2812 deletions

View file

@ -1,13 +1,15 @@
#include "CustomMenuAction.h"
CustomMenuAction::CustomMenuAction(const QString& displayName, QObject * parent)
:QAction(displayName, parent)
, m_name(displayName)
CustomMenuAction::CustomMenuAction (const QString& displayName,
QObject * parent)
: QAction (displayName, parent),
m_name (displayName)
{
}
CustomMenuAction::CustomMenuAction(const QString& displayName, const QString& name, QObject * parent)
:QAction(displayName, parent)
, m_name(name)
CustomMenuAction::CustomMenuAction (const QString& displayName,
const QString& name, QObject * parent)
: QAction (displayName, parent),
m_name (name)
{
}

View file

@ -1,22 +1,18 @@
#ifndef CUSTOM_MENU_ACTION_H_
#define CUSTOM_MENU_ACTION_H_
#include <QAction>
class CustomMenuAction: public QAction
{
public:
CustomMenuAction(const QString& displayName, QObject * parent);
CustomMenuAction(const QString& displayName, QObject * parent);
CustomMenuAction(const QString& displayName, const QString& name, QObject * parent);
CustomMenuAction(const QString& displayName, const QString& name, QObject * parent);
QString getName() { return m_name;}
QString getName() {return m_name;}
private:
QString m_name;
QString m_name;
};
#endif //CUSTOM_MENU_ACTION_H_

View file

@ -5,34 +5,35 @@
#define COMPANY_NAME "virinext"
#define APPLICATION_NAME "pipeviz"
void CustomSettings::saveLastIODirectory(const QString &name)
void
CustomSettings::saveLastIODirectory (const QString &name)
{
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
settings.setValue("last_directory", name);
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
settings.setValue ("last_directory", name);
}
QString CustomSettings::lastIODirectory()
QString
CustomSettings::lastIODirectory ()
{
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
QString res = settings.value("last_directory").toString();
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
QString res = settings.value ("last_directory").toString ();
if(res.isEmpty())
res = "./";
if (res.isEmpty ())
res = "./";
return res;
return res;
}
void CustomSettings::saveMainWindowGeometry(const QByteArray &geometry)
void
CustomSettings::saveMainWindowGeometry (const QByteArray &geometry)
{
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
settings.setValue("geometry", geometry);
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
settings.setValue ("geometry", geometry);
}
QByteArray CustomSettings::mainWindowGeometry()
QByteArray
CustomSettings::mainWindowGeometry ()
{
QSettings settings(COMPANY_NAME, APPLICATION_NAME);
return settings.value("geometry").toByteArray();
QSettings settings (COMPANY_NAME, APPLICATION_NAME);
return settings.value ("geometry").toByteArray ();
}

View file

@ -4,16 +4,13 @@
#include <QString>
#include <QByteArray>
namespace CustomSettings
{
void saveLastIODirectory(const QString &name);
QString lastIODirectory();
void saveLastIODirectory(const QString &name);
QString lastIODirectory();
void saveMainWindowGeometry(const QByteArray &geometry);
QByteArray mainWindowGeometry();
void saveMainWindowGeometry(const QByteArray &geometry);
QByteArray mainWindowGeometry();
}
#endif

View file

@ -11,428 +11,387 @@
#include <gst/gst.h>
ElementProperties::ElementProperties(QSharedPointer<GraphManager> pGraph, const char *name,
QWidget *parent, Qt::WindowFlags flags):
QWidget(parent, flags),
m_pGraphManager(pGraph),
m_name(name)
ElementProperties::ElementProperties (QSharedPointer<GraphManager> pGraph,
const char *name, QWidget *parent,
Qt::WindowFlags flags)
: QWidget (parent, flags),
m_pGraphManager (pGraph),
m_name (name)
{
setWindowTitle(QString(name) + " properties");
setWindowTitle (QString (name) + " properties");
create();
create ();
}
void ElementProperties::addParamEnum(GParamSpec *param, GstElement *element, QGridLayout *play)
void
ElementProperties::addParamEnum (GParamSpec *param, GstElement *element,
QGridLayout *play)
{
GValue value = { 0 };
GValue value = { 0 };
g_value_init (&value, param -> value_type);
if(param -> flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT(element), param -> name, &value);
else
{
const GValue *valueDef = g_param_spec_get_default_value(param);
g_value_copy(valueDef, &value);
}
g_value_init (&value, param->value_type);
if (param->flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT (element), param->name, &value);
else {
const GValue *valueDef = g_param_spec_get_default_value (param);
g_value_copy (valueDef, &value);
}
QString propertyName = g_param_spec_get_name (param);
int propertyValue;
QString propertyName = g_param_spec_get_name (param);
int propertyValue;
propertyValue = g_value_get_enum (&value);
propertyValue = g_value_get_enum(&value);
GParamSpecEnum *penumSpec = G_PARAM_SPEC_ENUM (param);
GParamSpecEnum *penumSpec = G_PARAM_SPEC_ENUM(param);
if (!penumSpec)
return;
if(!penumSpec)
return;
QComboBox *pcomBox = new QComboBox;
QComboBox *pcomBox = new QComboBox;
for (std::size_t i = 0; i < penumSpec->enum_class->n_values; i++) {
QVariant var (penumSpec->enum_class->values[i].value);
QString valueName = penumSpec->enum_class->values[i].value_name;
for(std::size_t i=0; i<penumSpec -> enum_class -> n_values; i++)
{
QVariant var(penumSpec -> enum_class -> values[i].value);
QString valueName = penumSpec -> enum_class -> values[i].value_name;
pcomBox->addItem (valueName, var);
pcomBox -> addItem(valueName, var);
if (penumSpec->enum_class->values[i].value == propertyValue)
pcomBox->setCurrentIndex (i);
}
if(penumSpec -> enum_class -> values[i].value == propertyValue)
pcomBox -> setCurrentIndex(i);
}
int row = play -> rowCount();
play -> addWidget(new QLabel(propertyName), row, 0);
play -> addWidget(pcomBox, row, 1);
m_values.insert(propertyName, pcomBox);
int row = play->rowCount ();
play->addWidget (new QLabel (propertyName), row, 0);
play->addWidget (pcomBox, row, 1);
m_values.insert (propertyName, pcomBox);
}
void ElementProperties::addParamFlags(GParamSpec *param, GstElement *element, QGridLayout *play)
void
ElementProperties::addParamFlags (GParamSpec *param, GstElement *element,
QGridLayout *play)
{
GValue value = { 0 };
GValue value = { 0 };
g_value_init (&value, param -> value_type);
if(param -> flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT(element), param -> name, &value);
else
{
const GValue *valueDef = g_param_spec_get_default_value(param);
g_value_copy(valueDef, &value);
}
g_value_init (&value, param->value_type);
if (param->flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT (element), param->name, &value);
else {
const GValue *valueDef = g_param_spec_get_default_value (param);
g_value_copy (valueDef, &value);
}
QString propertyName = g_param_spec_get_name (param);
int propertyValue;
QString propertyName = g_param_spec_get_name (param);
int propertyValue;
propertyValue = g_value_get_flags (&value);
propertyValue = g_value_get_flags(&value);
GParamSpecFlags *pflagsSpec = G_PARAM_SPEC_FLAGS (param);
GParamSpecFlags *pflagsSpec = G_PARAM_SPEC_FLAGS(param);
if (!pflagsSpec)
return;
if(!pflagsSpec)
return;
QComboBox *pcomBox = new QComboBox;
QComboBox *pcomBox = new QComboBox;
for (std::size_t i = 0; i < pflagsSpec->flags_class->n_values; i++) {
QVariant var (pflagsSpec->flags_class->values[i].value);
QString valueName = pflagsSpec->flags_class->values[i].value_name;
for(std::size_t i=0; i<pflagsSpec -> flags_class -> n_values; i++)
{
QVariant var(pflagsSpec -> flags_class -> values[i].value);
QString valueName = pflagsSpec -> flags_class -> values[i].value_name;
pcomBox->addItem (valueName, var);
pcomBox -> addItem(valueName, var);
if (pflagsSpec->flags_class->values[i].value == propertyValue)
pcomBox->setCurrentIndex (i);
}
if(pflagsSpec -> flags_class -> values[i].value == propertyValue)
pcomBox -> setCurrentIndex(i);
}
int row = play->rowCount ();
int row = play -> rowCount();
play->addWidget (new QLabel (propertyName), row, 0);
play -> addWidget(new QLabel(propertyName), row, 0);
play->addWidget (pcomBox, row, 1);
play -> addWidget(pcomBox, row, 1);
m_values.insert(propertyName, pcomBox);
m_values.insert (propertyName, pcomBox);
}
void ElementProperties::addParamSimple(GParamSpec *param, GstElement *element, QGridLayout *play)
void
ElementProperties::addParamSimple (GParamSpec *param, GstElement *element,
QGridLayout *play)
{
bool readOnly = true;
bool readOnly = true;
if(param->flags & G_PARAM_WRITABLE)
readOnly = false;
GValue value = { 0 };
if (param->flags & G_PARAM_WRITABLE)
readOnly = false;
g_value_init (&value, param -> value_type);
if(param -> flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT(element), param -> name, &value);
else
{
const GValue *valueDef = g_param_spec_get_default_value(param);
g_value_copy(valueDef, &value);
}
GValue value = { 0 };
g_value_init (&value, param->value_type);
if (param->flags & G_PARAM_READABLE)
g_object_get_property (G_OBJECT (element), param->name, &value);
else {
const GValue *valueDef = g_param_spec_get_default_value (param);
g_value_copy (valueDef, &value);
}
QString propertyName = g_param_spec_get_name (param);
QString propertyValue;
QString propertyName = g_param_spec_get_name (param);
QString propertyValue;
bool skip = false;
bool skip = false;
switch (G_VALUE_TYPE (&value))
{
case G_TYPE_STRING:
{
const char *string_val = g_value_get_string (&value);
propertyValue = string_val;
break;
}
case G_TYPE_BOOLEAN:
{
gboolean bool_val = g_value_get_boolean (&value);
propertyValue = QString::number(bool_val);
break;
}
case G_TYPE_ULONG:
{
propertyValue = QString::number(g_value_get_ulong(&value));
break;
}
case G_TYPE_LONG:
{
propertyValue = QString::number(g_value_get_long(&value));
break;
}
case G_TYPE_UINT:
{
propertyValue = QString::number(g_value_get_uint(&value));
break;
}
case G_TYPE_INT:
{
propertyValue = QString::number(g_value_get_int(&value));
break;
}
case G_TYPE_UINT64:
{
propertyValue = QString::number(g_value_get_uint64(&value));
break;
}
case G_TYPE_INT64:
{
propertyValue = QString::number(g_value_get_int64(&value));
break;
}
case G_TYPE_FLOAT:
{
propertyValue = QString::number(g_value_get_float(&value));
break;
}
case G_TYPE_DOUBLE:
{
propertyValue = QString::number(g_value_get_double(&value));
break;
}
case G_TYPE_CHAR:
{
propertyValue = QString::number(g_value_get_char(&value));
break;
}
case G_TYPE_UCHAR:
{
propertyValue = QString::number(g_value_get_uchar(&value));
break;
}
switch (G_VALUE_TYPE (&value)) {
case G_TYPE_STRING: {
const char *string_val = g_value_get_string (&value);
propertyValue = string_val;
break;
}
case G_TYPE_BOOLEAN: {
gboolean bool_val = g_value_get_boolean (&value);
propertyValue = QString::number (bool_val);
break;
}
case G_TYPE_ULONG: {
propertyValue = QString::number (g_value_get_ulong (&value));
break;
}
case G_TYPE_LONG: {
propertyValue = QString::number (g_value_get_long (&value));
break;
}
case G_TYPE_UINT: {
propertyValue = QString::number (g_value_get_uint (&value));
break;
}
case G_TYPE_INT: {
propertyValue = QString::number (g_value_get_int (&value));
break;
}
case G_TYPE_UINT64: {
propertyValue = QString::number (g_value_get_uint64 (&value));
break;
}
case G_TYPE_INT64: {
propertyValue = QString::number (g_value_get_int64 (&value));
break;
}
case G_TYPE_FLOAT: {
propertyValue = QString::number (g_value_get_float (&value));
break;
}
case G_TYPE_DOUBLE: {
propertyValue = QString::number (g_value_get_double (&value));
break;
}
case G_TYPE_CHAR: {
propertyValue = QString::number (g_value_get_char (&value));
break;
}
case G_TYPE_UCHAR: {
propertyValue = QString::number (g_value_get_uchar (&value));
break;
}
default:
{
skip = true;
qDebug() << "property " << propertyName << " not supported";
break;
}
};
default: {
skip = true;
qDebug () << "property " << propertyName << " not supported";
break;
}
};
int row = play -> rowCount();
int row = play->rowCount ();
play -> addWidget(new QLabel(propertyName), row, 0);
play->addWidget (new QLabel (propertyName), row, 0);
QLineEdit *ple = new QLineEdit(propertyValue);
ple -> setReadOnly(readOnly);
play -> addWidget(ple, row, 1);
if(!skip)
m_values.insert(propertyName, ple);
else
ple -> setReadOnly(true);
QLineEdit *ple = new QLineEdit (propertyValue);
ple->setReadOnly (readOnly);
play->addWidget (ple, row, 1);
if (!skip)
m_values.insert (propertyName, ple);
else
ple->setReadOnly (true);
}
void ElementProperties::create()
void
ElementProperties::create ()
{
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraphManager -> m_pGraph), m_name.toStdString().c_str());
GstElement *element = gst_bin_get_by_name (
GST_BIN (m_pGraphManager->m_pGraph), m_name.toStdString ().c_str ());
if(!element)
return;
if (!element)
return;
QGridLayout *play = new QGridLayout;
QGridLayout *play = new QGridLayout;
GParamSpec **prop_specs;
guint num_props;
GParamSpec **prop_specs;
guint num_props;
prop_specs = g_object_class_list_properties(G_OBJECT_GET_CLASS (element),
&num_props);
prop_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (element),
&num_props);
for(std::size_t i = 0; i<num_props; i++)
{
GParamSpec *param = prop_specs[i];
for (std::size_t i = 0; i < num_props; i++) {
GParamSpec *param = prop_specs[i];
if(G_IS_PARAM_SPEC_ENUM(param))
addParamEnum(param, element, play);
else if(G_IS_PARAM_SPEC_FLAGS(param))
addParamFlags(param, element, play);
else
addParamSimple(param, element, play);
}
if (G_IS_PARAM_SPEC_ENUM (param))
addParamEnum (param, element, play);
else if (G_IS_PARAM_SPEC_FLAGS (param))
addParamFlags (param, element, play);
else
addParamSimple (param, element, play);
}
QVBoxLayout *pvblay = new QVBoxLayout;
QWidget *pwgt = new QWidget(this);
pwgt -> setLayout(play);
QScrollArea *pscroll = new QScrollArea(this);
pscroll -> setWidget(pwgt);
QVBoxLayout *pvblay = new QVBoxLayout;
QWidget *pwgt = new QWidget (this);
pwgt->setLayout (play);
QScrollArea *pscroll = new QScrollArea (this);
pscroll->setWidget (pwgt);
pvblay -> addWidget(pscroll);
pvblay->addWidget (pscroll);
QHBoxLayout *phblay = new QHBoxLayout;
QHBoxLayout *phblay = new QHBoxLayout;
QPushButton *pcmdApply = new QPushButton("Apply");
QPushButton *pcmdOk = new QPushButton("OK");
QPushButton *pcmdCancel = new QPushButton("Cancel");
QPushButton *pcmdApply = new QPushButton ("Apply");
QPushButton *pcmdOk = new QPushButton ("OK");
QPushButton *pcmdCancel = new QPushButton ("Cancel");
phblay->addStretch (1);
phblay->addWidget (pcmdApply);
phblay->addWidget (pcmdCancel);
phblay->addWidget (pcmdOk);
phblay -> addStretch(1);
phblay -> addWidget(pcmdApply);
phblay -> addWidget(pcmdCancel);
phblay -> addWidget(pcmdOk);
pvblay->addLayout (phblay);
pvblay -> addLayout(phblay);
QObject::connect (pcmdApply, SIGNAL (clicked ()), this,
SLOT (applyClicked ()));
QObject::connect (pcmdCancel, SIGNAL (clicked ()), this, SLOT (close ()));
QObject::connect (pcmdOk, SIGNAL (clicked ()), this, SLOT (okClicked ()));
QObject::connect(pcmdApply, SIGNAL(clicked()), this, SLOT(applyClicked()));
QObject::connect(pcmdCancel, SIGNAL(clicked()), this, SLOT(close()));
QObject::connect(pcmdOk, SIGNAL(clicked()), this, SLOT(okClicked()));
setLayout (pvblay);
setLayout(pvblay);
g_free(prop_specs);
gst_object_unref(element);
g_free (prop_specs);
gst_object_unref (element);
}
void ElementProperties::applyClicked()
void
ElementProperties::applyClicked ()
{
GstElement *element = gst_bin_get_by_name (GST_BIN(m_pGraphManager -> m_pGraph),
m_name.toStdString().c_str());
GstElement *element = gst_bin_get_by_name (
GST_BIN (m_pGraphManager->m_pGraph), m_name.toStdString ().c_str ());
if(!element)
return;
if (!element)
return;
QMap<QString, QWidget *>::iterator itr = m_values.begin();
QMap<QString, QWidget *>::iterator itr = m_values.begin ();
for(;itr != m_values.end(); itr++)
{
GParamSpec *param = g_object_class_find_property(G_OBJECT_GET_CLASS (element),
itr.key().toStdString().c_str());
for (; itr != m_values.end (); itr++) {
GParamSpec *param = g_object_class_find_property (
G_OBJECT_GET_CLASS (element), itr.key ().toStdString ().c_str ());
if(!param)
{
qDebug() << "problem with setting " << itr.key() << " property";
continue;
}
if (!param) {
qDebug () << "problem with setting " << itr.key () << " property";
continue;
}
if(!(param -> flags & G_PARAM_WRITABLE))
continue;
if (!(param->flags & G_PARAM_WRITABLE))
continue;
QString valStr;
QString valStr;
if(dynamic_cast<QLineEdit *>(itr.value()))
valStr = ((QLineEdit *) itr.value()) -> text();
else if(dynamic_cast<QComboBox *>(itr.value()))
{
QComboBox *pcomBox = (QComboBox *) itr.value();
int val = pcomBox -> itemData(pcomBox -> currentIndex()).toInt();
valStr = QString::number(val);
}
if (dynamic_cast<QLineEdit *> (itr.value ()))
valStr = ((QLineEdit *) itr.value ())->text ();
else if (dynamic_cast<QComboBox *> (itr.value ())) {
QComboBox *pcomBox = (QComboBox *) itr.value ();
int val = pcomBox->itemData (pcomBox->currentIndex ()).toInt ();
valStr = QString::number (val);
}
std::string tmpStr = itr.key().toStdString();
const char *propName = tmpStr.c_str();
std::string tmpStr = itr.key ().toStdString ();
const char *propName = tmpStr.c_str ();
if(G_IS_PARAM_SPEC_ENUM(param) || G_IS_PARAM_SPEC_FLAGS(param))
{
if(dynamic_cast<QComboBox *>(itr.value()))
{
QComboBox *pcomBox = (QComboBox *) itr.value();
int val = pcomBox -> itemData(pcomBox -> currentIndex()).toInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
}
}
else
{
switch (param -> value_type)
{
case G_TYPE_STRING:
{
g_object_set(G_OBJECT(element), propName, valStr.toStdString().c_str(), NULL);
break;
}
case G_TYPE_BOOLEAN:
{
gboolean val = valStr.toInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_ULONG:
{
gulong val = valStr.toULong();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_LONG:
{
glong val = valStr.toLong();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_UINT:
{
guint val = valStr.toUInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_INT:
{
gint val = valStr.toInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_UINT64:
{
guint64 val = valStr.toULongLong();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_INT64:
{
gint64 val = valStr.toLongLong();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_FLOAT:
{
gfloat val = valStr.toFloat();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_DOUBLE:
{
gdouble val = valStr.toDouble();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_CHAR:
{
gchar val = valStr.toInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
case G_TYPE_UCHAR:
{
guchar val = valStr.toUInt();
g_object_set(G_OBJECT(element), propName, val, NULL);
break;
}
default:
{
qDebug() << "property " << itr.key() << " not supported";
break;
}
};
}
}
if (G_IS_PARAM_SPEC_ENUM (param) || G_IS_PARAM_SPEC_FLAGS (param)) {
if (dynamic_cast<QComboBox *> (itr.value ())) {
QComboBox *pcomBox = (QComboBox *) itr.value ();
int val = pcomBox->itemData (pcomBox->currentIndex ()).toInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
}
}
else {
switch (param->value_type) {
case G_TYPE_STRING: {
g_object_set (G_OBJECT (element), propName,
valStr.toStdString ().c_str (), NULL);
break;
}
case G_TYPE_BOOLEAN: {
gboolean val = valStr.toInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_ULONG: {
gulong val = valStr.toULong ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_LONG: {
glong val = valStr.toLong ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_UINT: {
guint val = valStr.toUInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_INT: {
gint val = valStr.toInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_UINT64: {
guint64 val = valStr.toULongLong ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_INT64: {
gint64 val = valStr.toLongLong ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_FLOAT: {
gfloat val = valStr.toFloat ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_DOUBLE: {
gdouble val = valStr.toDouble ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_CHAR: {
gchar val = valStr.toInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
case G_TYPE_UCHAR: {
guchar val = valStr.toUInt ();
g_object_set (G_OBJECT (element), propName, val, NULL);
break;
}
default: {
qDebug () << "property " << itr.key () << " not supported";
break;
}
};
}
}
gst_object_unref(element);
gst_object_unref (element);
delete layout();
qDeleteAll(children());
delete layout ();
qDeleteAll (
children ());
create();
create ();
}
void ElementProperties::okClicked()
void
ElementProperties::okClicked ()
{
applyClicked();
close();
applyClicked ();
close ();
}

View file

@ -12,26 +12,24 @@
class ElementProperties: public QWidget
{
Q_OBJECT
Q_OBJECT
public:
ElementProperties(QSharedPointer<GraphManager> pGraphManager, const char *name,
QWidget *parent = 0, Qt::WindowFlags flags = 0);
ElementProperties(QSharedPointer<GraphManager> pGraphManager, const char *name,
QWidget *parent = 0, Qt::WindowFlags flags = 0);
private slots:
void applyClicked();
void okClicked();
void applyClicked();
void okClicked();
private:
QSharedPointer<GraphManager> m_pGraphManager;
QMap<QString, QWidget *> m_values;
QString m_name;
QSharedPointer<GraphManager> m_pGraphManager;
QMap<QString, QWidget *> m_values;
QString m_name;
void create();
void addParamSimple(GParamSpec *value, GstElement *element, QGridLayout *play);
void addParamEnum(GParamSpec *value, GstElement *element, QGridLayout *play);
void addParamFlags(GParamSpec *value, GstElement *element, QGridLayout *play);
void create();
void addParamSimple(GParamSpec *value, GstElement *element, QGridLayout *play);
void addParamEnum(GParamSpec *value, GstElement *element, QGridLayout *play);
void addParamFlags(GParamSpec *value, GstElement *element, QGridLayout *play);
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -7,88 +7,81 @@
#include <QSharedPointer>
#include <QPoint>
#include "GraphManager.h"
#include <vector>
class GraphDisplay: public QWidget
{
Q_OBJECT
Q_OBJECT
public:
GraphDisplay(QWidget *parent=0, Qt::WindowFlags f=0);
void update(const std::vector <ElementInfo> &info);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
GraphDisplay(QWidget *parent=0, Qt::WindowFlags f=0);
void update(const std::vector <ElementInfo> &info);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void keyPressEvent(QKeyEvent* event);
void keyPressEvent(QKeyEvent* event);
QSharedPointer<GraphManager> m_pGraph;
QSharedPointer<GraphManager> m_pGraph;
private slots:
void addRequestPad(int row, int collumn);
void addRequestPad(int row, int collumn);
private:
enum MoveAction
{
None = 0,
MoveComponent,
MakeConnect,
Select
};
enum MoveAction
{
None = 0,
MoveComponent,
MakeConnect,
Select
};
struct MoveInfo
{
MoveInfo(): m_action(None)
{
}
struct MoveInfo
{
MoveInfo(): m_action(None)
{
}
MoveAction m_action;
size_t m_elementId;
size_t m_padId;
QPoint m_position;
QPoint m_startPosition;
};
MoveAction m_action;
size_t m_elementId;
size_t m_padId;
QPoint m_position;
QPoint m_startPosition;
};
struct ElementDisplayInfo
{
QRect m_rect;
size_t m_id;
std::string m_name;
bool m_isSelected;
};
struct ElementDisplayInfo
{
QRect m_rect;
size_t m_id;
std::string m_name;
bool m_isSelected;
};
void calculatePositions();
void updateDisplayInfoIds();
ElementDisplayInfo calculateOnePosition(const ElementInfo &info);
void showContextMenu(QMouseEvent *event);
void showElementProperties(std::size_t id);
void showPadProperties(std::size_t elementId, std::size_t padId);
void renderPad(std::size_t elementId, std::size_t padId, bool capsAny);
void removePlugin(std::size_t id);
void removeSelected();
void getIdByPosition(const QPoint &pos, std::size_t &elementId, std::size_t &padId);
QPoint getPadPosition(std::size_t elementId, std::size_t padId);
void disconnect(std::size_t elementId, std::size_t padId);
void requestPad(std::size_t elementId);
void connectPlugin(std::size_t elementId, const QString& destElementName);
void calculatePositions();
void updateDisplayInfoIds();
ElementDisplayInfo calculateOnePosition(const ElementInfo &info);
void showContextMenu(QMouseEvent *event);
void showElementProperties(std::size_t id);
void showPadProperties(std::size_t elementId, std::size_t padId);
void renderPad(std::size_t elementId, std::size_t padId, bool capsAny);
void removePlugin(std::size_t id);
void removeSelected();
void getIdByPosition(const QPoint &pos, std::size_t &elementId, std::size_t &padId);
QPoint getPadPosition(std::size_t elementId, std::size_t padId);
void disconnect(std::size_t elementId, std::size_t padId);
void requestPad(std::size_t elementId);
void connectPlugin(std::size_t elementId, const QString& destElementName);
ElementInfo* getElement(std::size_t elementId);
PadInfo* getPad(std::size_t elementId, std::size_t padId);
ElementInfo* getElement(std::size_t elementId);
PadInfo* getPad(std::size_t elementId, std::size_t padId);
std::vector <ElementInfo> m_info;
std::vector <ElementDisplayInfo> m_displayInfo;
std::vector <ElementInfo> m_info;
std::vector <ElementDisplayInfo> m_displayInfo;
MoveInfo m_moveInfo;
MoveInfo m_moveInfo;
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -81,6 +81,7 @@ struct ElementInfo
class GraphManager
{
public:
GraphManager();
~GraphManager();
@ -111,8 +112,6 @@ public:
GstElement *m_pGraph;
PluginsList *m_pluginsList;
};
#endif

View file

@ -33,345 +33,356 @@
#include <gst/gst.h>
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags flags):
QMainWindow(parent, flags)
,m_pGraph(new GraphManager)
MainWindow::MainWindow (QWidget *parent, Qt::WindowFlags flags)
: QMainWindow (parent, flags),
m_pGraph (new GraphManager)
{
QToolBar *ptb = addToolBar("Menu");
QToolBar *ptb = addToolBar ("Menu");
QAction *pactAdd = ptb -> addAction("Add...");
pactAdd -> setShortcut(QKeySequence("Ctrl+F"));
connect(pactAdd, SIGNAL(triggered()), SLOT(AddPlugin()));
QAction *pactAdd = ptb->addAction ("Add...");
pactAdd->setShortcut (QKeySequence ("Ctrl+F"));
connect (pactAdd, SIGNAL (triggered ()), SLOT (AddPlugin ()));
QAction *pactOpenFile = ptb->addAction ("Open Media File...");
connect (pactOpenFile, SIGNAL (triggered ()), SLOT (OpenMediaFile ()));
QAction *pactOpenFile = ptb -> addAction("Open Media File...");
connect(pactOpenFile, SIGNAL(triggered()), SLOT(OpenMediaFile()));
ptb->addSeparator ();
ptb -> addSeparator();
QPixmap pxPlay (24, 24);
pxPlay.fill (QColor (0, 0, 0, 0));
QPainter pntrPlay (&pxPlay);
pntrPlay.setPen (Qt::darkGreen);
pntrPlay.setBrush (QBrush (Qt::darkGreen));
QPixmap pxPlay(24, 24);
pxPlay.fill(QColor(0, 0, 0, 0));
QPainter pntrPlay(&pxPlay);
pntrPlay.setPen(Qt::darkGreen);
pntrPlay.setBrush(QBrush(Qt::darkGreen));
QPolygon polygon (3);
polygon.setPoint (0, 4, 4);
polygon.setPoint (1, 4, 20);
polygon.setPoint (2, 20, 12);
QPolygon polygon(3);
polygon.setPoint(0, 4, 4);
polygon.setPoint(1, 4, 20);
polygon.setPoint(2, 20, 12);
pntrPlay.drawPolygon (polygon, Qt::WindingFill);
pntrPlay.drawPolygon(polygon, Qt::WindingFill);
QAction *pactPlay = ptb -> addAction(QIcon(pxPlay), "Play");
connect(pactPlay, SIGNAL(triggered()), SLOT(Play()));
QAction *pactPlay = ptb->addAction (QIcon (pxPlay), "Play");
connect (pactPlay, SIGNAL (triggered ()), SLOT (Play ()));
QPixmap pxPause(24, 24);
pxPause.fill(QColor(0, 0, 0, 0));
QPainter pntrPause(&pxPause);
pntrPause.setPen(Qt::darkGray);
pntrPause.setBrush(QBrush(Qt::darkGray));
QPixmap pxPause (24, 24);
pxPause.fill (QColor (0, 0, 0, 0));
QPainter pntrPause (&pxPause);
pntrPause.setPen (Qt::darkGray);
pntrPause.setBrush (QBrush (Qt::darkGray));
pntrPause.drawRect(8, 4, 3, 16);
pntrPause.drawRect(13, 4, 3, 16);
pntrPause.drawRect (8, 4, 3, 16);
pntrPause.drawRect (13, 4, 3, 16);
QAction *pactPause = ptb -> addAction(QIcon(pxPause), "Pause");
connect(pactPause, SIGNAL(triggered()), SLOT(Pause()));
QAction *pactPause = ptb->addAction (QIcon (pxPause), "Pause");
connect (pactPause, SIGNAL (triggered ()), SLOT (Pause ()));
QPixmap pxStop(24, 24);
pxStop.fill(QColor(0, 0, 0, 0));
QPainter pntrStop(&pxStop);
pntrStop.setPen(Qt::darkRed);
pntrStop.setBrush(QBrush(Qt::darkRed));
QPixmap pxStop (24, 24);
pxStop.fill (QColor (0, 0, 0, 0));
QPainter pntrStop (&pxStop);
pntrStop.setPen (Qt::darkRed);
pntrStop.setBrush (QBrush (Qt::darkRed));
pntrStop.drawRect(6, 6, 12, 12);
pntrStop.drawRect (6, 6, 12, 12);
QAction *pactStop = ptb -> addAction(QIcon(pxStop), "Stop");
connect(pactStop, SIGNAL(triggered()), SLOT(Stop()));
QAction *pactStop = ptb->addAction (QIcon (pxStop), "Stop");
connect (pactStop, SIGNAL (triggered ()), SLOT (Stop ()));
QPixmap pxFulsh(24, 24);
pxFulsh.fill(QColor(0, 0, 0, 0));
QPainter pntrFlush(&pxFulsh);
pntrFlush.setPen(Qt::darkGreen);
pntrFlush.setBrush(QBrush(Qt::darkGreen));
QPixmap pxFulsh (24, 24);
pxFulsh.fill (QColor (0, 0, 0, 0));
QPainter pntrFlush (&pxFulsh);
pntrFlush.setPen (Qt::darkGreen);
pntrFlush.setBrush (QBrush (Qt::darkGreen));
pntrFlush.drawRect(3, 4, 3, 16);
pntrFlush.drawRect (3, 4, 3, 16);
polygon = QPolygon(3);
polygon.setPoint(0, 9, 4);
polygon.setPoint(1, 9, 20);
polygon.setPoint(2, 21, 12);
polygon = QPolygon (3);
polygon.setPoint (0, 9, 4);
polygon.setPoint (1, 9, 20);
polygon.setPoint (2, 21, 12);
pntrFlush.drawPolygon(polygon, Qt::WindingFill);
pntrFlush.drawPolygon (polygon, Qt::WindingFill);
QAction *pactFlush = ptb -> addAction(QIcon(pxFulsh), "Flush");
connect(pactFlush, SIGNAL(triggered()), SLOT(Flush()));
QAction *pactFlush = ptb->addAction (QIcon (pxFulsh), "Flush");
connect (pactFlush, SIGNAL (triggered ()), SLOT (Flush ()));
QAction *pactClear = ptb -> addAction("Clear");
connect(pactClear, SIGNAL(triggered()), SLOT(ClearGraph()));
ptb -> addSeparator();
QAction *pactClear = ptb->addAction ("Clear");
connect (pactClear, SIGNAL (triggered ()), SLOT (ClearGraph ()));
ptb->addSeparator ();
m_pslider = new SeekSlider();
m_pslider -> setOrientation(Qt::Horizontal);
m_pslider -> setRange(0, 10000);
m_pslider -> setTracking(false);
m_pslider = new SeekSlider ();
m_pslider->setOrientation (Qt::Horizontal);
m_pslider->setRange (0, 10000);
m_pslider->setTracking (false);
connect(m_pslider, SIGNAL(valueChanged(int)), SLOT(Seek(int)));
ptb -> addWidget(m_pslider);
connect(m_pslider, SIGNAL(valueChanged(int)), SLOT(Seek(int)));
ptb->addWidget (m_pslider);
QMenu *pmenu = menuBar() -> addMenu("&File");
QMenu *pmenu = menuBar ()->addMenu ("&File");
QAction *pactOpen = pmenu -> addAction ("Open...", this, SLOT(Open()), QKeySequence::Open);
addAction (pactOpen);
QAction *pactOpenMediaFile = pmenu -> addAction ("Open Media File...", this, SLOT(OpenMediaFile()), QKeySequence::Open);
addAction (pactOpenMediaFile);
QAction *pactOpen = pmenu->addAction ("Open...", this, SLOT (Open ()),
QKeySequence::Open);
addAction (pactOpen);
QAction *pactSave = pmenu -> addAction ("Save", this, SLOT(Save()), QKeySequence::Save);
addAction (pactSave);
QAction *pactOpenMediaFile = pmenu->addAction ("Open Media File...", this,
SLOT (OpenMediaFile ()),
QKeySequence::Open);
addAction (pactOpenMediaFile);
QAction *pactSaveAs = pmenu -> addAction ("Save As...", this, SLOT(SaveAs()), QKeySequence::SaveAs);
addAction (pactSaveAs);
QAction *pactSave = pmenu->addAction ("Save", this, SLOT (Save ()),
QKeySequence::Save);
addAction (pactSave);
pmenu -> addSeparator();
pmenu -> addAction("Exit", this, SLOT(close()));
QAction *pactSaveAs = pmenu->addAction ("Save As...", this, SLOT (SaveAs ()),
QKeySequence::SaveAs);
addAction (pactSaveAs);
pmenu->addSeparator ();
pmenu->addAction ("Exit", this, SLOT (close ()));
pmenu = menuBar() -> addMenu("&Graph");
pmenu = menuBar ()->addMenu ("&Graph");
pmenu -> addAction(pactAdd);
pmenu -> addAction(pactOpenMediaFile);
pmenu -> addAction ("Open Media Uri...", this, SLOT(OpenMediaUri()));
pmenu -> addSeparator();
pmenu -> addAction(pactPlay);
pmenu -> addAction(pactPause);
pmenu -> addAction(pactStop);
pmenu -> addAction(pactFlush);
pmenu -> addSeparator();
pmenu -> addAction(pactClear);
pmenu->addAction (pactAdd);
pmenu->addAction (pactOpenMediaFile);
pmenu->addAction ("Open Media Uri...", this, SLOT (OpenMediaUri ()));
pmenu->addSeparator ();
pmenu->addAction (pactPlay);
pmenu->addAction (pactPause);
pmenu->addAction (pactStop);
pmenu->addAction (pactFlush);
pmenu->addSeparator ();
pmenu->addAction (pactClear);
pmenu = menuBar ()->addMenu ("&Help");
pmenu = menuBar() -> addMenu("&Help");
pmenu->addAction ("About pipeviz...", this, SLOT (About ()));
pmenu -> addAction ("About pipeviz...", this, SLOT(About()));
m_pGraphDisplay = new GraphDisplay;
m_pGraphDisplay = new GraphDisplay;
QScrollArea *pscroll = new QScrollArea;
pscroll -> setWidget(m_pGraphDisplay);
pscroll -> setWidgetResizable(false);
m_pGraphDisplay -> resize(10000, 10000);
m_pGraphDisplay -> m_pGraph = m_pGraph;
setCentralWidget(pscroll);
m_pstatusBar = new QStatusBar;
setStatusBar(m_pstatusBar);
m_pluginListDlg = new PluginsListDialog(m_pGraph->getPluginsList(), this);
m_pluginListDlg->setModal(false);
restoreGeometry(CustomSettings::mainWindowGeometry());
startTimer(100);
QScrollArea *pscroll = new QScrollArea;
pscroll->setWidget (m_pGraphDisplay);
pscroll->setWidgetResizable (false);
m_pGraphDisplay->resize (10000, 10000);
m_pGraphDisplay->m_pGraph = m_pGraph;
setCentralWidget (pscroll);
m_pstatusBar = new QStatusBar;
setStatusBar (m_pstatusBar);
m_pluginListDlg = new PluginsListDialog (m_pGraph->getPluginsList (), this);
m_pluginListDlg->setModal (false);
restoreGeometry (CustomSettings::mainWindowGeometry ());
startTimer (100);
}
MainWindow::~MainWindow()
MainWindow::~MainWindow ()
{
CustomSettings::saveMainWindowGeometry(saveGeometry());
delete m_pluginListDlg;
CustomSettings::saveMainWindowGeometry (saveGeometry ());
delete m_pluginListDlg;
}
void MainWindow::AddPlugin()
void
MainWindow::AddPlugin ()
{
m_pluginListDlg->setGraph(m_pGraph.data());
m_pluginListDlg->show();
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
m_pGraphDisplay -> update(info);
m_pluginListDlg->setGraph (m_pGraph.data ());
m_pluginListDlg->show ();
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
m_pGraphDisplay->update (info);
}
void MainWindow::OpenMediaFile()
void
MainWindow::OpenMediaFile ()
{
QString dir = CustomSettings::lastIODirectory();
QString dir = CustomSettings::lastIODirectory ();
QString path = QFileDialog::getOpenFileName(this, "Open File...", dir);
if(!path.isEmpty())
{
gchar *uri = gst_filename_to_uri(path.toStdString().c_str(), NULL);
if(uri)
{
qDebug() << "Open Source file: " << path;
QString path = QFileDialog::getOpenFileName (this, "Open File...", dir);
if (!path.isEmpty ()) {
gchar *uri = gst_filename_to_uri (path.toStdString ().c_str (), NULL);
if (uri) {
qDebug () << "Open Source file: " << path;
m_pGraph -> OpenUri(uri, NULL);
g_free(uri);
m_pGraph->OpenUri (uri, NULL);
g_free (uri);
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
m_pGraphDisplay -> update(info);
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
m_pGraphDisplay->update (info);
QString dir = QFileInfo(path).absoluteDir().absolutePath();
CustomSettings::saveLastIODirectory(dir);
}
}
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
CustomSettings::saveLastIODirectory (dir);
}
}
}
void MainWindow::OpenMediaUri()
void
MainWindow::OpenMediaUri ()
{
QString uri = QInputDialog::getText(this, "Open Uri...", "Uri:");
QString uri = QInputDialog::getText (this, "Open Uri...", "Uri:");
if(!uri.isEmpty())
{
qDebug() << "Open uri: " << uri;
m_pGraph -> OpenUri(uri.toStdString().c_str(), NULL);
if (!uri.isEmpty ()) {
qDebug () << "Open uri: " << uri;
m_pGraph->OpenUri (uri.toStdString ().c_str (), NULL);
std::vector<ElementInfo> info = m_pGraph -> GetInfo();
m_pGraphDisplay -> update(info);
}
std::vector<ElementInfo> info = m_pGraph->GetInfo ();
m_pGraphDisplay->update (info);
}
}
void MainWindow::Play()
void
MainWindow::Play ()
{
qDebug() << "Play";
m_pGraph -> Play();
qDebug () << "Play";
m_pGraph->Play ();
}
void MainWindow::Pause()
void
MainWindow::Pause ()
{
qDebug() << "Pause";
m_pGraph -> Pause();
qDebug () << "Pause";
m_pGraph->Pause ();
}
void MainWindow::Stop()
void
MainWindow::Stop ()
{
qDebug() << "Stop";
m_pGraph -> Stop();
qDebug () << "Stop";
m_pGraph->Stop ();
}
void MainWindow::Flush()
void
MainWindow::Flush ()
{
qDebug() << "Flush";
qDebug () << "Flush";
if(m_pGraph -> m_pGraph)
{
gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_start());
if (m_pGraph->m_pGraph) {
gst_element_send_event (GST_ELEMENT (m_pGraph->m_pGraph),
gst_event_new_flush_start ());
#if GST_VERSION_MAJOR >= 1
gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_stop(true));
gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_stop(true));
#else
gst_element_send_event(GST_ELEMENT(m_pGraph -> m_pGraph), gst_event_new_flush_stop());
gst_element_send_event (GST_ELEMENT (m_pGraph->m_pGraph),
gst_event_new_flush_stop ());
#endif
}
}
}
void MainWindow::ClearGraph()
void
MainWindow::ClearGraph ()
{
qDebug() << "ClearGraph";
PipelineIE::Clear(m_pGraph);
qDebug () << "ClearGraph";
PipelineIE::Clear (m_pGraph);
}
void MainWindow::Seek(int val)
void
MainWindow::Seek (int val)
{
if(m_pGraph -> SetPosition((double)(val) / m_pslider -> maximum()))
qDebug() << "Seek to" << val;
else
qDebug() << "Seek to" << val << "was FAILED";
if (m_pGraph->SetPosition ((double) (val) / m_pslider->maximum ()))
qDebug () << "Seek to" << val;
else
qDebug () << "Seek to" << val << "was FAILED";
}
void MainWindow::timerEvent(QTimerEvent *)
void
MainWindow::timerEvent (QTimerEvent *)
{
GstState state;
GstStateChangeReturn res = gst_element_get_state (m_pGraph -> m_pGraph, &state, NULL, GST_MSECOND);
GstState state;
GstStateChangeReturn res = gst_element_get_state (m_pGraph->m_pGraph, &state,
NULL,
GST_MSECOND);
if(res == GST_STATE_CHANGE_SUCCESS)
{
QString str;
switch(state)
{
case GST_STATE_VOID_PENDING:
str = "Pending";
break;
case GST_STATE_NULL:
str = "Null";
break;
case GST_STATE_READY:
str = "Ready";
break;
case GST_STATE_PAUSED:
str = "Paused";
break;
case GST_STATE_PLAYING:
str = "Playing";
break;
};
if (res == GST_STATE_CHANGE_SUCCESS) {
QString str;
switch (state) {
case GST_STATE_VOID_PENDING:
str = "Pending";
break;
case GST_STATE_NULL:
str = "Null";
break;
case GST_STATE_READY:
str = "Ready";
break;
case GST_STATE_PAUSED:
str = "Paused";
break;
case GST_STATE_PLAYING:
str = "Playing";
break;
};
m_pstatusBar -> showMessage(str);
}
else
{
m_pstatusBar -> showMessage(QString(gst_element_state_change_return_get_name(res)));
}
m_pstatusBar->showMessage (str);
}
else {
m_pstatusBar->showMessage (
QString (gst_element_state_change_return_get_name (res)));
}
double pos = m_pGraph -> GetPosition();
double pos = m_pGraph->GetPosition ();
if(m_pslider -> value() != (int)(m_pslider -> maximum() * pos))
m_pslider -> setSliderPosition(m_pslider -> maximum() * pos);
if (m_pslider->value () != (int) (m_pslider->maximum () * pos))
m_pslider->setSliderPosition (m_pslider->maximum () * pos);
m_pGraphDisplay -> update(m_pGraph -> GetInfo());
m_pGraphDisplay->update (m_pGraph->GetInfo ());
}
void MainWindow::Save()
void
MainWindow::Save ()
{
if(m_fileName.isEmpty())
SaveAs();
else {
QFileInfo fileInfo(m_fileName);
if (fileInfo.completeSuffix().isEmpty() || fileInfo.completeSuffix() != "gpi")
m_fileName = m_fileName + ".gpi";
if (m_fileName.isEmpty ())
SaveAs ();
else {
QFileInfo fileInfo (m_fileName);
if (fileInfo.completeSuffix ().isEmpty ()
|| fileInfo.completeSuffix () != "gpi")
m_fileName = m_fileName + ".gpi";
PipelineIE::Export (m_pGraph, m_fileName);
PipelineIE::Export(m_pGraph, m_fileName);
}
}
}
void MainWindow::SaveAs()
void
MainWindow::SaveAs ()
{
QString dir = CustomSettings::lastIODirectory();
QString dir = CustomSettings::lastIODirectory ();
QString path = QFileDialog::getSaveFileName(this, "Save As...", dir, tr("*.gpi"));
QString path = QFileDialog::getSaveFileName (this, "Save As...", dir,
tr ("*.gpi"));
if(!path.isEmpty())
{
m_fileName = path;
Save();
if (!path.isEmpty ()) {
m_fileName = path;
Save ();
QString dir = QFileInfo(path).absoluteDir().absolutePath();
CustomSettings::saveLastIODirectory(dir);
}
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
CustomSettings::saveLastIODirectory (dir);
}
}
void MainWindow::Open()
void
MainWindow::Open ()
{
QString dir = CustomSettings::lastIODirectory();
QString dir = CustomSettings::lastIODirectory ();
QString path = QFileDialog::getOpenFileName(this, "Open...", dir, tr("GPI (*.gpi *.xpm);;All files (*.*)"));
QString path = QFileDialog::getOpenFileName (
this, "Open...", dir, tr ("GPI (*.gpi *.xpm);;All files (*.*)"));
if(!path.isEmpty())
{
if(PipelineIE::Import(m_pGraph, path))
m_fileName = path;
if (!path.isEmpty ()) {
if (PipelineIE::Import (m_pGraph, path))
m_fileName = path;
QString dir = QFileInfo(path).absoluteDir().absolutePath();
CustomSettings::saveLastIODirectory(dir);
}
QString dir = QFileInfo (path).absoluteDir ().absolutePath ();
CustomSettings::saveLastIODirectory (dir);
}
}
void MainWindow::About()
void
MainWindow::About ()
{
QString message;
message = "<center><b>pipeviz</b></center><br>";
message = "<center>virinext@gmail.com</center><br>";
message += QString("<center>Version: ") + VERSION_STR + "</center><br>";
message += "<center>GUI Based on Qt</center>";
message += "<center>using ";
message += gst_version_string();
message += "</center>";
QString message;
message = "<center><b>pipeviz</b></center><br>";
message = "<center>virinext@gmail.com</center><br>";
message += QString ("<center>Version: ") + VERSION_STR + "</center><br>";
message += "<center>GUI Based on Qt</center>";
message += "<center>using ";
message += gst_version_string ();
message += "</center>";
QMessageBox::about(this, "About", message);
QMessageBox::about (this, "About", message);
}

View file

@ -19,41 +19,40 @@ class PluginsListDialog;
class MainWindow: public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~MainWindow();
Q_OBJECT
public:
MainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
~MainWindow();
protected:
void timerEvent(QTimerEvent *);
protected:
void timerEvent(QTimerEvent *);
private slots:
void AddPlugin();
void OpenMediaFile();
void OpenMediaUri();
void Play();
void Pause();
void Stop();
void Flush();
void Seek(int);
private slots:
void AddPlugin();
void OpenMediaFile();
void OpenMediaUri();
void Play();
void Pause();
void Stop();
void Flush();
void Seek(int);
void Save();
void SaveAs();
void Open();
void Save();
void SaveAs();
void Open();
void ClearGraph();
void About();
void ClearGraph();
void About();
private:
QSharedPointer<GraphManager> m_pGraph;
GraphDisplay *m_pGraphDisplay;
private:
QSharedPointer<GraphManager> m_pGraph;
GraphDisplay *m_pGraphDisplay;
QStatusBar *m_pstatusBar;
QSlider *m_pslider;
QStatusBar *m_pstatusBar;
QSlider *m_pslider;
QString m_fileName;
PluginsListDialog *m_pluginListDlg;
QString m_fileName;
PluginsListDialog *m_pluginListDlg;
};
#endif

View file

@ -8,96 +8,99 @@
#include <gst/gst.h>
PadProperties::PadProperties(QSharedPointer<GraphManager> pGraphManager, const char *elementName, const char *padName,
QWidget *parent, Qt::WindowFlags flags):
QWidget(parent, flags)
PadProperties::PadProperties (QSharedPointer<GraphManager> pGraphManager,
const char *elementName, const char *padName,
QWidget *parent, Qt::WindowFlags flags)
: QWidget (parent, flags)
{
setWindowTitle(QString(elementName) + "::" + padName + " properties");
GstElement *element = gst_bin_get_by_name (GST_BIN(pGraphManager -> m_pGraph), elementName);
setWindowTitle (QString (elementName) + "::" + padName + " properties");
GstElement *element = gst_bin_get_by_name (GST_BIN (pGraphManager->m_pGraph),
elementName);
if(!element)
return;
if (!element)
return;
GstPad *pad = gst_element_get_static_pad(GST_ELEMENT(element), padName);
GstPad *pad = gst_element_get_static_pad (GST_ELEMENT (element), padName);
QGridLayout *play = new QGridLayout;
QGridLayout *play = new QGridLayout;
play -> addWidget(new QLabel("Name"), 0, 0);
play->addWidget (new QLabel ("Name"), 0, 0);
QLabel *plbl = new QLabel(padName);
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play -> addWidget(plbl, 0, 1);
QLabel *plbl = new QLabel (padName);
plbl->setTextInteractionFlags (
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play->addWidget (plbl, 0, 1);
play -> addWidget(new QLabel("All caps:"), 1, 0);
play->addWidget (new QLabel ("All caps:"), 1, 0);
#if GST_VERSION_MAJOR >= 1
GstCaps *caps = gst_pad_query_caps(pad, NULL);
GstCaps *caps = gst_pad_query_caps(pad, NULL);
#else
GstCaps *caps = gst_pad_get_caps(pad);
GstCaps *caps = gst_pad_get_caps (pad);
#endif
gchar *str;
gchar *noSpecified = (gchar *)"not specified";
if(caps)
str = gst_caps_to_string(caps);
else
str = noSpecified;
gchar *str;
gchar *noSpecified = (gchar *) "not specified";
if (caps)
str = gst_caps_to_string (caps);
else
str = noSpecified;
plbl = new QLabel(QString(str));
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play -> addWidget(plbl, 1, 1);
if(caps)
{
g_free(str);
gst_caps_unref(caps);
}
plbl = new QLabel (QString (str));
plbl->setTextInteractionFlags (
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play->addWidget (plbl, 1, 1);
if (caps) {
g_free (str);
gst_caps_unref (caps);
}
play -> addWidget(new QLabel("Allowed caps:"), 2, 0);
caps = gst_pad_get_allowed_caps(pad);
str = NULL;
if(caps)
str = gst_caps_to_string(caps);
else
str = noSpecified;
play->addWidget (new QLabel ("Allowed caps:"), 2, 0);
caps = gst_pad_get_allowed_caps (pad);
str = NULL;
if (caps)
str = gst_caps_to_string (caps);
else
str = noSpecified;
plbl = new QLabel(QString(str));
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play -> addWidget(plbl, 2, 1);
if(caps)
{
g_free(str);
gst_caps_unref(caps);
}
plbl = new QLabel (QString (str));
plbl->setTextInteractionFlags (
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play->addWidget (plbl, 2, 1);
if (caps) {
g_free (str);
gst_caps_unref (caps);
}
play -> addWidget(new QLabel("Current caps"), 3, 0);
play->addWidget (new QLabel ("Current caps"), 3, 0);
#if GST_VERSION_MAJOR >= 1
caps = gst_pad_get_current_caps(pad);
caps = gst_pad_get_current_caps(pad);
#else
caps = gst_pad_get_negotiated_caps(pad);
caps = gst_pad_get_negotiated_caps (pad);
#endif
str = NULL;
if(caps)
str = gst_caps_to_string(caps);
else
str = noSpecified;
str = NULL;
if (caps)
str = gst_caps_to_string (caps);
else
str = noSpecified;
plbl = new QLabel(QString(str));
plbl -> setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play -> addWidget(plbl, 3, 1);
if(caps)
{
g_free(str);
gst_caps_unref(caps);
}
plbl = new QLabel (QString (str));
plbl->setTextInteractionFlags (
Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard);
play->addWidget (plbl, 3, 1);
if (caps) {
g_free (str);
gst_caps_unref (caps);
}
gst_object_unref(element);
gst_object_unref (pad);
gst_object_unref (element);
gst_object_unref (pad);
QVBoxLayout *pvblay = new QVBoxLayout;
QWidget *pwgt = new QWidget(this);
pwgt -> setLayout(play);
QScrollArea *pscroll = new QScrollArea(this);
pscroll -> setWidget(pwgt);
QVBoxLayout *pvblay = new QVBoxLayout;
QWidget *pwgt = new QWidget (this);
pwgt->setLayout (play);
QScrollArea *pscroll = new QScrollArea (this);
pscroll->setWidget (pwgt);
pvblay -> addWidget(pscroll);
pvblay->addWidget (pscroll);
setLayout(pvblay);
setLayout (pvblay);
}

View file

@ -9,9 +9,8 @@
class PadProperties: public QWidget
{
public:
PadProperties(QSharedPointer<GraphManager> pGraphManager, const char *element, const char *pad
, QWidget *parent = 0, Qt::WindowFlags flags = 0);
PadProperties(QSharedPointer<GraphManager> pGraphManager, const char *element, const char *pad
, QWidget *parent = 0, Qt::WindowFlags flags = 0);
};
#endif

File diff suppressed because it is too large Load diff

View file

@ -8,9 +8,9 @@
namespace PipelineIE
{
bool Export(QSharedPointer<GraphManager> pgraph, const QString &fileName);
bool Import(QSharedPointer<GraphManager> pgraph, const QString &fileName);
bool Clear(QSharedPointer<GraphManager> pgraph);
bool Export(QSharedPointer<GraphManager> pgraph, const QString &fileName);
bool Import(QSharedPointer<GraphManager> pgraph, const QString &fileName);
bool Clear(QSharedPointer<GraphManager> pgraph);
};
#endif

View file

@ -14,31 +14,34 @@
#include <QDebug>
static gint plugins_sort_cb (gconstpointer a, gconstpointer b)
static gint
plugins_sort_cb (gconstpointer a, gconstpointer b)
{
Plugin* p1 = (Plugin*)a;
Plugin* p2 = (Plugin*)b;
qDebug() << "Sort p1: " << p1 -> getName() << " and p2: " << p2 -> getName();
if (p1->getRank() > p2->getRank())
return 1;
else if (p1->getRank() == p2->getRank()) {
Plugin* p1 = (Plugin*) a;
Plugin* p2 = (Plugin*) b;
qDebug () << "Sort p1: " << p1->getName () << " and p2: " << p2->getName ();
if (p1->getRank () > p2->getRank ())
return 1;
else if (p1->getRank () == p2->getRank ()) {
return 0;
} else {
return -1;
}
else {
return -1;
}
}
PluginsList::PluginsList()
PluginsList::PluginsList ()
{
init();
init ();
}
PluginsList::~PluginsList()
PluginsList::~PluginsList ()
{
//g_list_free(m_pluginsList);
}
void PluginsList::init()
void
PluginsList::init ()
{
std::size_t num = 0;
GList *plugins;
@ -47,33 +50,30 @@ void PluginsList::init()
#if GST_VERSION_MAJOR >= 1
registry = gst_registry_get();
#else
registry = gst_registry_get_default();
registry = gst_registry_get_default ();
#endif
plugins = gst_registry_get_plugin_list(registry);
while(plugins)
{
plugins = gst_registry_get_plugin_list (registry);
while (plugins) {
GstPlugin *plugin;
plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
#if GST_VERSION_MAJOR >= 1
registry = gst_registry_get();
#else
registry = gst_registry_get_default();
registry = gst_registry_get_default ();
#endif
GList *features = gst_registry_get_feature_list_by_plugin (registry,
gst_plugin_get_name (plugin));
GList *features = gst_registry_get_feature_list_by_plugin (
registry, gst_plugin_get_name (plugin));
while(features)
{
while (features) {
GstPluginFeature *feature;
feature = GST_PLUGIN_FEATURE (features->data);
if(GST_IS_ELEMENT_FACTORY (feature))
{
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory;
factory = GST_ELEMENT_FACTORY (feature);
int rank = gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory));
Plugin* p = new Plugin(GST_OBJECT_NAME (factory), rank);
m_pluginsList = g_list_append(m_pluginsList, p);
int rank = gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory));
Plugin* p = new Plugin (GST_OBJECT_NAME (factory), rank);
m_pluginsList = g_list_append (m_pluginsList, p);
num++;
}
@ -82,220 +82,238 @@ void PluginsList::init()
}
}
GList* PluginsList::getSortedByRank()
GList*
PluginsList::getSortedByRank ()
{
GList* sorted_list = g_list_sort(m_pluginsList, plugins_sort_cb);
GList* sorted_list = g_list_sort (m_pluginsList, plugins_sort_cb);
return sorted_list;
}
GList* PluginsList::getPluginListByCaps(GstPadDirection direction, GstCaps* caps)
GList*
PluginsList::getPluginListByCaps (GstPadDirection direction, GstCaps* caps)
{
GList * caps_plugins_list = NULL;
GList *l,*p;
GList *l, *p;
for (l = m_pluginsList; l != NULL; l = l->next) {
Plugin* plugin = (Plugin*)(l->data);
GstElementFactory* factory = gst_element_factory_find(plugin->getName().toStdString().c_str());
if (factory) {
const GList* pads = gst_element_factory_get_static_pad_templates(factory);
for (p = (GList*)pads; p != NULL; p = p->next) {
GstStaticPadTemplate* padTemplate = (GstStaticPadTemplate*)(p->data);
if (padTemplate->direction == direction && gst_caps_can_intersect(caps, padTemplate->static_caps.caps))
caps_plugins_list = g_list_append(caps_plugins_list, plugin);
}
Plugin* plugin = (Plugin*) (l->data);
GstElementFactory* factory = gst_element_factory_find (
plugin->getName ().toStdString ().c_str ());
if (factory) {
const GList* pads = gst_element_factory_get_static_pad_templates (
factory);
for (p = (GList*) pads; p != NULL; p = p->next) {
GstStaticPadTemplate* padTemplate = (GstStaticPadTemplate*) (p->data);
if (padTemplate->direction == direction
&& gst_caps_can_intersect (caps, padTemplate->static_caps.caps))
caps_plugins_list = g_list_append (caps_plugins_list, plugin);
}
}
}
return caps_plugins_list;
}
PluginsListDialog::PluginsListDialog(PluginsList* pluginList, QWidget *pwgt, Qt::WindowFlags f):
QDialog(pwgt, f)
, m_pPluginsList(pluginList)
, m_pGraph(NULL)
PluginsListDialog::PluginsListDialog (PluginsList* pluginList, QWidget *pwgt,
Qt::WindowFlags f)
: QDialog (pwgt, f),
m_pPluginsList (pluginList),
m_pGraph (NULL)
{
m_pPlugins = new QListWidget;
m_pPlugins->setSortingEnabled(true);
m_plblInfo = new QLabel;
m_pPlugins = new QListWidget;
m_pPlugins->setSortingEnabled (true);
m_plblInfo = new QLabel;
m_plblInfo -> setTextInteractionFlags(Qt::TextSelectableByMouse);
m_plblInfo -> setAlignment(Qt::AlignLeft | Qt::AlignTop);
QScrollArea *pscroll = new QScrollArea;
pscroll -> setWidget(m_plblInfo);
m_plblInfo -> resize(pscroll -> size());
m_plblInfo->setTextInteractionFlags (Qt::TextSelectableByMouse);
m_plblInfo->setAlignment (Qt::AlignLeft | Qt::AlignTop);
QScrollArea *pscroll = new QScrollArea;
pscroll->setWidget (m_plblInfo);
m_plblInfo->resize (pscroll->size ());
QHBoxLayout *phblay = new QHBoxLayout;
QHBoxLayout *phblay = new QHBoxLayout;
phblay -> addWidget(m_pPlugins, 1);
phblay -> addWidget(pscroll, 2);
phblay->addWidget (m_pPlugins, 1);
phblay->addWidget (pscroll, 2);
InitPluginsList();
InitPluginsList ();
QHBoxLayout *phblayFind = new QHBoxLayout;
QHBoxLayout *phblayFind = new QHBoxLayout;
QLineEdit *ple = new QLineEdit;
phblayFind -> addWidget(ple);
phblayFind -> addStretch(1);
QLineEdit *ple = new QLineEdit;
phblayFind->addWidget (ple);
phblayFind->addStretch (1);
ple -> setPlaceholderText("Search...");
ple->setPlaceholderText ("Search...");
QVBoxLayout *pvblay = new QVBoxLayout;
pvblay -> addLayout(phblayFind);
pvblay -> addLayout(phblay);
QVBoxLayout *pvblay = new QVBoxLayout;
pvblay->addLayout (phblayFind);
pvblay->addLayout (phblay);
setLayout(pvblay);
setLayout (pvblay);
setWindowTitle("Add plugin");
setWindowTitle ("Add plugin");
QObject::connect(m_pPlugins, SIGNAL(currentItemChanged (QListWidgetItem *, QListWidgetItem *)),
this, SLOT(showInfo(QListWidgetItem *, QListWidgetItem *)));
QObject::connect(m_pPlugins, SIGNAL(currentItemChanged (QListWidgetItem *, QListWidgetItem *)),
this, SLOT(showInfo(QListWidgetItem *, QListWidgetItem *)));
QObject::connect(m_pPlugins, SIGNAL(itemDoubleClicked (QListWidgetItem *)),
this, SLOT(insert(QListWidgetItem *)));
QObject::connect(m_pPlugins, SIGNAL(itemDoubleClicked (QListWidgetItem *)),
this, SLOT(insert(QListWidgetItem *)));
QObject::connect(ple, SIGNAL(textChanged(const QString &)), this, SLOT(filterPlagins(const QString &)));
QObject::connect(ple, SIGNAL(textChanged(const QString &)), this, SLOT(filterPlagins(const QString &)));
installEventFilter(this);
installEventFilter (this);
}
PluginsListDialog::~PluginsListDialog()
PluginsListDialog::~PluginsListDialog ()
{
if (m_pPluginsList)
delete m_pPluginsList;
}
void PluginsListDialog::showInfo(QListWidgetItem *pitem, QListWidgetItem *previous)
void
PluginsListDialog::showInfo (QListWidgetItem *pitem, QListWidgetItem *previous)
{
qDebug() << "Show Info: " << pitem -> text();
m_plblInfo -> clear();
QString descr;
descr += "<b>Plugin details</b><hr>";
qDebug () << "Show Info: " << pitem->text ();
m_plblInfo->clear ();
QString descr;
descr += "<b>Plugin details</b><hr>";
GstElementFactory *factory = gst_element_factory_find(pitem -> text().toStdString().c_str());
if(!factory)
{
qDebug() << "warning: " << pitem -> text() << " Not Found";
return;
}
GstElementFactory *factory = gst_element_factory_find (
pitem->text ().toStdString ().c_str ());
if (!factory) {
qDebug () << "warning: " << pitem->text () << " Not Found";
return;
}
factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE(factory)));
if(!factory)
{
qDebug() << "warning: " << pitem -> text() << " Not Found";
return;
}
factory = GST_ELEMENT_FACTORY (
gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory)));
if (!factory) {
qDebug () << "warning: " << pitem->text () << " Not Found";
return;
}
#if GST_VERSION_MAJOR >= 1
GstPlugin *plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
GstPlugin *plugin = gst_plugin_feature_get_plugin (GST_PLUGIN_FEATURE (factory));
#else
const gchar* plugin_name = GST_PLUGIN_FEATURE(factory)->plugin_name;
if (!plugin_name) {
return;
}
GstPlugin* plugin = gst_default_registry_find_plugin(plugin_name);
const gchar* plugin_name = GST_PLUGIN_FEATURE (factory)->plugin_name;
if (!plugin_name) {
return;
}
GstPlugin* plugin = gst_default_registry_find_plugin (plugin_name);
#endif
if(!plugin)
{
qDebug() << "warning: " << pitem -> text() << " Not Found";
return;
}
if (!plugin) {
qDebug () << "warning: " << pitem->text () << " Not Found";
return;
}
#if GST_VERSION_MAJOR >= 1
const gchar *release_date = gst_plugin_get_release_date_string (plugin);
const gchar *release_date = gst_plugin_get_release_date_string (plugin);
#else
const gchar *release_date = (plugin->desc.release_datetime) ? plugin->desc.release_datetime : "";
const gchar *release_date =
(plugin->desc.release_datetime) ? plugin->desc.release_datetime : "";
#endif
const gchar *filename = gst_plugin_get_filename(plugin);
const gchar *filename = gst_plugin_get_filename (plugin);
descr += "<b>Name</b>: " + QString(gst_plugin_get_name(plugin)) + "<br>";
descr += "<b>Description</b>: " + QString(gst_plugin_get_description(plugin)) + "<br>";
descr += "<b>Filename</b>: " + QString((filename != NULL) ? filename : "(null)") + "<br>";
descr += "<b>Version</b>: " + QString(gst_plugin_get_version (plugin)) + "<br>";
descr += "<b>License</b>: " + QString(gst_plugin_get_license (plugin)) + "<br>";
descr += "<b>Source module</b>: " + QString(gst_plugin_get_source (plugin)) + "<br>";
descr += "<b>Name</b>: " + QString (gst_plugin_get_name (plugin)) + "<br>";
descr += "<b>Description</b>: "
+ QString (gst_plugin_get_description (plugin)) + "<br>";
descr += "<b>Filename</b>: "
+ QString ((filename != NULL) ? filename : "(null)") + "<br>";
descr += "<b>Version</b>: " + QString (gst_plugin_get_version (plugin))
+ "<br>";
descr += "<b>License</b>: " + QString (gst_plugin_get_license (plugin))
+ "<br>";
descr += "<b>Source module</b>: " + QString (gst_plugin_get_source (plugin))
+ "<br>";
if (release_date != NULL)
{
const gchar *tz = "(UTC)";
gchar *str, *sep;
if (release_date != NULL) {
const gchar *tz = "(UTC)";
gchar *str, *sep;
str = g_strdup (release_date);
sep = strstr (str, "T");
if (sep != NULL)
{
*sep = ' ';
sep = strstr (sep + 1, "Z");
if (sep != NULL)
*sep = ' ';
}
else
{
tz = "";
}
descr += "<b>Source release date</b>: " + QString(str) + " " + QString(tz) + "<br>";
g_free (str);
}
descr += "<b>Binary package</b>: " + QString(gst_plugin_get_package (plugin)) + "<br>";
descr += "<b>Origin URL</b>: " + QString(gst_plugin_get_origin (plugin)) + "<br>";
descr += "<b>Rank</b>: " + QString::number(gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory)));
m_plblInfo -> setText(descr);
str = g_strdup (release_date);
sep = strstr (str, "T");
if (sep != NULL) {
*sep = ' ';
sep = strstr (sep + 1, "Z");
if (sep != NULL)
*sep = ' ';
}
else {
tz = "";
}
descr += "<b>Source release date</b>: " + QString (str) + " " + QString (tz)
+ "<br>";
g_free (str);
}
descr += "<b>Binary package</b>: " + QString (gst_plugin_get_package (plugin))
+ "<br>";
descr += "<b>Origin URL</b>: " + QString (gst_plugin_get_origin (plugin))
+ "<br>";
descr += "<b>Rank</b>: "
+ QString::number (
gst_plugin_feature_get_rank (GST_PLUGIN_FEATURE (factory)));
m_plblInfo->setText (descr);
}
void PluginsListDialog::insert(QListWidgetItem *pitem)
void
PluginsListDialog::insert (QListWidgetItem *pitem)
{
if(!pitem) {
qDebug() << "Do not insert null item";
return;
}
qDebug() << "Insert: " << pitem -> text();
if (!pitem) {
qDebug () << "Do not insert null item";
return;
}
qDebug () << "Insert: " << pitem->text ();
if(!m_pGraph || !m_pGraph -> AddPlugin(pitem -> text().toStdString().c_str(), NULL))
{
QMessageBox::warning(this, "Plugin addition problem", "Plugin `" + pitem -> text() + "` insertion was FAILED");
qDebug() << "Plugin `" << pitem -> text() << "` insertion FAILED";
return;
}
if (!m_pGraph
|| !m_pGraph->AddPlugin (pitem->text ().toStdString ().c_str (), NULL)) {
QMessageBox::warning (
this, "Plugin addition problem",
"Plugin `" + pitem->text () + "` insertion was FAILED");
qDebug () << "Plugin `" << pitem->text () << "` insertion FAILED";
return;
}
}
bool PluginsListDialog::eventFilter(QObject *obj, QEvent *event)
bool
PluginsListDialog::eventFilter (QObject *obj, QEvent *event)
{
if (event -> type() == QEvent::KeyPress)
{
QKeyEvent *key = static_cast<QKeyEvent*>(event);
if (event->type () == QEvent::KeyPress) {
QKeyEvent *key = static_cast<QKeyEvent*> (event);
if((key -> key() == Qt::Key_Enter) || (key -> key() == Qt::Key_Return) && m_pPlugins -> currentItem())
{
insert(m_pPlugins -> currentItem());
return true;
}
}
if ((key->key () == Qt::Key_Enter)
|| (key->key () == Qt::Key_Return) && m_pPlugins->currentItem ()) {
insert (m_pPlugins->currentItem ());
return true;
}
}
return QDialog::eventFilter(obj, event);
return QDialog::eventFilter (obj, event);
}
void PluginsListDialog::filterPlagins(const QString &text)
void
PluginsListDialog::filterPlagins (const QString &text)
{
for(std::size_t i=0; i<m_pPlugins -> count(); i++)
{
QListWidgetItem *pitem = m_pPlugins -> item(i);
for (std::size_t i = 0; i < m_pPlugins->count (); i++) {
QListWidgetItem *pitem = m_pPlugins->item (i);
if(pitem -> text().contains(text))
pitem -> setHidden(false);
else
pitem -> setHidden(true);
}
if (pitem->text ().contains (text))
pitem->setHidden (false);
else
pitem->setHidden (true);
}
}
void PluginsListDialog::InitPluginsList()
void
PluginsListDialog::InitPluginsList ()
{
if (!m_pPluginsList)
m_pPluginsList = new PluginsList ();
GList* plugins_list = m_pPluginsList->getList();
GList* plugins_list = m_pPluginsList->getList ();
GList* l;
std::size_t num = 0;
for (l = plugins_list; l != NULL; l = l->next) {
Plugin* plugin = (Plugin*)(l->data);
m_pPlugins->addItem(plugin->getName());
Plugin* plugin = (Plugin*) (l->data);
m_pPlugins->addItem (plugin->getName ());
num++;
}
}

View file

@ -5,24 +5,22 @@
#include <QLabel>
#include <QListWidgetItem>
#include "GraphManager.h"
class Plugin
{
public:
Plugin(const QString& name, int rank):
m_name(name),
m_rank(rank)
{
}
const QString getName() { return m_name;}
int getRank() { return m_rank;}
Plugin(const QString& name, int rank):
m_name(name),
m_rank(rank)
{
}
const QString getName() {return m_name;}
int getRank() {return m_rank;}
private:
const QString m_name;
int m_rank;
const QString m_name;
int m_rank;
};
@ -32,47 +30,43 @@ public:
PluginsList();
~PluginsList();
GList* getList() { return m_pluginsList;}
GList* getList() {return m_pluginsList;}
GList* getSortedByRank();
GList* getPluginListByCaps(GstPadDirection direction, GstCaps* caps);
private:
void init();
GList* m_pluginsList;
GList* m_pluginsList;
};
class PluginsListDialog: public QDialog
{
Q_OBJECT
Q_OBJECT
public:
PluginsListDialog(PluginsList* pluginList, QWidget *pwgt = NULL, Qt::WindowFlags f = Qt::Window);
PluginsListDialog(PluginsList* pluginList, QWidget *pwgt = NULL, Qt::WindowFlags f = Qt::Window);
~PluginsListDialog();
void setGraph(GraphManager* graph) { m_pGraph = graph;}
void setGraph(GraphManager* graph) {m_pGraph = graph;}
protected:
bool eventFilter(QObject *obj, QEvent *ev);
bool eventFilter(QObject *obj, QEvent *ev);
private:
void InitPluginsList();
void InitPluginsList();
public slots:
void showInfo(QListWidgetItem *current, QListWidgetItem *previous);
void insert(QListWidgetItem *);
void showInfo(QListWidgetItem *current, QListWidgetItem *previous);
void insert(QListWidgetItem *);
private slots:
void filterPlagins(const QString &text);
void filterPlagins(const QString &text);
private:
QLabel *m_plblInfo;
QListWidget *m_pPlugins;
PluginsList *m_pPluginsList;
GraphManager *m_pGraph;
QLabel *m_plblInfo;
QListWidget *m_pPlugins;
PluginsList *m_pPluginsList;
GraphManager *m_pGraph;
};
#endif

View file

@ -1,16 +1,19 @@
#include "SeekSlider.h"
void SeekSlider::mousePressEvent(QMouseEvent *event)
void
SeekSlider::mousePressEvent (QMouseEvent *event)
{
if(event->button() == Qt::LeftButton)
{
if(orientation() == Qt::Vertical)
setValue(minimum() + ((maximum()-minimum()) * (height()-event->y())) / height() ) ;
else
setValue(minimum() + ((maximum()-minimum()) * event->x()) / width() ) ;
if (event->button () == Qt::LeftButton) {
if (orientation () == Qt::Vertical)
setValue (minimum ()
+ ((maximum () - minimum ()) * (height () - event->y ())) / height ());
else
setValue (minimum ()
+ ((maximum () - minimum ()) * event->x ()) / width ());
event->accept();
}
event->accept ();
}
QSlider::mousePressEvent(event);
};
QSlider::mousePressEvent (event);
}
;

View file

@ -1,16 +1,13 @@
#ifndef SEEK_SLIDER_H_
#define SEEK_SLIDER_H_
#include <QSlider>
#include <QMouseEvent>
class SeekSlider: public QSlider
{
protected:
void mousePressEvent(QMouseEvent *);
protected:
void mousePressEvent(QMouseEvent *);
};
#endif

View file

@ -3,22 +3,23 @@
#include <gst/gst.h>
int main(int argc, char **argv)
int
main (int argc, char **argv)
{
gst_init (&argc, &argv);
gst_init (&argc, &argv);
GstRegistry *registry;
GstRegistry *registry;
#if GST_VERSION_MAJOR >= 1
registry = gst_registry_get();
registry = gst_registry_get();
#else
registry = gst_registry_get_default();
registry = gst_registry_get_default ();
#endif
gst_registry_scan_path(registry, "./plugins");
gst_registry_scan_path (registry, "./plugins");
QApplication app(argc, argv);
QApplication app (argc, argv);
MainWindow wgt;
wgt.show();
MainWindow wgt;
wgt.show ();
return app.exec();
return app.exec ();
}