1
0
forked from BRT/arc
arc/views/MainWindow.h

66 lines
2.1 KiB
C++

#pragma once
#include <QListWidget>
#include <QMainWindow>
#include <QVBoxLayout>
#include <QStackedWidget>
#include <QTimer>
#include <QLabel>
#include <QPixmap>
#include "TutorialWindow.h"
#include "bank/AccountWindow.h"
#include "db/DeviceInfo.h"
#include "log/FileLogWindow.h"
#include "widget/common/FlowLayout.h"
class NetworkService;
class QAction;
class MainWindow final : public QMainWindow {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
void loadDevices();
// Указатель на живой NetworkService (создаётся в main.cpp). Нужен, чтобы при
// старте обновления выключить все профили на сервере. Может быть nullptr.
void setNetworkService(NetworkService *net) { m_network = net; }
public slots:
// Подключается к NetworkService::syncHealthChanged. healthy=false показывает
// индикатор «нет связи» в status bar, healthy=true прячет (правило #9).
void setSyncHealth(bool healthy, int consecutiveFailures);
private:
QWidget *central;
FlowLayout *flowLayout;
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;
QWidget *m_bankListWindow = nullptr;
FileLogWindow *m_fileLogWindow = nullptr;
QWidget *m_eventWindow = nullptr;
QListWidget *m_logList = nullptr;
QLabel *m_syncHealthLabel = nullptr;
NetworkService *m_network = nullptr;
QAction *m_updateAction = nullptr;
void createDevicePage();
void deleteDevicePage();
void updateLogPanel();
// Ручная проверка обновлений: поднимает UpdateService в отдельном потоке,
// показывает диалоги/прогресс, на готовности апдейтера завершает приложение.
void checkForUpdates();
void resizeEvent(QResizeEvent *event) override;
};