mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
OP-1245 Added debuglog settings combo editor and databinding between C++ and qml.
This commit is contained in:
parent
e533215786
commit
fe36fbf927
@ -176,7 +176,44 @@ Rectangle {
|
||||
Layout.fillWidth: true
|
||||
text: "<b>" + qsTr("Log settings") + "</b>"
|
||||
}
|
||||
|
||||
Component {
|
||||
id: comboEditableDelegate
|
||||
Item {
|
||||
|
||||
Text {
|
||||
width: parent.width
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
elide: styleData.elideMode
|
||||
text: styleData.value !== undefined ? logManager.logSettings[styleData.value] : ""
|
||||
color: styleData.textColor
|
||||
visible: !styleData.selected
|
||||
}
|
||||
Loader {
|
||||
id: loaderEditor
|
||||
anchors.fill: parent
|
||||
Connections {
|
||||
target: loaderEditor.item
|
||||
onCurrentIndexChanged: {
|
||||
logManager.uavoEntries[styleData.row].setting = loaderEditor.item.currentIndex
|
||||
}
|
||||
}
|
||||
sourceComponent: styleData.selected ? editor : null
|
||||
Component {
|
||||
id: editor
|
||||
ComboBox {
|
||||
id: combo
|
||||
model: logManager.logSettings
|
||||
currentIndex: styleData.value
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TableView {
|
||||
id: settingsTable
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredHeight: 1000;
|
||||
@ -204,15 +241,8 @@ Rectangle {
|
||||
role: "setting";
|
||||
title: qsTr("Settings");
|
||||
width: 200;
|
||||
delegate:
|
||||
ComboBox {
|
||||
anchors.leftMargin: 5
|
||||
model: logManager.logSettings
|
||||
currentIndex: styleData.value
|
||||
//onCurrentIndexChanged:
|
||||
}
|
||||
delegate: comboEditableDelegate
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,6 @@ FlightLogDialog::FlightLogDialog(QWidget *parent, FlightLogManager *flightLogMan
|
||||
{
|
||||
qmlRegisterType<ExtendedDebugLogEntry>("org.openpilot", 1, 0, "DebugLogEntry");
|
||||
qmlRegisterType<UAVOLogSettingsWrapper>("org.openpilot", 1, 0, "UAVOLogSettingsWrapper");
|
||||
qmlRegisterUncreatableType<UAVObject>("org.openpilot", 1, 0, "UAVObject", "");
|
||||
qRegisterMetaType<UAVOLogSettingsWrapper::UAVLogSetting>("UAVOLogSettingsWrapper::UAVLogSetting");
|
||||
|
||||
setWindowIcon(QIcon(":/core/images/openpilot_logo_32.png"));
|
||||
setWindowTitle(tr("Manage flight side logs"));
|
||||
|
@ -362,7 +362,7 @@ UAVOLogSettingsWrapper::UAVOLogSettingsWrapper() : QObject()
|
||||
{}
|
||||
|
||||
UAVOLogSettingsWrapper::UAVOLogSettingsWrapper(UAVObject *object) : QObject(),
|
||||
m_object(object), m_setting(EVERY_5S)
|
||||
m_object(object), m_setting(DISABLED)
|
||||
{}
|
||||
|
||||
UAVOLogSettingsWrapper::~UAVOLogSettingsWrapper()
|
||||
|
@ -40,9 +40,8 @@
|
||||
|
||||
class UAVOLogSettingsWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
Q_ENUMS(UAVLogSetting)
|
||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
|
||||
Q_PROPERTY(UAVOLogSettingsWrapper::UAVLogSetting setting READ setting WRITE setSetting NOTIFY settingChanged)
|
||||
Q_PROPERTY(int setting READ setting WRITE setSetting NOTIFY settingChanged)
|
||||
|
||||
public:
|
||||
enum UAVLogSetting {DISABLED = 0, ON_CHANGE, EVERY_10MS, EVERY_50MS, EVERY_100MS,
|
||||
@ -57,27 +56,27 @@ public:
|
||||
return m_object->getName();
|
||||
}
|
||||
|
||||
UAVOLogSettingsWrapper::UAVLogSetting setting() const
|
||||
int setting() const
|
||||
{
|
||||
return m_setting;
|
||||
}
|
||||
|
||||
public slots:
|
||||
void setSetting(UAVOLogSettingsWrapper::UAVLogSetting arg)
|
||||
void setSetting(int setting)
|
||||
{
|
||||
if (m_setting != arg) {
|
||||
m_setting = arg;
|
||||
emit settingChanged(arg);
|
||||
if (m_setting != (int)setting) {
|
||||
m_setting = (int)setting;
|
||||
emit settingChanged((int)setting);
|
||||
}
|
||||
}
|
||||
|
||||
signals:
|
||||
void settingChanged(UAVLogSetting arg);
|
||||
void settingChanged(int setting);
|
||||
void nameChanged();
|
||||
|
||||
private:
|
||||
UAVObject *m_object;
|
||||
UAVLogSetting m_setting;
|
||||
int m_setting;
|
||||
};
|
||||
|
||||
class ExtendedDebugLogEntry : public DebugLogEntry {
|
||||
@ -223,6 +222,4 @@ private:
|
||||
bool m_adjustExportedTimestamps;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(UAVOLogSettingsWrapper::UAVLogSetting)
|
||||
|
||||
#endif // FLIGHTLOGMANAGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user