2d9bda5d90870cf0e0da8ef1bc9d3b79521e755d.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. beepThread->setBeep(BeepThread::OkBeep);
  22. title_font.setPointSize(40);
  23. normal_font.setPointSize(32);
  24. ui->setupUi(this);
  25. ui->title_label->setFont(title_font);
  26. ui->sta_label->setFont(normal_font);
  27. ui->num_label->setFont(normal_font);
  28. ui->normal_label->setFont(normal_font);
  29. ui->alarm_label->setFont(normal_font);
  30. ui->online_label->setFont(normal_font);
  31. ui->sleep_label->setFont(normal_font);
  32. ui->back_btn->hide();
  33. connect(ui->last_btn,SIGNAL(clicked()),this,SLOT(page_click()));
  34. connect(ui->next_btn,SIGNAL(clicked()),this,SLOT(page_click()));
  35. timer = new QTimer(this);
  36. connect(timer,SIGNAL(timeout()),this,SLOT(ui_timeout()));
  37. ui_timeout();
  38. timer->start(500);
  39. show_page();
  40. }
  41. YtWidget::~YtWidget()
  42. {
  43. delete ui;
  44. }
  45. void YtWidget::page_click()
  46. {
  47. QToolButton *btn = (QToolButton *)sender();
  48. if(btn==ui->last_btn)
  49. current_page--;
  50. else if(btn==ui->next_btn)
  51. current_page++;
  52. if(current_page>3)
  53. current_page=0;
  54. else if(current_page<0)
  55. current_page=3;
  56. beepThread->setBeep(BeepThread::BtnBeep);
  57. show_page();
  58. }
  59. void YtWidget::ui_timeout()
  60. {
  61. QDateTime dt = QDateTime::currentDateTime();
  62. ui->time_label->setText(QString("%1 %2")
  63. .arg(wd.at(dt.date().dayOfWeek()%8))
  64. .arg(dt.toString("yyyy-MM-dd HH:mm")));
  65. }
  66. void YtWidget::show_page()
  67. {
  68. QCursor::setPos(801,481);
  69. ui->title_label->setText(QString::fromUtf8(""));
  70. ui->sta_label->setText(QString::fromUtf8(""));
  71. ui->num_label->setText(QString::fromUtf8(""));
  72. ui->normal_label->setText(QString::fromUtf8(""));
  73. ui->alarm_label->setText(QString::fromUtf8(""));
  74. ui->online_label->setText(QString::fromUtf8(""));
  75. ui->sleep_label->setText(QString::fromUtf8(""));
  76. switch(current_page){
  77. case 0:
  78. ui->title_label->setText(QString::fromUtf8("火灾监控子系统"));
  79. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  80. ui->num_label->setText(QString::fromUtf8("监控点位数量:8"));
  81. ui->normal_label->setText(QString::fromUtf8("正常点位数量:8"));
  82. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  83. ui->online_label->setText(QString::fromUtf8("在线点位数量:8"));
  84. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  85. break;
  86. case 1:
  87. ui->title_label->setText(QString::fromUtf8("电气火灾监控子系统"));
  88. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  89. ui->num_label->setText(QString::fromUtf8("监控点位数量:16"));
  90. ui->normal_label->setText(QString::fromUtf8("正常点位数量:16"));
  91. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  92. ui->online_label->setText(QString::fromUtf8("在线点位数量:16"));
  93. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  94. break;
  95. case 2:
  96. ui->title_label->setText(QString::fromUtf8("消防水监控子系统"));
  97. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  98. ui->num_label->setText(QString::fromUtf8("监控点位数量:3"));
  99. ui->normal_label->setText(QString::fromUtf8("正常点位数量:3"));
  100. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  101. ui->online_label->setText(QString::fromUtf8("在线点位数量:3"));
  102. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  103. break;
  104. case 3:
  105. ui->title_label->setText(QString::fromUtf8("消防电源监控子系统"));
  106. ui->sta_label->setText(QString::fromUtf8("状态:正常"));
  107. ui->num_label->setText(QString::fromUtf8("监控点位数量:4"));
  108. ui->normal_label->setText(QString::fromUtf8("正常点位数量:4"));
  109. ui->alarm_label->setText(QString::fromUtf8("告警点位数量:0"));
  110. ui->online_label->setText(QString::fromUtf8("在线点位数量:4"));
  111. ui->sleep_label->setText(QString::fromUtf8("离线点位数量:0"));
  112. break;
  113. }
  114. }
  115. void YtWidget::show_html()
  116. {
  117. }