From c1b8d0c23c70b69fb9a4101bab804b7ffaf6b153 Mon Sep 17 00:00:00 2001 From: slava Date: Tue, 22 Apr 2025 10:18:52 +0700 Subject: [PATCH] Add menu navigation and cleanup main.cpp code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduced a navigation menu with actions "Окно 1" and "Окно 2" in `MainWindow`. Cleaned up commented-out code and adjusted formatting in `main.cpp` for clarity. --- main.cpp | 27 ++++++++++++++++++++------- views/MainWindow.cpp | 10 ++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 397de9e..a386728 100644 --- a/main.cpp +++ b/main.cpp @@ -1,5 +1,7 @@ #include #include + +#include "dao/AccountDAO.h" #include "views/MainWindow.h" #include "database/DatabaseManager.h" @@ -7,9 +9,9 @@ #include "db/AccountInfoScreener.h" #include "services/DeviceScreener.h" -void setupWorkerAndThread(QCoreApplication& app) { - auto* thread = new QThread; - auto* deviceScreenerWorker = new DeviceScreener; +void setupWorkerAndThread(QCoreApplication &app) { + auto *thread = new QThread; + auto *deviceScreenerWorker = new DeviceScreener; // Перемещаем worker в новый поток thread. // Это значит, что все слоты worker, вызываемые через connect(), теперь будут исполняться в этом фоне-потоке. @@ -41,8 +43,19 @@ void setupWorkerAndThread(QCoreApplication& app) { int main(int argc, char *argv[]) { QApplication app(argc, argv); - QList cards = AccountInfoScreener::parseCardData(QByteArray()); - qDebug() << "Cards data: " << cards.length(); + // QList cards = AccountInfoScreener::parseCardData(QByteArray()); + // for (const Card &card: cards) { + // AccountInfo info; + // info.deviceId = "6edc4a47"; + // info.appName = "bank"; + // info.cardName = card.name; + // info.amount = card.amount; + // info.description = card.description; + // info.status = "active"; + // info.updateTime = QDateTime::currentDateTime(); + // qDebug() << "Account info: " << AccountDAO::upsertAccount(info); + // } + // setupWorkerAndThread(app); // @@ -53,7 +66,7 @@ int main(int argc, char *argv[]) { // qDebug() << "Сохранившееся время:" << savedTime.toString(); // // - // MainWindow window; - // window.show(); + MainWindow window; + window.show(); return app.exec(); } diff --git a/views/MainWindow.cpp b/views/MainWindow.cpp index d808c5e..e486a6c 100644 --- a/views/MainWindow.cpp +++ b/views/MainWindow.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "db/DeviceInfo.h" #include "DeviceWidget.h" @@ -40,6 +41,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { scrollArea->setWidgetResizable(true); setCentralWidget(scrollArea); + // Меню + QMenu* menu = menuBar()->addMenu("Навигация"); + + QAction* actionPage1 = new QAction("Окно 1", this); + QAction* actionPage2 = new QAction("Окно 2", this); + + menu->addAction(actionPage1); + menu->addAction(actionPage2); + timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &MainWindow::loadDevices); timer->start(1000); // каждые 1 сек