2011-01-30 23:22:51 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file notifypluginoptionspage.h
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @brief Notify Plugin options page header
|
|
|
|
* @see The GNU Public License (GPL) Version 3
|
|
|
|
* @defgroup notify
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef NOTIFYPLUGINOPTIONSPAGE_H
|
|
|
|
#define NOTIFYPLUGINOPTIONSPAGE_H
|
|
|
|
|
|
|
|
#include "coreplugin/dialogs/ioptionspage.h"
|
|
|
|
#include "uavobjectmanager.h"
|
|
|
|
#include "uavobject.h"
|
|
|
|
|
|
|
|
#include "QString"
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QItemSelectionModel>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QtCore/QSettings>
|
2011-05-05 19:37:23 +02:00
|
|
|
#include <phonon/MediaObject>
|
|
|
|
#include <phonon/Path>
|
|
|
|
#include <phonon/AudioOutput>
|
|
|
|
#include <phonon/Global>
|
2011-09-29 20:26:46 +03:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QSpinBox>
|
2011-01-30 23:22:51 +00:00
|
|
|
|
|
|
|
class NotifyTableModel;
|
2011-09-15 00:38:18 +03:00
|
|
|
class NotificationItem;
|
2011-01-30 23:22:51 +00:00
|
|
|
class SoundNotifyPlugin;
|
|
|
|
|
2011-09-19 00:30:57 +03:00
|
|
|
namespace Ui {
|
|
|
|
class NotifyPluginOptionsPage;
|
|
|
|
};
|
2011-01-30 23:22:51 +00:00
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
class NotifyPluginOptionsPage : public IOptionsPage
|
|
|
|
{
|
2011-10-04 01:59:37 +03:00
|
|
|
Q_OBJECT
|
|
|
|
|
2011-01-30 23:22:51 +00:00
|
|
|
public:
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
explicit NotifyPluginOptionsPage(QObject *parent = 0);
|
|
|
|
~NotifyPluginOptionsPage();
|
|
|
|
QString id() const { return QLatin1String("settings"); }
|
|
|
|
QString trName() const { return tr("settings"); }
|
|
|
|
QString category() const { return QLatin1String("Notify Plugin");}
|
|
|
|
QString trCategory() const { return tr("Notify Plugin");}
|
2011-01-30 23:22:51 +00:00
|
|
|
|
|
|
|
QWidget *createPage(QWidget *parent);
|
|
|
|
void apply();
|
2011-10-04 01:59:37 +03:00
|
|
|
void finish();
|
|
|
|
void restoreFromSettings();
|
2011-01-30 23:22:51 +00:00
|
|
|
|
2011-10-04 01:59:37 +03:00
|
|
|
void updateConfigView(NotificationItem* notification);
|
|
|
|
void getOptionsPageValues(NotificationItem* notification);
|
|
|
|
UAVObjectField* getObjectFieldFromPage();
|
|
|
|
UAVObjectField* getObjectFieldFromSelected();
|
2011-01-30 23:22:51 +00:00
|
|
|
|
2011-09-29 20:26:46 +03:00
|
|
|
signals:
|
|
|
|
void updateNotifications(QList<NotificationItem*> list);
|
|
|
|
void entryUpdated(int index);
|
|
|
|
|
2011-10-04 01:59:37 +03:00
|
|
|
private slots:
|
|
|
|
void on_button_TestSoundNotification_clicked();
|
|
|
|
void on_button_AddNotification_clicked();
|
|
|
|
void on_button_DeleteNotification_clicked();
|
|
|
|
void on_button_ModifyNotification_clicked();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We can use continuous selection, to select simultaneously
|
|
|
|
* multiple rows to move them(using drag & drop) inside table ranges.
|
|
|
|
*/
|
|
|
|
void on_table_changeSelection( const QItemSelection & selected, const QItemSelection & deselected );
|
|
|
|
|
|
|
|
void on_soundLanguage_indexChanged(int index);
|
|
|
|
void on_buttonSoundFolder_clicked(const QString& path);
|
|
|
|
void on_UAVObject_indexChanged(QString val);
|
|
|
|
void on_UAVField_indexChanged(QString val);
|
|
|
|
void on_changeButtonText(Phonon::State newstate, Phonon::State oldstate);
|
|
|
|
void on_checkEnableSound_toggled(bool state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Important when we change to or from "In range" value
|
|
|
|
* For enums UI layout stayed the same, but for numeric values
|
|
|
|
* we need to change UI to show edit line,
|
|
|
|
* to have possibility assign range limits for value.
|
|
|
|
*/
|
|
|
|
void on_rangeValue_indexChanged(QString);
|
|
|
|
|
|
|
|
void on_FinishedPlaying(void);
|
|
|
|
|
|
|
|
|
2011-01-30 23:22:51 +00:00
|
|
|
private:
|
2011-09-19 00:30:57 +03:00
|
|
|
Q_DISABLE_COPY(NotifyPluginOptionsPage)
|
|
|
|
|
2011-09-29 20:26:46 +03:00
|
|
|
void resetValueRange();
|
2011-10-04 01:59:37 +03:00
|
|
|
void resetFieldType();
|
|
|
|
|
2011-09-29 20:26:46 +03:00
|
|
|
void setDynamicValueField(NotificationItem* notification);
|
|
|
|
void addDynamicField(UAVObjectField* objField);
|
|
|
|
void addDynamicValueLayout();
|
2011-10-04 01:59:37 +03:00
|
|
|
void setDynamicValueWidget(UAVObjectField* objField);
|
|
|
|
|
2011-09-16 02:24:35 +03:00
|
|
|
void initButtons();
|
|
|
|
void initPhononPlayer();
|
2011-09-19 00:30:57 +03:00
|
|
|
void initRulesTable();
|
2011-09-16 02:24:35 +03:00
|
|
|
|
|
|
|
private:
|
2011-01-30 23:22:51 +00:00
|
|
|
|
2011-10-04 01:59:37 +03:00
|
|
|
UAVObjectManager& _objManager;
|
|
|
|
SoundNotifyPlugin* _owner;
|
|
|
|
QStringList _listDirCollections;
|
|
|
|
QStringList _listSoundFiles;
|
|
|
|
QString _currentCollectionPath;
|
|
|
|
Phonon::MediaObject* _sound1;
|
|
|
|
Phonon::MediaObject* _sound2;
|
|
|
|
QScopedPointer<Phonon::MediaObject> _notifySound;
|
|
|
|
Phonon::AudioOutput* _audioOutput;
|
|
|
|
|
|
|
|
QScopedPointer<NotifyTableModel> _notifyRulesModel;
|
|
|
|
QItemSelectionModel* _notifyRulesSelection;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Local copy of notification list, which owned by notify plugin.
|
|
|
|
* Notification list readed once on application loaded, during
|
|
|
|
* notify plugin startup, then on open options page.
|
|
|
|
* This copy is simple assignment, but due to implicitly sharing
|
|
|
|
* we don't have additional cost for that, copy will created
|
|
|
|
* only after modification of private notify list.
|
|
|
|
*/
|
|
|
|
QList<NotificationItem*> _privListNotifications;
|
|
|
|
|
|
|
|
QScopedPointer<Ui::NotifyPluginOptionsPage> _optionsPage;
|
|
|
|
|
|
|
|
//! widget to convinient selection of condition for field value (equal, lower, greater)
|
2011-09-29 20:26:46 +03:00
|
|
|
QComboBox* _valueRange;
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
//! widget to convinient selection of order in which sounds will be played
|
2011-09-29 20:26:46 +03:00
|
|
|
QComboBox* _sayOrder;
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
//! widget to represent edit widget for UAVObjectfield,
|
|
|
|
//! can be spinbox - for numerics, combobox - enums, or
|
|
|
|
//! lineedit - for range limits
|
2011-09-29 20:26:46 +03:00
|
|
|
QWidget* _fieldValue;
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
//! type of UAVObjectField - numeric or ENUM
|
|
|
|
//! this variable needs to correctly set dynamic UI elemen _fieldValue
|
|
|
|
//! NOTE: ocassionaly it should be invalidated (= -1) to reset _fieldValue
|
2011-09-29 20:26:46 +03:00
|
|
|
int _fieldType;
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
//! actualy reference to optionsPageWidget,
|
|
|
|
//! we MUST hold it beyond the scope of createPage func
|
|
|
|
//! to have possibility change dynamic parts of options page layout in future
|
2011-09-29 20:26:46 +03:00
|
|
|
QWidget* _form;
|
2011-10-04 01:59:37 +03:00
|
|
|
|
|
|
|
//! needs to correctly update UI during transitions from "In Range" to other
|
|
|
|
//! _valueRange entries and back direction as well
|
|
|
|
QString _prevRangeValue;
|
|
|
|
|
|
|
|
//! Currently selected notification, all controls filled accroding to it.
|
|
|
|
//! On options page startup, always points to first row.
|
2011-09-29 20:26:46 +03:00
|
|
|
NotificationItem* _selectedNotification;
|
2011-01-30 23:22:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // NOTIFYPLUGINOPTIONSPAGE_H
|