RetroShare/retroshare-gui/src/gui/RsAutoUpdatePage.cpp

42 lines
981 B
C++
Raw Normal View History

#include <iostream>
#include <QTimer>
#include "RsAutoUpdatePage.h"
#include "MessengerWindow.h"
bool RsAutoUpdatePage::_locked = false ;
RsAutoUpdatePage::RsAutoUpdatePage(int ms_update_period,QWidget *parent)
: MainPage(parent)
{
_timer = new QTimer ;
_timer->setInterval(ms_update_period);
_timer->setSingleShot(true);
QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timerUpdate())) ;
_timer->start() ;
}
void RsAutoUpdatePage::showEvent(QShowEvent *event)
{
//std::cout << "RsAutoUpdatePage::showEvent() In show event !!" << std::endl ;
if(!_locked)
updateDisplay();
}
void RsAutoUpdatePage::timerUpdate()
{
// only update when the widget is visible.
//
if(_locked == false && isVisible()) {
updateDisplay();
update() ; // Qt flush
}
_timer->start() ;
}
void RsAutoUpdatePage::lockAllEvents() { _locked = true ; }
void RsAutoUpdatePage::unlockAllEvents() { _locked = false ; }
bool RsAutoUpdatePage::eventsLocked() { return _locked ; }