Exemple #1
0
void Progression::onRemoveLabel(QString name)
{
	qDebug() << "trying to remove label and progress bar for :" << name;
	for(int i = 0; i < vbl->count(); i++)
	{
		QLayoutItem* item = vbl->itemAt(i);
		QWidget* widget = item->widget();
		if (widget) {
			QLabel *label = qobject_cast<QLabel *>(widget);

			if(label and label->objectName() == name )
			{
				label->hide();
				vbl->removeItem(item);
				qDebug() << "Remove Label";
				i--;
			}

			QProgressBar * pb = qobject_cast<QProgressBar *>(widget);
			if(pb and pb->objectName() == name)
			{
				pb->hide();
				vbl->removeItem(item);
				qDebug() << "Remove Progbar";
				i--;
			}

		}
	}
	this->adjustSize();
}
Exemple #2
0
void Progression::incrementProgressBar(QString file, QString currentFile){
	//qDebug() << "The value was" << ProgressBars[file]->value();
	if(ProgressBars[file]->value() < ProgressBars[file]->maximum())
		ProgressBars[file]->setValue(ProgressBars[file]->value() + 1);
	//qDebug() << "The value is" << ProgressBars[file]->value();

	if(currentFile != "")
	{
		for(int i = 0; i < vbl->count(); i++)
		{
			QLayoutItem* item = vbl->itemAt(i);
			QWidget* widget = item->widget();
			if (widget) {
				QLabel *label = qobject_cast<QLabel *>(widget);
				if(label)
				{
					if(label->objectName() == file)
					{
						label->setText("Copy " + currentFile.split("/").last() + " to " + currentFile);
					}
				}
			}
		}
	}
	this->adjustSize();
}
void FilmPreviewer::setFilm(FilmListItem *value)
{
  if (!value) {
    static FilmListItem hideitem(0);
    value = & hideitem;
  }
  ffilm = value;
  QList<QLabel *> list = findChildren<QLabel *>();
  for(QList<QLabel*>::Iterator labIter = list.begin(); labIter!=list.end(); ++labIter) {
    QLabel *lab = *labIter;
    static QRegExp rxStaticText = QRegExp("^statictext[\\d]+$");
    QString name = lab->objectName();
    if (rxStaticText.indexIn( name ) >=0 ) continue;
    int baseProp = FilmListItem::jsonNames().indexOf(name);
    switch (baseProp) {
    case FilmListItem::JsonNPoster:
      if (ffilm->poster().isNull()) lab->setText(FilmListItem::noposter());
      else lab->setPixmap(ffilm->poster());
      break;
    case FilmListItem::JsonNTitle:
      lab->setText(ffilm->title);
      break;
    case FilmListItem::JsonNGenres:
      lab->setText("\""+ffilm->genres.join("\", \"")+"\"");
      break;
    case FilmListItem::JsonNOverview:
      lab->setText(ffilm->overview);
      break;
    default:
      lab->setText(ffilm->property.value(name).toString());
    }
  }
  ui->player_content->playMedia(ffilm->video);
}
Exemple #4
0
void CompareDialog::dropEvent(QDropEvent *event)
{
  QLabel * child = qobject_cast<QLabel*>(childAt(event->pos()));
  if (!child) return;
  if (child->objectName().contains("label_1")) {   
    model1Valid = handleDroppedModel(event->mimeData(), model1, ui->label_1);
  }
  else if (child->objectName().contains("label_2")) {
    model2Valid = handleDroppedModel(event->mimeData(), model2, ui->label_2);
  }
  event->accept();
  if (model1Valid && model2Valid) {
    multimodelprinter.setModel(0, model1);
    multimodelprinter.setModel(1, model2);
    ui->textEdit->setHtml(multimodelprinter.print(ui->textEdit->document()));
  }
}
void MainWindow::mousePressEvent(QMouseEvent *event){

    // imprimindo mensagem de debug
    qDebug()<<"MainWindow::mousePressEvent(QMouseEvent *event)";

    QLabel *label = static_cast<QLabel*>(childAt(event->pos()));
    if (!label || label->objectName()=="centralWidget"
            || label->objectName()==""
            || label->objectName()=="diagrama"){
        return;
    }

    // imprimindo mensagem para debug
    qDebug()<<label->objectName();

    QPixmap pixmap = *label->pixmap();
    QByteArray itemData;
    QDataStream dataStream(&itemData, QIODevice::WriteOnly);
    dataStream << pixmap << QPoint(event->pos() - label->pos());
    QMimeData *mimeData = new QMimeData();
    mimeData->setData("application/x-dnditemdata", itemData);
    QDrag *drag = new QDrag(this);
    drag->setMimeData(mimeData);
    drag->setPixmap(pixmap);
    drag->setHotSpot(event->pos() - label->pos());
    QPoint pointAtual = event->pos();

    if(pointAtual.x() > ui->diagrama->geometry().x()
            && pointAtual.y() > ui->diagrama->geometry().y()
            && pointAtual.x() < ui->diagrama->width()) {
        label->close();
    }

    if (drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction) {
        label->show();
        label->setPixmap(pixmap);
    }
}
Exemple #6
0
void Combat::initialLayout()
{
    vertical_layout = new QGridLayout;
    playerCount = detectWhichPlayer();
    for(int i = 0; i < playerCount.size(); i++)
    {
        switch (playerCount.at(i)) {
        case 1:
            vertical_layout->addWidget(createPlayerBox(PlayerOneThing,1),i,0);
            break;
        case 2:
            vertical_layout->addWidget(createPlayerBox(PlayerTwoThing,2),i,0);
            break;
        case 3:
            vertical_layout->addWidget(createPlayerBox(PlayerThreeThing,3),i,0);
            break;
        case 4:
            vertical_layout->addWidget(createPlayerBox(PlayerFourThing,4),i,0);
            break;
        default:
            break;
        }
        //initial the hitpoint for each player
        QLabel *hitPoint = new QLabel;
        hitPoint->setObjectName("0");
        QString temp ="Player " + QString::number(playerCount.at(i)) + " HitPoint : " + hitPoint->objectName();
        hitPoint->setText(temp);
        playerHitPoint.push_back(hitPoint);
        vertical_layout->addWidget(hitPoint,i,1);
        //initial the building if owerner have one
        if(ownPlayer == playerCount.at(i))
        {
            if(HexBuilding)
            {

                buildingButton = new QPushButton;
                buildingButton->setObjectName(QString::number(getHexBuilding()->getID()));
                QString temp = "border-image: url(" + getHexBuilding()->getUrl();
                buildingButton->setStyleSheet(temp + ")");
                buildingButton->setFixedSize(80,80);
                connect(buildingButton,SIGNAL(clicked()),this,SLOT(buildingButtonClickSlot()));
                vertical_layout->addWidget(buildingButton,i,2);
                //initial the building value
                buildingValue = getHexBuilding()->getIncome();
            }
        }
    }
    //roll the dice first
    rollDice = true;
    //initial the dice widget
    dice = new DiceWidget(this);
    vertical_layout->addWidget(dice,0,3);
    dice->setFixedSize(100,100);
    connect(dice, SIGNAL(updateDiceValueSignal(int)), this, SLOT(updateDiceValueSlot(int)));
    dice->show();
    //set the player turn label
    playerTurnLabel = new QLabel;
    playerTurnLabel->setStyleSheet("background-color: white;");
    setPlayerTurn(playerCount.at(0));
    vertical_layout->addWidget(playerTurnLabel,0,4);
    //initial the button
    button = new QPushButton;
    button2 = new QPushButton;
    button->setText("Continue");
    button2->setText("Retreats");
    vertical_layout->addWidget(button,1,3);
    vertical_layout->addWidget(button2,1,4);
    connect(button,SIGNAL(clicked()),this,SLOT(continueButtonSlot()));
    connect(button2,SIGNAL(clicked()),this,SLOT(retreatButtonSlot()));
    button->hide();
    button2->hide();
    //add the globalwidget
    globalWidget = new QWidget(this);
    globalWidget->setLayout(vertical_layout);
}