1
0
forked from BRT/arc

Add menu navigation and cleanup main.cpp code

Introduced a navigation menu with actions "Окно 1" and "Окно 2" in `MainWindow`. Cleaned up commented-out code and adjusted formatting in `main.cpp` for clarity.
This commit is contained in:
trnsmkot 2025-04-22 10:18:52 +07:00
parent 4f5229da0a
commit 9848b1b371
2 changed files with 30 additions and 7 deletions

View File

@ -1,5 +1,7 @@
#include <QApplication> #include <QApplication>
#include <QThread> #include <QThread>
#include "dao/AccountDAO.h"
#include "views/MainWindow.h" #include "views/MainWindow.h"
#include "database/DatabaseManager.h" #include "database/DatabaseManager.h"
@ -7,9 +9,9 @@
#include "db/AccountInfoScreener.h" #include "db/AccountInfoScreener.h"
#include "services/DeviceScreener.h" #include "services/DeviceScreener.h"
void setupWorkerAndThread(QCoreApplication& app) { void setupWorkerAndThread(QCoreApplication &app) {
auto* thread = new QThread; auto *thread = new QThread;
auto* deviceScreenerWorker = new DeviceScreener; auto *deviceScreenerWorker = new DeviceScreener;
// Перемещаем worker в новый поток thread. // Перемещаем worker в новый поток thread.
// Это значит, что все слоты worker, вызываемые через connect(), теперь будут исполняться в этом фоне-потоке. // Это значит, что все слоты worker, вызываемые через connect(), теперь будут исполняться в этом фоне-потоке.
@ -41,8 +43,19 @@ void setupWorkerAndThread(QCoreApplication& app) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
QApplication app(argc, argv); QApplication app(argc, argv);
QList<Card> cards = AccountInfoScreener::parseCardData(QByteArray()); // QList<Card> cards = AccountInfoScreener::parseCardData(QByteArray());
qDebug() << "Cards data: " << cards.length(); // 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); // setupWorkerAndThread(app);
// //
@ -53,7 +66,7 @@ int main(int argc, char *argv[]) {
// qDebug() << "Сохранившееся время:" << savedTime.toString(); // qDebug() << "Сохранившееся время:" << savedTime.toString();
// //
// //
// MainWindow window; MainWindow window;
// window.show(); window.show();
return app.exec(); return app.exec();
} }

View File

@ -2,6 +2,7 @@
#include <QLabel> #include <QLabel>
#include <QScrollArea> #include <QScrollArea>
#include <QMenuBar>
#include "db/DeviceInfo.h" #include "db/DeviceInfo.h"
#include "DeviceWidget.h" #include "DeviceWidget.h"
@ -40,6 +41,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
scrollArea->setWidgetResizable(true); scrollArea->setWidgetResizable(true);
setCentralWidget(scrollArea); 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); timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &MainWindow::loadDevices); connect(timer, &QTimer::timeout, this, &MainWindow::loadDevices);
timer->start(1000); // каждые 1 сек timer->start(1000); // каждые 1 сек