#include "ytwidget.h" #include "ui_ytwidget.h" //#define wd[8] {"","星期一","星期二","星期三","星期四","星期五","星期六","星期日"} YtWidget::YtWidget(QWidget *parent) : QWidget(parent), ui(new Ui::YtWidget) { current_page = 0; api = new Ycapi(); beepThread = new BeepThread(this,api); beepThread->start(); wd.clear(); wd.append(""); // wd.append(QString::fromUtf8("Mon")); // wd.append(QString::fromUtf8("Tus")); // wd.append(QString::fromUtf8("Wed")); // wd.append(QString::fromUtf8("Thu")); // wd.append(QString::fromUtf8("Fri")); // wd.append(QString::fromUtf8("Sat")); // wd.append(QString::fromUtf8("Sun")); wd.append(QString::fromUtf8("一")); wd.append(QString::fromUtf8("二")); wd.append(QString::fromUtf8("三")); wd.append(QString::fromUtf8("四")); wd.append(QString::fromUtf8("五")); wd.append(QString::fromUtf8("六")); wd.append(QString::fromUtf8("日")); beepThread->setBeep(BeepThread::OkBeep); title_font.setPointSize(40); normal_font.setPointSize(32); ui->setupUi(this); ui->title_label->setFont(title_font); ui->sta_label->setFont(normal_font); ui->num_label->setFont(normal_font); ui->normal_label->setFont(normal_font); ui->alarm_label->setFont(normal_font); ui->online_label->setFont(normal_font); ui->sleep_label->setFont(normal_font); ui->back_btn->hide(); connect(ui->last_btn,SIGNAL(clicked()),this,SLOT(page_click())); connect(ui->next_btn,SIGNAL(clicked()),this,SLOT(page_click())); connect(beepThread,SIGNAL(btn_click()),this,SLOT(btn_click())); timer = new QTimer(this); connect(timer,SIGNAL(timeout()),this,SLOT(ui_timeout())); ui_timeout(); timer->start(500); show_page(); } YtWidget::~YtWidget() { delete ui; } void YtWidget::btn_click() { QCursor::setPos(801,481); } void YtWidget::page_click() { QToolButton *btn = (QToolButton *)sender(); if(btn==ui->last_btn) current_page--; else if(btn==ui->next_btn) current_page++; if(current_page>3) current_page=0; else if(current_page<0) current_page=3; beepThread->setBeep(BeepThread::BtnBeep); show_page(); } void YtWidget::ui_timeout() { QDateTime dt = QDateTime::currentDateTime(); ui->time_label->setText(QString("%1 %2") .arg(wd.at(dt.date().dayOfWeek()%8)) .arg(dt.toString("yyyy-MM-dd HH:mm"))); } void YtWidget::show_page() { QCursor::setPos(801,481); ui->title_label->setText(QString::fromUtf8("")); ui->sta_label->setText(QString::fromUtf8("")); ui->num_label->setText(QString::fromUtf8("")); ui->normal_label->setText(QString::fromUtf8("")); ui->alarm_label->setText(QString::fromUtf8("")); ui->online_label->setText(QString::fromUtf8("")); ui->sleep_label->setText(QString::fromUtf8("")); switch(current_page){ case 0: ui->title_label->setText(QString::fromUtf8("火灾监控子系统")); ui->sta_label->setText(QString::fromUtf8("状态:正常")); ui->num_label->setText(QString::fromUtf8("监控点位数量:8")); ui->normal_label->setText(QString::fromUtf8("正常点位数量:8")); ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0")); ui->online_label->setText(QString::fromUtf8("在线点位数量:8")); ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0")); break; case 1: ui->title_label->setText(QString::fromUtf8("电气火灾监控子系统")); ui->sta_label->setText(QString::fromUtf8("状态:正常")); ui->num_label->setText(QString::fromUtf8("监控点位数量:16")); ui->normal_label->setText(QString::fromUtf8("正常点位数量:16")); ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0")); ui->online_label->setText(QString::fromUtf8("在线点位数量:16")); ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0")); break; case 2: ui->title_label->setText(QString::fromUtf8("消防水监控子系统")); ui->sta_label->setText(QString::fromUtf8("状态:正常")); ui->num_label->setText(QString::fromUtf8("监控点位数量:3")); ui->normal_label->setText(QString::fromUtf8("正常点位数量:3")); ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0")); ui->online_label->setText(QString::fromUtf8("在线点位数量:3")); ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0")); break; case 3: ui->title_label->setText(QString::fromUtf8("消防电源监控子系统")); ui->sta_label->setText(QString::fromUtf8("状态:正常")); ui->num_label->setText(QString::fromUtf8("监控点位数量:4")); ui->normal_label->setText(QString::fromUtf8("正常点位数量:4")); ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0")); ui->online_label->setText(QString::fromUtf8("在线点位数量:4")); ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0")); break; } } void YtWidget::show_html() { }