Empezando la configuración mediante el GUI

This commit is contained in:
Santi Noreña 2014-10-17 18:34:47 +02:00
parent 02fa9827c2
commit 5f27d17d8a
8 changed files with 256 additions and 84 deletions

View file

@ -73,7 +73,7 @@ libreMediaServerAudio::libreMediaServerAudio(QStringList args, QWidget *parent)
// Conectamos los menus
connect(ui.actionOpen_conf, SIGNAL(triggered()), this, SLOT(openFile()));
connect(ui.actionSave_conf, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(ui.actionChange_Media_Path, SIGNAL(triggered()), this, SLOT(ChangeMediaPath()));
connect(ui.action_Settings, SIGNAL(triggered()), this, SLOT(settings()));
connect(ui.actionLaunch_OLA_Setup, SIGNAL(triggered()), this, SLOT(olasetup()));
connect(Settings::getInstance(), SIGNAL( registerUniverse(int) ),
@ -132,19 +132,10 @@ void libreMediaServerAudio::saveFile()
// save(&file);
}
// Change Media path
void libreMediaServerAudio::ChangeMediaPath()
void libreMediaServerAudio::settings()
{
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::Directory);
QStringList fileNames;
if (!dialog.exec())
return;
fileNames = dialog.selectedFiles();
QString file = fileNames.at(0);
Settings::getInstance()->setPathMedia(file);
QString desc = tr("Media Path Changed to: %1").arg(file);
qDebug(desc.toLatin1().constData());
SettingsDialog sd = new SettingsDialog();
sd.show();
}
@ -159,9 +150,6 @@ void libreMediaServerAudio::olasetup()
view->show();
}
/**
* Parse the dmx information
*/
void libreMediaServerAudio::dmxInput(int layer, int channel, int value)
{
// This qDebug slows all the program. Uncomment only for debugging purpouse and comment again in normal use

View file

@ -25,7 +25,7 @@
#include <QFileInfo>
#include <QFileDialog>
#include <QTextStream>
#include <QWebView>
//#include <QWebView>
#include <QVBoxLayout>
#include <QTextEdit>
@ -36,6 +36,7 @@
#include "olathread.h"
#include "audiomasterwidget.h"
#include "defines.h"
#include "settingsdialog.h"
#include "ui_libremediaserver-audio.h"
@ -58,7 +59,7 @@ protected:
private:
// void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg);
// void MessageHandler(QtMsgType type, const QMessageLogContext &logcontext, const QString &msg);
AudioMasterWidget *amw;
olaThread *ola;
@ -73,14 +74,32 @@ public slots:
private slots:
/**
* @brief Shows the OLA web setup page
*/
void olasetup();
/**
* @brief Parser for new dmx data arriving
* @param layer
* @param channel
* @param value
*/
void dmxInput(int layer, int channel, int value);
// Menu File
/**
* @brief REad from dis a configuration file
*/
void openFile();
/**
* @brief Write to disk a configuration file
*/
void saveFile();
void ChangeMediaPath();// Change the path to medias
/**
* @brief OPen the settings dialog
*/
void settings();
};
#endif // LIBREMEDIASERVERAUDIO_H

View file

@ -3,8 +3,8 @@ TARGET = libremediaserver-audio
QT += webkitwidgets widgets
CONFIG += release
DESTDIR = ./release
CONFIG += debug
DESTDIR = ./debug
HEADERS += libremediaserver-audio.h \
medialibrary.h \
@ -28,7 +28,8 @@ SOURCES += main.cpp \
settingsdialog.cpp
FORMS += \
libremediaserver-audio.ui
libremediaserver-audio.ui \
settingsdialog.ui
#INCLUDEPATH += ./

View file

@ -30,7 +30,7 @@
</property>
<addaction name="actionOpen_conf"/>
<addaction name="actionSave_conf"/>
<addaction name="actionChange_Media_Path"/>
<addaction name="action_Settings"/>
<addaction name="actionLaunch_OLA_Setup"/>
</widget>
<addaction name="menuFile"/>
@ -42,17 +42,17 @@
</action>
<action name="actionOpen_conf">
<property name="text">
<string>Open Configuration</string>
<string>Open Configuration...</string>
</property>
</action>
<action name="actionSave_conf">
<property name="text">
<string>Save Configuration</string>
<string>Save Configuration...</string>
</property>
</action>
<action name="actionChange_Media_Path">
<action name="action_Settings">
<property name="text">
<string>Change Media Path</string>
<string>Settings...</string>
</property>
</action>
<action name="actionInitMSEX">
@ -75,7 +75,7 @@
</action>
<action name="actionLaunch_OLA_Setup">
<property name="text">
<string>OLA Setup</string>
<string>OLA Setup...</string>
</property>
</action>
</widget>

View file

@ -50,15 +50,19 @@ public:
inline QList<dmxSetting> getDmxSettings() { return m_settings; }
/**
* @brief getlayersNumber
* @brief Get the number of layer currently used
* @return
*/
inline int getLayersNumber() { return m_layersNumber; }
/**
* @brief Get the number of universes registered
* @return
*/
inline int getUniverseNumber() { return m_universe.size(); }
/**
* @brief readDefaultFile
* @brief Read the default xml configuration file at startup
*/
void readFile();

View file

@ -1,16 +1,55 @@
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
SettingsDialog::SettingsDialog(QWidget *parent) :
QWidget(parent)
QDialog(parent),
ui(new Ui::SettingsDialog)
{
QHBoxLayout *layout = new QHBoxLayout();
for (int i= 0; i < LAYERS_NUMBER; i++ ) {
layout->insertWidget(i, new SettingsLayerWidget(this, tr("Layer %1").arg(i)));
}
setLayout(layout);
ui->setupUi(this);
ui->layersNumber = Settings::getInstance()->getLayersNumber();
QString path;
path << "Path to root folder of the media tree: " << std::endl << Settings::getInstance()->getPathMedia();
ui->mediaPath->setText(path);
connect(ui->mediaPatchButton, SIGNAL(clicked()),
this, SLOT(changeMediaPath()));
// ToDo: Conectarlo todoooo
QList<dmxSetting> dmx = Settings::getInstance()->getDmxSettings();
foreach (it, dmx) {
QHBoxLayout *layer = new QHBoxLayout;
QSpinBox *universe = new QSpinBox();
universe->setValue(it.universe);
layer->addWidget(universe);
QSpinBox *address = new QSpinBox();
address->setValue(it.address);
layer->addWidget(address);
ui->layersLayout->addLayout(address);
connect(universe, SIGNAL(valueChanged(int)),
this, SLOT(universeChanged(int)));
connect(address, SIGNAL(valueChanged(int)),
this, SLOT(addressChnged(int)));
}
}
SettingsDialog::~SettingsDialog()
{
delete ui;
}
SettingsDialog::universeChanged(int uni)
{
}
SettingsDialog::addressChanged(int add)
{
}
// Change Media path
void SettingsDialog::ChangeMediaPath()
{
QFileDialog dialog(this);
@ -24,18 +63,3 @@ void SettingsDialog::ChangeMediaPath()
QString desc = tr("Media Path Changed to: %1").arg(file);
qDebug(desc.toLatin1().constData());
}
void SettingsDialog::olasetup()
{
QWebView *view = new QWebView();
view->load(QUrl("http://localhost:9090/ola.html"));
view->show();
}
SettingsLayerWidget::SettingsLayerWidget(QWidget *parent, QString title)
{
}

View file

@ -1,46 +1,27 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QWidget>
#include "defines.h"
#include <QHBoxLayout>
#include <QComboBox>
#include <QLabel>
#include <QPushButton>
#include <QCheckBox>
#include <QWebView>
#include <QFileDialog>
#include <QDialog>
#include "settings.h"
#include "medialibrary.h"
namespace Ui {
class SettingsDialog;
}
class SettingsDialog : public QWidget
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget *parent = 0);
~SettingsDialog();
private slots:
universeChanged(int uni);
addressChanged(int add);
void ChangeMediaPath();
void olasetup();
signals:
public slots:
private:
QLabel m_path;
QPushButton m_changePathToMedias;
QPushButton m_olaSetup;
};
class SettingsLayerWidget : public QWidget
{
Q_OBJECT
public:
explicit SettingsLayerWidget(QWidget *parent = 0, QString title = "layer");
private:
QComboBox m_universe;
QComboBox m_address;
signals:
Ui::SettingsDialog *ui;
};
#endif // SETTINGSDIALOG_H

155
src/settingsdialog.ui Normal file
View file

@ -0,0 +1,155 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingsDialog</class>
<widget class="QDialog" name="SettingsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>429</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>290</x>
<y>390</y>
<width>101</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
<widget class="QSpinBox" name="layersNumber">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>52</width>
<height>31</height>
</rect>
</property>
<property name="whatsThis">
<string>Layers Number</string>
</property>
<property name="accessibleName">
<string>Layers Number</string>
</property>
<property name="accessibleDescription">
<string>Layers Number</string>
</property>
<property name="wrapping">
<bool>false</bool>
</property>
<property name="specialValueText">
<string/>
</property>
<property name="showGroupSeparator" stdset="0">
<bool>true</bool>
</property>
<property name="prefix">
<string/>
</property>
</widget>
<widget class="QLabel" name="layersNumber_label">
<property name="geometry">
<rect>
<x>60</x>
<y>40</y>
<width>111</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>Layers Number</string>
</property>
</widget>
<widget class="QLabel" name="mediaPath">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>371</width>
<height>21</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QPushButton" name="mediaPatchButton">
<property name="geometry">
<rect>
<x>200</x>
<y>40</y>
<width>191</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>Change Path to Media</string>
</property>
<property name="default">
<bool>false</bool>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>99</y>
<width>381</width>
<height>281</height>
</rect>
</property>
<layout class="QVBoxLayout" name="layersLayout"/>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>SettingsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>SettingsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>