Add remind user to execute empty scan.

This commit is contained in:
sunwen
2024-05-09 16:33:57 +08:00
parent 580f221338
commit c6cf91694d
8 changed files with 79 additions and 10 deletions

View File

@@ -26,6 +26,7 @@
#include "components/UTextEdit.h"
#include "components/WarningMessageWidget.h"
#include "json/jsonobject.h"
#include "db/SQLHelper.h"
MainWindow::MainWindow(QWidget* aParent)
@@ -94,6 +95,9 @@ MainWindow::MainWindow(QWidget* aParent)
QApplication::processEvents();
});
connect(EventCenter::Default(), &EventCenter::LoginSuccess, this,&MainWindow::checkEmptyScanValidity);
connect(EventCenter::Default(), &EventCenter::EmptyScanFinished, this,&MainWindow::enableAllTabWidget);
connect(mTabWidget, &QTabWidget::currentChanged, this, [this](int aIndex)
{
if(aIndex == 1)
@@ -147,6 +151,30 @@ void MainWindow::initializeLayout()
mShutdownWidget->setVisible(false);
}
void MainWindow::checkEmptyScanValidity()
{
QDate lastScanDate = SQLHelper::queryValue("SELECT ScanDateTime FROM EScan ORDER BY ScanDateTime DESC LIMIT 1").toDate();
QDate expirationScanDate = lastScanDate.addMonths(1);
QDate currentDate = QDate::currentDate();
if(currentDate.daysTo(expirationScanDate) < 0)
{
mTabWidget->setTabEnabled(0, false);
mTabWidget->setTabEnabled(1, false);
mTabWidget->setTabEnabled(2, false);
mTabWidget->setCurrentIndex(3);
DialogManager::Default()->requestAlertMessage(tr("Please execute the empty scan, assist with system calibration, when empty scan is completed, the system should operate normally."), OkOnly, tr("Warning"));
return;
}
if(currentDate.daysTo(expirationScanDate) < 3)
{
DialogManager::Default()->requestAlertMessage(tr("There are %1 days left until the next empty scan. Please remind users to conduct the empty scan in time.").arg(currentDate.daysTo(expirationScanDate) + 1), OkOnly, tr("Warning"));
return;
}
}
void MainWindow::initializeTabWidget()
{
mTabWidget->setTabPosition(QTabWidget::South);
@@ -160,6 +188,8 @@ void MainWindow::initializeTabWidget()
mAdminTabIndex+=3;
mTabWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
void MainWindow::reloadLanguage() {
@@ -333,3 +363,12 @@ void MainWindow::resetRoleLayout() {
}
qApp->processEvents();
}
void MainWindow::enableAllTabWidget()
{
for(int i=0; i<mTabWidget->count(); ++i)
{
mTabWidget->setTabEnabled(i, true);
}
}