2024-10-31 22:02:32 +08:00
|
|
|
|
#include "mainwindow.h"
|
2024-10-31 17:47:16 +08:00
|
|
|
|
#include "ui_mainwindow.h"
|
2024-10-31 22:02:32 +08:00
|
|
|
|
#include "view/coaldistributchartwidget.h"
|
2024-10-31 17:47:16 +08:00
|
|
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
this->setWindowFlag(Qt::FramelessWindowHint);
|
|
|
|
|
this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint |
|
|
|
|
|
Qt::WindowMinimizeButtonHint);
|
2024-10-31 17:47:16 +08:00
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
calendarLoopPlay();
|
2024-10-31 17:47:16 +08:00
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
addcoalDistributChart();
|
2024-10-31 17:47:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
MainWindow::~MainWindow() { delete ui; }
|
2024-10-31 17:47:16 +08:00
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
void MainWindow::on_pushButton_close_clicked() { this->close(); }
|
|
|
|
|
|
|
|
|
|
void MainWindow::on_pushButton_max_clicked() {
|
|
|
|
|
if (isFullScreen()) {
|
|
|
|
|
this->showMaximized();
|
|
|
|
|
} else {
|
|
|
|
|
this->showFullScreen();
|
|
|
|
|
}
|
2024-10-31 17:47:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
void MainWindow::on_pushButton_min_clicked() { this->showMinimized(); }
|
|
|
|
|
|
|
|
|
|
void MainWindow::calendarLoopPlay() {
|
|
|
|
|
ui->label_calendar->clear();
|
|
|
|
|
QTimer *timer_calendar = new QTimer(this);
|
|
|
|
|
connect(timer_calendar, &QTimer::timeout, this, [this]() {
|
|
|
|
|
QDateTime time = QDateTime::currentDateTime();
|
|
|
|
|
QString str = time.toString("yyyy-MM-dd hh:mm:ss dddd");
|
|
|
|
|
ui->label_calendar->setText(str);
|
|
|
|
|
});
|
|
|
|
|
timer_calendar->start(1000); //每一秒溢出一次进入槽函数
|
2024-10-31 17:47:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 22:02:32 +08:00
|
|
|
|
void MainWindow::addcoalDistributChart() {
|
|
|
|
|
|
|
|
|
|
CoalDistributChartWidget *coalDistributChartWidget =
|
|
|
|
|
new CoalDistributChartWidget(ui->widget_coalDistributChart);
|
|
|
|
|
|
|
|
|
|
// 可选:设置大小
|
|
|
|
|
coalDistributChartWidget->setMinimumSize(400, 300); // 设置最小大小以确保可见
|
|
|
|
|
|
|
|
|
|
// 确保将部件添加到布局中
|
|
|
|
|
QVBoxLayout *layout =
|
|
|
|
|
qobject_cast<QVBoxLayout *>(ui->widget_coalDistributChart->layout());
|
|
|
|
|
if (layout) {
|
|
|
|
|
layout->addWidget(coalDistributChartWidget);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果没有布局,可以手动添加部件
|
|
|
|
|
ui->widget_coalDistributChart->setLayout(new QVBoxLayout());
|
|
|
|
|
ui->widget_coalDistributChart->layout()->addWidget(
|
|
|
|
|
coalDistributChartWidget);
|
|
|
|
|
}
|
2024-10-31 17:47:16 +08:00
|
|
|
|
}
|