0bcff486f81847dd02ed067e045c6fd54c5b6101.svn-base 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #include "ytwidget.h"
  2. #include "ui_ytwidget.h"
  3. //#define wd[8] {"","星期一","星期二","星期三","星期四","星期五","星期六","星期日"}
  4. YtWidget::YtWidget(QWidget *parent) :
  5. QWidget(parent),
  6. ui(new Ui::YtWidget)
  7. {
  8. current_page = 0;
  9. api = new Ycapi();
  10. beepThread = new BeepThread(this,api);
  11. beepThread->start();
  12. wd.clear();
  13. wd.append("");
  14. // wd.append(QString::fromUtf8("Mon"));
  15. // wd.append(QString::fromUtf8("Tus"));
  16. // wd.append(QString::fromUtf8("Wed"));
  17. // wd.append(QString::fromUtf8("Thu"));
  18. // wd.append(QString::fromUtf8("Fri"));
  19. // wd.append(QString::fromUtf8("Sat"));
  20. // wd.append(QString::fromUtf8("Sun"));
  21. wd.append(QString::fromUtf8("一"));
  22. wd.append(QString::fromUtf8("二"));
  23. wd.append(QString::fromUtf8("三"));
  24. wd.append(QString::fromUtf8("四"));
  25. wd.append(QString::fromUtf8("五"));
  26. wd.append(QString::fromUtf8("六"));
  27. wd.append(QString::fromUtf8("日"));
  28. beepThread->setBeep(BeepThread::OkBeep);
  29. title_font.setPointSize(40);
  30. normal_font.setPointSize(32);
  31. ui->setupUi(this);
  32. ui->title_label->setFont(title_font);
  33. ui->sta_label->setFont(normal_font);
  34. ui->num_label->setFont(normal_font);
  35. ui->normal_label->setFont(normal_font);
  36. ui->alarm_label->setFont(normal_font);
  37. ui->online_label->setFont(normal_font);
  38. ui->sleep_label->setFont(normal_font);
  39. ui->back_btn->hide();
  40. connect(ui->last_btn,SIGNAL(clicked()),this,SLOT(page_click()));
  41. connect(ui->next_btn,SIGNAL(clicked()),this,SLOT(page_click()));
  42. connect(beepThread,SIGNAL(btn_click()),this,SLOT(btn_click()));
  43. timer = new QTimer(this);
  44. connect(timer,SIGNAL(timeout()),this,SLOT(ui_timeout()));
  45. ui_timeout();
  46. timer->start(500);
  47. show_page();
  48. }
  49. YtWidget::~YtWidget()
  50. {
  51. delete ui;
  52. }
  53. void YtWidget::btn_click()
  54. {
  55. QCursor::setPos(801,481);
  56. }
  57. void YtWidget::page_click()
  58. {
  59. QToolButton *btn = (QToolButton *)sender();
  60. if(btn==ui->last_btn)
  61. current_page--;
  62. else if(btn==ui->next_btn)
  63. current_page++;
  64. if(current_page>3)
  65. current_page=0;
  66. else if(current_page<0)
  67. current_page=3;
  68. beepThread->setBeep(BeepThread::BtnBeep);
  69. show_page();
  70. }
  71. void YtWidget::ui_timeout()
  72. {
  73. QDateTime dt = QDateTime::currentDateTime();
  74. ui->time_label->setText(QString("%1 %2")
  75. .arg(wd.at(dt.date().dayOfWeek()%8))
  76. .arg(dt.toString("yyyy-MM-dd HH:mm")));
  77. }
  78. void YtWidget::show_page()
  79. {
  80. QCursor::setPos(801,481);
  81. ui->title_label->setText(QString::fromUtf8(""));
  82. ui->sta_label->setText(QString::fromUtf8(""));
  83. ui->num_label->setText(QString::fromUtf8(""));
  84. ui->normal_label->setText(QString::fromUtf8(""));
  85. ui->alarm_label->setText(QString::fromUtf8(""));
  86. ui->online_label->setText(QString::fromUtf8(""));
  87. ui->sleep_label->setText(QString::fromUtf8(""));
  88. switch(current_page){
  89. case 0:
  90. ui->title_label->setText(QString::fromUtf8("火灾监控子系统"));
  91. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  92. ui->num_label->setText(QString::fromUtf8("监控点位数量:8"));
  93. ui->normal_label->setText(QString::fromUtf8("正常点位数量:8"));
  94. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  95. ui->online_label->setText(QString::fromUtf8("在线点位数量:8"));
  96. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  97. break;
  98. case 1:
  99. ui->title_label->setText(QString::fromUtf8("电气火灾监控子系统"));
  100. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  101. ui->num_label->setText(QString::fromUtf8("监控点位数量:16"));
  102. ui->normal_label->setText(QString::fromUtf8("正常点位数量:16"));
  103. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  104. ui->online_label->setText(QString::fromUtf8("在线点位数量:16"));
  105. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  106. break;
  107. case 2:
  108. ui->title_label->setText(QString::fromUtf8("消防水监控子系统"));
  109. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  110. ui->num_label->setText(QString::fromUtf8("监控点位数量:3"));
  111. ui->normal_label->setText(QString::fromUtf8("正常点位数量:3"));
  112. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  113. ui->online_label->setText(QString::fromUtf8("在线点位数量:3"));
  114. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  115. break;
  116. case 3:
  117. ui->title_label->setText(QString::fromUtf8("消防电源监控子系统"));
  118. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  119. ui->num_label->setText(QString::fromUtf8("监控点位数量:4"));
  120. ui->normal_label->setText(QString::fromUtf8("正常点位数量:4"));
  121. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  122. ui->online_label->setText(QString::fromUtf8("在线点位数量:4"));
  123. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  124. break;
  125. }
  126. }
  127. void YtWidget::show_html()
  128. {
  129. }