mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
Latest update from Daniel for the Notify Plugin
Please help test it, all sound files are in SVN as well. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@975 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
6f06d0a69a
commit
6f6a8e50ee
@ -1,4 +1,4 @@
|
|||||||
<plugin name="NotifyPlugin" version="0.0.1" compatVersion="1.0.0">
|
<plugin name="NotifyPlugin" version="1.0.0" compatVersion="1.0.0">
|
||||||
<vendor>The OpenPilot Project</vendor>
|
<vendor>The OpenPilot Project</vendor>
|
||||||
<copyright>(C) 2010 Daniel Godin</copyright>
|
<copyright>(C) 2010 Daniel Godin</copyright>
|
||||||
<license>The GNU Public License (GPL) Version 3</license>
|
<license>The GNU Public License (GPL) Version 3</license>
|
||||||
|
BIN
ground/src/plugins/notify/images/add.png
Normal file
BIN
ground/src/plugins/notify/images/add.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
BIN
ground/src/plugins/notify/images/delete.png
Normal file
BIN
ground/src/plugins/notify/images/delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
BIN
ground/src/plugins/notify/images/modify.png
Normal file
BIN
ground/src/plugins/notify/images/modify.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 832 B |
BIN
ground/src/plugins/notify/images/play.png
Normal file
BIN
ground/src/plugins/notify/images/play.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.6 KiB |
BIN
ground/src/plugins/notify/images/play2.png
Normal file
BIN
ground/src/plugins/notify/images/play2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
BIN
ground/src/plugins/notify/images/stop.png
Normal file
BIN
ground/src/plugins/notify/images/stop.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
@ -10,12 +10,17 @@ QT += phonon
|
|||||||
|
|
||||||
HEADERS += notifyplugin.h \
|
HEADERS += notifyplugin.h \
|
||||||
notifypluginoptionspage.h \
|
notifypluginoptionspage.h \
|
||||||
notifypluginconfiguration.h
|
notifypluginconfiguration.h \
|
||||||
|
notifyitemdelegate.h
|
||||||
SOURCES += notifyplugin.cpp \
|
SOURCES += notifyplugin.cpp \
|
||||||
notifypluginoptionspage.cpp \
|
notifypluginoptionspage.cpp \
|
||||||
notifypluginconfiguration.cpp
|
notifypluginconfiguration.cpp \
|
||||||
|
notifyitemdelegate.cpp
|
||||||
|
|
||||||
OTHER_FILES += NotifyPlugin.pluginspec
|
OTHER_FILES += NotifyPlugin.pluginspec
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
notifypluginoptionspage.ui
|
notifypluginoptionspage.ui
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
res.qrc
|
||||||
|
@ -1,343 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>NotifyGadgetOptionsPage</class>
|
|
||||||
<widget class="QWidget" name="NotifyGadgetOptionsPage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>376</width>
|
|
||||||
<height>400</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QGroupBox" name="groupBox">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>190</y>
|
|
||||||
<width>351</width>
|
|
||||||
<height>171</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Current Notifications</string>
|
|
||||||
</property>
|
|
||||||
<widget class="QTableView" name="CurrentActions">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>20</y>
|
|
||||||
<width>331</width>
|
|
||||||
<height>111</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
|
||||||
p, li { white-space: pre-wrap; }
|
|
||||||
</style></head><body style=" font-family:'Segoe UI'; font-size:9pt; font-weight:400; font-style:normal;">
|
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Lists the notifactions already configured. Clicking on an item enables it to be modified. </p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<attribute name="verticalHeaderVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
<attribute name="verticalHeaderVisible">
|
|
||||||
<bool>false</bool>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="layoutWidget">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>9</x>
|
|
||||||
<y>140</y>
|
|
||||||
<width>331</width>
|
|
||||||
<height>25</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="checkBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Enable Sounds</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>138</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="pushButton_4">
|
|
||||||
<property name="text">
|
|
||||||
<string>Delete</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>358</width>
|
|
||||||
<height>177</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_11">
|
|
||||||
<property name="text">
|
|
||||||
<string>Sound Collection: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="comboBox">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>147</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
|
||||||
p, li { white-space: pre-wrap; }
|
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Select the sound collection</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>28</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QPushButton" name="loadFile">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
|
||||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
|
||||||
p, li { white-space: pre-wrap; }
|
|
||||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
|
|
||||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Locate the base directory of the Sound Collections</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Locate...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="label_8">
|
|
||||||
<property name="text">
|
|
||||||
<string>Object:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QComboBox" name="uavObject1">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLabel" name="label_9">
|
|
||||||
<property name="text">
|
|
||||||
<string>Field:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="3" colspan="3">
|
|
||||||
<widget class="QComboBox" name="objectField1">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_12">
|
|
||||||
<property name="text">
|
|
||||||
<string>Value is:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1" colspan="4">
|
|
||||||
<widget class="QComboBox" name="Value">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Equal to</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Greater than</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Less than</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="5">
|
|
||||||
<widget class="QDoubleSpinBox" name="doubleSpinBox"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_10">
|
|
||||||
<property name="text">
|
|
||||||
<string>Sound 1:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1" colspan="3">
|
|
||||||
<widget class="QComboBox" name="Sound">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="4" colspan="2">
|
|
||||||
<widget class="QPushButton" name="pushButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Test</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<widget class="QLabel" name="label_14">
|
|
||||||
<property name="text">
|
|
||||||
<string>Sound 2:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1" colspan="3">
|
|
||||||
<widget class="QComboBox" name="Sound_2">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="4" colspan="2">
|
|
||||||
<widget class="QPushButton" name="pushButton_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>Test</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="0">
|
|
||||||
<widget class="QLabel" name="label_13">
|
|
||||||
<property name="text">
|
|
||||||
<string>Say Value: </string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="1">
|
|
||||||
<widget class="QComboBox" name="comboBox_2">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Select if the value of the object should be spoken and if so, either before the configured sound or after it.</string>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Never</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>Before Snd 1</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>After Snd 1</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>After Snd 2</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="2" colspan="2">
|
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
|
||||||
<property name="text">
|
|
||||||
<string>Modify</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="4" colspan="2">
|
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
206
ground/src/plugins/notify/notifyitemdelegate.cpp
Normal file
206
ground/src/plugins/notify/notifyitemdelegate.cpp
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file notifyitemdelegate.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup notifyplugin
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "notifyitemdelegate.h"
|
||||||
|
#include <QtGui>
|
||||||
|
|
||||||
|
//RepeatCounterDelegate::RepeatCounterDelegate(QObject *parent)
|
||||||
|
// : QItemDelegate(parent) {}
|
||||||
|
|
||||||
|
// QWidget* RepeatCounterDelegate::createEditor(QWidget *parent,
|
||||||
|
// const QStyleOptionViewItem &,
|
||||||
|
// const QModelIndex &index) const
|
||||||
|
// {
|
||||||
|
// if (index.row() == 2) {
|
||||||
|
// QSpinBox *editor = new QSpinBox(parent);
|
||||||
|
// editor->setMinimum(0);
|
||||||
|
// editor->setMaximum(100);
|
||||||
|
// return editor;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// QLabel *editor = new QLabel(parent);
|
||||||
|
|
||||||
|
// connect(editor, SIGNAL(editingFinished()),
|
||||||
|
// this, SLOT(commitAndCloseEditor()));
|
||||||
|
// return editor;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void RepeatCounterDelegate::commitAndCloseEditor()
|
||||||
|
// {
|
||||||
|
// QLabel* editor = qobject_cast<QLabel*>(sender());
|
||||||
|
// emit commitData(editor);
|
||||||
|
// emit closeEditor(editor);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void RepeatCounterDelegate::setEditorData(QWidget *editor,
|
||||||
|
// const QModelIndex &index) const
|
||||||
|
// {
|
||||||
|
// QLabel* edit = qobject_cast<QLabel*>(editor);
|
||||||
|
// if (edit) {
|
||||||
|
// edit->setText(index.model()->data(index, Qt::EditRole).toString());
|
||||||
|
// } else {
|
||||||
|
// QSpinBox* spinBox = static_cast<QSpinBox*>(editor);
|
||||||
|
// if (spinBox)
|
||||||
|
// {
|
||||||
|
// int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||||
|
// spinBox->setValue(value);
|
||||||
|
|
||||||
|
// //repeatEditor->setCurrentIndex(repeatEditor->findText(index.model()->data(index, Qt::EditRole).toString()));
|
||||||
|
//// repeatEditor->setDate(QDate::fromString(
|
||||||
|
//// index.model()->data(index, Qt::EditRole).toString(),
|
||||||
|
//// "d/M/yyyy"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// void RepeatCounterDelegate::setModelData(QWidget *editor,
|
||||||
|
// QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
|
// {
|
||||||
|
// QLabel* edit = qobject_cast<QLabel*>(editor);
|
||||||
|
// if (edit) {
|
||||||
|
// model->setData(index, edit->text());
|
||||||
|
// } else {
|
||||||
|
// QSpinBox* spinBox = static_cast<QSpinBox*>(editor);
|
||||||
|
// if (spinBox) {
|
||||||
|
// spinBox->interpretText();
|
||||||
|
// int value = spinBox->value();
|
||||||
|
// model->setData(index, value, Qt::EditRole);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
NotifyItemDelegate::NotifyItemDelegate(QStringList items,QObject *parent)
|
||||||
|
: QItemDelegate(parent),
|
||||||
|
m_parent(parent),
|
||||||
|
m_items(items) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *NotifyItemDelegate::createEditor(QWidget *parent,
|
||||||
|
const QStyleOptionViewItem &,
|
||||||
|
const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
if (index.column() == 1) {
|
||||||
|
QComboBox* editor = new QComboBox(parent);
|
||||||
|
editor->clear();
|
||||||
|
editor->addItems(m_items);
|
||||||
|
//repeatEditor->setCurrentIndex(0);
|
||||||
|
//repeatEditor->setItemDelegate(new RepeatCounterDelegate());
|
||||||
|
|
||||||
|
//connect(repeatEditor,SIGNAL(activated (const QString& )),this,SLOT(selectRow(const QString& )));
|
||||||
|
//QTableWidgetItem* item = qobject_cast<QTableWidgetItem *>(parent);
|
||||||
|
//((QTableWidgetItem*)parent)->setSelected(true);
|
||||||
|
connect(editor, SIGNAL(editingFinished()),
|
||||||
|
this, SLOT(commitAndCloseEditor()));
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
QLineEdit *editor = new QLineEdit(parent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
connect(editor, SIGNAL(editingFinished()),
|
||||||
|
this, SLOT(commitAndCloseEditor()));
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyItemDelegate::commitAndCloseEditor()
|
||||||
|
{
|
||||||
|
QLineEdit *editor = qobject_cast<QLineEdit *>(sender());
|
||||||
|
if (editor)
|
||||||
|
{
|
||||||
|
emit commitData(editor);
|
||||||
|
emit closeEditor(editor);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QComboBox* editor = qobject_cast<QComboBox*>(sender());
|
||||||
|
if (editor)
|
||||||
|
{
|
||||||
|
emit commitData(editor);
|
||||||
|
emit closeEditor(editor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyItemDelegate::setEditorData(QWidget *editor,
|
||||||
|
const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QLineEdit *edit = qobject_cast<QLineEdit*>(editor);
|
||||||
|
if (edit) {
|
||||||
|
edit->setText(index.model()->data(index, Qt::EditRole).toString());
|
||||||
|
} else {
|
||||||
|
QComboBox * repeatEditor = qobject_cast<QComboBox *>(editor);
|
||||||
|
if (repeatEditor)
|
||||||
|
repeatEditor->setCurrentIndex(repeatEditor->findText(index.model()->data(index, Qt::EditRole).toString()));
|
||||||
|
// QTableWidgetItem* item = ((QTableWidget*)m_parent)->item(index.row(),1);
|
||||||
|
// item->setSelected(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyItemDelegate::setModelData(QWidget *editor,
|
||||||
|
QAbstractItemModel *model, const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QLineEdit *edit = qobject_cast<QLineEdit *>(editor);
|
||||||
|
if (edit) {
|
||||||
|
model->setData(index, edit->text());
|
||||||
|
} else {
|
||||||
|
QComboBox * repeatEditor = qobject_cast<QComboBox *>(editor);
|
||||||
|
if (repeatEditor) {
|
||||||
|
model->setData(index, repeatEditor->currentText());
|
||||||
|
// emit commitData(repeatEditor);
|
||||||
|
// emit closeEditor(repeatEditor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void NotifyItemDelegate::selectRow(const QString & text)
|
||||||
|
{
|
||||||
|
//QList<QTableWidgetItem *> list = ((QTableWidget*)(sender()->parent()))->findItems(text,Qt::MatchExactly);
|
||||||
|
QComboBox* combo = qobject_cast<QComboBox*>(sender());
|
||||||
|
QTableWidget* table = new QTableWidget;
|
||||||
|
table = (QTableWidget*)(combo->parent());
|
||||||
|
qDebug()<<table->columnCount();
|
||||||
|
qDebug()<<table->rowCount();
|
||||||
|
qDebug()<<table->currentRow();
|
||||||
|
//table->setCurrentIndex(1);
|
||||||
|
//table->findItems(text,Qt::MatchExactly);
|
||||||
|
//item->model()->index()
|
||||||
|
//item->setSelected(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// bool NotifyItemDelegate::editorEvent(QEvent * event, QAbstractItemModel * model,
|
||||||
|
// const QStyleOptionViewItem & option, const QModelIndex & index )
|
||||||
|
// {
|
||||||
|
// if(event->type()==QEvent::EnabledChange)
|
||||||
|
// {
|
||||||
|
// QTableWidgetItem* item = ((QTableWidget*)parent())->item(index.row(),index.column());
|
||||||
|
// item->setSelected(true);
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
|
// }
|
74
ground/src/plugins/notify/notifyitemdelegate.h
Normal file
74
ground/src/plugins/notify/notifyitemdelegate.h
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file notifyitemdelegate.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup notifyplugin
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* 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 NOTIFYITEMDELEGATE_H
|
||||||
|
#define NOTIFYITEMDELEGATE_H
|
||||||
|
|
||||||
|
#include <QItemDelegate>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
//class RepeatCounterDelegate : public QItemDelegate
|
||||||
|
//{
|
||||||
|
// Q_OBJECT
|
||||||
|
|
||||||
|
//public:
|
||||||
|
// RepeatCounterDelegate(QObject *parent = 0);
|
||||||
|
// QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
||||||
|
// const QModelIndex &index) const;
|
||||||
|
// void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||||
|
// void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
// const QModelIndex &index) const;
|
||||||
|
|
||||||
|
//private slots:
|
||||||
|
// void commitAndCloseEditor();
|
||||||
|
//};
|
||||||
|
|
||||||
|
class NotifyItemDelegate : public QItemDelegate
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
NotifyItemDelegate(QStringList items, QObject *parent = 0);
|
||||||
|
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
|
||||||
|
const QModelIndex &index) const;
|
||||||
|
void setEditorData(QWidget *editor, const QModelIndex &index) const;
|
||||||
|
void setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
const QModelIndex &index) const;
|
||||||
|
// bool editorEvent(QEvent * event, QAbstractItemModel * model,
|
||||||
|
// const QStyleOptionViewItem & option, const QModelIndex & index );
|
||||||
|
private:
|
||||||
|
QObject* m_parent;
|
||||||
|
QStringList m_items;
|
||||||
|
QComboBox* repeatEditor;
|
||||||
|
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void selectRow(const QString & text);
|
||||||
|
void commitAndCloseEditor();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // NOTIFYITEMDELEGATE_H
|
@ -1,12 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file donothingplugin.cpp
|
* @file notifyplugin.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup donothingplugin
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -67,9 +66,9 @@ void SoundNotifyPlugin::extensionsInitialized()
|
|||||||
int size = settings->beginReadArray("listNotifies");
|
int size = settings->beginReadArray("listNotifies");
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
notify = new NotifyPluginConfiguration;
|
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
|
||||||
notify->restoreState(settings);
|
notification->restoreState(settings);
|
||||||
lstNotifications.append(notify);
|
lstNotifications.append(notification);
|
||||||
}
|
}
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
setEnableSound(settings->value(QLatin1String("EnableSound"),0).toBool());
|
setEnableSound(settings->value(QLatin1String("EnableSound"),0).toBool());
|
||||||
@ -95,28 +94,41 @@ void SoundNotifyPlugin::connectNotifications()
|
|||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||||
|
|
||||||
QList<Phonon::MediaObject*> deleteList = mapMediaObjects.values();
|
lstNotifiedUAVObjects.clear();
|
||||||
if(!deleteList.isEmpty())
|
|
||||||
foreach(Phonon::MediaObject* mediaObj,deleteList)
|
// QList<Phonon::MediaObject*> deleteList = mapMediaObjects.values();
|
||||||
delete mediaObj;
|
// if(!deleteList.isEmpty())
|
||||||
|
// foreach(Phonon::MediaObject* mediaObj,deleteList)
|
||||||
|
// delete mediaObj;
|
||||||
|
|
||||||
// Check validity of arguments first, reject empty args and unknown fields.
|
// Check validity of arguments first, reject empty args and unknown fields.
|
||||||
foreach(NotifyPluginConfiguration* notify,lstNotifications) {
|
foreach(NotifyPluginConfiguration* notify,lstNotifications) {
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(notify->getDataObject()) );
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(notify->getDataObject()) );
|
||||||
if (obj != NULL ) {
|
if (obj != NULL ) {
|
||||||
std::cout << "Connected Object (" << notify->getDataObject().toStdString() << ")." << std::endl;
|
if(!lstNotifiedUAVObjects.contains(obj))
|
||||||
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(playNotification(UAVObject*)));
|
{
|
||||||
lstNotifiedUAVObjects.append(obj);
|
lstNotifiedUAVObjects.append(obj);
|
||||||
notify->parseNotifyMessage();
|
connect(obj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(playNotification(UAVObject*)));
|
||||||
mediaSource = notify->getNotifyMessageList();
|
}
|
||||||
lstMediaSource.append(new QList<Phonon::MediaSource>);
|
//lstMediaSource.append(new QList<Phonon::MediaSource>);
|
||||||
foreach(QString item, mediaSource)
|
|
||||||
lstMediaSource.last()->append(Phonon::MediaSource(item));
|
|
||||||
|
|
||||||
|
QMap<QString, PhononObject>::const_iterator iter = mapMediaObjects.find(obj->getName());
|
||||||
|
if(iter==mapMediaObjects.end()) {
|
||||||
// set notification message to current event
|
// set notification message to current event
|
||||||
mapMediaObjects[obj->getName()] = new Phonon::MediaObject;
|
mapMediaObjects[obj->getName()].mo = new Phonon::MediaObject;
|
||||||
mapMediaObjects[obj->getName()] = Phonon::createPlayer(Phonon::NotificationCategory);
|
mapMediaObjects[obj->getName()].mo = Phonon::createPlayer(Phonon::NotificationCategory);
|
||||||
mapMediaObjects[obj->getName()]->setQueue(*lstMediaSource.last());
|
mapMediaObjects[obj->getName()].ms = new QList<Phonon::MediaSource>;
|
||||||
|
mapMediaObjects[obj->getName()].mo->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
// notify->parseNotifyMessage();
|
||||||
|
// foreach(QString item, notify->getNotifyMessageList())
|
||||||
|
// {
|
||||||
|
// mapMediaObjects[obj->getName()].ms->clear();
|
||||||
|
// mapMediaObjects[obj->getName()].ms->append(Phonon::MediaSource(item));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//mapMediaObjects[obj->getName()].ms = lstMediaSource.last();
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Error: Object is unknown (" << notify->getDataObject().toStdString() << ")." << std::endl;
|
std::cout << "Error: Object is unknown (" << notify->getDataObject().toStdString() << ")." << std::endl;
|
||||||
}
|
}
|
||||||
@ -128,42 +140,56 @@ void SoundNotifyPlugin::playNotification(UAVObject *object)
|
|||||||
UAVObjectField* field;
|
UAVObjectField* field;
|
||||||
double threshold;
|
double threshold;
|
||||||
QString direction;
|
QString direction;
|
||||||
|
QString fieldName;
|
||||||
bool play = false;
|
bool play = false;
|
||||||
|
NotifyPluginConfiguration* notification;
|
||||||
|
|
||||||
foreach(NotifyPluginConfiguration* notify, lstNotifications) {
|
foreach(notification, lstNotifications) {
|
||||||
if(object->getName()==notify->getDataObject()) {
|
if(object->getName()==notification->getDataObject()) {
|
||||||
QString fld = notify->getObjectField();
|
fieldName = notification->getObjectField();
|
||||||
field = object->getField(fld);
|
field = object->getField(fieldName);
|
||||||
threshold = notify->getSpinBoxValue();
|
threshold = notification->getSpinBoxValue();
|
||||||
direction = notify->getValue();
|
direction = notification->getValue();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field) {
|
if (field) {
|
||||||
|
double value = field->getDouble();
|
||||||
|
//qDebug() << fieldName << " - value - " << value;
|
||||||
|
|
||||||
switch(direction[0].toAscii())
|
switch(direction[0].toAscii())
|
||||||
{
|
{
|
||||||
case 'E':
|
case 'E':
|
||||||
if(field->getDouble()==threshold)
|
if(value==threshold)
|
||||||
play = true;
|
play = true;
|
||||||
break;
|
break;
|
||||||
case 'G':
|
case 'G':
|
||||||
if(field->getDouble()>threshold)
|
if(value>threshold)
|
||||||
play = true;
|
play = true;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
if(field->getDouble()<threshold)
|
if(value<threshold)
|
||||||
play = true;
|
play = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(play)
|
if(play)
|
||||||
{
|
{
|
||||||
if((mapMediaObjects[object->getName()]->state()==Phonon::PausedState) ||
|
play = false;
|
||||||
(mapMediaObjects[object->getName()]->state()==Phonon::StoppedState))
|
if((mapMediaObjects[object->getName()].mo->state()==Phonon::PausedState) ||
|
||||||
|
(mapMediaObjects[object->getName()].mo->state()==Phonon::StoppedState))
|
||||||
{
|
{
|
||||||
mapMediaObjects[object->getName()]->clear();
|
qDebug() << fieldName << " - value - " << value;
|
||||||
mapMediaObjects[object->getName()]->setQueue(*lstMediaSource.last());
|
mapMediaObjects[object->getName()].mo->clear();
|
||||||
mapMediaObjects[object->getName()]->play();
|
mapMediaObjects[object->getName()].ms->clear();
|
||||||
|
notification->parseNotifyMessage();
|
||||||
|
foreach(QString item, notification->getNotifyMessageList())
|
||||||
|
mapMediaObjects[object->getName()].ms->append(Phonon::MediaSource(item));
|
||||||
|
mapMediaObjects[object->getName()].mo->setQueue(*mapMediaObjects[object->getName()].ms);
|
||||||
|
mapMediaObjects[object->getName()].mo->play();
|
||||||
|
if(notification->getRepeatFlag()=="Once")
|
||||||
|
lstNotifications.removeOne(notification);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file donothingplugin.h
|
* @file notifyplugin.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup donothingplugin
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -37,6 +36,11 @@
|
|||||||
class NotifyPluginOptionsPage;
|
class NotifyPluginOptionsPage;
|
||||||
class NotifyPluginConfiguration;
|
class NotifyPluginConfiguration;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Phonon::MediaObject* mo;
|
||||||
|
QList<Phonon::MediaSource>* ms;
|
||||||
|
} PhononObject, *pPhononObject;
|
||||||
|
|
||||||
class SoundNotifyPlugin : public ExtensionSystem::IPlugin
|
class SoundNotifyPlugin : public ExtensionSystem::IPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -60,7 +64,9 @@ private:
|
|||||||
bool enableSound;
|
bool enableSound;
|
||||||
QList< QList<Phonon::MediaSource>* > lstMediaSource;
|
QList< QList<Phonon::MediaSource>* > lstMediaSource;
|
||||||
QStringList mediaSource;
|
QStringList mediaSource;
|
||||||
QMap<QString, Phonon::MediaObject*> mapMediaObjects;
|
//QMap<QString, Phonon::MediaObject*> mapMediaObjects;
|
||||||
|
QMap<QString, PhononObject> mapMediaObjects;
|
||||||
|
|
||||||
QSettings* settings;
|
QSettings* settings;
|
||||||
|
|
||||||
QList<UAVDataObject*> lstNotifiedUAVObjects;
|
QList<UAVDataObject*> lstNotifiedUAVObjects;
|
||||||
@ -68,7 +74,7 @@ private:
|
|||||||
QList<NotifyPluginConfiguration*> lstNotifications;
|
QList<NotifyPluginConfiguration*> lstNotifications;
|
||||||
QString m_field;
|
QString m_field;
|
||||||
|
|
||||||
NotifyPluginConfiguration *notify;
|
|
||||||
NotifyPluginOptionsPage *mop;
|
NotifyPluginOptionsPage *mop;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file NotifyPluginConfiguration.cpp
|
* @file notifyPluginConfiguration.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Airspeed Plugin Gadget configuration
|
* @brief Notify Plugin configuration
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup Airspeed
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -39,7 +39,8 @@ NotifyPluginConfiguration::NotifyPluginConfiguration(QObject *parent) :
|
|||||||
sound1(""),
|
sound1(""),
|
||||||
sound2(""),
|
sound2(""),
|
||||||
sayOrder("Never"),
|
sayOrder("Never"),
|
||||||
spinBoxValue(0)
|
spinBoxValue(0),
|
||||||
|
repeatString("Continue")
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -56,7 +57,7 @@ void NotifyPluginConfiguration::saveState(QSettings* settings) const
|
|||||||
settings->setValue(QLatin1String("Sound1"), getSound1());
|
settings->setValue(QLatin1String("Sound1"), getSound1());
|
||||||
settings->setValue(QLatin1String("Sound2"), getSound2());
|
settings->setValue(QLatin1String("Sound2"), getSound2());
|
||||||
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
|
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
|
||||||
|
settings->setValue(QLatin1String("Repeat"), getRepeatFlag());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyPluginConfiguration::restoreState(QSettings* settings)
|
void NotifyPluginConfiguration::restoreState(QSettings* settings)
|
||||||
@ -71,6 +72,7 @@ void NotifyPluginConfiguration::restoreState(QSettings* settings)
|
|||||||
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
||||||
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toString());
|
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toString());
|
||||||
setSpinBoxValue(settings->value(QLatin1String("ValueSpinBox"), tr("")).toDouble());
|
setSpinBoxValue(settings->value(QLatin1String("ValueSpinBox"), tr("")).toDouble());
|
||||||
|
setRepeatFlag(settings->value(QLatin1String("Repeat"), tr("")).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -136,11 +138,11 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
|
|||||||
|
|
||||||
if((numberParts.at(0).size()==1) || (numberParts.at(0).toInt()<20))
|
if((numberParts.at(0).size()==1) || (numberParts.at(0).toInt()<20))
|
||||||
{
|
{
|
||||||
if(numberParts.at(0)!="0")
|
//if(numberParts.at(0)!="0")
|
||||||
numberFiles.append(numberParts.at(0));
|
numberFiles.append(numberParts.at(0));
|
||||||
} else {
|
} else {
|
||||||
int i=0;
|
int i=0;
|
||||||
if(numberParts.at(0).right(2).toInt()<20) {
|
if(numberParts.at(0).right(2).toInt()<20 && numberParts.at(0).right(2).toInt()!=0) {
|
||||||
if(numberParts.at(0).right(2).toInt()<10)
|
if(numberParts.at(0).right(2).toInt()<10)
|
||||||
numberFiles.append(numberParts.at(0).right(1));
|
numberFiles.append(numberParts.at(0).right(1));
|
||||||
else
|
else
|
||||||
@ -165,9 +167,12 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
|
|||||||
|
|
||||||
if(numberParts.size()>1) {
|
if(numberParts.size()>1) {
|
||||||
numberFiles.append("point");
|
numberFiles.append("point");
|
||||||
if((numberParts.at(1).size()==1) || (numberParts.at(1).toInt()<20))
|
if((numberParts.at(1).size()==1) /*|| (numberParts.at(1).toInt()<20)*/)
|
||||||
numberFiles.append(numberParts.at(1));
|
numberFiles.append(numberParts.at(1));
|
||||||
else {
|
else {
|
||||||
|
if(numberParts.at(1).left(1)=="0")
|
||||||
|
numberFiles.append(numberParts.at(1).left(1));
|
||||||
|
else
|
||||||
numberFiles.append(numberParts.at(1).left(1)+'0');
|
numberFiles.append(numberParts.at(1).left(1)+'0');
|
||||||
numberFiles.append(numberParts.at(1).right(1));
|
numberFiles.append(numberParts.at(1).right(1));
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file NotifyPluginConfiguration.h
|
* @file notifypluginconfiguration.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Airspeed Plugin Gadget configuration
|
* @brief Notify Plugin configuration header
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup Airspeed
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -71,6 +71,8 @@ public:
|
|||||||
QStringList getNotifyMessageList() const { return notifyMessageList; }
|
QStringList getNotifyMessageList() const { return notifyMessageList; }
|
||||||
void setNotifyMessageList(QStringList text) { notifyMessageList = text; }
|
void setNotifyMessageList(QStringList text) { notifyMessageList = text; }
|
||||||
|
|
||||||
|
QString getRepeatFlag() const { return repeatString; }
|
||||||
|
void setRepeatFlag(QString value) { repeatString = value; }
|
||||||
|
|
||||||
void saveState(QSettings* settings) const;
|
void saveState(QSettings* settings) const;
|
||||||
void restoreState(QSettings* settings);
|
void restoreState(QSettings* settings);
|
||||||
@ -88,6 +90,7 @@ private:
|
|||||||
QString sound2;
|
QString sound2;
|
||||||
QString sayOrder;
|
QString sayOrder;
|
||||||
double spinBoxValue;
|
double spinBoxValue;
|
||||||
|
QString repeatString;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file notifypluginfactory.cpp
|
* @file notifypluginfactory.cpp
|
||||||
* @author David "Buzz" Carlson Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup airspeed
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file notifypluginfactory.h
|
* @file notifypluginfactory.h
|
||||||
* @author David "Buzz" Carlson Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup airspeed
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file NotifyPlugingadget.h
|
* @file notifyplugingadget.h
|
||||||
* @author David "Buzz" Carlson Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief
|
* @brief
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup NotifyPlugin
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* @file notifypluginoptionspage.cpp
|
* @file notifypluginoptionspage.cpp
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Sound Notify Plugin options page
|
* @brief Notify Plugin options page
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup Airspeed
|
* @defgroup notifyplugin
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -40,7 +40,7 @@
|
|||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
#include "notifyplugin.h"
|
#include "notifyplugin.h"
|
||||||
|
#include "notifyitemdelegate.h"
|
||||||
|
|
||||||
NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotifyPluginConfiguration *config,*/ QObject *parent) :
|
NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotifyPluginConfiguration *config,*/ QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
@ -61,37 +61,34 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
|||||||
QWidget *optionsPageWidget = new QWidget;
|
QWidget *optionsPageWidget = new QWidget;
|
||||||
//main layout
|
//main layout
|
||||||
options_page->setupUi(optionsPageWidget);
|
options_page->setupUi(optionsPageWidget);
|
||||||
|
delegateItems.clear();
|
||||||
|
delegateItems << "Continue" << "Once";
|
||||||
|
|
||||||
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
options_page->chkEnableSound->setChecked(owner->getEnableSound());
|
||||||
options_page->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
options_page->SoundDirectoryPathChooser->setExpectedKind(Utils::PathChooser::Directory);
|
||||||
options_page->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory"));
|
options_page->SoundDirectoryPathChooser->setPromptDialogTitle(tr("Choose sound collection directory"));
|
||||||
|
// connect(options_page->tableNotifications->model(),SIGNAL(rowsInserted ( const QModelIndex & , int , int )),this,
|
||||||
|
// SLOT(showPersistentComboBox ( const QModelIndex & , int , int )));
|
||||||
|
// connect(options_page->tableNotifications->model(),SIGNAL(dataChanged ( const QModelIndex & , const QModelIndex & )),this,
|
||||||
|
// SLOT(showPersistentComboBox2( const QModelIndex & , const QModelIndex & )));
|
||||||
|
|
||||||
|
|
||||||
options_page->tableNotifications->setRowCount(0);
|
options_page->tableNotifications->setRowCount(0);
|
||||||
|
options_page->tableNotifications->setItemDelegate(new NotifyItemDelegate(delegateItems,options_page->tableNotifications));
|
||||||
|
|
||||||
|
QStringList labels;
|
||||||
|
labels << "Name" << "Repeats";
|
||||||
|
options_page->tableNotifications->setHorizontalHeaderLabels(labels);
|
||||||
privListNotifications.clear();
|
privListNotifications.clear();
|
||||||
listSoundFiles.clear();
|
listSoundFiles.clear();
|
||||||
|
|
||||||
settings = Core::ICore::instance()->settings();
|
settings = Core::ICore::instance()->settings();
|
||||||
settings->beginGroup(QLatin1String("NotifyPlugin"));
|
settings->beginGroup(QLatin1String("NotifyPlugin"));
|
||||||
|
|
||||||
int size = settings->beginReadArray("listNotifies");
|
|
||||||
for (int i = 0; i < size; ++i) {
|
|
||||||
settings->setArrayIndex(i);
|
|
||||||
notify = new NotifyPluginConfiguration;
|
|
||||||
notify->restoreState(settings);
|
|
||||||
privListNotifications.append(notify);
|
|
||||||
}
|
|
||||||
settings->endArray();
|
|
||||||
|
|
||||||
settings->beginReadArray("Current");
|
|
||||||
settings->setArrayIndex(0);
|
|
||||||
notify = new NotifyPluginConfiguration;
|
|
||||||
notify->restoreState(settings);
|
|
||||||
settings->endArray();
|
|
||||||
options_page->chkEnableSound->setChecked(settings->value(QLatin1String("EnableSound"),0).toBool());
|
|
||||||
settings->endGroup();
|
|
||||||
|
|
||||||
// Fills the combo boxes for the UAVObjects
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
objManager = pm->getObject<UAVObjectManager>();
|
objManager = pm->getObject<UAVObjectManager>();
|
||||||
|
|
||||||
|
// Fills the combo boxes for the UAVObjects
|
||||||
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
QList< QList<UAVDataObject*> > objList = objManager->getDataObjects();
|
||||||
foreach (QList<UAVDataObject*> list, objList) {
|
foreach (QList<UAVDataObject*> list, objList) {
|
||||||
foreach (UAVDataObject* obj, list) {
|
foreach (UAVDataObject* obj, list) {
|
||||||
@ -112,9 +109,23 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
|||||||
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
|
||||||
connect(this, SIGNAL(updateNotifications()), owner, SLOT(connectNotifications()));
|
connect(this, SIGNAL(updateNotifications()), owner, SLOT(connectNotifications()));
|
||||||
|
|
||||||
//connect(options_page->chkEnableSound, SIGNAL(stateChanged(int)), this, SLOT(enableSound(int)));
|
int size = settings->beginReadArray("listNotifies");
|
||||||
|
for (int i = 0; i < size; ++i) {
|
||||||
|
settings->setArrayIndex(i);
|
||||||
|
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
|
||||||
|
notification->restoreState(settings);
|
||||||
|
privListNotifications.append(notification);
|
||||||
|
}
|
||||||
|
settings->endArray();
|
||||||
|
|
||||||
updateConfigView(notify);
|
settings->beginReadArray("Current");
|
||||||
|
settings->setArrayIndex(0);
|
||||||
|
NotifyPluginConfiguration notification;
|
||||||
|
notification.restoreState(settings);
|
||||||
|
updateConfigView(¬ification);
|
||||||
|
settings->endArray();
|
||||||
|
options_page->chkEnableSound->setChecked(settings->value(QLatin1String("EnableSound"),0).toBool());
|
||||||
|
settings->endGroup();
|
||||||
|
|
||||||
foreach(NotifyPluginConfiguration* notification,privListNotifications)
|
foreach(NotifyPluginConfiguration* notification,privListNotifications)
|
||||||
{
|
{
|
||||||
@ -122,7 +133,13 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
|||||||
options_page->tableNotifications->setItem (options_page->tableNotifications->rowCount()-1,0,
|
options_page->tableNotifications->setItem (options_page->tableNotifications->rowCount()-1,0,
|
||||||
new QTableWidgetItem(notification->parseNotifyMessage()));
|
new QTableWidgetItem(notification->parseNotifyMessage()));
|
||||||
|
|
||||||
|
QString str = notification->getRepeatFlag();
|
||||||
|
options_page->tableNotifications->setItem (options_page->tableNotifications->rowCount()-1,1,
|
||||||
|
new QTableWidgetItem(str));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
options_page->buttonModify->setEnabled(false);
|
options_page->buttonModify->setEnabled(false);
|
||||||
options_page->buttonDelete->setEnabled(false);
|
options_page->buttonDelete->setEnabled(false);
|
||||||
options_page->buttonPlayNotification->setEnabled(false);
|
options_page->buttonPlayNotification->setEnabled(false);
|
||||||
@ -143,17 +160,38 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
|
|||||||
return optionsPageWidget;
|
return optionsPageWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyPluginOptionsPage::getOptionsPageValues()
|
void NotifyPluginOptionsPage::showPersistentComboBox( const QModelIndex & parent, int start, int end )
|
||||||
{
|
{
|
||||||
notify->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
// for (int i=start; i<end+1; i++) {
|
||||||
notify->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
// options_page->tableNotifications->openPersistentEditor(options_page->tableNotifications->item(i,1));
|
||||||
notify->setDataObject(options_page->UAVObject->currentText());
|
// }
|
||||||
notify->setObjectField(options_page->UAVObjectField->currentText());
|
}
|
||||||
notify->setSound1(options_page->Sound1->currentText());
|
|
||||||
notify->setSound2(options_page->Sound2->currentText());
|
void NotifyPluginOptionsPage::showPersistentComboBox2( const QModelIndex & topLeft, const QModelIndex & bottomRight )
|
||||||
notify->setSayOrder(options_page->SayOrder->currentText());
|
{
|
||||||
notify->setValue(options_page->Value->currentText());
|
//for (QModelIndex i=topLeft; i<bottomRight+1; i++)
|
||||||
notify->setSpinBoxValue(options_page->ValueSpinBox->value());
|
{
|
||||||
|
options_page->tableNotifications->openPersistentEditor(options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void NotifyPluginOptionsPage::getOptionsPageValues(NotifyPluginConfiguration* notification)
|
||||||
|
{
|
||||||
|
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||||
|
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||||
|
notification->setDataObject(options_page->UAVObject->currentText());
|
||||||
|
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||||
|
notification->setSound1(options_page->Sound1->currentText());
|
||||||
|
notification->setSound2(options_page->Sound2->currentText());
|
||||||
|
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||||
|
notification->setValue(options_page->Value->currentText());
|
||||||
|
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||||
|
if(options_page->tableNotifications->currentRow()>-1)
|
||||||
|
{
|
||||||
|
qDebug() << "delegate value:" << options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),1)->data(Qt::EditRole);
|
||||||
|
notification->setRepeatFlag(options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),1)->data(Qt::EditRole).toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
@ -164,13 +202,15 @@ void NotifyPluginOptionsPage::getOptionsPageValues()
|
|||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
void NotifyPluginOptionsPage::apply()
|
void NotifyPluginOptionsPage::apply()
|
||||||
{
|
{
|
||||||
|
NotifyPluginConfiguration notification;
|
||||||
|
|
||||||
settings->beginGroup(QLatin1String("NotifyPlugin"));
|
settings->beginGroup(QLatin1String("NotifyPlugin"));
|
||||||
|
|
||||||
getOptionsPageValues();
|
getOptionsPageValues(¬ification);
|
||||||
|
|
||||||
settings->beginWriteArray("Current");
|
settings->beginWriteArray("Current");
|
||||||
settings->setArrayIndex(0);
|
settings->setArrayIndex(0);
|
||||||
notify->saveState(settings);
|
notification.saveState(settings);
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
|
|
||||||
//settings->remove("listNotifies");
|
//settings->remove("listNotifies");
|
||||||
@ -184,13 +224,13 @@ void NotifyPluginOptionsPage::apply()
|
|||||||
settings->setArrayIndex(i);
|
settings->setArrayIndex(i);
|
||||||
privListNotifications.at(i)->saveState(settings);
|
privListNotifications.at(i)->saveState(settings);
|
||||||
}
|
}
|
||||||
owner->setListNotifications(privListNotifications);
|
|
||||||
settings->endArray();
|
settings->endArray();
|
||||||
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
|
||||||
settings->setValue(QLatin1String("EnableSound"), options_page->chkEnableSound->isChecked());
|
settings->setValue(QLatin1String("EnableSound"), options_page->chkEnableSound->isChecked());
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
|
|
||||||
//emit updateNotifications();
|
owner->setEnableSound(options_page->chkEnableSound->isChecked());
|
||||||
|
owner->setListNotifications(privListNotifications);
|
||||||
|
emit updateNotifications();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotifyPluginOptionsPage::finish()
|
void NotifyPluginOptionsPage::finish()
|
||||||
@ -252,31 +292,43 @@ void NotifyPluginOptionsPage::changeButtonText(Phonon::State newstate, Phonon::
|
|||||||
{
|
{
|
||||||
if(sender()==sound1)
|
if(sender()==sound1)
|
||||||
{
|
{
|
||||||
if(newstate == Phonon::PausedState)
|
if(newstate == Phonon::PausedState) {
|
||||||
options_page->buttonTestSound1->setText("Play");
|
options_page->buttonTestSound1->setText("Play");
|
||||||
|
options_page->buttonTestSound1->setIcon(QPixmap(":/notify/images/play.png"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if(newstate == Phonon::PlayingState)
|
if(newstate == Phonon::PlayingState) {
|
||||||
options_page->buttonTestSound1->setText("Stop");
|
options_page->buttonTestSound1->setText("Stop");
|
||||||
|
options_page->buttonTestSound1->setIcon(QPixmap(":/notify/images/stop.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sender()==sound2)
|
if(sender()==sound2)
|
||||||
{
|
{
|
||||||
if(newstate == Phonon::PausedState)
|
if(newstate == Phonon::PausedState) {
|
||||||
options_page->buttonTestSound2->setText("Play");
|
options_page->buttonTestSound2->setText("Play");
|
||||||
|
options_page->buttonTestSound2->setIcon(QPixmap(":/notify/images/play.png"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if(newstate == Phonon::PlayingState)
|
if(newstate == Phonon::PlayingState) {
|
||||||
options_page->buttonTestSound2->setText("Stop");
|
options_page->buttonTestSound2->setText("Stop");
|
||||||
|
options_page->buttonTestSound2->setIcon(QPixmap(":/notify/images/stop.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(sender()==notifySound)
|
if(sender()==notifySound)
|
||||||
{
|
{
|
||||||
if(newstate == Phonon::PausedState)
|
if(newstate == Phonon::PausedState){
|
||||||
options_page->buttonPlayNotification->setText("Play");
|
options_page->buttonPlayNotification->setText("Play");
|
||||||
|
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/play.png"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
if(newstate == Phonon::PlayingState)
|
if(newstate == Phonon::PlayingState) {
|
||||||
options_page->buttonPlayNotification->setText("Stop");
|
options_page->buttonPlayNotification->setText("Stop");
|
||||||
|
options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/stop.png"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -318,11 +370,12 @@ void NotifyPluginOptionsPage::on_buttonTestSound2_clicked()
|
|||||||
void NotifyPluginOptionsPage::on_buttonTestSoundNotification_clicked()
|
void NotifyPluginOptionsPage::on_buttonTestSoundNotification_clicked()
|
||||||
{
|
{
|
||||||
QList <Phonon::MediaSource> messageNotify;
|
QList <Phonon::MediaSource> messageNotify;
|
||||||
|
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
|
||||||
//getOptionsPageValues();
|
//getOptionsPageValues();
|
||||||
if(options_page->tableNotifications->currentRow()==-1) return;
|
if(options_page->tableNotifications->currentRow()==-1) return;
|
||||||
notify = privListNotifications.at(options_page->tableNotifications->currentRow());
|
notification = privListNotifications.at(options_page->tableNotifications->currentRow());
|
||||||
notify->parseNotifyMessage();
|
notification->parseNotifyMessage();
|
||||||
QStringList stringList = notify->getNotifyMessageList();
|
QStringList stringList = notification->getNotifyMessageList();
|
||||||
foreach(QString item, stringList)
|
foreach(QString item, stringList)
|
||||||
messageNotify.append(Phonon::MediaSource(item));
|
messageNotify.append(Phonon::MediaSource(item));
|
||||||
notifySound->clear();
|
notifySound->clear();
|
||||||
@ -352,8 +405,14 @@ void NotifyPluginOptionsPage::on_chkEnableSound_toggled(bool state)
|
|||||||
|
|
||||||
void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notification)
|
void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notification)
|
||||||
{
|
{
|
||||||
|
QString path = notification->getSoundCollectionPath();
|
||||||
options_page->SoundDirectoryPathChooser->setPath(notification->getSoundCollectionPath());
|
if(path=="")
|
||||||
|
{
|
||||||
|
//QDir dir = QDir::currentPath();
|
||||||
|
//path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds";
|
||||||
|
path = "../share/sounds";
|
||||||
|
}
|
||||||
|
options_page->SoundDirectoryPathChooser->setPath(path);
|
||||||
|
|
||||||
if(options_page->SoundCollectionList->findText(notification->getCurrentLanguage())!=-1){
|
if(options_page->SoundCollectionList->findText(notification->getCurrentLanguage())!=-1){
|
||||||
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage()));
|
||||||
@ -368,7 +427,8 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi
|
|||||||
|
|
||||||
// Now load the object field values:
|
// Now load the object field values:
|
||||||
options_page->UAVObjectField->clear();
|
options_page->UAVObjectField->clear();
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(notification->getDataObject()/*objList.at(0).at(0)->getName()*/) );
|
QString uavDataObject = notification->getDataObject();
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(uavDataObject/*objList.at(0).at(0)->getName()*/) );
|
||||||
if (obj != NULL ) {
|
if (obj != NULL ) {
|
||||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||||
foreach (UAVObjectField* field, fieldList) {
|
foreach (UAVObjectField* field, fieldList) {
|
||||||
@ -405,6 +465,7 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi
|
|||||||
// don't show item if it wasn't find in stored location
|
// don't show item if it wasn't find in stored location
|
||||||
//options_page->Sound2->setCurrentIndex(-1);
|
//options_page->Sound2->setCurrentIndex(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(options_page->Value->findText(notification->getValue())!=-1) {
|
if(options_page->Value->findText(notification->getValue())!=-1) {
|
||||||
options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue()));
|
options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue()));
|
||||||
}
|
}
|
||||||
@ -417,12 +478,10 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi
|
|||||||
|
|
||||||
void NotifyPluginOptionsPage::on_tableNotification_changeSelection()
|
void NotifyPluginOptionsPage::on_tableNotification_changeSelection()
|
||||||
{
|
{
|
||||||
QTableWidgetItem * item = options_page->tableNotifications->currentItem();
|
QTableWidgetItem * item = options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),0);
|
||||||
//qDebug()
|
|
||||||
if(!item) return;
|
if(!item) return;
|
||||||
// if(notify)
|
|
||||||
// delete notify;
|
|
||||||
//notify = );
|
|
||||||
updateConfigView(privListNotifications.at(item->row()));
|
updateConfigView(privListNotifications.at(item->row()));
|
||||||
options_page->buttonModify->setEnabled(item->isSelected());
|
options_page->buttonModify->setEnabled(item->isSelected());
|
||||||
options_page->buttonDelete->setEnabled(item->isSelected());
|
options_page->buttonDelete->setEnabled(item->isSelected());
|
||||||
@ -431,6 +490,8 @@ void NotifyPluginOptionsPage::on_tableNotification_changeSelection()
|
|||||||
|
|
||||||
void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
||||||
{
|
{
|
||||||
|
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
|
||||||
|
|
||||||
if(options_page->SoundDirectoryPathChooser->path()=="")
|
if(options_page->SoundDirectoryPathChooser->path()=="")
|
||||||
{
|
{
|
||||||
QPalette textPalette=options_page->SoundDirectoryPathChooser->palette();
|
QPalette textPalette=options_page->SoundDirectoryPathChooser->palette();
|
||||||
@ -440,31 +501,31 @@ void NotifyPluginOptionsPage::on_buttonAddNotification_clicked()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
notify->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
|
||||||
notify->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
|
||||||
notify->setDataObject(options_page->UAVObject->currentText());
|
notification->setDataObject(options_page->UAVObject->currentText());
|
||||||
notify->setObjectField(options_page->UAVObjectField->currentText());
|
notification->setObjectField(options_page->UAVObjectField->currentText());
|
||||||
notify->setValue(options_page->Value->currentText());
|
notification->setValue(options_page->Value->currentText());
|
||||||
notify->setSpinBoxValue(options_page->ValueSpinBox->value());
|
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
|
||||||
|
|
||||||
if(options_page->Sound1->currentText()!="")
|
if(options_page->Sound1->currentText()!="")
|
||||||
notify->setSound1(options_page->Sound1->currentText());
|
notification->setSound1(options_page->Sound1->currentText());
|
||||||
|
|
||||||
notify->setSound2(options_page->Sound2->currentText());
|
notification->setSound2(options_page->Sound2->currentText());
|
||||||
|
|
||||||
if((options_page->Sound2->currentText()=="")&&(options_page->SayOrder->currentText()=="After second"))
|
if((options_page->Sound2->currentText()=="")&&(options_page->SayOrder->currentText()=="After second"))
|
||||||
return;
|
return;
|
||||||
else
|
else
|
||||||
notify->setSayOrder(options_page->SayOrder->currentText());
|
notification->setSayOrder(options_page->SayOrder->currentText());
|
||||||
|
|
||||||
int row = options_page->tableNotifications->rowCount();
|
int row = options_page->tableNotifications->rowCount();
|
||||||
options_page->tableNotifications->setRowCount(row+1);
|
options_page->tableNotifications->setRowCount(row+1);
|
||||||
row = options_page->tableNotifications->rowCount();
|
row = options_page->tableNotifications->rowCount();
|
||||||
options_page->tableNotifications->setItem (row-1,0,
|
options_page->tableNotifications->setItem (row-1,0,new QTableWidgetItem(notification->parseNotifyMessage()));
|
||||||
new QTableWidgetItem(notify->parseNotifyMessage()));
|
options_page->tableNotifications->setItem (row-1,1,new QTableWidgetItem(delegateItems.first()));
|
||||||
|
//options_page->tableNotifications->openPersistentEditor(options_page->tableNotifications->item(row-1,1));
|
||||||
|
|
||||||
privListNotifications.append(notify);
|
privListNotifications.append(notification);
|
||||||
notify = new NotifyPluginConfiguration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -495,10 +556,14 @@ void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked()
|
|||||||
|
|
||||||
void NotifyPluginOptionsPage::on_buttonModifyNotification_clicked()
|
void NotifyPluginOptionsPage::on_buttonModifyNotification_clicked()
|
||||||
{
|
{
|
||||||
QTableWidgetItem * item = options_page->tableNotifications->currentItem();
|
NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
|
||||||
|
//NotifyPluginConfiguration notification;
|
||||||
|
|
||||||
|
QTableWidgetItem * item = options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),0);
|
||||||
if(!item) return;
|
if(!item) return;
|
||||||
notify = privListNotifications.at(item->row());
|
//notify = privListNotifications.at(item->row()); // ???
|
||||||
getOptionsPageValues();
|
getOptionsPageValues(notification);
|
||||||
item->setText(notify->parseNotifyMessage());
|
privListNotifications.replace(item->row(),notification);
|
||||||
|
item->setText(notification->parseNotifyMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
*
|
*
|
||||||
* @file notifypluginoptionspage.h
|
* @file notifypluginoptionspage.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
* @brief Airspeed Plugin Gadget options page
|
* @brief Notify Plugin options page header
|
||||||
* @see The GNU Public License (GPL) Version 3
|
* @see The GNU Public License (GPL) Version 3
|
||||||
* @defgroup SoundNotify
|
* @defgroup notify
|
||||||
* @{
|
* @{
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
@ -68,7 +68,7 @@ public:
|
|||||||
void restoreFromSettings();
|
void restoreFromSettings();
|
||||||
|
|
||||||
void updateConfigView(NotifyPluginConfiguration* notification);
|
void updateConfigView(NotifyPluginConfiguration* notification);
|
||||||
void getOptionsPageValues();
|
void getOptionsPageValues(NotifyPluginConfiguration* notification);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UAVObjectManager *objManager;
|
UAVObjectManager *objManager;
|
||||||
@ -82,16 +82,20 @@ private:
|
|||||||
Phonon::MediaObject *sound2;
|
Phonon::MediaObject *sound2;
|
||||||
Phonon::MediaObject *notifySound;
|
Phonon::MediaObject *notifySound;
|
||||||
Phonon::AudioOutput *audioOutput;
|
Phonon::AudioOutput *audioOutput;
|
||||||
|
QStringList delegateItems;
|
||||||
|
|
||||||
QList<NotifyPluginConfiguration*> privListNotifications;
|
QList<NotifyPluginConfiguration*> privListNotifications;
|
||||||
|
|
||||||
Ui::NotifyPluginOptionsPage *options_page;
|
Ui::NotifyPluginOptionsPage *options_page;
|
||||||
NotifyPluginConfiguration *notify;
|
//NotifyPluginConfiguration *notify;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateNotifications();
|
void updateNotifications();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void showPersistentComboBox( const QModelIndex & parent, int start, int end );
|
||||||
|
void showPersistentComboBox2 ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
|
||||||
|
|
||||||
void on_buttonTestSound1_clicked();
|
void on_buttonTestSound1_clicked();
|
||||||
void on_buttonTestSound2_clicked();
|
void on_buttonTestSound2_clicked();
|
||||||
void on_buttonTestSoundNotification_clicked();
|
void on_buttonTestSoundNotification_clicked();
|
||||||
|
@ -44,6 +44,10 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Play</string>
|
<string>Play</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="res.qrc">
|
||||||
|
<normaloff>:/notify/images/play.png</normaloff>:/notify/images/play.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="12">
|
<item row="2" column="12">
|
||||||
@ -162,6 +166,10 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Play</string>
|
<string>Play</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="res.qrc">
|
||||||
|
<normaloff>:/notify/images/play.png</normaloff>:/notify/images/play.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="10">
|
<item row="1" column="10">
|
||||||
@ -288,22 +296,22 @@ p, li { white-space: pre-wrap; }
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="editTriggers">
|
<property name="editTriggers">
|
||||||
<set>QAbstractItemView::NoEditTriggers</set>
|
<set>QAbstractItemView::DoubleClicked</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="columnCount">
|
<property name="columnCount">
|
||||||
<number>1</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="horizontalHeaderVisible">
|
<attribute name="horizontalHeaderVisible">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderDefaultSectionSize">
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
<number>300</number>
|
<number>200</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="horizontalHeaderMinimumSectionSize">
|
<attribute name="horizontalHeaderMinimumSectionSize">
|
||||||
<number>200</number>
|
<number>100</number>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="verticalHeaderVisible">
|
<attribute name="verticalHeaderVisible">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -315,6 +323,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
<column/>
|
<column/>
|
||||||
|
<column/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="layoutWidget">
|
<widget class="QWidget" name="layoutWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
@ -322,7 +331,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>180</y>
|
<y>180</y>
|
||||||
<width>481</width>
|
<width>481</width>
|
||||||
<height>25</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@ -351,6 +360,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Play</string>
|
<string>Play</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="res.qrc">
|
||||||
|
<normaloff>:/notify/images/play.png</normaloff>:/notify/images/play.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -384,6 +397,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="res.qrc">
|
||||||
|
<normaloff>:/notify/images/add.png</normaloff>:/notify/images/add.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -391,6 +408,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Modify</string>
|
<string>Modify</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="res.qrc">
|
||||||
|
<normaloff>:/notify/images/modify.png</normaloff>:/notify/images/modify.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -398,6 +419,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Delete</string>
|
<string>Delete</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../libs/utils/utils.qrc">
|
||||||
|
<normaloff>:/utils/images/removesubmitfield.png</normaloff>:/utils/images/removesubmitfield.png</iconset>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
@ -471,7 +496,10 @@ p, li { white-space: pre-wrap; }
|
|||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="../../libs/utils/utils.qrc"/>
|
||||||
|
<include location="res.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
<slots>
|
<slots>
|
||||||
<slot>addNewNotification()</slot>
|
<slot>addNewNotification()</slot>
|
||||||
|
10
ground/src/plugins/notify/res.qrc
Normal file
10
ground/src/plugins/notify/res.qrc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/notify">
|
||||||
|
<file>images/modify.png</file>
|
||||||
|
<file>images/play.png</file>
|
||||||
|
<file>images/play2.png</file>
|
||||||
|
<file>images/add.png</file>
|
||||||
|
<file>images/delete.png</file>
|
||||||
|
<file>images/stop.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
Loading…
x
Reference in New Issue
Block a user