Esempio n. 1
0
// +-----------------------------------------------------------
void gc::Questionnaire::setQuestionValue(const uint iIndex, QVariant oValue)
{
	Q_ASSERT(static_cast<uint>(m_vQuestionTypes.size()) >= iIndex);
	QuestionType eType = m_vQuestionTypes[iIndex];

	Q_ASSERT(static_cast<uint>(m_vQuestionFields.size()) >= iIndex);
	bool bUndefined = false;
	switch(eType)
	{
		case Integer:
			static_cast<QSpinBox*>(m_vQuestionFields[iIndex])->setValue(oValue.toInt());
			if(oValue.toInt() <= 0)
				bUndefined = true;
			break;

		case String:
			static_cast<QLineEdit*>(m_vQuestionFields[iIndex])->setText(oValue.toString());
			if(oValue.toString().length() == 0)
				bUndefined = true;
			break;

		case Likert:
			static_cast<LikertScale*>(m_vQuestionFields[iIndex])->setSelected(oValue.toInt());
			if(oValue.toInt() == -1)
				bUndefined = true;
			break;
	}

	QLabel *pLabel = m_vQuestionLabels[iIndex];
	pLabel->setProperty("undefined", bUndefined);
	pLabel->style()->unpolish(pLabel);
	pLabel->style()->polish(pLabel);

	m_pScrollArea->ensureVisible(pLabel->x(), pLabel->y());
}
Esempio n. 2
0
void MainWindow::furTimeHit()
{
    Obstacle& o = Obstacle::instance();

    for (unsigned int i = 0 ; i < furBalls.size(); i++)
    {
        QLabel * ball = furBalls[i];
        ball->move(ball->x() + 2 , ball->y());
        /*if (enemyExists == false)
        {

        }
        else if (enemyExists)
        {*/
            for (unsigned int j = 0; j < o.spawnedObstacles.size(); j++)
            {
                QLabel * badGuy = new QLabel;
                badGuy = o.spawnedObstacles[i];
                if (/*enemyExists &&*/ ball->geometry().intersects(badGuy->geometry()))
                {
                    //delete ball;
                    delete badGuy;
                    o.spawnedObstacles.erase(o.spawnedObstacles.cbegin());
                    furBalls.erase(furBalls.cbegin());
                    //ball = new QLabel(this);
                    badGuy = new QLabel(this);
                    delete ball;
                    ball = new QLabel(this);
                }
                else if (/*enemyExists && */badGuy->x() < -75)
                {
                    delete badGuy;
                    o.spawnedObstacles.erase(o.spawnedObstacles.cbegin());
                    badGuy = new QLabel(this);
                }
                else if (ball->x() > this->width())
                {
                    delete ball;
                    furBalls.erase(furBalls.cbegin());
                    ball = new QLabel(this);
                }
            }
       // }


        /*else if (ball->geometry().intersects(dog->geometry()))
        {
            delete dog;
            //dog->deleteLater();
            dog = new QLabel(this);

        }*/
    }
}
Esempio n. 3
0
void MainWindow::obstacleTimerHit()
{
    Obstacle& o = Obstacle::instance();

    for (unsigned int i = 0; i < o.spawnedObstacles.size(); i++)
    {
        QLabel * obst = new QLabel;
        obst = o.spawnedObstacles[i];
        obst->move(obst->x() - 1, obst->y());
    }

}
Esempio n. 4
0
void Progression::addCopy(QString src, QString){
	QLabel * label = new QLabel(src, this);
	label->setObjectName(src);
	label->setMaximumSize(780, 30);
	label->setGeometry(label->x(), label->y(), 780, label->height());
	QProgressBar * prog = new QProgressBar(this);
	prog->setObjectName(src);
	prog->setMaximum(QFile(src).size());
	vbl->addWidget(label);
	vbl->addWidget(prog);
	ProgressBars[label->text()] = prog;
	qDebug() << label->text();
	this->adjustSize();
}
Esempio n. 5
0
void HudScheduling::refresh()
{
	int highestPriority = findHighestPriority();
	int lowestCycles = findLowestCycles();
	int highestCycles = findHighestCycles();

	// Update progressbar
	const int kPrecition = 500;
	float timeUntilScheduling = SETTINGS->timeUntilScheduling;
	if(timeUntilScheduling < 0.0f)
		timeUntilScheduling = 0.0f;
	float schedulerTime = SETTINGS->schedulerTime;

	float schedulingRatio = timeUntilScheduling /schedulerTime;
	int test = timeUntilScheduling /schedulerTime * kPrecition;
	int schedulingProgressbarRatio = kPrecition - test;
	if(progressbar->value() != schedulingProgressbarRatio)
	{
		progressbar->setValue(schedulingProgressbarRatio);
		progressbar->update();

		// Turn bar red if at scheduling
		if(schedulingProgressbarRatio == kPrecition)
		{
			if(!isScheduling)
			{
				isScheduling = true;
				progressbar->setStyleSheet("QProgressBar::chunk{background-color: rgba(255, 0, 0, 75);}");
			}
		}
		else if(isScheduling)
		{
			isScheduling = false;
			progressbar->setStyleSheet("");
		}
	}


	// Put each item (player) into the correct place relative 
	// to each other based on their priority

	int labelSize = subWindow->height();
	int areaWidth = subWindow->width() - itemWidth;
	float sectionSize = 0; 
	if(highestPriority > 0)
		sectionSize = areaWidth/highestPriority;


	// Determine size and location for each label
	for(int i=0; i<items.size(); i++)
	{
		HudScheduling_Item* item = &items[i];

		int priority = item->ptr_player->priority;
		int cycles = item->ptr_player->cycles;


		// Find our relative index and number of neighbours
		CountAndIndex countAndIndex = findRelativeIndex(priority, i);
		int numNeighbours = countAndIndex.count;
		int relativeIndex = countAndIndex.index;


		// Compute size
		float cycleRatio = 1.0f;
		int deltaCycles = highestCycles - lowestCycles;
		if(deltaCycles > 0)
			cycleRatio = ((float)(cycles - lowestCycles)) / deltaCycles;
		const float kCycleRatioInfluence = 0.4f;
		int newItemHeight = itemHeight * (1.0f - kCycleRatioInfluence) + itemHeight * kCycleRatioInfluence * cycleRatio;
			
		if(item->label->height() != newItemHeight)
			item->label->resize(itemWidth, newItemHeight);
		

		// Compute location
		int index = item->ptr_player->priority;
		if(index < 0)
			index = 0;

		// Make sure all indicators fits by 
		// flipping them if they reach the left
		// edge (reaches max priority)
		if(priority > 0 && priority == highestPriority)
			relativeIndex = -relativeIndex;

		float crowdOffset = relativeIndex * itemWidth;
		int offset = (int)(sectionSize * index + crowdOffset);
		Float2 target;
		target.x = subWindow->x() + offset;
		target.y = subWindow->y() + (itemHeight - newItemHeight);
		item->targetPosition = target;
	}

	// Update labels so they can
	// interpolate to the correct
	// position
	for(int i=0; i<items.size(); i++)
	{
		HudScheduling_Item* item = &items[i];
		item->update();
	}

	// Update advantage label
	QLabel* ownerLabel = items[ownerIndex].label;
	if(advantageLabel->x() !=  ownerLabel->x() || advantageLabel->y() !=  ownerLabel->y() + ownerLabel->height())
		advantageLabel->move(ownerLabel->x(), ownerLabel->y() + ownerLabel->height());
}
Esempio n. 6
0
void FCenterWindow::cloudAntimation(animation_Direction direction)
{
    QLabel* circle = new QLabel(stackWidget->currentWidget());
    QLabel* line = new QLabel(this);
    line->setObjectName(QString("AntimationLine"));
    line->resize(0, 2);
    line->show();
    #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
        circle->setPixmap(QPixmap::grabWidget(stackWidget->widget(preindex), stackWidget->widget(preindex)->geometry()));
    #else
        circle->setPixmap(stackWidget->widget(preindex)->grab());
    #endif

//    circle->setScaledContents(true);
    circle->show();
    circle->resize(stackWidget->currentWidget()->size());
    QPropertyAnimation *animation = new QPropertyAnimation(circle, "geometry");

    animation->setDuration(500);
    animation->setStartValue(circle->geometry());

//    QPropertyAnimation* animation_line = new QPropertyAnimation(line, "size");
//    animation_line->setDuration(500);
//    animation_line->setEasingCurve(QEasingCurve::OutQuart);

    switch (direction) {
    case animationTop:
        animation->setEndValue(QRect(circle->x(), circle->y() - 10, circle->width(), 0));
        break;
    case animationTopRight:
        animation->setEndValue(QRect(circle->width(), 0, 0, 0));
        break;
    case animationRight:
        line->move(0, stackWidget->y() - 2);
        animation->setEndValue(QRect(circle->width() + 3, 0, 0, circle->height()));
//        animation_line->setStartValue(QSize(0, 2));
//        animation_line->setEndValue(QSize(stackWidget->width(), 2));
        break;
    case animationBottomRight:
        animation->setEndValue(QRect(circle->width(), circle->height(), 0, 0));
        break;
    case animationBottom:
        animation->setEndValue(QRect(0, circle->height() + 10, circle->width(), 0));
        break;
    case animationBottomLeft:
        animation->setEndValue(QRect(0, circle->height(), 0, 0));
        break;
    case animationLeft:
        animation->setEndValue(QRect(-3, 0, 0, circle->height()));
        line->move(stackWidget->x(), stackWidget->y() - 2);
//        animation_line->setStartValue(QSize(0, 2));
//        animation_line->setEndValue(QSize(stackWidget->width(), 2));
        break;
    case animationTopLeft:
        animation->setEndValue(QRect(0, 0, 0, 0));
        break;
    case animationCenter:
        animation->setEndValue(QRect(circle->width()/2, circle->height()/2, 0, 0));
        break;
    default:
        break;
    }
    animation->setEasingCurve(QEasingCurve::OutQuart);

    QPropertyAnimation* animation_opacity = new QPropertyAnimation(circle, "windowOpacity");
    animation_opacity->setDuration(500);
    animation_opacity->setStartValue(1);
    animation_opacity->setEndValue(0);
    animation_opacity->setEasingCurve(QEasingCurve::OutQuart);

    QParallelAnimationGroup *group = new QParallelAnimationGroup;

    connect(group,SIGNAL(finished()), circle, SLOT(hide()));
    connect(group,SIGNAL(finished()), circle, SLOT(deleteLater()));
    connect(group,SIGNAL(finished()), line, SLOT(deleteLater()));
    connect(group,SIGNAL(finished()), group, SLOT(deleteLater()));
    connect(group,SIGNAL(finished()), animation, SLOT(deleteLater()));
    connect(group,SIGNAL(finished()), animation_opacity, SLOT(deleteLater()));
//    connect(group,SIGNAL(finished()), animation_line, SLOT(deleteLater()));
    group->addAnimation(animation);
    group->addAnimation(animation_opacity);
//    group->addAnimation(animation_line);
    group->start();
}