HourSelector::HourSelector(QWidget *parent,const char *name) : QWidget(parent,name) { // // Fonts // QFont font("helvetica",16,QFont::Bold); font.setPixelSize(16); // // Palettes // hour_active_palette= QPalette(QColor(BUTTON_STOPPED_BACKGROUND_COLOR),backgroundColor()); // // Buttons // QSignalMapper *mapper=new QSignalMapper(this); connect(mapper,SIGNAL(mapped(int)),this,SLOT(hourClicked(int))); for(unsigned i=0;i<24;i++) { hour_button[i]=new QPushButton(this); hour_button[i]->setFont(font); hour_button[i]->setDisabled(true); mapper->setMapping(hour_button[i],i); connect(hour_button[i],SIGNAL(clicked()),mapper,SLOT(map())); } // // Update Timer // hour_update_timer=new QTimer(this); connect(hour_update_timer,SIGNAL(timeout()),this,SLOT(updateTimeData())); updateTimeData(); }
/** * @brief TimerWindow::slotAddStaticTime 鼠标不移动增加时间 */ void TimerWindow::slotAddStaticTime() { // qDebug()<<"slotAddStaticTime()"; if(++updateTime >= updateInterval){ //超过更新时间间隔 updateTimeData(); updateTime = 0; } nowPoint = QCursor::pos(); //获取鼠标当前位置 if(timer.isActive()){ if(lastPoint == nowPoint){ if(++staticTime >= staticDeadline){ timer.stop(); } }else{ staticTime = 0; } }else{ if(lastPoint != nowPoint){ timer.start(); staticTime = 0; } } lastPoint = nowPoint; }