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); }*/ } }
void NumberChoiceLive::chooseNumber(int number) { //numbers[number]->setText(QString(QChar(prizes[number]))); QPixmap *prizeImage; switch(prizes[number]) { case 'B': if (isVisible()) QSound::play("media/sounds/PrizeBronze.wav"); prizeImage = prizeBronze; break; case 'S': if (isVisible()) QSound::play("media/sounds/PrizeSilver.wav"); prizeImage = prizeSilver; break; case 'G': if (isVisible()) QSound::play("media/sounds/PrizeGold.wav"); prizeImage = prizeGold; break; } QPixmap smallerPrize = prizeImage->scaled(numbers[number]->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); QLabel *medal = new QLabel(numbers[number]->parentWidget()); medal->setAttribute(Qt::WA_DeleteOnClose); medal->setPixmap(smallerPrize); medal->resize(smallerPrize.size()); // Using . rather than -> with smallerPrize because smallerPrize isn't a pointer medal->move(numbers[number]->geometry().center() - medal->geometry().center()); medal->show(); connect(this, SIGNAL(resetAll(bool)), medal, SLOT(close())); }
void ProcessingPipeline::upClicked( int id ) { if( !isVeryTopElement( id ) ) { int actualID = findId( currentProcessingStepOrder, id ); int oneButtonUpID = actualID - 1; std::swap( currentProcessingStepOrder[ actualID ], currentProcessingStepOrder[ oneButtonUpID ] ); actualID = getActualID( actualID ); oneButtonUpID = getActualID( oneButtonUpID ); // swap the down button positions QPushButton * clickedButtonDown = processingPipelineConfigWidget->getDownButtonById( actualID ); QRect tempPosDown = clickedButtonDown->geometry(); QPushButton * toSwapWithButtonDown = processingPipelineConfigWidget->getDownButtonById( oneButtonUpID ); clickedButtonDown->setGeometry( toSwapWithButtonDown->geometry() ); toSwapWithButtonDown->setGeometry( tempPosDown ); // swap the up button position QPushButton * clickedButtonUp = processingPipelineConfigWidget->getUpButtonByID( actualID ); QRect tempPosUp = clickedButtonUp->geometry(); QPushButton * toSwapWithButtonUp = processingPipelineConfigWidget->getUpButtonByID( oneButtonUpID ); clickedButtonUp->setGeometry( toSwapWithButtonUp->geometry() ); toSwapWithButtonUp->setGeometry( tempPosUp ); // swap labels QLabel * clickedLabel = processingPipelineConfigWidget->getLabelByID( actualID ); QRect tempPosLabel = clickedLabel->geometry(); QLabel * toSwapWithLabel = processingPipelineConfigWidget->getLabelByID( oneButtonUpID ); clickedLabel->setGeometry( toSwapWithLabel->geometry() ); toSwapWithLabel->setGeometry( tempPosLabel ); // config button QPushButton * clickedButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( actualID ); QRect tempPosConfig = clickedButtonConfig->geometry(); QPushButton * toSwapWithButtonConfig = processingPipelineConfigWidget->getConfigButtonByID( oneButtonUpID ); clickedButtonConfig->setGeometry( toSwapWithButtonConfig->geometry() ); toSwapWithButtonConfig->setGeometry( tempPosConfig ); // checkbox QCheckBox * clickedCheckBox = processingPipelineConfigWidget->getCheckBoxByID( actualID ); QRect tempPosCheckbox = clickedCheckBox->geometry(); QCheckBox * toSwapWithCheckbox = processingPipelineConfigWidget->getCheckBoxByID( oneButtonUpID ); clickedCheckBox->setGeometry( toSwapWithCheckbox->geometry() ); toSwapWithCheckbox->setGeometry( tempPosCheckbox ); } }
bool KexiReportFactory::startEditing(const QCString &c, QWidget *w, KFormDesigner::Container *container) { m_container = container; if(c == "Label") { QLabel *label = static_cast<QLabel*>(w); if(label->textFormat() == RichText) { m_widget = w; editText(); } else createEditor(c, label->text(), label, container, label->geometry(), label->alignment()); return true; } return false; }
/*! \internal */ QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType) { QLabel *label = qobject_cast<QLabel *>(widget()); if (!label) return QRect(); const QPixmap *pixmap = label->pixmap(); if (!pixmap) return QRect(); switch (coordType) { case QAccessible2::RelativeToScreen: return QRect(label->mapToGlobal(label->pos()), label->size()); case QAccessible2::RelativeToParent: return label->geometry(); } return QRect(); }
void tst_QFormLayout::wrapping() { QWidget *w = new QWidget; QFormLayout *fl = new QFormLayout(w); fl->setRowWrapPolicy(QFormLayout::WrapLongRows); QLineEdit *le = new QLineEdit; QLabel *lbl = new QLabel("A long label"); le->setMinimumWidth(200); fl->addRow(lbl, le); w->setFixedWidth(240); w->show(); QCOMPARE(le->geometry().y() > lbl->geometry().y(), true); //TODO: additional tests covering different wrapping cases delete w; }
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(); }
bool StdWidgetFactory::startEditing(const QCString &classname, QWidget *w, KFormDesigner::Container *container) { setWidget(w, container); // m_container = container; if(classname == "KLineEdit") { KLineEdit *lineedit = static_cast<KLineEdit*>(w); createEditor(classname, lineedit->text(), lineedit, container, lineedit->geometry(), lineedit->alignment(), true); return true; } else if(classname == "QLabel") { QLabel *label = static_cast<QLabel*>(w); if(label->textFormat() == RichText) { //m_widget = w; // setWidget(w, container); editText(); } else createEditor(classname, label->text(), label, container, label->geometry(), label->alignment()); return true; } else if(classname == "KPushButton") { KPushButton *push = static_cast<KPushButton*>(w); QRect r = w->style().subRect(QStyle::SR_PushButtonContents, w); QRect editorRect = QRect(push->x() + r.x(), push->y() + r.y(), r.width(), r.height()); //r.setX(r.x() + 5); //r.setY(r.y() + 5); //r.setWidth(r.width()-10); //r.setHeight(r.height() - 10); createEditor(classname, push->text(), push, container, editorRect, Qt::AlignCenter, false, false, Qt::PaletteButton); return true; } else if(classname == "QRadioButton") { QRadioButton *radio = static_cast<QRadioButton*>(w); QRect r = w->style().subRect(QStyle::SR_RadioButtonContents, w); QRect editorRect = QRect(radio->x() + r.x(), radio->y() + r.y(), r.width(), r.height()); createEditor(classname, radio->text(), radio, container, editorRect, Qt::AlignAuto); return true; } else if(classname == "QCheckBox") { QCheckBox *check = static_cast<QCheckBox*>(w); //QRect r(check->geometry()); //r.setX(r.x() + 20); QRect r = w->style().subRect(QStyle::SR_CheckBoxContents, w); QRect editorRect = QRect(check->x() + r.x(), check->y() + r.y(), r.width(), r.height()); createEditor(classname, check->text(), check, container, editorRect, Qt::AlignAuto); return true; } else if((classname == "KComboBox") || (classname == "KListBox")) { QStringList list; if(classname == "KListBox") { KListBox *listbox = (KListBox*)w; for(uint i=0; i < listbox->count(); i++) list.append(listbox->text(i)); } else if(classname == "KComboBox") { KComboBox *combo = (KComboBox*)w; for(int i=0; i < combo->count(); i++) list.append(combo->text(i)); } if(editList(w, list)) { if(classname == "KListBox") { ((KListBox*)w)->clear(); ((KListBox*)w)->insertStringList(list); } else if(classname == "KComboBox") { ((KComboBox*)w)->clear(); ((KComboBox*)w)->insertStringList(list); } } return true; } else if((classname == "KTextEdit") || (classname == "KDateTimeWidget") || (classname == "KTimeWidget") || (classname == "KDateWidget") || (classname == "KIntSpinBox")) { disableFilter(w, container); return true; } return false; }
ISOSelectView::ISOSelectView(QWidget *parent) : QFrame(parent) { setObjectName("ISOSelectView"); QVBoxLayout *mainLayout = new QVBoxLayout(this); mainLayout->setContentsMargins(0, 9, 0, 0); QLabel *m_title = new QLabel(tr("Select an ISO image file")); m_title->setFixedHeight(38); m_title->setStyleSheet("font-size: 26px;"); QLabel *isoIcon = new QLabel(this); isoIcon->setObjectName("ISOIcon"); isoIcon->setFixedSize(96, 96); isoIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/media-optical-96px.svg", this)); QLabel *growIcon = new QLabel(this); growIcon->setObjectName("GrowIcon"); growIcon->setPixmap(WidgetUtil::getDpiPixmap(":/theme/light/image/glow.svg", this)); growIcon->setFixedSize(220, 220); growIcon->hide(); DropFrame *isoPanel = new DropFrame; isoPanel->setObjectName("IosPanel"); isoPanel->setFixedSize(412, 322); QVBoxLayout *isoPanelLayout = new QVBoxLayout(isoPanel); isoPanelLayout->setMargin(0); m_fileLabel = new QLabel(tr("Drag an ISO image file and drop it here")); m_fileLabel->setObjectName("IsoFileName"); // m_fileLabel->setFixedHeight(18); m_hits = new QLabel(tr("OR")); m_hits->setObjectName("IsoHits"); m_hits->setFixedHeight(18); QLabel *spliter = new QLabel; spliter->setObjectName("IsoSpliter"); spliter->setFixedSize(230, 1); m_fileSelect = new QLabel(); m_fileSelect->setObjectName("IsoFileSelect"); // m_fileSelect->setFixedHeight(15); m_fileSelect->setOpenExternalLinks(false); QString selectText = tr("Select an ISO image file"); QString linkText = QString(s_linkTemplate).arg(selectText).arg(selectText); m_fileSelect->setText(linkText); isoPanelLayout->addSpacing(62); isoPanelLayout->addWidget(isoIcon, 0, Qt::AlignCenter); isoPanelLayout->addSpacing(5); isoPanelLayout->addWidget(m_fileLabel, 0, Qt::AlignCenter); isoPanelLayout->addSpacing(4); isoPanelLayout->addWidget(m_hits, 0, Qt::AlignCenter); isoPanelLayout->addSpacing(7); isoPanelLayout->addWidget(spliter, 0, Qt::AlignCenter); isoPanelLayout->addSpacing(12); isoPanelLayout->addWidget(m_fileSelect, 0, Qt::AlignCenter); isoPanelLayout->addStretch(); m_nextSetp = new SuggestButton(); m_nextSetp->setObjectName("NextStepButton"); m_nextSetp->setText(tr("Next")); m_nextSetp->setDisabled(true); mainLayout->addWidget(m_title, 0, Qt::AlignCenter); mainLayout->addSpacing(24); mainLayout->addWidget(isoPanel, 0, Qt::AlignCenter); mainLayout->addStretch(); mainLayout->addWidget(m_nextSetp, 0, Qt::AlignCenter); this->setStyleSheet(WidgetUtil::getQss(":/theme/light/ISOSelectView.theme")); #ifdef Q_OS_WIN m_fileLabel->hide(); spliter->hide(); m_hits->hide(); #endif connect(isoPanel, &DropFrame::fileAboutAccept, this, [ = ]() { growIcon->show(); auto center = isoIcon->geometry().center(); growIcon->move(center); auto topleft = growIcon->mapFromGlobal(isoIcon->mapToGlobal(center)); auto offset = 220 - 96; topleft.setX(topleft.x() - offset / 2); topleft.setY(topleft.y() - offset / 2); growIcon->move(topleft); isoPanel->setProperty("active", true); this->style()->unpolish(isoPanel); this->style()->polish(isoPanel); }); connect(isoPanel, &DropFrame::fileCancel, this, [ = ]() { growIcon->hide(); isoPanel->setProperty("active", false); this->style()->unpolish(isoPanel); this->style()->polish(isoPanel); }); connect(m_fileSelect, &QLabel::linkActivated, this, [ = ](const QString & /*link*/) { QFileDialog fileDlg(this); fileDlg.setViewMode(QFileDialog::Detail); fileDlg.setFileMode(QFileDialog::ExistingFile); fileDlg.setDirectory(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first()); fileDlg.setNameFilter("ISO (*.iso)"); fileDlg.selectNameFilter("ISO (*.iso)"); if (QFileDialog::Accepted == fileDlg.exec()) { QString text = fileDlg.selectedFiles().first(); onFileSelected(text); } }); connect(m_nextSetp, &SuggestButton::clicked, this, &ISOSelectView::isoFileSelected); connect(isoPanel, &DropFrame::fileDrop, this, &ISOSelectView::onFileSelected); }