Skip to content

Commit

Permalink
chore: add interface
Browse files Browse the repository at this point in the history
x-tools-author committed Nov 5, 2024
1 parent d88f80e commit 820a254
Showing 6 changed files with 110 additions and 83 deletions.
5 changes: 5 additions & 0 deletions Source/IO/UI/Communication/CommunicationUi.cpp
Original file line number Diff line number Diff line change
@@ -22,4 +22,9 @@ xIO::CommunicationType CommunicationUi::type() const
return m_type;
}

QList<QWidget *> CommunicationUi::communicationControllers()
{
return {};
}

} // namespace xTools
1 change: 1 addition & 0 deletions Source/IO/UI/Communication/CommunicationUi.h
Original file line number Diff line number Diff line change
@@ -24,6 +24,7 @@ class CommunicationUi : public AbstractIOUi
CommunicationUi(xIO::CommunicationType type, QWidget *parent = nullptr);

xIO::CommunicationType type() const;
virtual QList<QWidget *> communicationControllers();

private:
xIO::CommunicationType const m_type;
13 changes: 13 additions & 0 deletions Source/IOPage/CommunicationSettings.cpp
Original file line number Diff line number Diff line change
@@ -118,6 +118,19 @@ void CommunicationSettings::load(const QVariantMap &data)
ui->comboBoxMaxBytes->setCurrentIndex(index);
}

void CommunicationSettings::addWidgets(QList<QWidget *> widgets)
{
auto *layout = this->layout();
if (!layout) {
qWarning() << "No layout found";
return;
}

for (auto *widget : widgets) {
layout->addWidget(widget);
}
}

static const QString settingsFileName()
{
QStandardPaths::StandardLocation type = QStandardPaths::AppConfigLocation;
1 change: 1 addition & 0 deletions Source/IOPage/CommunicationSettings.h
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ class CommunicationSettings : public QWidget
void saveData(const QByteArray &data, bool isRx);
QVariantMap save();
void load(const QVariantMap &data);
void addWidgets(QList<QWidget *> widgets);

private:
struct
170 changes: 87 additions & 83 deletions Source/IOPage/CommunicationSettings.ui
Original file line number Diff line number Diff line change
@@ -6,105 +6,109 @@
<rect>
<x>0</x>
<y>0</y>
<width>217</width>
<height>182</height>
<width>211</width>
<height>172</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxSaveTx">
<property name="text">
<string>Save tx data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButtonSavePathBrowser">
<property name="text">
<string>Browser</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBoxSaveDate">
<property name="text">
<string>Save Date</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSaveToFile">
<property name="text">
<string>Save to file</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxSaveMs">
<property name="text">
<string>Save millisecond</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxSaveRx">
<property name="text">
<string>Save rx data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="checkBoxSaveTime">
<property name="text">
<string>Save Time</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1">
<widget class="QCheckBox" name="checkBoxSaveTx">
<property name="text">
<string>Save format</string>
<string>Save tx data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxSaveTextFormat"/>
<widget class="QPushButton" name="pushButtonSavePathBrowser">
<property name="text">
<string>Browser</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="checkBoxSaveMs">
<property name="text">
<string>Save millisecond</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<widget class="QCheckBox" name="checkBoxSaveRx">
<property name="text">
<string>Max bytes</string>
<string>Save rx data</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxMaxBytes"/>
<item row="3" column="1">
<widget class="QCheckBox" name="checkBoxSaveDate">
<property name="text">
<string>Save Date</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxSaveToFile">
<property name="text">
<string>Save to file</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QCheckBox" name="checkBoxSaveTime">
<property name="text">
<string>Save Time</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Save format</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxSaveTextFormat"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Max bytes</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxMaxBytes"/>
</item>
</layout>
</item>
</layout>
</item>
3 changes: 3 additions & 0 deletions Source/IOPage/IOPage.cpp
Original file line number Diff line number Diff line change
@@ -481,6 +481,9 @@ void IOPage::onCommunicationTypeChanged()
if (m_ioUi) {
loadControllerParameters();
ui->verticalLayoutCommunicationController->addWidget(m_ioUi);

QList<QWidget *> widgets = m_ioUi->communicationControllers();
m_ioSettings->addWidgets(widgets);
}
}

0 comments on commit 820a254

Please sign in to comment.