diff --git a/src/candiagnostictool.cpp b/src/candiagnostictool.cpp index 17991d8..40f531c 100644 --- a/src/candiagnostictool.cpp +++ b/src/candiagnostictool.cpp @@ -1,11 +1,24 @@ #include "candiagnostictool.h" -#include "deviceerrorview.h" +#include + +#include CanDiagnosticTool::CanDiagnosticTool(QWidget* parent) : QMainWindow(parent) { setFont(QFont("Arial", 12)); setLocale(QLocale(QLocale::Russian, QLocale::Russia)); + searchAction = new QAction(u8"Обнаружить устройство", this); + readAction = new QAction(u8"Прочитать ошибки", this); + resetAction = new QAction(u8"Очистить ошибки", this); + + fileMenu = menuBar()->addMenu(u8"Файл"); + + diagnosticMenu = menuBar()->addMenu(u8"Диагностика"); + diagnosticMenu->addAction(searchAction); + diagnosticMenu->addAction(readAction); + diagnosticMenu->addAction(resetAction); + central = new QWidget(this); setCentralWidget(central); @@ -19,24 +32,15 @@ CanDiagnosticTool::CanDiagnosticTool(QWidget* parent) : QMainWindow(parent) { canBusView = new CanBusView(leftColumn); leftColumnLayout->addWidget(canBusView); - buttonSearch = new QPushButton(u8"Обнаружить устройство", leftColumn); - leftColumnLayout->addWidget(buttonSearch); - - buttonRead = new QPushButton(u8"Прочитать ошибки", leftColumn); - leftColumnLayout->addWidget(buttonRead); - - buttonReset = new QPushButton(u8"Очистить ошибки", leftColumn); - leftColumnLayout->addWidget(buttonReset); - diagnosticView = new DiagnosticView(central); mainLayout->addWidget(diagnosticView, 0, 1); connect(canBusView, &CanBusView::BusConnected, diagnosticView, &DiagnosticView::SetCanBusDevice); - connect(buttonSearch, &QPushButton::clicked, diagnosticView, + connect(searchAction, &QAction::triggered, diagnosticView, &DiagnosticView::SearchDevice); - connect(buttonRead, &QPushButton::clicked, diagnosticView, + connect(readAction, &QAction::triggered, diagnosticView, &DiagnosticView::ReadErrors); - connect(buttonReset, &QPushButton::clicked, diagnosticView, + connect(resetAction, &QAction::triggered, diagnosticView, &DiagnosticView::ResetErrors); } diff --git a/src/candiagnostictool.h b/src/candiagnostictool.h index 01dd88f..592493c 100644 --- a/src/candiagnostictool.h +++ b/src/candiagnostictool.h @@ -1,7 +1,8 @@ #pragma once +#include #include -#include +#include #include #include #include @@ -16,12 +17,14 @@ class CanDiagnosticTool : public QMainWindow { CanDiagnosticTool(QWidget* parent = Q_NULLPTR); private: + QAction* readAction; + QAction* resetAction; + QAction* searchAction; CanBusView* canBusView; DiagnosticView* diagnosticView; QGridLayout* mainLayout; - QPushButton* buttonRead; - QPushButton* buttonReset; - QPushButton* buttonSearch; + QMenu* fileMenu; + QMenu* diagnosticMenu; QVBoxLayout* leftColumnLayout; QWidget* central; QWidget* leftColumn;