2 ******************************************************************************
4 * @file notifypluginoptionspage.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @brief Notify Plugin options page header
7 * @see The GNU Public License (GPL) Version 3
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #ifndef NOTIFYPLUGINOPTIONSPAGE_H
30 #define NOTIFYPLUGINOPTIONSPAGE_H
32 #include "coreplugin/dialogs/ioptionspage.h"
33 #include "uavobjectmanager.h"
34 #include "uavobject.h"
37 #include <QStringList>
38 #include <QItemSelectionModel>
40 #include <QtCore/QSettings>
43 #include <QSoundEffect>
44 #include <QMediaPlayer>
46 class NotifyTableModel
;
47 class NotificationItem
;
48 class SoundNotifyPlugin
;
51 class NotifyPluginOptionsPage
;
56 class NotifyPluginOptionsPage
: public IOptionsPage
{
60 enum { equal
, bigger
, smaller
, inrange
};
61 explicit NotifyPluginOptionsPage(QObject
*parent
= 0);
62 ~NotifyPluginOptionsPage();
65 return QLatin1String("settings");
67 QString
trName() const
69 return tr("settings");
71 QString
category() const
73 return QLatin1String("Notify Plugin");
75 QString
trCategory() const
77 return tr("Notification");
80 QWidget
*createPage(QWidget
*parent
);
83 void restoreFromSettings();
84 static QStringList conditionValues
;
87 void updateNotifications(QList
<NotificationItem
*> list
);
88 void entryUpdated(int index
);
91 void on_clicked_buttonTestSoundNotification();
92 void on_clicked_buttonAddNotification();
93 void on_clicked_buttonDeleteNotification();
94 void on_clicked_buttonModifyNotification();
97 * We can use continuous selection, to select simultaneously
98 * multiple rows to move them(using drag & drop) inside table ranges.
100 void on_changedSelection_notifyTable(const QItemSelection
& selected
, const QItemSelection
& deselected
);
102 void on_changedIndex_soundLanguage(int index
);
103 void on_clicked_buttonSoundFolder(const QString
& path
);
104 void on_changedIndex_UAVObject(QString val
);
105 void on_changedIndex_UAVField(QString val
);
106 void on_changed_playButtonText(QMediaPlayer::State newstate
);
107 void on_toggled_checkEnableSound(bool state
);
110 * Important when we change to or from "In range" value
111 * For enums UI layout stayed the same, but for numeric values
112 * we need to change UI to show edit line,
113 * to have possibility assign range limits for value.
115 void on_changedIndex_rangeValue(QString
);
117 void on_FinishedPlaying(void);
121 Q_DISABLE_COPY(NotifyPluginOptionsPage
)
124 void initPhononPlayer();
125 void initRulesTable();
127 void setSelectedNotification(NotificationItem
*ntf
);
128 void resetValueRange();
129 void resetFieldType();
131 void updateConfigView(NotificationItem
*notification
);
132 void getOptionsPageValues(NotificationItem
*notification
);
133 UAVObjectField
*getObjectFieldFromPage();
134 UAVObjectField
*getObjectFieldFromSelected();
136 void addDynamicFieldLayout();
137 void addDynamicField(UAVObjectField
*objField
);
138 void addDynamicFieldWidget(UAVObjectField
*objField
);
139 void setDynamicFieldValue(NotificationItem
*notification
);
143 UAVObjectManager
& _objManager
;
144 SoundNotifyPlugin
*_owner
;
146 // ! Media object uses to test sound playing
147 QMediaPlayer
*_testSound
;
149 QScopedPointer
<NotifyTableModel
> _notifyRulesModel
;
150 QItemSelectionModel
*_notifyRulesSelection
;
153 * Local copy of notification list, which owned by notify plugin.
154 * Notification list readed once on application loaded, during
155 * notify plugin startup, then on open options page.
156 * This copy is simple assignment, but due to implicitly sharing
157 * we don't have additional cost for that, copy will created
158 * only after modification of private notify list.
160 QList
<NotificationItem
*> _privListNotifications
;
162 QScopedPointer
<Ui::NotifyPluginOptionsPage
> _optionsPage
;
164 // ! Widget to convinient selection of condition for field value (equal, lower, greater)
165 QComboBox
*_dynamicFieldCondition
;
167 // ! Represents edit widget for dynamic UAVObjectfield,
168 // ! can be spinbox - for numerics, combobox - enums, or
169 // ! lineedit - for numerics with range constraints
170 QWidget
*_dynamicFieldWidget
;
172 // ! Type of UAVObjectField - numeric or ENUM,
173 // ! this variable needs to correctly set appropriate dynamic UI element (_dynamicFieldWidget)
174 // ! NOTE: ocassionaly it should be invalidated (= -1) to reset _dynamicFieldWidget
175 int _dynamicFieldType
;
177 // ! Widget to convinient selection of position of <dynamic field value>
178 // ! between sounds[1..3]
179 QComboBox
*_sayOrder
;
181 // ! Actualy reference to optionsPageWidget,
182 // ! we MUST hold it beyond the scope of createPage func
183 // ! to have possibility change dynamic parts of options page layout in future
186 // ! Currently selected notification, all controls filled accroding to it.
187 // ! On options page startup, always points to first row.
188 NotificationItem
*_selectedNotification
;
190 // ! Retrieved from UAVObjectManager by name from _selectedNotification,
191 // ! if UAVObjectManager doesn't have such object, this field will be NULL
192 UAVDataObject
*_currUAVObject
;
193 QMediaPlaylist
*playlist
;
196 #endif // NOTIFYPLUGINOPTIONSPAGE_H