diff --git a/CMakeLists.txt b/CMakeLists.txt index 2aa3cc6..56223d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,12 @@ cmake_minimum_required(VERSION 3.16) -project(ARCDesktopProject LANGUAGES CXX) +project(ARC LANGUAGES CXX) #mkdir build #cd build #cmake .. -A x64 -DCMAKE_PREFIX_PATH="C:/Qt/6.9.0/msvc2022_64" -DCMAKE_BUILD_TYPE=Release #cmake .. -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH="C:/Qt/6.9.0/msvc2022_64" -DCMAKE_BUILD_TYPE=Release #cmake --build . --config Release -#"C:\Qt\6.9.0\msvc2022_64\bin\windeployqt.exe" .\Release\ARCDesktopProject.exe +#"C:\Qt\6.9.0\msvc2022_64\bin\windeployqt.exe" .\Release\ARC.exe set(CMAKE_CXX_STANDARD 17) set(CMAKE_AUTOMOC ON) @@ -83,8 +83,9 @@ file(GLOB_RECURSE ANDROID_SOURCES ) if (WIN32) -add_executable(ARCDesktopProject WIN32 +add_executable(ARC WIN32 main.cpp + app.rc ${VIEW_SOURCES} ${SERVICES_SOURCES} ${DB_SOURCES} @@ -98,7 +99,7 @@ add_executable(ARCDesktopProject WIN32 database/dao/GeneralLogDAO.h ) elseif (APPLE) - add_executable(ARCDesktopProject + add_executable(ARC main.cpp ${VIEW_SOURCES} ${SERVICES_SOURCES} @@ -115,7 +116,7 @@ elseif (APPLE) endif () if (WIN32) - target_link_libraries(ARCDesktopProject + target_link_libraries(ARC Qt6::Widgets Qt6::Xml Qt6::Sql @@ -132,37 +133,37 @@ if (WIN32) file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/config.ini" DESTINATION "${CMAKE_BINARY_DIR}") file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/tools/adb/windows" DESTINATION "${CMAKE_BINARY_DIR}/tools/adb") - add_custom_command(TARGET ARCDesktopProject POST_BUILD + add_custom_command(TARGET ARC POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory - "$/database" + "$/database" COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tutorials" - "$/tutorials" + "$/tutorials" COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/images" - "$/images" + "$/images" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/rus.traineddata" - "$/rus.traineddata" + "$/rus.traineddata" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/eng.traineddata" - "$/eng.traineddata" + "$/eng.traineddata" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/config.ini" - "$/config.ini" + "$/config.ini" COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/tools/adb/windows" - "$/tools/adb/windows" + "$/tools/adb/windows" ) elseif (APPLE) - target_link_libraries(ARCDesktopProject + target_link_libraries(ARC Qt6::Widgets Qt6::Sql Qt6::Xml @@ -172,7 +173,7 @@ elseif (APPLE) ) endif () -target_include_directories(ARCDesktopProject PRIVATE +target_include_directories(ARC PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/views ${CMAKE_CURRENT_SOURCE_DIR}/database ${CMAKE_CURRENT_SOURCE_DIR}/services diff --git a/arc.ico b/arc.ico new file mode 100644 index 0000000..59b0e72 Binary files /dev/null and b/arc.ico differ diff --git a/arc.png b/arc.png new file mode 100644 index 0000000..a0be21c Binary files /dev/null and b/arc.png differ diff --git a/config.ini b/config.ini index 2d9cad1..71851d0 100644 --- a/config.ini +++ b/config.ini @@ -9,11 +9,7 @@ version=0.0.1 dbPath=~/CLionProjects/ARCDeskProject/ARCDeskProject/database/app_data.db [net] -accountUpdate=http://localhost:9999/api/v1/account/update apiBase=http://93.183.75.134:8005 -appInfoUpdate=http://localhost:9999/api/v1/device/update -appStatusUpdate=http://localhost:9999/api/v1/application/update -eventStatusUpdate=http://localhost:9999/api/v1/event/update pathAuthLogin=/api/v1/auth/login pathAuthRefresh=/api/v1/auth/refresh_token pathBankProfile=/api/v1/profile/bank_profile @@ -21,9 +17,6 @@ pathDesktopCreate=/api/v1/desktop/ pathDevice=/api/v1/device/ pathDeviceScreenshot=/api/v1/device/add_screenshot/ pathMaterial=/api/v1/profile/material -paymentsGet=http://localhost:9999/api/v1/payments -transactionInsert=http://localhost:9999/api/v1/transaction/insert -transactionUpdate=http://localhost:9999/api/v1/transaction/update [black] android_package_name=app.blackwallet.ar diff --git a/main.cpp b/main.cpp index d84866f..a93c060 100644 --- a/main.cpp +++ b/main.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "AppLogger.h" @@ -221,6 +222,8 @@ void messageHandler( int main(int argc, char *argv[]) { QApplication app(argc, argv); + app.setApplicationName("ARC"); + app.setWindowIcon(QIcon("arc.png")); // Выбрать стиль Fusion + принудительная светлая тема QApplication::setStyle(QStyleFactory::create("Fusion")); diff --git a/no_devices.png b/no_devices.png new file mode 100644 index 0000000..b56ed14 Binary files /dev/null and b/no_devices.png differ diff --git a/views/MainWindow.cpp b/views/MainWindow.cpp index 1419f5e..46fa37f 100644 --- a/views/MainWindow.cpp +++ b/views/MainWindow.cpp @@ -2,6 +2,8 @@ #include "bank/AccountWindow.h" #include +#include +#include #include #include #include @@ -14,9 +16,13 @@ #include "db/DeviceInfo.h" #include "device/DeviceWidget.h" #include "dao/DeviceDAO.h" +#include "dao/SettingsDAO.h" +#include #include "widget/common/FlowLayout.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { + setWindowTitle("ARC"); + // Инициализируем таймер обновления timer = new QTimer(this); connect(timer, &QTimer::timeout, this, &MainWindow::loadDevices); @@ -109,12 +115,15 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { m_fileLogWindow->activateWindow(); }); - // m_tutorialWindow = new TutorialWindow(this); - // m_tutorialWindow->show(); - // QTimer::singleShot(0, m_tutorialWindow, [w = m_tutorialWindow]() { - // w->raise(); - // w->activateWindow(); - // }); + if (SettingsDAO::get("tutorial_shown").isEmpty()) { + QTimer::singleShot(0, this, [this]() { + m_tutorialWindow = new TutorialWindow(this); + m_tutorialWindow->show(); + m_tutorialWindow->raise(); + m_tutorialWindow->activateWindow(); + SettingsDAO::set("tutorial_shown", "1"); + }); + } } @@ -123,27 +132,46 @@ void MainWindow::createDevicePage() { return; } - auto *scrollArea = new QScrollArea(this); + auto *container = new QWidget(this); + auto *containerLayout = new QVBoxLayout(container); + containerLayout->setContentsMargins(0, 0, 0, 0); + + m_noDevicesLabel = new QLabel(container); + m_noDevicesPixmap = QPixmap("no_devices.png"); + m_noDevicesLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); + m_noDevicesLabel->setAlignment(Qt::AlignCenter); + containerLayout->addWidget(m_noDevicesLabel); + + m_scrollArea = new QScrollArea(container); auto *contentWidget = new QWidget; flowLayout = new FlowLayout(contentWidget, 0, 0, 0); - // flowLayout->setContentsMargins(0, 0, 0, 0); - // flowLayout->setSpacing(0); QVector devices = DeviceDAO::getAllDevices(false); for (const auto &device: devices) { - auto *deviceWidget = new DeviceWidget(device); - // deviceWidget->setFixedSize(220, 400); - flowLayout->addWidget(deviceWidget); + flowLayout->addWidget(new DeviceWidget(device)); } contentWidget->setLayout(flowLayout); - scrollArea->setWidget(contentWidget); - scrollArea->setWidgetResizable(true); + static_cast(m_scrollArea)->setWidget(contentWidget); + static_cast(m_scrollArea)->setWidgetResizable(true); + containerLayout->addWidget(m_scrollArea); - m_devicesWindow = scrollArea; + m_noDevicesLabel->setVisible(devices.isEmpty()); + m_scrollArea->setVisible(!devices.isEmpty()); + + m_devicesWindow = container; stackedWidget->addWidget(m_devicesWindow); timer->start(1000); + + if (devices.isEmpty()) { + QTimer::singleShot(0, this, [this]() { + if (m_noDevicesLabel && !m_noDevicesPixmap.isNull()) { + m_noDevicesLabel->setPixmap(m_noDevicesPixmap.scaled( + m_noDevicesLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + } + }); + } } void MainWindow::deleteDevicePage() { @@ -177,4 +205,15 @@ void MainWindow::loadDevices() { for (const auto &device: devices) { flowLayout->addWidget(new DeviceWidget(device)); } + + m_noDevicesLabel->setVisible(devices.isEmpty()); + m_scrollArea->setVisible(!devices.isEmpty()); +} + +void MainWindow::resizeEvent(QResizeEvent *event) { + QMainWindow::resizeEvent(event); + if (m_noDevicesLabel && m_noDevicesLabel->isVisible() && !m_noDevicesPixmap.isNull()) { + m_noDevicesLabel->setPixmap(m_noDevicesPixmap.scaled( + m_noDevicesLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation)); + } } diff --git a/views/MainWindow.h b/views/MainWindow.h index 93b5029..de5690f 100644 --- a/views/MainWindow.h +++ b/views/MainWindow.h @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include "TutorialWindow.h" #include "bank/AccountWindow.h" @@ -23,6 +25,9 @@ private: QTimer *timer; QStackedWidget *stackedWidget; + QLabel *m_noDevicesLabel = nullptr; + QPixmap m_noDevicesPixmap; + QWidget *m_scrollArea = nullptr; QWidget *m_devicesWindow = nullptr; QWidget *m_accountsWindow = nullptr; QWidget *m_tutorialWindow = nullptr; @@ -32,6 +37,6 @@ private: QWidget *m_eventWindow = nullptr; void createDevicePage(); - void deleteDevicePage(); + void resizeEvent(QResizeEvent *event) override; };