1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
//
// C++ Implementation: toBackground
//
// Copyright: See COPYING file that comes with this distribution
//
#include "utils.h"
#include "tobackground.h"
#include "toconnection.h"
#include <qlabel.h>
#include <qstatusbar.h>
#include <qtooltip.h>
#include "tobackgroundlabel.h"
#include "tomain.h"
int toBackground::Running = 0;
toBackground::toBackground(QObject* parent, const char* name)
: toTimer(parent, name)
{ //createToBackgroundLabel()
main = toMainWidget();
}
void toBackground::start(int msec)
{
main = toMainWidget();
if (!isActive())
{
Running++;
main->getBackgroundLabel()->unpause();
}
main->getBackgroundLabel()->setSpeed(std::min(Running, 1)*100);
//Animation->setSpeed(std::min(Running, 1)*100);
if (Running > 1){
main->getBackgroundLabel()->setTip(tr("%1 queries running in background.").arg(Running));
//QToolTip::add(Label, tr("%1 queries running in background.").arg(Running));
}
else{
main->getBackgroundLabel()->setTip(tr("One query running in background."));
// QToolTip::add(Label, tr("One query running in background."));
}
toTimer::start(msec);
}
void toBackground::stop(void)
{
main = toMainWidget();
/*if (!Animation)
init(); */
if (isActive())
{
Running--;
if (Running == 0 )
main->getBackgroundLabel()->pause();
else
main->getBackgroundLabel()->setSpeed(Running*100);
if (Running > 1)
main->getBackgroundLabel()->setTip(tr("%1 queries running in background.").arg(Running));
else if (Running == 1)
main->getBackgroundLabel()->setTip("One query running in background.");
else
main->getBackgroundLabel()->setTip(tr("No background queries."));
}
toTimer::stop();
}
/*void toBackground::init(void)
{
toMain *main = toMainWidget();
if (!main || Label)
return ;
Label = theToBackgroundLabel(main->statusBar());
Label->show();
main->statusBar()->addWidget(Label, 0, true);
QToolTip::add
(Label, tr("No background queries."));
}*/
toBackground::~toBackground()
{
stop();
}
|