/** ****************************************************************************** * * @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 #include #include #include #include #include #include #include #include #include class NotifyTableModel; class NotificationItem; class SoundNotifyPlugin; namespace Ui { class NotifyPluginOptionsPage; }; using namespace Core; class NotifyPluginOptionsPage : public IOptionsPage { Q_OBJECT public: 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");} QWidget *createPage(QWidget *parent); void apply(); void finish(); void restoreFromSettings(); void updateConfigView(NotificationItem* notification); void getOptionsPageValues(NotificationItem* notification); UAVObjectField* getObjectFieldFromPage(); UAVObjectField* getObjectFieldFromSelected(); signals: void updateNotifications(QList list); void entryUpdated(int index); 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); private: Q_DISABLE_COPY(NotifyPluginOptionsPage) void resetValueRange(); void resetFieldType(); void setDynamicValueField(NotificationItem* notification); void addDynamicField(UAVObjectField* objField); void addDynamicValueLayout(); void setDynamicValueWidget(UAVObjectField* objField); void initButtons(); void initPhononPlayer(); void initRulesTable(); private: UAVObjectManager& _objManager; SoundNotifyPlugin* _owner; QStringList _listDirCollections; QStringList _listSoundFiles; QString _currentCollectionPath; Phonon::MediaObject* _sound1; Phonon::MediaObject* _sound2; QScopedPointer _notifySound; Phonon::AudioOutput* _audioOutput; QScopedPointer _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 _privListNotifications; QScopedPointer _optionsPage; //! widget to convinient selection of condition for field value (equal, lower, greater) QComboBox* _valueRange; //! widget to convinient selection of order in which sounds will be played QComboBox* _sayOrder; //! widget to represent edit widget for UAVObjectfield, //! can be spinbox - for numerics, combobox - enums, or //! lineedit - for range limits QWidget* _fieldValue; //! 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 int _fieldType; //! 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 QWidget* _form; //! 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. NotificationItem* _selectedNotification; }; #endif // NOTIFYPLUGINOPTIONSPAGE_H