Example #1
0
void view::showEvent(QShowEvent *)
{
  myTimerId=startTimer(200);
}
Example #2
0
void TabBarWidget::enterEvent(QEvent *event)
{
	QTabBar::enterEvent(event);

	m_previewTimer = startTimer(250);
}
Example #3
0
 void startTimer(bool up, int msec) { timerUp = up; startTimer(msec); }
Example #4
0
void Settings::propertyChanged()
{
    ++propertyChanges;
    if (timerId == 0)
        timerId = startTimer(500);
}
Example #5
0
/*
 * This is the constructor for the main widget. It sets up the menu and the
 * TaskMan widget.
 */
TopLevel::TopLevel(QWidget *parent, const char *name, int sfolder)
	: KTMainWindow(name)
{
	/*
	 * create main menu
	 */

	menubar = new MainMenu(this, "MainMenu");
	connect(menubar, SIGNAL(quit()), this, SLOT(quitSlot()));
	// register the menu bar with KTMainWindow
	setMenu(menubar);

	statusbar = new KStatusBar(this, "statusbar");
	statusbar->insertItem(i18n("88888 Processes"), 0);
	statusbar->insertItem(i18n("Memory: 888888 kB used, "
							   "888888 kB free"), 1);
	statusbar->insertItem(i18n("Swap: 888888 kB used, "
							   "888888 kB free"), 2);
	setStatusBar(statusbar);
	// call timerEvent to fill the status bar with real values
	timerEvent(0);

	assert(Kapp);
	setCaption(i18n("KDE Task Manager"));

	// create the tab dialog
	taskman = new TaskMan(this, "", sfolder);

	// register the tab dialog with KTMainWindow as client widget
	setView(taskman);

	connect(taskman, SIGNAL(enableRefreshMenu(bool)),
			menubar, SLOT(enableRefreshMenu(bool)));

	setMinimumSize(KTOP_MIN_W, KTOP_MIN_H);

	/*
	 * Restore size of the dialog box that was used at end of last session.
	 * Due to a bug in Qt we need to set the width to one more than the
	 * defined min width. If this is not done the widget is not drawn
	 * properly the first time. Subsequent redraws after resize are no problem.
	 *
	 * I need to implement some propper session management some day!
	 */
	QString t = Kapp->getConfig()->readEntry(QString("G_Toplevel"));
	if(!t.isNull())
	{
		if (t.length() == 19)
		{ 
			int xpos, ypos, ww, wh;
			sscanf(t.data(), "%04d:%04d:%04d:%04d", &xpos, &ypos, &ww, &wh);
			setGeometry(xpos, ypos,
						ww <= KTOP_MIN_W ? KTOP_MIN_W + 1 : ww,
						wh <= KTOP_MIN_H ? KTOP_MIN_H : wh);
		}
	}

	readProperties(Kapp->getConfig());

	timerID = startTimer(2000);

	// show the dialog box
    show();

	// switch to the selected startup page
    taskman->raiseStartUpPage();
}
void CaretComponent::setCaretPosition (const Rectangle<int>& characterArea)
{
    startTimer (380);
    setVisible (shouldBeShown());
    setBounds (characterArea.withWidth (2));
}
void SMILTimeContainer::updateAnimations(SMILTime elapsed, bool seekToTime)
{
    SMILTime earliestFireTime = SMILTime::unresolved();

#ifndef NDEBUG
    // This boolean will catch any attempts to schedule/unschedule scheduledAnimations during this critical section.
    // Similarly, any elements removed will unschedule themselves, so this will catch modification of animationsToApply.
    m_preventScheduledAnimationsChanges = true;
#endif

    AnimationsVector animationsToApply;
    for (auto& it : m_scheduledAnimations) {
        AnimationsVector* scheduled = it.value.get();

        // Sort according to priority. Elements with later begin time have higher priority.
        // In case of a tie, document order decides. 
        // FIXME: This should also consider timing relationships between the elements. Dependents
        // have higher priority.
        sortByPriority(*scheduled, elapsed);

        SVGSMILElement* resultElement = 0;
        unsigned size = scheduled->size();
        for (unsigned n = 0; n < size; n++) {
            SVGSMILElement* animation = scheduled->at(n);
            ASSERT(animation->timeContainer() == this);
            ASSERT(animation->targetElement());
            ASSERT(animation->hasValidAttributeName());

            // Results are accumulated to the first animation that animates and contributes to a particular element/attribute pair.
            if (!resultElement) {
                if (!animation->hasValidAttributeType())
                    continue;
                resultElement = animation;
            }

            // This will calculate the contribution from the animation and add it to the resultsElement.
            if (!animation->progress(elapsed, resultElement, seekToTime) && resultElement == animation)
                resultElement = 0;

            SMILTime nextFireTime = animation->nextProgressTime();
            if (nextFireTime.isFinite())
                earliestFireTime = std::min(nextFireTime, earliestFireTime);
        }

        if (resultElement)
            animationsToApply.append(resultElement);
    }

    unsigned animationsToApplySize = animationsToApply.size();
    if (!animationsToApplySize) {
#ifndef NDEBUG
        m_preventScheduledAnimationsChanges = false;
#endif
        startTimer(earliestFireTime, animationFrameDelay);
        return;
    }

    // Apply results to target elements.
    for (unsigned i = 0; i < animationsToApplySize; ++i)
        animationsToApply[i]->applyResultsToTarget();

#ifndef NDEBUG
    m_preventScheduledAnimationsChanges = false;
#endif

    startTimer(earliestFireTime, animationFrameDelay);
}
Example #8
0
//Most important function of the whole program, it gets a strength variable as an input and based
//on it bumps a ball in the air if it is laying still on the ground and is not bouncing or in the air
void bump(struct SPHERE *sp, double strength) {

	//if ball not in Air compute it current new airtime SEC based on the strength value
	if(!sp->inAir&&strength>MAXSTRENGTH/10) {
		startTimer(sp); //start the timer
		//this is the main calculation, SEC is always higher for smaller balls than for
		//bigger balls with the same strength input, that is what the second term of the
		//function is for, the last term is the max air time and is calculated in
		sp->SEC=strength/MAXSTRENGTH*(1-(sp->r/(NUMSPHERES*2)))*NUMSEC;
		
		//change color of the ball slightly
		if(COLORCHANGE) {
			int choice=(int) (rand() % 3);
			int plusminus=(int) (rand() % 2);
			float change=(strength/MAXSTRENGTH)/10+0.02;
			if (plusminus==1) change=-change;
			sp->color[choice]+=(sp->color[choice]+change<1.0&&sp->color[choice]+change>0.0)?change:-change;
		}

		sp->firstUp=true;
		sp->inAir=true;
	}
	
	//stop the timer and compute seconds till the start of the timer
	stopTimer(sp);
	double seconds=timerSeconds(sp);
	
	//compute the speed based on the speedfactor and the number of spheres
	double speed=NUMSPHERES*SPEEDFACTOR;

	//let the ball fly up and down
	if(sp->SEC>0.05)
	{
		if(!BOUNCE) sp->inAir=true;
		
		//up-direction
		if(sp->up==true) {
			double max=4.905*sp->SEC*sp->SEC;
			sp->height=(max-4.905*(sp->SEC-seconds)*(sp->SEC-seconds))*speed;
		}
		//down-direction
		else {
			double max=4.905*sp->SEC*sp->SEC;
			sp->height=(max-4.905*seconds*seconds)*speed;
		}
		
		//if ball reaches the floor or is at the top of its flight turn the direction and
		//probably decrease the height for let the ball bounce
		if(seconds>sp->SEC) {
				sp->up=(sp->up==true)?false:true;
				startTimer(sp);
				if(sp->SEC>0&&sp->up==true) {
					sp->firstUp=false;
					sp->SEC-=(sp->SEC*4/9);

					if(!BOUNCE) sp->inAir=false;
				}
					
		}
	}
	//finished with bouncing or at the ground again and accepting input again
	else {
		sp->inAir=false;
	}
}
Example #9
0
int main(int    argc,
         char **argv)
{
l_int32      i, w, h, d, rotflag;
PIX         *pixs, *pixt, *pixd;
l_float32    angle, deg2rad, pops, ang;
char        *filein, *fileout;
static char  mainName[] = "rotatetest1";

    if (argc != 4)
        return ERROR_INT(" Syntax:  rotatetest1 filein angle fileout",
                         mainName, 1);

    filein = argv[1];
    angle = atof(argv[2]);
    fileout = argv[3];
    deg2rad = 3.1415926535 / 180.;

    lept_mkdir("lept/rotate");

    if ((pixs = pixRead(filein)) == NULL)
        return ERROR_INT("pix not made", mainName, 1);
    if (pixGetDepth(pixs) == 1) {
        pixt = pixScaleToGray3(pixs);
        pixDestroy(&pixs);
        pixs = pixAddBorderGeneral(pixt, 1, 0, 1, 0, 255);
        pixDestroy(&pixt);
    }

    pixGetDimensions(pixs, &w, &h, &d);
    fprintf(stderr, "w = %d, h = %d\n", w, h);

#if 0
        /* repertory of rotation operations to choose from */
    pixd = pixRotateAM(pixs, deg2rad * angle, L_BRING_IN_WHITE);
    pixd = pixRotateAMColor(pixs, deg2rad * angle, 0xffffff00);
    pixd = pixRotateAMColorFast(pixs, deg2rad * angle, 255);
    pixd = pixRotateAMCorner(pixs, deg2rad * angle, L_BRING_IN_WHITE);
    pixd = pixRotateShear(pixs, w /2, h / 2, deg2rad * angle,
                          L_BRING_IN_WHITE);
    pixd = pixRotate3Shear(pixs, w /2, h / 2, deg2rad * angle,
                           L_BRING_IN_WHITE);
    pixRotateShearIP(pixs, w / 2, h / 2, deg2rad * angle); pixd = pixs;
#endif

#if 0
        /* timing of shear rotation */
    for (i = 0; i < NITERS; i++) {
        pixd = pixRotateShear(pixs, (i * w) / NITERS,
                              (i * h) / NITERS, deg2rad * angle,
                              L_BRING_IN_WHITE);
        pixDisplay(pixd, 100 + 20 * i, 100 + 20 * i);
        pixDestroy(&pixd);
    }
#endif

#if 0
        /* timing of in-place shear rotation */
    for (i = 0; i < NITERS; i++) {
        pixRotateShearIP(pixs, w/2, h/2, deg2rad * angle, L_BRING_IN_WHITE);
/*        pixRotateShearCenterIP(pixs, deg2rad * angle, L_BRING_IN_WHITE); */
        pixDisplay(pixs, 100 + 20 * i, 100 + 20 * i);
    }
    pixd = pixs;
    if (pixGetDepth(pixd) == 1)
        pixWrite(fileout, pixd, IFF_PNG);
    else
        pixWrite(fileout, pixd, IFF_JFIF_JPEG);
    pixDestroy(&pixs);
#endif

#if 0
        /* timing of various rotation operations (choose) */
    startTimer();
    w = pixGetWidth(pixs);
    h = pixGetHeight(pixs);
    for (i = 0; i < NTIMES; i++) {
        pixd = pixRotateShearCenter(pixs, deg2rad * angle, L_BRING_IN_WHITE);
        pixDestroy(&pixd);
    }
    pops = (l_float32)(w * h * NTIMES / 1000000.) / stopTimer();
    fprintf(stderr, "vers. 1, mpops: %f\n", pops);
    startTimer();
    w = pixGetWidth(pixs);
    h = pixGetHeight(pixs);
    for (i = 0; i < NTIMES; i++) {
        pixRotateShearIP(pixs, w/2, h/2, deg2rad * angle, L_BRING_IN_WHITE);
    }
    pops = (l_float32)(w * h * NTIMES / 1000000.) / stopTimer();
    fprintf(stderr, "shear, mpops: %f\n", pops);
    pixWrite(fileout, pixs, IFF_PNG);
    for (i = 0; i < NTIMES; i++) {
        pixRotateShearIP(pixs, w/2, h/2, -deg2rad * angle, L_BRING_IN_WHITE);
    }
    pixWrite("/usr/tmp/junkout", pixs, IFF_PNG);
#endif

#if 0
        /* area-mapping rotation operations */
    pixd = pixRotateAM(pixs, deg2rad * angle, L_BRING_IN_WHITE);
/*    pixd = pixRotateAMColorFast(pixs, deg2rad * angle, 255); */
    if (pixGetDepth(pixd) == 1)
        pixWrite(fileout, pixd, IFF_PNG);
    else
        pixWrite(fileout, pixd, IFF_JFIF_JPEG);
#endif

#if 0
        /* compare the standard area-map color rotation with
         * the fast area-map color rotation, on a pixel basis */
    {
    PIX    *pix1, *pix2;
    NUMA   *nar, *nag, *nab, *naseq;
    GPLOT  *gplot;

    startTimer();
    pix1 = pixRotateAMColor(pixs, 0.12, 0xffffff00);
    fprintf(stderr, " standard color rotate: %7.2f sec\n", stopTimer());
    pixWrite("/tmp/lept/rotate/color1.jpg", pix1, IFF_JFIF_JPEG);
    startTimer();
    pix2 = pixRotateAMColorFast(pixs, 0.12, 0xffffff00);
    fprintf(stderr, " fast color rotate: %7.2f sec\n", stopTimer());
    pixWrite("/tmp/lept/rotate/color2.jpg", pix2, IFF_JFIF_JPEG);
    pixd = pixAbsDifference(pix1, pix2);
    pixGetColorHistogram(pixd, 1, &nar, &nag, &nab);
    naseq = numaMakeSequence(0., 1., 256);
    gplot = gplotCreate("/tmp/lept/rotate/absdiff", GPLOT_PNG,
                        "Number vs diff", "diff", "number");
    gplotAddPlot(gplot, naseq, nar, GPLOT_POINTS, "red");
    gplotAddPlot(gplot, naseq, nag, GPLOT_POINTS, "green");
    gplotAddPlot(gplot, naseq, nab, GPLOT_POINTS, "blue");
    gplotMakeOutput(gplot);
    l_fileDisplay("/tmp/lept/rotate/absdiff.png", 100, 100, 1.0);
    pixDestroy(&pix1);
    pixDestroy(&pix2);
    pixDestroy(&pixd);
    numaDestroy(&nar);
    numaDestroy(&nag);
    numaDestroy(&nab);
    numaDestroy(&naseq);
    gplotDestroy(&gplot);
    }
#endif

        /* Do a succession of 180 7-degree rotations in a cw
         * direction, and unwind the result with another set in
         * a ccw direction.  Although there is a considerable amount
         * of distortion after successive rotations, after all
         * 360 rotations, the resulting image is restored to
         * its original pristine condition! */
#if 1
    rotflag = L_ROTATE_AREA_MAP;
/*    rotflag = L_ROTATE_SHEAR;     */
/*    rotflag = L_ROTATE_SAMPLING;   */
    ang = 7.0 * deg2rad;
    pixGetDimensions(pixs, &w, &h, NULL);
    pixd = pixRotate(pixs, ang, rotflag, L_BRING_IN_WHITE, w, h);
    pixWrite("/tmp/lept/rotate/rot7.png", pixd, IFF_PNG);
    for (i = 1; i < 180; i++) {
        pixs = pixd;
        pixd = pixRotate(pixs, ang, rotflag, L_BRING_IN_WHITE, w, h);
        if ((i % 30) == 0)  pixDisplay(pixd, 600, 0);
        pixDestroy(&pixs);
    }

    pixWrite("/tmp/lept/rotate/spin.png", pixd, IFF_PNG);
    pixDisplay(pixd, 0, 0);

    for (i = 0; i < 180; i++) {
        pixs = pixd;
        pixd = pixRotate(pixs, -ang, rotflag, L_BRING_IN_WHITE, w, h);
        if (i && (i % 30) == 0)  pixDisplay(pixd, 600, 500);
        pixDestroy(&pixs);
    }

    pixWrite("/tmp/lept/rotate/unspin.png", pixd, IFF_PNG);
    pixDisplay(pixd, 0, 500);
    pixDestroy(&pixd);
#endif

    return 0;
}
Example #10
0
UBIdleTimer::UBIdleTimer(QObject *parent)
     : QObject(parent)
     , mCursorIsHidden(false)
{
    startTimer(100);
}
Example #11
0
void TFrameHandle::setTimer(int frameRate) {
  m_previewFrameRate = frameRate;
  if (m_timerId != 0) killTimer(m_timerId);
  int interval = troundp(1000.0 / double(m_previewFrameRate));
  m_timerId    = startTimer(interval);
}
Example #12
0
void CSceneWidget::start()
{
    // only one timer
    if(_timerId == 0)
        _timerId = startTimer(1000 / 25);
}
Example #13
0
void Sender::run()
{
    QEventLoop loop;
    startTimer(2000);
    loop.exec();
}
Example #14
0
void Plot::start()
{
    d_clock.start();
    d_timerId = startTimer(10);
}
Example #15
0
void BitmapImage::startAnimation(CatchUpAnimation catchUpIfNecessary)
{
    if (m_frameTimer || !shouldAnimate() || frameCount() <= 1)
        return;

    // If we aren't already animating, set now as the animation start time.
    const double time = monotonicallyIncreasingTime();
    if (!m_desiredFrameStartTime)
        m_desiredFrameStartTime = time;

    // Don't advance the animation to an incomplete frame.
    size_t nextFrame = (m_currentFrame + 1) % frameCount();
    if (!m_allDataReceived && !frameIsCompleteAtIndex(nextFrame))
        return;

    // Don't advance past the last frame if we haven't decoded the whole image
    // yet and our repetition count is potentially unset. The repetition count
    // in a GIF can potentially come after all the rest of the image data, so
    // wait on it.
    if (!m_allDataReceived && repetitionCount(false) == cAnimationLoopOnce && m_currentFrame >= (frameCount() - 1))
        return;

    // Determine time for next frame to start. By ignoring paint and timer lag
    // in this calculation, we make the animation appear to run at its desired
    // rate regardless of how fast it's being repainted.
    const double currentDuration = frameDurationAtIndex(m_currentFrame);
    m_desiredFrameStartTime += currentDuration;

#if !PLATFORM(IOS)
    // When an animated image is more than five minutes out of date, the
    // user probably doesn't care about resyncing and we could burn a lot of
    // time looping through frames below. Just reset the timings.
    const double cAnimationResyncCutoff = 5 * 60;
    if ((time - m_desiredFrameStartTime) > cAnimationResyncCutoff)
        m_desiredFrameStartTime = time + currentDuration;
#else
    // Maintaining frame-to-frame delays is more important than
    // maintaining absolute animation timing, so reset the timings each frame.
    m_desiredFrameStartTime = time + currentDuration;
#endif

    // The image may load more slowly than it's supposed to animate, so that by
    // the time we reach the end of the first repetition, we're well behind.
    // Clamp the desired frame start time in this case, so that we don't skip
    // frames (or whole iterations) trying to "catch up". This is a tradeoff:
    // It guarantees users see the whole animation the second time through and
    // don't miss any repetitions, and is closer to what other browsers do; on
    // the other hand, it makes animations "less accurate" for pages that try to
    // sync an image and some other resource (e.g. audio), especially if users
    // switch tabs (and thus stop drawing the animation, which will pause it)
    // during that initial loop, then switch back later.
    if (nextFrame == 0 && m_repetitionsComplete == 0 && m_desiredFrameStartTime < time)
        m_desiredFrameStartTime = time;

    if (catchUpIfNecessary == DoNotCatchUp || time < m_desiredFrameStartTime) {
        // Haven't yet reached time for next frame to start; delay until then.
        startTimer(std::max<double>(m_desiredFrameStartTime - time, 0));
        return;
    }

    ASSERT(!m_frameTimer);

    // We've already reached or passed the time for the next frame to start.
    // See if we've also passed the time for frames after that to start, in
    // case we need to skip some frames entirely. Remember not to advance
    // to an incomplete frame.

#if !LOG_DISABLED
    size_t startCatchupFrameIndex = nextFrame;
#endif
    
    for (size_t frameAfterNext = (nextFrame + 1) % frameCount(); frameIsCompleteAtIndex(frameAfterNext); frameAfterNext = (nextFrame + 1) % frameCount()) {
        // Should we skip the next frame?
        double frameAfterNextStartTime = m_desiredFrameStartTime + frameDurationAtIndex(nextFrame);
        if (time < frameAfterNextStartTime)
            break;

        // Yes; skip over it without notifying our observers. If we hit the end while catching up,
        // tell the observer asynchronously.
        if (!internalAdvanceAnimation(SkippingFramesToCatchUp)) {
            m_animationFinishedWhenCatchingUp = true;
            startTimer(0);
            LOG(Images, "BitmapImage %p startAnimation catching up from frame %lu, ended", this, startCatchupFrameIndex);
            return;
        }
        m_desiredFrameStartTime = frameAfterNextStartTime;
        nextFrame = frameAfterNext;
    }

    LOG(Images, "BitmapImage %p startAnimation catching up jumped from from frame %lu to %d", this, startCatchupFrameIndex, (int)nextFrame - 1);

    // Draw the next frame as soon as possible. Note that m_desiredFrameStartTime
    // may be in the past, meaning the next time through this function we'll
    // kick off the next advancement sooner than this frame's duration would suggest.
    startTimer(0);
}
Example #16
0
bool QAbstractKineticScrollerPrivate::handleMouseRelease(QMouseEvent *e)
{
    qKSDebug() << "MR: pos: " << e->globalPos() << " - time: " << QTime::currentTime().msec();
    Q_Q(QAbstractKineticScroller);

    if (e->button() != Qt::LeftButton)
        return false;
    if ((state != QAbstractKineticScroller::MousePressed) && (state != QAbstractKineticScroller::Pushing))
        return false;

    // if last event was a motion-notify we have to check the
    // movement and launch the animation
    if (lastType == QEvent::MouseMove) {
        if (moved) {
            QPoint delta = e->globalPos() - pos;
            handleMove(e, delta);

            // move all the way to the last position now
            if (scrollTimerId) {
                killTimer(scrollTimerId);
                scrollTimerId = 0;
                setScrollPositionHelper(q->scrollPosition() - overshootDist - motion);
                motion = QPoint(0, 0);
            }
        }
    }
    // If overshoot has been initiated with a finger down,
    // on release set max speed
    if (overshootDist.x()) {
        overshooting = bounceSteps; // Hack to stop a bounce in the finger down case
        velocity.setX(-overshootDist.x() * qreal(0.8));

    }
    if (overshootDist.y()) {
        overshooting = bounceSteps; // Hack to stop a bounce in the finger down case
        velocity.setY(-overshootDist.y() * qreal(0.8));
    }

    bool forceFast = true;

    // if widget was moving fast in the panning, increase speed even more
    if ((lastPressTime.elapsed() < FastClick) &&
        ((qAbs(oldVelocity.x()) > minVelocity) ||
         (qAbs(oldVelocity.y()) > minVelocity)) &&
        ((qAbs(oldVelocity.x()) > MinimumAccelerationThreshold) ||
         (qAbs(oldVelocity.y()) > MinimumAccelerationThreshold))) {

        qKSDebug() << "FAST CLICK - using oldVelocity " << oldVelocity;
        int signX = 0, signY = 0;
        if (velocity.x())
            signX = (velocity.x() > 0) == (oldVelocity.x() > 0) ? 1 : -1;
        if (velocity.y())
            signY = (velocity.y() > 0) == (oldVelocity.y() > 0) ? 1 : -1;

        // calculate the acceleration velocity
        QPoint maxPos = q->maximumScrollPosition();
        accelerationVelocity  = QPoint(0, 0);
        QSize size = q->viewportSize();
        if (size.width())
            accelerationVelocity.setX(qMin(int(q->maximumVelocity()), maxPos.x() / size.width() * AccelFactor));
        if (size.height())
            accelerationVelocity.setY(qMin(int(q->maximumVelocity()), maxPos.y() / size.height() * AccelFactor));

        velocity.setX(signX * (oldVelocity.x() + (oldVelocity.x() > 0 ? accelerationVelocity.x() : -accelerationVelocity.x())));
        velocity.setY(signY * (oldVelocity.y() + (oldVelocity.y() > 0 ? accelerationVelocity.y() : -accelerationVelocity.y())));
        forceFast = false;
    }

    if ((qAbs(velocity.x()) >= minVelocity) ||
        (qAbs(velocity.y()) >= minVelocity)) {

        qKSDebug() << "over min velocity: " << velocity;
        // we have to move because we are in overshooting position
        if (!moved) {
            // (opt) emit panningStarted()
        }
        // (must) enable scrollbars

        if (forceFast) {
            if ((qAbs(velocity.x()) > MaximumVelocityThreshold) &&
                (accelerationVelocity.x() > MaximumVelocityThreshold)) {
                velocity.setX(velocity.x() > 0 ? accelerationVelocity.x() : -accelerationVelocity.x());
            }
            if ((qAbs(velocity.y()) > MaximumVelocityThreshold) &&
                (accelerationVelocity.y() > MaximumVelocityThreshold)) {
                velocity.setY(velocity.y() > 0 ? accelerationVelocity.y() : -accelerationVelocity.y());
            }
            qKSDebug() << "Force fast is on - velocity: " << velocity;

        }
        changeState(QAbstractKineticScroller::AutoScrolling);

    } else {
        if (moved) {
            // (opt) emit panningFinished()
        }
        changeState(QAbstractKineticScroller::Inactive);
    }

    // -- create the idle timer if we are auto scrolling or overshooting.
    if (!idleTimerId
            && ((qAbs(velocity.x()) >= minVelocity)
                || (qAbs(velocity.y()) >= minVelocity)
                || overshootDist.x()
                || overshootDist.y()) ) {
        idleTimerId = startTimer(1000 / scrollsPerSecond);
    }

    lastTime.restart();
    lastType = e->type();

    bool wasMoved = moved;
    moved = false;
    qKSDebug("MR: end %d", wasMoved);
    return wasMoved; // do not swallow the mouse release, if we didn't move at all
}
CreateSnapshotDialog::CreateSnapshotDialog(
        QWidget       *parent,
        QString        domainName,
        QString        _conName,
        bool           _state,
        virConnectPtr *connPtrPtr) :
    QDialog(parent)
{
    QString winTitle = QString("Create Snapshot of <%1> in [ %2 ] connection")
            .arg(domainName).arg(_conName);
    setWindowTitle(winTitle);
    settings.beginGroup("CreateSnapshotDialog");
    restoreGeometry( settings.value("Geometry").toByteArray() );
    settings.endGroup();
    titleLayout = new QHBoxLayout(this);
    nameLabel = new QLabel("Name:", this);
    name = new QLineEdit(this);
    name->setPlaceholderText("generate if omit");
    name->setMinimumWidth(100);
    addTimeSuff = new QCheckBox(this);
    addTimeSuff->setToolTip("Add Time to Snapshot Name");
    timeLabel = new QLabel(this);
    QString _date(QTime::currentTime().toString());
    _date.append("-");
    _date.append(QDate::currentDate().toString("dd.MM.yyyy"));
    timeLabel->setText(_date);
    timeLabel->setEnabled(false);
    titleLayout->addWidget(nameLabel);
    titleLayout->addWidget(name);
    titleLayout->addWidget(addTimeSuff);
    titleLayout->addWidget(timeLabel);
    titleWdg = new QWidget(this);
    titleWdg->setLayout(titleLayout);
    description = new QLineEdit(this);
    description->setPlaceholderText("Short Description");
    snapshotType = new QComboBox(this);
    snapshotType->addItems(SNAPSHOT_TYPES);
    flagsMenu = new CreateSnapshotFlags(this);
    flags = new QPushButton(QIcon::fromTheme("flag"), "", this);
    flags->setMenu(flagsMenu);
    flags->setMaximumWidth(flags->sizeHint().width());
    flags->setToolTip("Creation Snapshot Flags");
    // because first item is non-actual there
    flags->setEnabled(false);
    typeLayout = new QHBoxLayout(this);
    typeLayout->addWidget(snapshotType);
    typeLayout->addWidget(flags);
    typeWdg = new QWidget(this);
    typeWdg->setLayout(typeLayout);
    baseWdg = new QStackedWidget(this);
    baseWdg->addWidget(new MemStateSnapshot(this, _state));
    baseWdg->addWidget(new DiskSnapshot(this, _state, false));
    baseWdg->addWidget(new DiskSnapshot(this, _state, true));
    baseWdg->addWidget(new SystemCheckpoint(this, _state, false));
    baseWdg->addWidget(new SystemCheckpoint(this, _state, true));
    info = new QLabel("<a href='https://libvirt.org/formatsnapshot.html'>About</a>", this);
    info->setOpenExternalLinks(true);
    info->setToolTip("https://libvirt.org/formatsnapshot.html");
    ok = new QPushButton("Ok", this);
    // because first item is non-actual there
    ok->setEnabled(false);
    cancel = new QPushButton("Cancel", this);
    buttonsLayout = new QHBoxLayout(this);
    buttonsLayout->addWidget(info);
    buttonsLayout->addWidget(ok);
    buttonsLayout->addWidget(cancel);
    buttonsWdg = new QWidget(this);
    buttonsWdg->setLayout(buttonsLayout);
    commonLayout = new QVBoxLayout(this);
    commonLayout->addWidget(titleWdg);
    commonLayout->addWidget(description);
    commonLayout->addWidget(typeWdg);
    commonLayout->addWidget(baseWdg);
    commonLayout->addWidget(buttonsWdg);
    //commonLayout->addStretch(-1);
    setLayout(commonLayout);
    connect(snapshotType, SIGNAL(currentIndexChanged(int)),
            baseWdg, SLOT(setCurrentIndex(int)));
    connect(snapshotType, SIGNAL(currentIndexChanged(int)),
            this, SLOT(snapshotTypeChange(int)));
    connect(ok, SIGNAL(clicked()), this, SLOT(accept()));
    connect(cancel, SIGNAL(clicked()), this, SLOT(reject()));
    connect(addTimeSuff, SIGNAL(toggled(bool)),
            timeLabel, SLOT(setEnabled(bool)));
    for (int i=0; i<baseWdg->count(); i++) {
        _SnapshotStuff *wdg = static_cast<_SnapshotStuff*>(
                    baseWdg->widget(i));
        if ( nullptr!=wdg ) wdg->setParameters(connPtrPtr, domainName);
        connect(wdg, SIGNAL(errMsg(QString&)),
                this, SIGNAL(errMsg(QString&)));
    };
    timerID = startTimer(1000);
}
Example #18
0
void testApp::update() {	
	kinect.update();
	if(!panel.getValueB("pause") && kinect.isFrameNew())	{
		zCutoff = panel.getValueF("zCutoff");
		
		float fovWidth = panel.getValueF("fovWidth");
		float fovHeight = panel.getValueF("fovHeight");
		int left = Xres * (1 - fovWidth) / 2;
		int top = Yres * (1 - fovHeight) / 2;
		int right = left + Xres * fovWidth;
		int bottom = top + Yres * fovHeight;
		roiStart = Point2d(left, top);
		roiEnd = Point2d(right, bottom);
		
		ofVec3f nw = ConvertProjectiveToRealWorld(roiStart.x, roiStart.y, zCutoff);
		ofVec3f se = ConvertProjectiveToRealWorld(roiEnd.x - 1, roiEnd.y - 1, zCutoff);
		float width = (se - nw).x;
		float height = (se - nw).y;
		globalScale = panel.getValueF("stlSize") / MAX(width, height);
		
		backOffset = panel.getValueF("backOffset") / globalScale;
		
		cutoffKinect();
		
		if(panel.getValueB("useSmoothing")) {
			smoothKinect();
		}
		
		if(panel.getValueB("useWatermark")) {
			startTimer();
			injectWatermark();
			injectWatermarkTime = stopTimer();
		}
		
		startTimer();
		updateSurface();
		updateSurfaceTime = stopTimer();
		
		bool exportStl = panel.getValueB("exportStl");
		bool useRandomExport = panel.getValueB("useRandomExport");
		
		startTimer();
		if((exportStl && useRandomExport) || panel.getValueB("useRandom")) {
			updateTrianglesRandom();
		} else if(panel.getValueB("useSimplify")) {
			updateTrianglesSimplify();
		} else {
			updateTriangles();
		}
		calculateNormals(triangles, normals);
		updateTrianglesTime = stopTimer();
		
		startTimer();
		updateBack();
		updateBackTime = stopTimer();
		
		startTimer();
		postProcess();
		postProcessTime = stopTimer();
		
		if(exportStl) {
			string pocoTime = Poco::DateTimeFormatter::format(Poco::LocalDateTime(), "%Y-%m-%d at %H.%M.%S");
			
			ofxSTLExporter exporter;
			exporter.beginModel("Kinect Export");
			addTriangles(exporter, triangles, normals);
			addTriangles(exporter, backTriangles, backNormals);
			exporter.saveModel("Kinect Export " + pocoTime + ".stl");
			
#ifdef USE_REPLICATORG
			if(printer.isConnected()) {
				printer.printToFile("/home/matt/MakerBot/repg_workspace/ReplicatorG/examples/Snake.stl", "/home/matt/Desktop/snake.s3g");
			}
#endif
			
			panel.setValueB("exportStl", false);
		}
	}
	
	float diffuse = panel.getValueF("diffuseAmount");
	redLight.setDiffuseColor(ofColor(diffuse / 2, diffuse / 2, 0));
	greenLight.setDiffuseColor(ofColor(0, diffuse / 2, diffuse / 2));
	blueLight.setDiffuseColor(ofColor(diffuse / 2, 0, diffuse / 2));
	
	float ambient = 255 - diffuse;
	redLight.setAmbientColor(ofColor(ambient / 2, ambient / 2, 0));
	greenLight.setAmbientColor(ofColor(0, ambient / 2, ambient / 2));
	blueLight.setAmbientColor(ofColor(ambient / 2, 0, ambient / 2));
	
	float lightY = ofGetHeight() / 2 + panel.getValueF("lightY");
	float lightZ = panel.getValueF("lightZ");
	float lightDistance = panel.getValueF("lightDistance");
	float lightRotation = panel.getValueF("lightRotation");
	redLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 0 * TWO_PI / 3) * lightDistance,
											 lightY + sin(lightRotation + 0 * TWO_PI / 3) * lightDistance,
											 lightZ);
	greenLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 1 * TWO_PI / 3) * lightDistance,
												 lightY + sin(lightRotation + 1 * TWO_PI / 3) * lightDistance,
												 lightZ);
	blueLight.setPosition(ofGetWidth() / 2 + cos(lightRotation + 2 * TWO_PI / 3) * lightDistance,
												lightY + sin(lightRotation + 2 * TWO_PI / 3) * lightDistance,
												lightZ);
}
dvrkTeleopQWidget::dvrkTeleopQWidget(const std::string &name, const double &period):
    QWidget(), counter_(0)
{
    is_head_in_ = false;
    is_clutched_ = false;
    is_move_psm_ = false;

    // subscriber
    // NOTE: queue size is set to 1 to make sure data is fresh
    sub_mtm_pose_ = nh_.subscribe("/dvrk_mtm/cartesian_pose_current", 1,
                                    &dvrkTeleopQWidget::master_pose_cb, this);
    sub_psm_pose_ = nh_.subscribe("/dvrk_psm/cartesian_pose_current", 1,
                                   &dvrkTeleopQWidget::slave_pose_cb, this);

    // publisher
    pub_teleop_enable_ = nh_.advertise<std_msgs::Bool>("/dvrk_teleop/enable", 100);
    pub_mtm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_mtm/control_mode", 100);
    pub_psm_control_mode_ = nh_.advertise<std_msgs::Int8>("/dvrk_psm/control_mode", 100);
    pub_enable_slider_ = nh_.advertise<sensor_msgs::JointState>("/dvrk_mtm/joint_state_publisher/enable_slider", 100);

    // pose display
    mtm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead;
    psm_pose_qt_ = new vctQtWidgetFrame4x4DoubleRead;

    QVBoxLayout *poseLayout = new QVBoxLayout;
    poseLayout->addWidget(mtm_pose_qt_);
    poseLayout->addWidget(psm_pose_qt_);

    // common console
    QGroupBox *consoleBox = new QGroupBox("Console");
    QPushButton *consoleHomeButton = new QPushButton(tr("Home"));
    QPushButton *consoleManualButton = new QPushButton(tr("Manual"));
    QPushButton *consoleTeleopTestButton = new QPushButton(tr("TeleopTest"));
    consoleTeleopButton = new QPushButton(tr("Teleop"));
    consoleHomeButton->setStyleSheet("font: bold; color: green;");
    consoleManualButton->setStyleSheet("font: bold; color: red;");
    consoleTeleopTestButton->setStyleSheet("font: bold; color: blue;");
    consoleTeleopButton->setStyleSheet("font: bold; color: brown;");
    consoleHomeButton->setCheckable(true);
    consoleManualButton->setCheckable(true);
    consoleTeleopTestButton->setCheckable(true);
    consoleTeleopButton->setCheckable(true);

    QButtonGroup *consoleButtonGroup = new QButtonGroup;
    consoleButtonGroup->setExclusive(true);
    consoleButtonGroup->addButton(consoleHomeButton);
    consoleButtonGroup->addButton(consoleManualButton);
    consoleButtonGroup->addButton(consoleTeleopTestButton);
    consoleButtonGroup->addButton(consoleTeleopButton);

    QHBoxLayout *consoleBoxLayout = new QHBoxLayout;
    consoleBoxLayout->addWidget(consoleHomeButton);
    consoleBoxLayout->addWidget(consoleManualButton);
    consoleBoxLayout->addWidget(consoleTeleopTestButton);
    consoleBoxLayout->addWidget(consoleTeleopButton);
    consoleBoxLayout->addStretch();
    consoleBox->setLayout(consoleBoxLayout);

    // mtm console
    mtmBox = new QGroupBox("MTM");
    QVBoxLayout *mtmBoxLayout = new QVBoxLayout;
    mtmClutchButton = new QPushButton(tr("Clutch"));
    mtmClutchButton->setCheckable(true);
    mtmBoxLayout->addWidget(mtmClutchButton);

    mtmHeadButton = new QPushButton(tr("Head"));
    mtmHeadButton->setCheckable(true);
    mtmBoxLayout->addWidget(mtmHeadButton);

    mtmBoxLayout->addStretch();
    mtmBox->setLayout(mtmBoxLayout);

    // psm console
    psmBox = new QGroupBox("PSM");
    QVBoxLayout *psmBoxLayout = new QVBoxLayout;
    psmMoveButton = new QPushButton(tr("Move Tool"));
    psmMoveButton->setCheckable(true);
    psmBoxLayout->addWidget(psmMoveButton);
    psmBoxLayout->addStretch();
    psmBox->setLayout(psmBoxLayout);

    // rightLayout
    QGridLayout *rightLayout = new QGridLayout;
    rightLayout->addWidget(consoleBox, 0, 0, 1, 2);
    rightLayout->addWidget(mtmBox, 1, 0);
    rightLayout->addWidget(psmBox, 1, 1);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(poseLayout);
    mainLayout->addLayout(rightLayout);

    this->setLayout(mainLayout);
    this->resize(sizeHint());
    this->setWindowTitle("Teleopo GUI");

    // set stylesheet
    std::string filename = ros::package::getPath("dvrk_teleop");
    filename.append("/src/default.css");
    QFile defaultStyleFile(filename.c_str());
    defaultStyleFile.open(QFile::ReadOnly);
    QString styleSheet = QLatin1String(defaultStyleFile.readAll());
    this->setStyleSheet(styleSheet);

    // now connect everything
    connect(consoleHomeButton, SIGNAL(clicked()), this, SLOT(slot_homeButton_pressed()));
    connect(consoleManualButton, SIGNAL(clicked()), this, SLOT(slot_manualButton_pressed()));
    connect(consoleTeleopTestButton, SIGNAL(clicked()), this, SLOT(slot_teleopTestButton_pressed()));
    connect(consoleTeleopButton, SIGNAL(toggled(bool)), this, SLOT(slot_teleopButton_toggled(bool)));

    connect(mtmHeadButton, SIGNAL(clicked(bool)), this, SLOT(slot_headButton_pressed(bool)));
    connect(mtmClutchButton, SIGNAL(clicked(bool)), this, SLOT(slot_clutchButton_pressed(bool)));
    connect(psmMoveButton, SIGNAL(clicked(bool)), this, SLOT(slot_moveToolButton_pressed(bool)));

    // show widget & start timer
    startTimer(period);  // 50 ms
    slot_teleopButton_toggled(false);
}
/* Time are expressed in us */
t_uint32 METH(startHighPrecisionTimer)(t_uint32 fisrtAlarm, t_uint32 period) {
  return startTimer(fisrtAlarm, period);
}
void SMILTimeContainer::notifyIntervalsChanged()
{
    // Schedule updateAnimations() to be called asynchronously so multiple intervals
    // can change with updateAnimations() only called once at the end.
    startTimer(0);
}
Example #22
0
DisplayStatsData::DisplayStatsData()
{
	clear();
	m_timer = startTimer(STAT_TIMER_INTERVAL * 1000);
}
Example #23
0
int main(int argc, char **argv) {
	int np, rank;
	int size = atoi(argv[1]);
	int matrix[size][size]; //[wiersz][kolumna]
	int vector[size];
	
	int result[size];

	MPI_Init(&argc, &argv);
	MPI_Status status;
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);
	MPI_Comm_size(MPI_COMM_WORLD, &np);
	int partition = size / np;
	int subresult[partition];
	int submatrix[size*partition];
	pTimer T = newTimer(); //deklaruje czas T
	double gotowe_time; //zmienna pod która bedę podstawiał czas do wyświetlenia

	int i, j;
	
	/* Walidacja równego podziału na macierzy na procesy */
	if ((size <= 0) || ((size % np) != 0)){
	   if (rank == 0){
	      printf("Nie mogę tego równo podzielić! Koniec.\n");
	   }
	   MPI_Finalize();
	   return 0;
	}
	
	if(rank == 0) {
		srand(time(0));
		for(i = 0; i < size; i++) {
			for(j = 0; j < size; j++) {
				matrix[i][j] = (int)(rand() % 10);
			}
		}
		for(i = 0; i < size; i++){
		   vector[i] = (int)(rand() % 10);
		} 
	}
	
	/*
		czyszczenie wszystkich zmiennych żeby nie było cudów
	*/
		for(i = 0; i < size; i++) {
		   result[i] = 0;
		}
		for(i=0; i < size*partition; i++) {
		   submatrix[i]=0;
		}
		for(i=0; i < partition; i++) {
		  subresult[i]=0;
		}
		
	startTimer(T);           // czas start
	
	/*
	   	Dziel na wiersze i wysyłam do procesów
	*/
	
	MPI_Scatter(matrix, size*partition, MPI_INT, submatrix, size*partition, MPI_INT, 0, MPI_COMM_WORLD);
		
	/*
		Broadcast wysyłam vektor do każdego procesu
	*/
	MPI_Bcast(vector, size, MPI_INT, 0, MPI_COMM_WORLD);

	/*     
		Każdy proces liczy swój wiersz
	*/
	for(i=0; i<partition; i++){
	   for(j=0; j<size; j++){
	      subresult[i]+= submatrix[j+size*i] * vector[j]; //size*i żeby przeskoczył do następnego wiersza jeśli otrzyma ich kilka
	   }
	}
	
	/*
		Proces zbiera wyniki i skleja je do result
	*/
	MPI_Gather(subresult, partition, MPI_INT, result, partition, MPI_INT, 0, MPI_COMM_WORLD);
	
	if(rank == 0) {
	     stopTimer(T);  // czas stop
	     gotowe_time = getTime(T); //podstawiam czas
	     printf("Koniec obliczeń, czas obliczeń = %f\n", gotowe_time);
	     if(size<8){
		     for(i = 0; i < size; i++) {
			   for(j=0; j < size; j++){
			     printf("%d\t",matrix[i][j]);
			   }
			   printf("|%d\t| %d\t\n", vector[i],result[i]);
		     }
	    }
	    else {
	         printf("Nie wyświetle w terminalu poprawnie tak dużej macierzy\n");
	    }
	}
	
	MPI_Finalize();
	
	return 0;
}
Example #24
0
void AddressWidget::handleUserInput(const QString &text)
{
	const BookmarkInformation *bookmark = BookmarksManager::getBookmarkByKeyword(text);

	if (bookmark)
	{
		WindowsManager *windowsManager = SessionsManager::getWindowsManager();

		if (windowsManager)
		{
			windowsManager->open(bookmark);

			return;
		}
	}

	if (text == QString(QLatin1Char('~')) || text.startsWith(QLatin1Char('~') + QDir::separator()))
	{
		const QStringList locations = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);

		if (!locations.isEmpty())
		{
			emit requestedLoadUrl(QUrl(locations.first() + text.mid(1)));

			return;
		}
	}

	if (QFileInfo(text).exists())
	{
		emit requestedLoadUrl(QUrl::fromLocalFile(QFileInfo(text).canonicalFilePath()));

		return;
	}

	const QUrl url = QUrl::fromUserInput(text);

	if (url.isValid() && (url.isLocalFile() || QRegularExpression(QLatin1String("^(\\w+\\:\\S+)|([\\w\\-]+\\.[a-zA-Z]{2,}(/\\S*)?$)")).match(text).hasMatch()))
	{
		emit requestedLoadUrl(url);

		return;
	}

	const QString shortcut = text.section(QLatin1Char(' '), 0, 0);
	const QStringList engines = SearchesManager::getSearchEngines();
	SearchInformation *engine = NULL;

	for (int i = 0; i < engines.count(); ++i)
	{
		engine = SearchesManager::getSearchEngine(engines.at(i));

		if (engine && shortcut == engine->shortcut)
		{
			emit requestedSearch(text.section(QLatin1Char(' '), 1), engine->identifier);

			return;
		}
	}

	const int lookupTimeout = SettingsManager::getValue(QLatin1String("AddressField/HostLookupTimeout")).toInt();

	if (url.isValid() && lookupTimeout > 0)
	{
		if (text == m_lookupQuery)
		{
			return;
		}

		m_lookupQuery = text;

		if (m_lookupTimer != 0)
		{
			QHostInfo::abortHostLookup(m_lookupIdentifier);

			killTimer(m_lookupTimer);

			m_lookupTimer = 0;
		}

		m_lookupIdentifier = QHostInfo::lookupHost(url.host(), this, SLOT(verifyLookup(QHostInfo)));
		m_lookupTimer = startTimer(lookupTimeout);

		return;
	}

	emit requestedSearch(text, SettingsManager::getValue(QLatin1String("Search/DefaultSearchEngine")).toString());
}
NotificationDialog::NotificationDialog(Notification *notification, QWidget *parent) : QFrame(parent),
	m_notification(notification),
	m_closeLabel(new QLabel(this)),
	m_iconLabel(new QLabel(this)),
	m_messageLabel(new QLabel(this)),
	m_closeTimer(0)
{
	m_iconLabel->setStyleSheet(QLatin1String("padding:5px;"));
	m_iconLabel->setAttribute(Qt::WA_TransparentForMouseEvents);

	m_messageLabel->setStyleSheet(QLatin1String("padding:5px;font-size:13px;"));
	m_messageLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
	m_messageLabel->setWordWrap(true);

	QStyleOption option;
	option.rect = QRect(0, 0, 16, 16);
	option.state = (QStyle::State_Enabled | QStyle::State_AutoRaise);

	QPixmap pixmap(16, 16);
	pixmap.fill(Qt::transparent);

	QPainter painter(&pixmap);

	style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &option, &painter, this);

	m_closeLabel->setToolTip(tr("Close"));
	m_closeLabel->setPixmap(pixmap);
	m_closeLabel->setAttribute(Qt::WA_TransparentForMouseEvents);
	m_closeLabel->setAlignment(Qt::AlignTop);
	m_closeLabel->setMargin(5);

	QBoxLayout *layout(new QBoxLayout(QBoxLayout::LeftToRight));
	layout->setContentsMargins(0, 0, 0, 0);
	layout->setSpacing(0);
	layout->setSizeConstraint(QLayout::SetMinimumSize);
	layout->addWidget(m_iconLabel);
	layout->addWidget(m_messageLabel);
	layout->addWidget(m_closeLabel);

	setLayout(layout);
	setObjectName(QLatin1String("notificationFrame"));
	setStyleSheet(QLatin1String("#notificationFrame {padding:5px;border:1px solid #CCC;border-radius:10px;background:#F0F0f0;}"));
	setCursor(QCursor(Qt::PointingHandCursor));
	setFixedWidth(400);
	setMinimumHeight(50);
	setMaximumHeight(150);
	setWindowOpacity(0);
	setWindowFlags(Qt::WindowStaysOnTopHint | Qt::Tool | Qt::FramelessWindowHint);
	setFocusPolicy(Qt::NoFocus);
	setAttribute(Qt::WA_DeleteOnClose, true);
	setAttribute(Qt::WA_ShowWithoutActivating, true);
	updateMessage();
	adjustSize();

	m_animation = new QPropertyAnimation(this, QStringLiteral("windowOpacity").toLatin1());
	m_animation->setDuration(500);
	m_animation->setStartValue(0.0);
	m_animation->setEndValue(1.0);
	m_animation->start();

	const int visibilityDuration(SettingsManager::getOption(SettingsManager::Interface_NotificationVisibilityDurationOption).toInt());

	if (visibilityDuration > 0)
	{
		m_closeTimer = startTimer(visibilityDuration * 1000);
	}

	connect(notification, &Notification::modified, this, &NotificationDialog::updateMessage);
	connect(notification, &Notification::requestedClose, this, &NotificationDialog::close);
}
Example #26
0
//==============================================================================
AutomizerAudioProcessorEditor::AutomizerAudioProcessorEditor (AutomizerAudioProcessor* ownerFilter)
    : AudioProcessorEditor (ownerFilter),
	outputGainLabel("", "Output Gain(dB):"), 
	voice1GainLabel("", "Voice 1 Gain(dB):"),
	voice2GainLabel("", "Voice 2 Gain(dB):"),
	shiftTypeLabel("", "Formant Preservation:"), 
	transposeLabel("", "Transpose:"),
	pan1Label("", "Voice 1 Pan(%):"), 
	pan2Label("", "Voice 2 Pan(%):"),
	keyLabel("", "Key:"),
	scaleLabel("", "Scale:"),
	autotuneLabel("","Autotune:"),
	attackLabel("","Attack(ms):"),
	refLabel("", "Reference(Hz):"),
	shiftLabel("", "Intelligent Harmony:"),
	rollOnLabel("", "Spectral Roll On(%):"),
	whitenLabel("", "Spectral Whitening(%):"),
	harmonyLabel("", "Harmony Type:"),
	tuneLabel("", "Chord Tuning"),
	harm1AttackLabel("", "Voice 1 Attack(ms):"),
	harm2AttackLabel("", "Voice 2 Attack(ms):"),
	vDepthLabel("", "Vibrato Depth(%):"),
	vRateLabel("", "Vibrato Rate(Hz):"),
	inputLabel("","INPUT 1 (L) VOX"),
	input2Label("","INPUT 2 (R) INS"),
	systemLabel("","SYSTEM"),
	outputLabel("","OUTPUT"),
	nameLabel("","THE AUTOMIZER by Daniel Oluyomi"),
	voice1Label("","VOICE 1"),
	voice2Label("","VOICE 2"),
	pitchLabel (String::empty),
	chordLabel(String::empty),
	transposePitchLabel(String::empty),
	centsLabel(String::empty), 
	MIDINoteLabel(String::empty),
	harm1Label(String::empty),
	harm2Label(String::empty),
	groupComponent (0),
	groupComponent2 (0),
	groupComponent3 (0),
	groupComponent4 (0)
{
   // Set up the sliders
    addAndMakeVisible (&outputGainSlider);
    outputGainSlider.setSliderStyle (Slider::LinearHorizontal);
	outputGainSlider.setColour (Slider::thumbColourId, Colours::white);

    outputGainSlider.addListener (this);
    outputGainSlider.setRange (-30, 6, 0.1);

    addAndMakeVisible (&voice1GainSlider);
    voice1GainSlider.setSliderStyle (Slider::Rotary);
    voice1GainSlider.addListener (this);
    voice1GainSlider.setRange (-30, 6, 0.1);
    voice1GainSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    voice1GainSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
    
	addAndMakeVisible (&voice2GainSlider);
    voice2GainSlider.setSliderStyle (Slider::Rotary);
    voice2GainSlider.addListener (this);
    voice2GainSlider.setRange (-30, 6, 0.1);
    voice2GainSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    voice2GainSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
    
    addAndMakeVisible (&transposeSlider);
    transposeSlider.setSliderStyle (Slider::Rotary);
    transposeSlider.addListener (this);
    transposeSlider.setRange (-12, 12, 0.1);
    transposeSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    transposeSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
    
	addAndMakeVisible (&pan1Slider);
    pan1Slider.setSliderStyle (Slider::Rotary);
    pan1Slider.addListener (this);
    pan1Slider.setRange (0, 100, 1);
    pan1Slider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    pan1Slider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
   
	addAndMakeVisible (&pan2Slider);
    pan2Slider.setSliderStyle (Slider::Rotary);
    pan2Slider.addListener (this);
    pan2Slider.setRange (0, 100, 1);
    pan2Slider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    pan2Slider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
   
	addAndMakeVisible (&attackSlider);
    attackSlider.setSliderStyle (Slider::Rotary);
    attackSlider.addListener (this);
    attackSlider.setRange (0, 100, 1);
    attackSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    attackSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));

	addAndMakeVisible (&refSlider);
    refSlider.setSliderStyle (Slider::Rotary);
    refSlider.addListener (this);
    refSlider.setRange (430, 450, 1);
    refSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    refSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));

    addAndMakeVisible (&rollOnSlider);
	rollOnSlider.setSliderStyle (Slider::Rotary);
    rollOnSlider.addListener (this);
    rollOnSlider.setRange (0, 5, 1);
    rollOnSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    rollOnSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));

    addAndMakeVisible (&whitenSlider);
    whitenSlider.setSliderStyle (Slider::Rotary);
    whitenSlider.addListener (this);
    whitenSlider.setRange (0, 100, 1);
    whitenSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    whitenSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));

	addAndMakeVisible (&harm1AttackSlider);
    harm1AttackSlider.setSliderStyle (Slider::Rotary);
    harm1AttackSlider.addListener (this);
    harm1AttackSlider.setRange (0, 100, 1);
    harm1AttackSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    harm1AttackSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));

	addAndMakeVisible (&harm2AttackSlider);
    harm2AttackSlider.setSliderStyle (Slider::Rotary);
    harm2AttackSlider.addListener (this);
    harm2AttackSlider.setRange (0, 100, 1);
    harm2AttackSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    harm2AttackSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));
	
    addAndMakeVisible (&vDepthSlider);
    vDepthSlider.setSliderStyle (Slider::Rotary);
    vDepthSlider.addListener (this);
    vDepthSlider.setRange (0, 0.05, 0.01);
    vDepthSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    vDepthSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));	

    addAndMakeVisible (&vRateSlider);
    vRateSlider.setSliderStyle (Slider::Rotary);
    vRateSlider.addListener (this);
    vRateSlider.setRange (0.1, 10, 0.1);
    vRateSlider.setColour (Slider::rotarySliderFillColourId, Colour (0xfbffffff));
    vRateSlider.setColour (Slider::rotarySliderOutlineColourId, Colour (0xff3c3c54));	

    addAndMakeVisible(&harmonyComboBox);
    harmonyComboBox.setEditableText(false);
	harmonyComboBox.setJustificationType(Justification::left);
	harmonyComboBox.addItem("High and Higher",HarmonizerEngine::HighAndHigher);
	harmonyComboBox.addItem("Low and Lower",HarmonizerEngine::LowAndLower);
	harmonyComboBox.addItem("Higher and Lower",HarmonizerEngine::HigherAndLower);
	harmonyComboBox.addItem("High and Low",HarmonizerEngine::HighAndLow);
    harmonyComboBox.addListener (this);

    addAndMakeVisible(&shiftTypeComboBox);
    shiftTypeComboBox.setEditableText(false);
    shiftTypeComboBox.setJustificationType(Justification::left);
	shiftTypeComboBox.addItem("On", HarmonizerEngine::lent);
    shiftTypeComboBox.addItem("Off",HarmonizerEngine::delay);
    shiftTypeComboBox.addListener(this);

    addAndMakeVisible(&shiftComboBox);
    shiftComboBox.setEditableText(false);
    shiftComboBox.setJustificationType(Justification::left);
	shiftComboBox.addItem("On", HarmonizerEngine::on);
    shiftComboBox.addItem("Off",HarmonizerEngine::off);
    shiftComboBox.addListener(this);

    addAndMakeVisible(&keyComboBox);
    keyComboBox.setEditableText(false);
    keyComboBox.setJustificationType(Justification::left);
	keyComboBox.addItem("C", HarmonizerEngine::C);
	keyComboBox.addItem("C#/Db",HarmonizerEngine::CSharp);
	keyComboBox.addItem("D", HarmonizerEngine::D);
	keyComboBox.addItem("D#/Eb", HarmonizerEngine::DSharp);
	keyComboBox.addItem("E", HarmonizerEngine::E);
	keyComboBox.addItem("F",HarmonizerEngine::F);
	keyComboBox.addItem("F#/Gb", HarmonizerEngine::FSharp);
	keyComboBox.addItem("G", HarmonizerEngine::G);
	keyComboBox.addItem("G#/Ab", HarmonizerEngine::GSharp);
	keyComboBox.addItem("A",HarmonizerEngine::A);
	keyComboBox.addItem("A#/Bb", HarmonizerEngine::ASharp);
	keyComboBox.addItem("B", HarmonizerEngine::B);
    keyComboBox.addListener(this);

	addAndMakeVisible(&scaleComboBox);
    scaleComboBox.setEditableText(false);
    scaleComboBox.setJustificationType(Justification::left);
	scaleComboBox.addItem("Major", HarmonizerEngine::Major);
    scaleComboBox.addItem("Harmonic Minor",HarmonizerEngine::Minor);
	scaleComboBox.addItem("Pentatonic", HarmonizerEngine::Pentatonic);
	scaleComboBox.addItem("Chromatic",HarmonizerEngine::Chromatic);
    scaleComboBox.addListener(this);

    addAndMakeVisible(&autotuneComboBox);
    autotuneComboBox.setEditableText(false);
    autotuneComboBox.setJustificationType(Justification::left);
	autotuneComboBox.addItem("On", HarmonizerEngine::on);
    autotuneComboBox.addItem("Off",HarmonizerEngine::off);
    autotuneComboBox.addListener(this);

    addAndMakeVisible(&tuneComboBox);
    tuneComboBox.setEditableText(false);
    tuneComboBox.setJustificationType(Justification::left);
	tuneComboBox.addItem("Automatic", HarmonizerEngine::on);
    tuneComboBox.addItem("Fixed",HarmonizerEngine::off);
    tuneComboBox.addListener(this);

	addAndMakeVisible (groupComponent = new GroupComponent (String::empty,
                                                            String::empty));
	groupComponent->setColour (GroupComponent::outlineColourId, Colours::dimgrey);
    groupComponent->setColour (GroupComponent::textColourId, Colours::white);

	addAndMakeVisible (groupComponent2 = new GroupComponent (String::empty,
                                                            String::empty));
    groupComponent2->setColour (GroupComponent::outlineColourId, Colours::dimgrey);
    groupComponent2->setColour (GroupComponent::textColourId, Colours::white);

	addAndMakeVisible (groupComponent3 = new GroupComponent (String::empty,
                                                            String::empty));
    groupComponent3->setColour (GroupComponent::outlineColourId, Colours::dimgrey);
    groupComponent3->setColour (GroupComponent::textColourId, Colours::white);

	addAndMakeVisible (groupComponent4 = new GroupComponent (String::empty,
                                                            String::empty));
    groupComponent4->setColour (GroupComponent::outlineColourId, Colours::dimgrey);
    groupComponent4->setColour (GroupComponent::textColourId, Colours::white);


    outputGainLabel.attachToComponent(&outputGainSlider, false);
    outputGainLabel.setFont(Font (16.0f));
	outputGainLabel.setColour(Label::textColourId, Colours::white);
    
    voice1GainLabel.attachToComponent(&voice1GainSlider, false);
    voice1GainLabel.setFont(Font (16.0f));
	voice1GainLabel.setColour(Label::textColourId, Colours::white);

    voice2GainLabel.attachToComponent(&voice2GainSlider, false);
    voice2GainLabel.setFont(Font (16.0f));
	voice2GainLabel.setColour(Label::textColourId, Colours::white);

    transposeLabel.attachToComponent(&transposeSlider, false);
    transposeLabel.setFont(Font (16.0f));
	transposeLabel.setColour(Label::textColourId, Colours::white);
    
    pan1Label.attachToComponent(&pan1Slider, false);
    pan1Label.setFont(Font (16.0f));
	pan1Label.setColour(Label::textColourId, Colours::white);
	
	pan2Label.attachToComponent(&pan2Slider, false);
    pan2Label.setFont(Font (16.0f));
	pan2Label.setColour(Label::textColourId, Colours::white);

	keyLabel.attachToComponent(&keyComboBox, false);
    keyLabel.setFont(Font (16.0f));
	keyLabel.setColour(Label::textColourId, Colours::white);

	scaleLabel.attachToComponent(&scaleComboBox, false);
    scaleLabel.setFont(Font (16.0f));
	scaleLabel.setColour(Label::textColourId, Colours::white);

	attackLabel.attachToComponent(&attackSlider, false);
    attackLabel.setFont(Font (16.0f));
	attackLabel.setColour(Label::textColourId, Colours::white);

	refLabel.attachToComponent(&refSlider, false);
    refLabel.setFont(Font (16.0f));
	refLabel.setColour(Label::textColourId, Colours::white);

	rollOnLabel.attachToComponent(&rollOnSlider, false);
    rollOnLabel.setFont(Font (16.0f));
	rollOnLabel.setColour(Label::textColourId, Colours::white);

	whitenLabel.attachToComponent(&whitenSlider, false);
    whitenLabel.setFont(Font (16.0f));
	whitenLabel.setColour(Label::textColourId, Colours::white);

	harm1AttackLabel.attachToComponent(&harm1AttackSlider, false);
    harm1AttackLabel.setFont(Font (16.0f));
	harm1AttackLabel.setColour(Label::textColourId, Colours::white);

	harm2AttackLabel.attachToComponent(&harm2AttackSlider, false);
    harm2AttackLabel.setFont(Font (16.0f));
	harm2AttackLabel.setColour(Label::textColourId, Colours::white);

	vDepthLabel.attachToComponent(&vDepthSlider, false);
    vDepthLabel.setFont(Font (16.0f));
	vDepthLabel.setColour(Label::textColourId, Colours::white);

	vRateLabel.attachToComponent(&vRateSlider, false);
    vRateLabel.setFont(Font (16.0f));
	vRateLabel.setColour(Label::textColourId, Colours::white);

	harmonyLabel.attachToComponent(&harmonyComboBox, false);
    harmonyLabel.setFont(Font (16.0f));
	harmonyLabel.setColour(Label::textColourId, Colours::white);
	
	shiftTypeLabel.attachToComponent(&shiftTypeComboBox, false);
    shiftTypeLabel.setFont(Font (16.0f));
	shiftTypeLabel.setColour(Label::textColourId, Colours::white);

	shiftLabel.attachToComponent(&shiftComboBox, false);
    shiftLabel.setFont(Font (16.0f));
	shiftLabel.setColour(Label::textColourId, Colours::white);

	autotuneLabel.attachToComponent(&autotuneComboBox, false);
	autotuneLabel.setColour (Label::textColourId, Colours::white);
    autotuneLabel.setFont(Font (16.0f));

	tuneLabel.attachToComponent(&tuneComboBox, false);
    tuneLabel.setFont(Font (16.0f));
	tuneLabel.setColour(Label::textColourId, Colours::white);

    addAndMakeVisible (&inputLabel);
	inputLabel.setFont(Font (24.0f));
    inputLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&input2Label);
	input2Label.setFont(Font (24.0f));
    input2Label.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&voice1Label);
	voice1Label.setFont(Font (18.0f));
    voice2Label.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&voice2Label);
	voice2Label.setFont(Font (18.0f));
    voice2Label.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&outputLabel);
	outputLabel.setFont(Font (24.0f));
    outputLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&systemLabel);
	systemLabel.setFont(Font (24.0f));
    systemLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&nameLabel);
	nameLabel.setFont(Font (16.0f));
    nameLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&pitchLabel);
  	pitchLabel.setFont(Font (16.0f));
    pitchLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&chordLabel);
  	chordLabel.setFont(Font (18.0f));
	chordLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&harm1Label);
  	harm1Label.setFont(Font (18.0f));
    harm1Label.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&harm2Label);
  	harm2Label.setFont(Font (18.0f));
    harm2Label.setColour (Label::textColourId, Colours::white);
	
    addAndMakeVisible (&transposePitchLabel);
  	transposePitchLabel.setFont(Font (16.0f));
    transposePitchLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&centsLabel);
  	centsLabel.setFont(Font (16.0f));
    centsLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&MIDINoteLabel);
  	MIDINoteLabel.setFont(Font (18.0f));
    MIDINoteLabel.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&voice1Label);
  	voice1Label.setFont(Font (20.0f));
    voice1Label.setColour (Label::textColourId, Colours::white);

    addAndMakeVisible (&voice2Label);
  	voice2Label.setFont(Font (20.0f));
    voice2Label.setColour (Label::textColourId, Colours::white);


    // add the triangular resizer component for the bottom-right of the UI
    addAndMakeVisible(resizer = new ResizableCornerComponent (this, &resizeLimits));
    resizeLimits.setSizeLimits(800, 600, 800, 600);

	// set our component's initial size to be the last one that was stored in the filter's settings
    setSize(ownerFilter->lastUIWidth,
            ownerFilter->lastUIHeight);
    
    startTimer(100);
}
Example #27
0
void TabBarWidget::contextMenuEvent(QContextMenuEvent *event)
{
	m_clickedTab = tabAt(event->pos());

	if (m_previewWidget && m_previewWidget->isVisible())
	{
		m_previewWidget->hide();
	}

	if (m_previewTimer > 0)
	{
		killTimer(m_previewTimer);

		m_previewTimer = 0;
	}

	QMenu menu(this);
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTab")));
	menu.addAction(ActionsManager::getAction(QLatin1String("NewTabPrivate")));

	if (m_clickedTab >= 0)
	{
		const bool isPinned = getTabProperty(m_clickedTab, QLatin1String("isPinned"), false).toBool();
		int amount = 0;

		for (int i = 0; i < count(); ++i)
		{
			if (getTabProperty(i, QLatin1String("isPinned"), false).toBool() || i == m_clickedTab)
			{
				continue;
			}

			++amount;
		}

		menu.addAction(tr("Clone Tab"), this, SLOT(cloneTab()))->setEnabled(getTabProperty(m_clickedTab, QLatin1String("canClone"), false).toBool());
		menu.addAction((isPinned ? tr("Unpin Tab") : tr("Pin Tab")), this, SLOT(pinTab()));
		menu.addSeparator();
		menu.addAction(tr("Detach Tab"), this, SLOT(detachTab()))->setEnabled(count() > 1);
		menu.addSeparator();

		if (isPinned)
		{
			QAction *closeAction = menu.addAction(QString());

			ActionsManager::setupLocalAction(closeAction, QLatin1String("CloseTab"), true);

			closeAction->setEnabled(false);
		}
		else
		{
			menu.addAction(ActionsManager::getAction(QLatin1String("CloseTab")));
		}

		menu.addAction(Utils::getIcon(QLatin1String("tab-close-other")), tr("Close Other Tabs"), this, SLOT(closeOther()))->setEnabled(amount > 0);
	}

	menu.exec(event->globalPos());

	m_clickedTab = -1;

	if (underMouse())
	{
		m_previewTimer = startTimer(250);
	}
}
Example #28
0
void GenericEditor::fadeIn()
{
	isFading = true;
	startTimer(10);
}
Example #29
0
void Simulator::start(){
	 if (!timerId)
            timerId = startTimer(1000 / 60.0);
}
Example #30
0
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    GlobalCache *globalCache = new GlobalCache();
    loginStatus = false;

    updateTimer = startTimer(100);

    QTimerEvent *e= new QTimerEvent(updateTimer);

    setWindowTitle("#precIsioN Billing Software 1.2");

    /* Setting height and width properties */
    QDesktopWidget *desktop = QApplication::desktop();
    int width = desktop->width();
    int height = desktop->height();
    GlobalCache::setScreenWidth(width);
    GlobalCache::setScreenHeight(height);
    resize(width/2, height/2);
    int sideWidth = 10; //width/48;
    int sideHeight = (height-50)/14;
    widgetWidth = width - 20; //sideWidth *46;
    widgetHeight = sideHeight * 14;

    /* Creating menu bar and status bar */
    menubar = new QMenuBar(this);
    setMenuBar(menubar);

    menuAdministrator = new QMenu(menubar);
    menuAdministrator->setTitle("Administrator");
    menubar->addMenu(menuAdministrator);

    QAction *homeAct = new QAction(("&Home"), this);
    homeAct->setShortcut(QKeySequence(tr("Ctrl+H")));
    menuAdministrator->addAction(homeAct);
    menuAdministrator->addSeparator();
    QAction *changePasswordAct = new QAction("Change Password", this);
    menuAdministrator->addAction(changePasswordAct);
    QAction *refreshAct = new QAction(("&Refresh"), this);
    refreshAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuAdministrator->addAction(refreshAct);
    QAction *fullScreenAct = new QAction(("&Full Screen"), this);
    fullScreenAct->setShortcut(Qt::Key_F11);
    menuAdministrator->addAction(fullScreenAct);
    QAction *restartAct = new QAction("Restart", this);
    restartAct->setShortcut(QKeySequence((tr("Shift+Ctrl+X"))));
    menuAdministrator->addAction(restartAct);
    QAction *quitAct = new QAction(("Quit Application"), this);
    quitAct->setShortcut(QKeySequence(tr("Ctrl+X")));
    menuAdministrator->addAction(quitAct);

    menuStock = new QMenu(menubar);
    menuStock->setTitle("Stock");
    menubar->addMenu(menuStock);

    QAction *manageStockAct = new QAction(("Manage Stock"), this);
    manageStockAct->setShortcut(QKeySequence(tr("Ctrl+M")));
    menuStock->addAction(manageStockAct);
    QAction *bulkStockUpdationAct = new QAction("Bulk Stock Updation", this);
    bulkStockUpdationAct->setShortcut(QKeySequence(tr("Ctrl+U")));
    menuStock->addAction(bulkStockUpdationAct);
    menuStock->addSeparator();
    QAction *stockPruchaseInvoiceAct = new QAction(("Stock Purchase Invoice"), this);
    menuStock->addAction(stockPruchaseInvoiceAct);
    QAction *oldStockPurchaseInvoiceAct = new QAction(("Old Stock Purchase Invoice"), this);
    menuStock->addAction(oldStockPurchaseInvoiceAct);
    menuStock->addSeparator();
    QAction *stockUpdationAct = new QAction(("Single Stock Updation"), this);
    menuStock->addAction(stockUpdationAct);
    menuStock->addSeparator();
    QAction *addNewStockAct = new QAction(("Add New Stock"), this);
    menuStock->addAction(addNewStockAct);
    QAction *deleteStockact = new QAction(("Remove Stock"), this);
    menuStock->addAction(deleteStockact);
    QAction *updateStockAct = new QAction(("Edit Stock Details"), this);
    menuStock->addAction(updateStockAct);
    menuStock->addSeparator();
    QAction *checkStockAct = new QAction("Check Stock", this);
    checkStockAct->setShortcut(QKeySequence("Ctrl+F"));
    menuStock->addAction(checkStockAct);

    menuInvoice = new QMenu(menubar);
    menuInvoice->setTitle("Invoice");
    menubar->addMenu(menuInvoice);

    QAction *invoiceAct = new QAction(("&New Invoice"), this);
    invoiceAct->setShortcut(QKeySequence(tr("Ctrl+N")));
    menuInvoice->addAction(invoiceAct);
    QAction *setInvoiceAct = new QAction(("Set Invoice No"), this);
    menuInvoice->addAction(setInvoiceAct);
    QAction *cancelInvoiceAct = new QAction(("Cancel Invoice"), this);
    menuInvoice->addAction(cancelInvoiceAct);
    QAction *oldInvoiceAct = new QAction(("Old Invoices"), this);
    menuInvoice->addAction(oldInvoiceAct);

    menuEstimate = new QMenu(menubar);
    menuEstimate->setTitle("Estimate");
    menubar->addMenu(menuEstimate);

    QAction *estimateAct = new QAction(("&New Estimate"), this);
    estimateAct->setShortcut(QKeySequence(tr("Ctrl+E")));
    menuEstimate->addAction(estimateAct);
    QAction *setEstimateAct = new QAction(("Set Estimate No"), this);
    menuEstimate->addAction(setEstimateAct);
    QAction *cancelEstimateAct = new QAction(("Cancel Estimate"), this);
    menuEstimate->addAction(cancelEstimateAct);
    QAction *oldEstimateAct = new QAction(("Old Estimates"), this);
    menuEstimate->addAction(oldEstimateAct);
    menuEstimate->addSeparator();
    QAction *itemEstimateAct = new QAction("Item Estimates", this);
    menuEstimate->addAction(itemEstimateAct);


    menuDealer = new QMenu(menubar);
    menuDealer->setTitle("Dealer");
//    menubar->addMenu(menuDealer);

    QAction *dealerHomeAct = new QAction(("&Dealer Home"), this);
    dealerHomeAct->setShortcut(QKeySequence(tr("Ctrl+D")));
    menuDealer->addAction(dealerHomeAct);
    QAction *salesDetailsAct = new QAction(("Sales De&tais"), this);
    salesDetailsAct->setShortcut(QKeySequence(tr("Ctrl+T")));
    menuDealer->addAction(salesDetailsAct);
    QAction *addNewDealerAct = new QAction(("Add New Dealer"), this);
    menuDealer->addAction(addNewDealerAct);
    QAction *deleteDealerAct = new QAction(("Delete Dealer"), this);
    menuDealer->addAction(deleteDealerAct);
    QAction *updateDealerAct = new QAction(("Edit Dealer Details"), this);
    menuDealer->addAction(updateDealerAct);

    menuAccounts = new QMenu(menubar);
    menuAccounts->setTitle("Accounts");
    menubar->addMenu(menuAccounts);

    QAction *accountsAct = new QAction(("Accounts"), this);
    accountsAct->setShortcut(QKeySequence(tr("Ctrl+A")));
    menuAccounts->addAction(accountsAct);

    menuReports = new QMenu(menubar);
    menuReports->setTitle("Reports");
    menubar->addMenu(menuReports);

    QAction *todaysItemSalesAct = new QAction(("Today's &Item Sales"), this);
    todaysItemSalesAct->setShortcut(QKeySequence(tr("Ctrl+I")));
    menuReports->addAction(todaysItemSalesAct);
    QAction *dailyReportAct = new QAction(("Daily Sales &Report"), this);
    dailyReportAct->setShortcut(QKeySequence(tr("Ctrl+R")));
    menuReports->addAction(dailyReportAct);
    QAction *itemSalesReportAct = new QAction("Selected Item Sales Report", this);
    menuReports->addAction(itemSalesReportAct);
    QAction *historyItemSalesAct = new QAction(("History Item Sales"), this);
    menuReports->addAction(historyItemSalesAct);
    menuReports->addSeparator();
    QAction *purchaseReportAct = new QAction("Purchase Report", this);
    menuReports->addAction(purchaseReportAct);
    QAction *purchaseItemsAct = new QAction("Purchased Item Report", this);
    menuReports->addAction(purchaseItemsAct);

    menuSettings = new QMenu(menubar);
    menuSettings->setTitle("Settings");
    menubar->addMenu(menuSettings);

    QAction *configurationAct = new QAction(("Configure Product"), this);
    menuSettings->addAction(configurationAct);
    QAction *deleteDataAct = new QAction("Clear Data", this);
    menuSettings->addAction(deleteDataAct);
    QAction *backupAct = new QAction(("Backup"), this);
    menuSettings->addAction(backupAct);

    menuHelp = new QMenu(menubar);
    menuHelp->setTitle("Help");
    menubar->addMenu(menuHelp);

    QAction *shortcutAct = new QAction(("Shorcuts Used"), this);
    menuHelp->addAction(shortcutAct);
    QAction *aboutAct = new QAction(("About"), this);
    menuHelp->addAction(aboutAct);

    adminHome = new AdminHomeWidget(widgetWidth, this);
    adminHome->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    manageStock = new ManageStockWidget(widgetWidth, this);
    manageStock->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseInvoice = new StockPurchaseInvoiceWidget(widgetWidth, this);
    purchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldPurchaseInvoice = new OldPurchaseInvoiceWidget(widgetWidth, this);
    oldPurchaseInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    invoice = new InvoiceWidget(widgetWidth, this);
    invoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    dailyReport = new DailySalesReportWidget(widgetWidth, this);
    dailyReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemSales = new TodaysItemSalesWidget(widgetWidth, this);
    itemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldInvoice = new OldInvoicesWidget(widgetWidth, this);
    oldInvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    allInvoices = new AllInvoices(widgetWidth, this);
    allInvoices->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    oldEstimate = new OldEstimates(widgetWidth, this);
    oldEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    itemEstimate = new ItemEstimateWidget(widgetWidth, this);
    itemEstimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    estimate = new EstimateWidget(widgetWidth, this);
    estimate->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    salesDetails = new SalesDetailsWidget(widgetWidth, this);
    salesDetails->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    accounts = new AccountsWidget(widgetWidth, this);
    accounts->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchaseReport = new PurchaseReportWidget(widgetWidth, this);
    purchaseReport->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    purchasedItems = new PurchasedItemWidget(widgetWidth, this);
    purchasedItems->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyDsr = new HistoryDSRWidget(widgetWidth, this);
    historyDsr->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyItemSales = new HistoryItemSalesWidget(widgetWidth, this);
    historyItemSales->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);
    historyinvoice = new HistoryInvoiceWidget(widgetWidth, this);
    historyinvoice->setGeometry(sideWidth, 50, widgetWidth, widgetHeight - 50);

    /* Main Window setup */

    connect( homeAct, SIGNAL(triggered()), this, SLOT(getAdminHome()));
    connect( todaysItemSalesAct, SIGNAL(triggered()), this, SLOT(getItemSales()));
    connect( dailyReportAct, SIGNAL(triggered()), this, SLOT(getDailySalesReport()));
    connect( itemSalesReportAct, SIGNAL(triggered()), this, SLOT(getItemSalesReport()));
    connect( bulkStockUpdationAct, SIGNAL(triggered()), this, SLOT(getBulkStockUpdationDialog()));
    connect( stockUpdationAct, SIGNAL(triggered()), this, SLOT(getStockUpdationDialog()));
    connect( addNewStockAct, SIGNAL(triggered()), this, SLOT(getAddNewStockDialog()));
    connect( deleteStockact, SIGNAL(triggered()), this, SLOT(getDeleteStockDialog()));
    connect( updateStockAct, SIGNAL(triggered()), this, SLOT(getUpdateStockDialog()));
    connect( checkStockAct, SIGNAL(triggered()), this, SLOT(getCheckStockDialog()));
    connect( changePasswordAct, SIGNAL(triggered()), this, SLOT(getChangePasswordDialog()));
    connect( refreshAct, SIGNAL(triggered()), this, SLOT(refresh()));
    connect( fullScreenAct, SIGNAL(triggered()), this, SLOT(getFullScreen()));
    connect( restartAct, SIGNAL(triggered()), this, SLOT(restart()));
    connect( quitAct, SIGNAL(triggered()), qApp, SLOT(quit()));
    connect( manageStockAct, SIGNAL(triggered()), this, SLOT(getManageStockWidget()));
    connect( stockPruchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getStockPurchaseInvoice()));
    connect( oldStockPurchaseInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldStockPurchaseInvoice()));
    connect( invoiceAct, SIGNAL(triggered()), this, SLOT(getInvoice()));
    connect( setInvoiceAct, SIGNAL(triggered()), this, SLOT(getSetInvoiceDialog()));
    connect( cancelInvoiceAct, SIGNAL(triggered()), this, SLOT(cancelInvoice()));
    connect( oldInvoiceAct, SIGNAL(triggered()), this, SLOT(getOldInvoice()));
    connect( estimateAct, SIGNAL(triggered()), this, SLOT(getEstimate()));
    connect( setEstimateAct, SIGNAL(triggered()), this, SLOT(getSetEstimateDialog()));
    connect( cancelEstimateAct, SIGNAL(triggered()), this, SLOT(cancelEstimate()));
    connect( oldEstimateAct, SIGNAL(triggered()), this, SLOT(getOldEstimates()));
    connect( itemEstimateAct, SIGNAL(triggered()), this, SLOT(getItemEstimate()));
    connect( salesDetailsAct, SIGNAL(triggered()), this, SLOT(getSalesDetails()));
    connect( accountsAct, SIGNAL(triggered()), this, SLOT(getAccountsWidget()));
    connect( purchaseReportAct, SIGNAL(triggered()), this, SLOT(getPurchaseReport()));
    connect( purchaseItemsAct, SIGNAL(triggered()), this, SLOT(getPurchasedItems()));
    connect( historyItemSalesAct, SIGNAL(triggered()), this, SLOT(getHistoryItemSales()));
    connect( configurationAct, SIGNAL(triggered()), this, SLOT(getConfiguration()));
    connect( deleteDataAct, SIGNAL(triggered()), this, SLOT(getDeleteDataAct()));
    connect( backupAct, SIGNAL(triggered()), this, SLOT(getBackup()));
    connect( shortcutAct, SIGNAL(triggered()), this, SLOT(shortcuts()));
    connect( aboutAct, SIGNAL(triggered()), this, SLOT(about()));
    connect( qApp, SIGNAL(lastWindowClosed()), qApp, SLOT(quit()));

    hideAllWidgets();
    showMinimized();
}