提交 374f5ccc 编写于 作者: 泡沫o0's avatar 泡沫o0 🤖

删除 mainwindow.cpp

上级 04a98e43
#include "mainwindow.h"
#include "ui_mainwindow.h"
//static QString widgetbackgroundSheet ="background-color: qconicalgradient(cx:0.5, cy:0, angle:0, stop:0 rgba(55, 55, 202, 100), stop:1 rgba(207, 179, 179, 255))";
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
qRegisterMetaType<atime_t>("atime_t");//注册PortConfig类型
qRegisterMetaType<c_type>("c_type");//注册PortConfig类型
memset(&mshut,0,sizeof(mshut));
ui->widget_note->hide();
time_worker = new timethread;
mythread=new QThread(this);//Create child thread
time_worker->moveToThread(mythread);//Add custom threads to child threads
connect(mythread,&QThread::finished,time_worker,&QObject::deleteLater); //Thread suicide through deleteLater
connect(time_worker,SIGNAL(time_Signal(atime_t)),this,SLOT(Show_time(atime_t)));//Processing real-time clock signals sent by sub-threads
connect(this, SIGNAL(kill_Signal(c_type)), time_worker, SLOT(shotdown(c_type)));
connect(this, &MainWindow::time_Start, time_worker, &timethread::beginToWork); //Connect signal to thread start function
mythread->start();//Start the thread, but have not started the thread processing function
emit time_Start();
}
MainWindow::~MainWindow()
{
delete ui;
}
//用于接收子线程发来的时间数据
void MainWindow::Show_time(atime_t mtime)
{
ui->label_systemtime->setText(mtime.systime.toString("MM/dd hh:mm:ss"));
if(work==true)
ui->label_Countdown->setText(mtime.Countdowntime.toString("hh:mm:ss"));
}
void MainWindow::on_radioButton_1_clicked()
{
if(ui->radioButton_1->isChecked())
{
ui->radioButton_2->setChecked(false);
}
else
ui->radioButton_2->setChecked(true);
}
void MainWindow::on_radioButton_2_clicked()
{
if(ui->radioButton_2->isChecked())
{
ui->radioButton_1->setChecked(false);
}
else
ui->radioButton_1->setChecked(true);
}
void MainWindow::on_pushButton_clicked()
{
work=true;
if(ui->radioButton_1->isChecked())
{
qDebug()<<QString("将在%1关机").arg(ui->timeEditpowertime_1->time().toString("hh:mm"))<<endl;
mshut.endtime=ui->timeEditpowertime_1->time();
mshut.type=1;
emit kill_Signal(mshut);
}
else if(ui->radioButton_2->isChecked())
{
qDebug()<<QString("将在%1后关机").arg(ui->timeEditpowertime_2->time().toString("hh:mm"))<<endl;
mshut.endtime=ui->timeEditpowertime_2->time();
mshut.type=2;
emit kill_Signal(mshut);
}
if(ui->checkBox->isChecked())
{
mshut.endtime=ui->timeEdit_screen->time();
mshut.type=3;
emit kill_Signal(mshut);
}
ui->radioButton_1->setEnabled(false);
ui->radioButton_2->setEnabled(false);
ui->timeEditpowertime_1->setEnabled(false);
ui->timeEditpowertime_2->setEnabled(false);
ui->widget_set->setStyleSheet("background-color: rgb(204, 204, 204);");
ui->widget_note->show();
}
void MainWindow::on_pushButton_2_clicked()
{
work=false;
ui->radioButton_1->setEnabled(true);
ui->radioButton_2->setEnabled(true);
ui->timeEditpowertime_1->setEnabled(true);
ui->timeEditpowertime_2->setEnabled(true);
ui->timeEditpowertime_1->setTime(QTime(0,0,0));
ui->timeEditpowertime_2->setTime(QTime(0,0,0));
ui->widget_set->setStyleSheet("background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(255, 178, 102, 255), stop:0.55 rgba(235, 148, 61, 255), stop:0.98 rgba(0, 0, 0, 255), stop:1 rgba(0, 0, 0, 0));");
ui->widget_note->hide();
memset(&mshut,0,sizeof(mshut));
emit kill_Signal(mshut);
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册