-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
141 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#include "hexvalidator.h" | ||
|
||
QValidator::State HexValidator::validate(QString& input, int& pos) const { | ||
bool success; | ||
input.toUInt(&success, 16); | ||
if (success) | ||
return QValidator::Acceptable; | ||
if (input.isEmpty()) | ||
return QValidator::Intermediate; | ||
return QValidator::Invalid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
|
||
#include <QString> | ||
#include <QValidator> | ||
|
||
class HexValidator final : public QValidator { | ||
public: | ||
explicit HexValidator(QObject* parent) : QValidator(parent) {} | ||
|
||
QValidator::State validate(QString& input, int& pos) const override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "optionsdialog.h" | ||
|
||
OptionsDialog::OptionsDialog(QWidget* parent) : QDialog(parent) { | ||
setFont(QFont("Arial", 12)); | ||
setLocale(QLocale(QLocale::Russian, QLocale::Russia)); | ||
setWindowTitle(u8"Íàñòðîéêè"); | ||
|
||
layout = new QVBoxLayout(this); | ||
|
||
form = new QWidget(this); | ||
layout->addWidget(form); | ||
|
||
formLayout = new QFormLayout(form); | ||
|
||
hexValidator = new HexValidator(this); | ||
|
||
editRequestId = new QLineEdit(this); | ||
editRequestId->setValidator(hexValidator); | ||
formLayout->addRow(u8"CAN ID çàïðîñà:", editRequestId); | ||
|
||
editResponseId = new QLineEdit(this); | ||
editResponseId->setValidator(hexValidator); | ||
formLayout->addRow(u8"CAN ID îòâåòà:", editResponseId); | ||
|
||
spinTimeout = new QSpinBox(this); | ||
spinTimeout->setMinimum(100); | ||
spinTimeout->setMaximum(10000); | ||
formLayout->addRow(u8"Òàéìàóò:", spinTimeout); | ||
|
||
spinMaxRetries = new QSpinBox(this); | ||
spinMaxRetries->setMinimum(1); | ||
spinMaxRetries->setMaximum(20); | ||
formLayout->addRow(u8"×èñëî ïîâòîðíûõ ïîïûòîê:", spinMaxRetries); | ||
|
||
buttonCancel = new QPushButton(u8"Îòìåíà", this); | ||
layout->addWidget(buttonCancel); | ||
|
||
buttonOk = new QPushButton(u8"Ñîõðàíèòü", this); | ||
buttonOk->setFocus(); | ||
layout->addWidget(buttonOk); | ||
|
||
connect(buttonCancel, &QPushButton::clicked, this, &OptionsDialog::reject); | ||
connect(buttonOk, &QPushButton::clicked, this, &OptionsDialog::accept); | ||
} | ||
|
||
void OptionsDialog::accept() { | ||
DiagnosticProtocolOptions options; | ||
options.SetRequestCanId(editRequestId->text().toUInt()); | ||
options.SetResponseCanId(editResponseId->text().toUInt()); | ||
options.SetTimeout(spinTimeout->value()); | ||
options.SetMaxRetries(spinMaxRetries->value()); | ||
emit OptionsConfigured(options); | ||
QDialog::accept(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <QDialog> | ||
#include <QFormLayout> | ||
#include <QLineEdit> | ||
#include <QPushButton> | ||
#include <QSpinBox> | ||
#include <QVBoxLayout> | ||
|
||
#include <hexvalidator.h> | ||
#include <diagnosticprotocol.h> | ||
|
||
class OptionsDialog : public QDialog { | ||
Q_OBJECT | ||
|
||
public: | ||
OptionsDialog(QWidget *parent = Q_NULLPTR); | ||
|
||
void accept() override; | ||
|
||
signals: | ||
void OptionsConfigured(const DiagnosticProtocolOptions&); | ||
|
||
private: | ||
HexValidator* hexValidator; | ||
QFormLayout* formLayout; | ||
QLineEdit* editRequestId; | ||
QLineEdit* editResponseId; | ||
QPushButton* buttonCancel; | ||
QPushButton* buttonOk; | ||
QSpinBox* spinMaxRetries; | ||
QSpinBox* spinTimeout; | ||
QVBoxLayout* layout; | ||
QWidget* form; | ||
}; |