From 374f5ccc4eab2fee79c42ea1e39aa3e9d5ded47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B3=A1=E6=B2=ABo0?= <442701102@qq.com> Date: Thu, 27 Oct 2022 13:59:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=20mainwindow.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mainwindow.cpp | 102 --------------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 src/mainwindow.cpp diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp deleted file mode 100644 index 1469c5f..0000000 --- a/src/mainwindow.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#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");//注册PortConfig类型 - qRegisterMetaType("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()<timeEditpowertime_1->time().toString("hh:mm"))<timeEditpowertime_1->time(); - mshut.type=1; - emit kill_Signal(mshut); - } - else if(ui->radioButton_2->isChecked()) - { - qDebug()<timeEditpowertime_2->time().toString("hh:mm"))<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); -} -- GitLab