本文整理汇总了C++中QPropertyAnimation::setEndValue方法的典型用法代码示例。如果您正苦于以下问题:C++ QPropertyAnimation::setEndValue方法的具体用法?C++ QPropertyAnimation::setEndValue怎么用?C++ QPropertyAnimation::setEndValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPropertyAnimation
的用法示例。
在下文中一共展示了QPropertyAnimation::setEndValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QMainWindow
//.........这里部分代码省略.........
connect(config_dialog, SIGNAL(bg_changed()), this, SLOT(changeBackground()));
connect(config_dialog, SIGNAL(tableBg_changed()), this, SLOT(changeBackground()));
connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
connect(ui->actionAcknowledgement_2, SIGNAL(triggered()), this, SLOT(on_actionAcknowledgement_triggered()));
StartScene *start_scene = new StartScene(this);
QList<QAction *> actions;
actions << ui->actionStart_Game
<< ui->actionStart_Server
<< ui->actionPC_Console_Start
<< ui->actionReplay
<< ui->actionConfigure
<< ui->actionGeneral_Overview
<< ui->actionCard_Overview
<< ui->actionAbout;
foreach(QAction *action, actions)
start_scene->addButton(action);
#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
ui->menuSumMenu->setAttribute(Qt::WA_TranslucentBackground);
ui->menuGame->setAttribute(Qt::WA_TranslucentBackground);
ui->menuView->setAttribute(Qt::WA_TranslucentBackground);
ui->menuOptions->setAttribute(Qt::WA_TranslucentBackground);
ui->menuDIY->setAttribute(Qt::WA_TranslucentBackground);
ui->menuCheat->setAttribute(Qt::WA_TranslucentBackground);
ui->menuHelp->setAttribute(Qt::WA_TranslucentBackground);
#endif
view = new FitView(scene);
setCentralWidget(view);
restoreFromConfig();
roundCorners();
BackLoader::preload();
gotoScene(start_scene);
addAction(ui->actionFullscreen);
#if defined(Q_OS_WIN) || defined(Q_OS_ANDROID)
menu = new QPushButton(this);
menu->setMenu(ui->menuSumMenu);
menu->setProperty("control", true);
StyleHelper::getInstance()->setIcon(menu, QChar(0xf0c9), 15);
menu->setToolTip(tr("<font color=%1>Config</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
#endif
#if defined(Q_OS_WIN)
minButton = new QPushButton(this);
minButton->setProperty("control", true);
maxButton = new QPushButton(this);
maxButton->setProperty("bold", true);
maxButton->setProperty("control", true);
normalButton = new QPushButton(this);
normalButton->setProperty("bold", true);
normalButton->setProperty("control", true);
closeButton= new QPushButton(this);
closeButton->setObjectName("closeButton");
closeButton->setProperty("control", true);
StyleHelper::getInstance()->setIcon(minButton, QChar(0xf068), 15);
StyleHelper::getInstance()->setIcon(maxButton, QChar(0xf106), 15);
StyleHelper::getInstance()->setIcon(normalButton, QChar(0xf107), 15);
StyleHelper::getInstance()->setIcon(closeButton, QChar(0xf00d), 15);
minButton->setToolTip(tr("<font color=%1>Minimize</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
connect(minButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
maxButton->setToolTip(tr("<font color=%1>Maximize</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
connect(maxButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
normalButton->setToolTip(tr("<font color=%1>Restore downward</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
connect(normalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
closeButton->setToolTip(tr("<font color=%1>Close</font>").arg(Config.SkillDescriptionInToolTipColor.name()));
connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
menuBar()->hide();
#elif defined(Q_OS_ANDROID)
ui->menuSumMenu->removeAction(ui->menuView->menuAction());
#endif
repaintButtons();
#ifndef Q_OS_ANDROID
QPropertyAnimation *animation = new QPropertyAnimation(this, "windowOpacity");
animation->setDuration(1000);
animation->setStartValue(0);
animation->setEndValue(1);
animation->setEasingCurve(QEasingCurve::OutCurve);
animation->start(QAbstractAnimation::DeleteWhenStopped);
#endif
start_scene->showOrganization();
systray = NULL;
}
示例2: StyledButtonItem
AbstractConfig::AbstractConfig(AbstractContent * content, AbstractConfig_PARENT * parent)
: AbstractConfig_TYPE(parent)
, m_content(content)
, m_commonUi(new Ui::AbstractConfig())
#if !defined(MOBILE_UI)
, m_closeButton(0)
, m_okButton(0)
#endif
, m_frame(FrameFactory::defaultPanelFrame())
{
#if !defined(MOBILE_UI)
// close button
m_closeButton = new StyledButtonItem(tr(" x "), font(), this);//this, ":/data/button-close.png", ":/data/button-close-hovered.png", ":/data/button-close-pressed.png");
connect(m_closeButton, SIGNAL(clicked()), this, SIGNAL(requestClose()));
// WIDGET setup (populate contents and set base palette (only) to transparent)
QWidget * widget = new QWidget();
m_commonUi->setupUi(widget);
QPalette pal;
QColor oldColor = pal.window().color();
pal.setBrush(QPalette::Window, Qt::transparent);
widget->setPalette(pal);
pal.setBrush(QPalette::Window, oldColor);
m_commonUi->tab->setPalette(pal);
#else
m_commonUi->setupUi(this);
#endif
populateFrameList();
// select the frame
quint32 frameClass = m_content->frameClass();
if (frameClass != Frame::NoFrame) {
for (int i = 0; i < m_commonUi->framesList->count(); ++i) {
QListWidgetItem * item = m_commonUi->framesList->item(i);
if (item->data(Qt::UserRole).toUInt() == frameClass) {
item->setSelected(true);
break;
}
}
}
// read other properties
m_commonUi->reflection->setChecked(m_content->mirrored());
m_commonUi->contentLocked->setChecked(m_content->locked());
m_commonUi->fixedPosition->setChecked(m_content->fixedPosition());
m_commonUi->fixedRotation->setChecked(m_content->fixedRotation());
m_commonUi->fixedPerspective->setChecked(m_content->fixedPerspective());
connect(m_commonUi->front, SIGNAL(clicked()), m_content, SLOT(slotStackFront()));
connect(m_commonUi->raise, SIGNAL(clicked()), m_content, SLOT(slotStackRaise()));
connect(m_commonUi->lower, SIGNAL(clicked()), m_content, SLOT(slotStackLower()));
connect(m_commonUi->back, SIGNAL(clicked()), m_content, SLOT(slotStackBack()));
connect(m_commonUi->save, SIGNAL(clicked()), m_content, SLOT(slotSaveAs()));
connect(m_commonUi->background, SIGNAL(clicked()), m_content, SIGNAL(requestBackgrounding()));
connect(m_commonUi->del, SIGNAL(clicked()), m_content, SIGNAL(requestRemoval()));
connect(m_commonUi->contentLocked, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetLocked(int)));
connect(m_commonUi->fixedPosition, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPosition(int)));
connect(m_commonUi->fixedRotation, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedRotation(int)));
connect(m_commonUi->fixedPerspective, SIGNAL(stateChanged(int)), m_content, SLOT(slotSetFixedPerspective(int)));
connect(m_commonUi->newFrame, SIGNAL(clicked()), this, SLOT(slotAddFrame()));
connect(m_commonUi->removeFrame, SIGNAL(clicked()), this, SLOT(slotRemoveFrame()));
connect(m_commonUi->lookApplyAll, SIGNAL(clicked()), this, SLOT(slotLookApplyAll()));
connect(m_commonUi->framesList, SIGNAL(itemSelectionChanged()), this, SLOT(slotFrameSelectionChanged()));
connect(m_commonUi->reflection, SIGNAL(toggled(bool)), this, SLOT(slotReflectionToggled(bool)));
// ITEM setup
#if !defined(MOBILE_UI)
setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
setWidget(widget);
static qreal s_propZBase = 99999;
setZValue(s_propZBase++);
#endif
#if !defined(MOBILE_UI) && QT_VERSION >= 0x040600
// fade in animation
QPropertyAnimation * ani = new QPropertyAnimation(this, "opacity");
ani->setEasingCurve(QEasingCurve::OutCubic);
ani->setDuration(400);
ani->setStartValue(0.0);
ani->setEndValue(1.0);
ani->start(QPropertyAnimation::DeleteWhenStopped);
#endif
}
示例3: drawControl
void FancyTabProxyStyle::drawControl(
ControlElement element, const QStyleOption* option,
QPainter* p, const QWidget* widget) const
{
const QStyleOptionTab* v_opt = qstyleoption_cast<const QStyleOptionTab*>(option);
if (element != CE_TabBarTab || !v_opt) {
QProxyStyle::drawControl(element, option, p, widget);
return;
}
const QRect rect = v_opt->rect;
const bool selected = v_opt->state & State_Selected;
const bool vertical_tabs = v_opt->shape == QTabBar::RoundedWest;
const QString text = v_opt->text;
if (selected) {
//background
p->save();
QLinearGradient grad(rect.topLeft(), rect.topRight());
grad.setColorAt(0, QColor(255, 255, 255, 140));
grad.setColorAt(1, QColor(255, 255, 255, 210));
p->fillRect(rect.adjusted(0, 0, 0, -1), grad);
p->restore();
//shadows
p->setPen(QColor(0, 0, 0, 110));
p->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
p->drawLine(rect.bottomLeft(), rect.bottomRight());
p->setPen(QColor(0, 0, 0, 40));
p->drawLine(rect.topLeft(), rect.bottomLeft());
//highlights
p->setPen(QColor(255, 255, 255, 50));
p->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
p->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0, 1));
p->setPen(QColor(255, 255, 255, 40));
p->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
p->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
p->drawLine(rect.bottomLeft() + QPoint(0, -1), rect.bottomRight() - QPoint(0, 1));
}
QTransform m;
if (vertical_tabs) {
m = QTransform::fromTranslate(rect.left(), rect.bottom());
m.rotate(-90);
}
else {
m = QTransform::fromTranslate(rect.left(), rect.top());
}
const QRect draw_rect(QPoint(0, 0), m.mapRect(rect).size());
p->save();
p->setTransform(m);
QRect icon_rect(QPoint(8, 0), v_opt->iconSize);
QRect text_rect(icon_rect.topRight() + QPoint(4, 0), draw_rect.size());
text_rect.setRight(draw_rect.width());
icon_rect.translate(0, (draw_rect.height() - icon_rect.height()) / 2);
QFont boldFont(p->font());
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
boldFont.setBold(true);
p->setFont(boldFont);
p->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
int textFlags = Qt::AlignHCenter | Qt::AlignVCenter;
p->drawText(text_rect, textFlags, text);
p->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
if (widget) {
const QString fader_key = "tab_" + text + "_fader";
const QString animation_key = "tab_" + text + "_animation";
const QString tab_hover = widget->property("tab_hover").toString();
int fader = widget->property(fader_key.toUtf8().constData()).toInt();
QPropertyAnimation* animation = widget->property(animation_key.toUtf8().constData()).value<QPropertyAnimation*>();
if (!animation) {
QWidget* mut_widget = const_cast<QWidget*>(widget);
fader = 0;
mut_widget->setProperty(fader_key.toUtf8().constData(), fader);
animation = new QPropertyAnimation(mut_widget, fader_key.toUtf8(), mut_widget);
connect(animation, SIGNAL(valueChanged(QVariant)), mut_widget, SLOT(update()));
mut_widget->setProperty(animation_key.toUtf8().constData(), QVariant::fromValue(animation));
}
if (text == tab_hover) {
if (animation->state() != QAbstractAnimation::Running && fader != 40) {
animation->stop();
animation->setDuration(80);
animation->setEndValue(40);
animation->start();
}
}
else {
if (animation->state() != QAbstractAnimation::Running && fader != 0) {
animation->stop();
animation->setDuration(160);
animation->setEndValue(0);
//.........这里部分代码省略.........
示例4: slideInWgt
void SlidingStackedWidget::slideInWgt(QWidget * newWidget, Direction direction)
{
if (active)
{
// At the moment, do not allow re-entrance before an animation is
// completed. Other possibility may be to finish the previous animation
// abrupt, or to revert the previous animation with a counter
// animation, before going ahead or to revert the previous animation
// abrupt and all those only, if the newwidget is not the same as that
// of the previous running animation.
return;
}
else
active=true;
Direction directionHint;
int now = currentIndex();
int next = indexOf(newWidget);
if (now == next)
{
active = false;
return;
}
else if (now < next)
directionHint = vertical ? TOP2BOTTOM : RIGHT2LEFT;
else
directionHint=vertical ? BOTTOM2TOP : LEFT2RIGHT;
if (direction == AUTOMATIC)
direction = directionHint;
int offsetX = frameRect().width();
int offsetY = frameRect().height();
// The following is important, to ensure that the new widget
// has correct geometry information when sliding in first time
widget(next)->setGeometry(0, 0, offsetX, offsetY);
if (direction == BOTTOM2TOP)
{
offsetX = 0;
offsetY = -offsetY;
}
else if (direction == TOP2BOTTOM)
offsetX = 0;
else if (direction == RIGHT2LEFT)
{
offsetX = -offsetX;
offsetY = 0;
}
else if (direction == LEFT2RIGHT)
offsetY = 0;
// Re-position the next widget outside/aside of the display area
QPoint pNext = widget(next)->pos();
QPoint pNow = widget(now)->pos();
pNow = pNow;
widget(next)->move(pNext.x() - offsetX, pNext.y() - offsetY);
widget(next)->show();
widget(next)->raise();
// Animate both, the now and next widget to the side, using animation framework
QPropertyAnimation *animNow = new QPropertyAnimation(widget(now), "pos");
animNow->setDuration(speed);
animNow->setEasingCurve(animationType);
animNow->setStartValue(QPoint(pNow.x(), pNow.y()));
animNow->setEndValue(QPoint(offsetX + pNow.x(), offsetY + pNow.y()));
QPropertyAnimation *animNext = new QPropertyAnimation(widget(next), "pos");
animNext->setDuration(speed);
animNext->setEasingCurve(animationType);
animNext->setStartValue(QPoint(-offsetX + pNext.x(), offsetY + pNext.y()));
animNext->setEndValue(QPoint(pNext.x(), pNext.y()));
QParallelAnimationGroup *animGroup = new QParallelAnimationGroup;
animGroup->addAnimation(animNow);
animGroup->addAnimation(animNext);
QObject::connect(animGroup, SIGNAL(finished()), this, SLOT(animationDoneSlot()));
this->next = next;
this->now = now;
active = true;
animGroup->start();
// Note: the rest is done via a connect from the animation ready;
// animation->finished() provides a signal when animation is done;
// so we connect this to some post processing slot,
// that we implement here below in animationDoneSlot.
}
示例5: slideInWgt
void SlidingStackedWidget::slideInWgt(QWidget * newwidget, enum t_direction direction) {
if (m_active) {
return; // at the moment, do not allow re-entrance before an animation is completed.
//other possibility may be to finish the previous animation abrupt, or
//to revert the previous animation with a counter animation, before going ahead
//or to revert the previous animation abrupt
//and all those only, if the newwidget is not the same as that of the previous running animation.
}
else m_active=true;
enum t_direction directionhint;
int now=currentIndex(); //currentIndex() is a function inherited from QStackedWidget
int next=indexOf(newwidget);
if (now==next) {
m_active=false;
return;
}
else if (now<next){
directionhint=m_vertical ? TOP2BOTTOM : RIGHT2LEFT;
}
else {
directionhint=m_vertical ? BOTTOM2TOP : LEFT2RIGHT;
}
if (direction == AUTOMATIC) {
direction=directionhint;
}
//NOW....
//calculate the shifts
int offsetx=frameRect().width(); //inherited from mother
int offsety=frameRect().height();//inherited from mother
//the following is important, to ensure that the new widget
//has correct geometry information when sliding in first time
widget(next)->setGeometry ( 0, 0, offsetx, offsety );
if (direction==BOTTOM2TOP) {
offsetx=0;
offsety=-offsety;
}
else if (direction==TOP2BOTTOM) {
offsetx=0;
//offsety=offsety;
}
else if (direction==RIGHT2LEFT) {
offsetx=-offsetx;
offsety=0;
}
else if (direction==LEFT2RIGHT) {
//offsetx=offsetx;
offsety=0;
}
//re-position the next widget outside/aside of the display area
QPoint pnext=widget(next)->pos();
QPoint pnow=widget(now)->pos();
m_pnow=pnow;
widget(next)->move(pnext.x()-offsetx,pnext.y()-offsety);
//make it visible/show
widget(next)->show();
widget(next)->raise();
//animate both, the now and next widget to the side, using animation framework
QPropertyAnimation *animnow = new QPropertyAnimation(widget(now), "pos");
animnow->setDuration(m_speed);
animnow->setEasingCurve(m_animationtype);
animnow->setStartValue(QPoint(pnow.x(), pnow.y()));
animnow->setEndValue(QPoint(offsetx+pnow.x(), offsety+pnow.y()));
QPropertyAnimation *animnext = new QPropertyAnimation(widget(next), "pos");
animnext->setDuration(m_speed);
animnext->setEasingCurve(m_animationtype);
animnext->setStartValue(QPoint(-offsetx+pnext.x(), offsety+pnext.y()));
animnext->setEndValue(QPoint(pnext.x(), pnext.y()));
QParallelAnimationGroup *animgroup = new QParallelAnimationGroup;
animgroup->addAnimation(animnow);
animgroup->addAnimation(animnext);
QObject::connect(animgroup, SIGNAL(finished()),this,SLOT(animationDoneSlot()));
m_next=next;
m_now=now;
m_active=true;
animgroup->start();
emit this->animationStarted(next);
//note; the rest is done via a connect from the animation ready;
//animation->finished() provides a signal when animation is done;
//so we connect this to some post processing slot,
//that we implement here below in animationDoneSlot.
}
示例6: cloudAntimation
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();
}
示例7: eventFilter
/*
Most important function of an interactor component
When an event arrive on your interactor : this function is call
You have to process it and return true. If the event do nothing in your interactor : this function
return false;
*/
bool eventFilter(QObject *, QEvent *e) {
/*
If you have clicked on a node/edge, information widget is visible.
And if you use the wheel of the mouse we hide the information widget
*/
if (_informationWidgetItem->isVisible() && e->type() == QEvent::Wheel) {
_informationWidgetItem->setVisible(false);
return false;
}
/*
Check if the event is a mouse event
*/
QMouseEvent *qMouseEv = dynamic_cast<QMouseEvent *>(e);
if (qMouseEv != nullptr) {
GlMainView *glMainView = static_cast<GlMainView *>(view());
/*
Check if event is a left mouse button press
*/
if (e->type() == QEvent::MouseButtonPress && qMouseEv->button() == Qt::LeftButton) {
/*
If you have clicked on a node/edge, information widget is visible.
And if you reclick : hide it
*/
if (_informationWidgetItem->isVisible()) {
_informationWidgetItem->setVisible(false);
} else {
/*
Select entities under the mouse cursor
The result of selection is stored in SelectedEntity
And pickNodesEdges return true if you click on node or edge
*/
SelectedEntity selectedEntity;
if (glMainView->getGlMainWidget()->pickNodesEdges(qMouseEv->x(), qMouseEv->y(),
selectedEntity)) {
/*
Change text of the information label with
- If you click on a node : "Click on node id : nodeId"
- If you click on an edge : "Click on edge id : edgeId"
*/
QString text("Click on ");
if (selectedEntity.getEntityType() == SelectedEntity::NODE_SELECTED)
text += "node ";
else
text += "edge ";
text += " id : " + QString::number(selectedEntity.getComplexEntityId());
/*
- Update QLabel with new text
- Auto resize QLabel
- Set position of the label at mouse position
- Display it
*/
_informationLabel->setText(text);
_informationLabel->adjustSize();
_informationWidgetItem->setPos(qMouseEv->pos());
_informationWidgetItem->setVisible(true);
/*
Here we just add a small smooth animation on the label pop
*/
QPropertyAnimation *animation =
new QPropertyAnimation(_informationWidgetItem, "opacity");
animation->setDuration(100);
animation->setStartValue(0.);
animation->setEndValue(0.99);
animation->start();
/*
We have treated the event so we return true
*/
return true;
}
}
}
}
/*
We don't have treated the event se we return false
*/
return false;
}
示例8: blinkCode
//.........这里部分代码省略.........
QRectF r = l->boundingRect();
bottom += r.height();
if(idx < sidx) {
// Block not within the selection. Will skip it.
top = bottom;
}
else {
// Block within the selection.
width = qMax(width, l->maximumWidth() + r.left());
}
}
if(block == endBlock) break;
block = block.next();
++idx;
if(top == bottom)
firstBlock = block;
}
lastBlock = block;
if(bottom == top) {
//qDebug("no visible block.");
return;
}
// Construct a pixmap to render the code on:
QPixmap pix( QSize(qCeil(width), qCeil(bottom - top)) );
pix.fill(QColor(0,0,0,0));
// Render the visible blocks:
QPainter painter(&pix);
QVector<QTextLayout::FormatRange> selections;
block = firstBlock;
int y=0;
while( block.isValid() )
{
if (block.isVisible())
{
QRectF blockRect = block.layout()->boundingRect();
// Use extra char formatting to hide code outside of selection
// and modify the appearance of selected code:
QTextLayout::FormatRange range;
selections.clear();
int start = 0;
if(block == startBlock) {
range.start = 0;
range.length = startPos;
range.format.setForeground(QColor(0,0,0,0));
range.format.setBackground(Qt::NoBrush);
selections.append(range);
start = startPos;
}
range.start = start;
range.length = (block == endBlock ? endPos : block.length() - 1) - range.start;
range.format = evalCodeTextFormat;
selections.append(range);
if(block == endBlock) {
range.start = range.start + range.length;
range.length = block.length() - 1 - range.start;
range.format.setForeground(QColor(0,0,0,0));
range.format.setBackground(Qt::NoBrush);
selections.append(range);
}
block.layout()->draw(&painter, QPointF(0,y), selections);
y += blockRect.height();
}
if(block == lastBlock) break;
block = block.next();
}
// Create an overlay item to display the pixmap, and animate it:
CodeFragmentOverlay *item = new CodeFragmentOverlay();
item->setPixmap(pix);
item->setPos(geom.left(), top);
mOverlay->addItem(item);
QPropertyAnimation *anim = new QPropertyAnimation(item, "opacity", item);
anim->setDuration(mBlinkDuration);
anim->setStartValue(1.0);
anim->setEndValue(0.0);
anim->setEasingCurve( QEasingCurve::InCubic );
anim->start();
connect(anim, SIGNAL(finished()), item, SLOT(deleteLater()));
}
示例9: drawStones
void BoardView::drawStones()
{
static QPixmap* bstone = new QPixmap(":/images/blackstone.gif");
static QPixmap* wstone = new QPixmap(":/images/wwstone.gif");
if (this->_board != 0)
{
Coord* lastCoord = 0;
QBrush lastBrush;
for (unsigned int i = 0; i < this->_board->getSize(); i++)
{
for (unsigned int j = 0; j < this->_board->getSize(); j++)
{
QBrush brush;
if (BoardCell::matchMask(*this->_board->getCell(i, j), WHITE))
brush = QBrush(Qt::white);
else if (BoardCell::matchMask(*this->_board->getCell(i, j), BLACK))
brush = QBrush(Qt::black);
if (!BoardCell::isEmpty(*this->_board->getCell(i, j)))
{
Coord c = this->getCoord(i, j);
if (this->_board->getLastPlayed())
{
Coord lastCell = this->getCoord(this->_board->getLastPlayed()->x, this->_board->getLastPlayed()->y);
if (c.x == lastCell.x && c.y == lastCell.y)
{
lastCoord = new Coord(c.x, c.y);
lastBrush = brush;
}
}
if (!lastCoord || lastCoord->x != c.x || lastCoord->y != c.y)
{
QGraphicsPixmapItem* item;
double width;
if (brush.color() == Qt::black)
{
item = this->_scene.addPixmap(*bstone);
width = bstone->width();
}
else
{
item = this->_scene.addPixmap(*wstone);
width = wstone->width();
}
item->setPos(c.x, c.y);
item->setScale(this->_lineSpacing/width);
}
}
}
}
if (lastCoord)
{
Stone* stone = new Stone();
double width;
if (lastBrush.color() == Qt::black)
{
stone->setPixmap(*bstone);
width = bstone->width();
}
else
{
stone->setPixmap(*wstone);
width = wstone->width();
}
stone->initScaleAndOffset(lastCoord->x, lastCoord->y,
this->_lineSpacing/width, this->_lineSpacing/2);
this->_scene.addItem(stone);
QPropertyAnimation* animation = new QPropertyAnimation(stone, "scale");
animation->setDuration(200);
animation->setStartValue(0.0);
animation->setEndValue(this->_lineSpacing/width);
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
delete lastCoord;
}
}
else
std::cout << "drawStones(): Warning: No board set in BoardView" << std::endl;
}
示例10: setScores
void DraftScoreWindow::setScores(double rating1, double rating2, double rating3,
QString synergy1, QString synergy2, QString synergy3)
{
double ratings[3] = {rating1, rating2, rating3};
QString synergies[3] = {synergy1, synergy2, synergy3};
double maxRating = std::max(std::max(rating1,rating2),rating3);
for(int i=0; i<3; i++)
{
int rating255 = std::max(std::min((int)(ratings[i]*2.55), 255), 0);
int r = std::min(255, (255 - rating255)*2);
int g = std::min(255,rating255*2);
int b = 0;
scoresPushButton[i]->setText(QString::number((int)ratings[i]));
scoresPushButton[i]->setStyleSheet(
"QPushButton{background-color: "
"qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, "
"stop: 0 black, "
"stop: 0.5 rgb("+ QString::number(r) +","+ QString::number(g) +","+ QString::number(b) +"), "
"stop: 1 black);"
"border-style: solid;border-color: black;" +
((!synergies[i].isEmpty())?"border-bottom-style: dotted;":"") +
"border-width: " + QString::number(scoreWidth/20) + "px;border-radius: "
+ QString::number(scoreWidth/3) + "px;}");
QPropertyAnimation *animation = new QPropertyAnimation(scoresPushButton[i], "maximumHeight");
animation->setDuration(ANIMATION_TIME);
animation->setStartValue(0);
animation->setEndValue(scoreWidth);
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
animation = new QPropertyAnimation(scoresPushButton[i], "minimumHeight");
animation->setDuration(ANIMATION_TIME);
animation->setStartValue(0);
animation->setEndValue(scoreWidth);
animation->setEasingCurve(QEasingCurve::OutBounce);
animation->start();
scoresPushButton[i]->setDrawArrow(!synergies[i].isEmpty());
scoresPushButton[i]->setDrawHLines(ratings[i]==maxRating);
//Insert synergies
synergiesListWidget[i]->clear();
QStringList synergiesList = synergies[i].split(" - ", QString::SkipEmptyParts);
foreach(QString name, synergiesList)
{
QString code = Utility::cardEnCodeFromName(name);
DeckCard deckCard(code);
deckCard.listItem = new QListWidgetItem(synergiesListWidget[i]);
deckCard.draw();
}
synergiesListWidget[i]->setMaximumWidth(0);
}
示例11: animate
void QQHuntPixmapItem::animate()
{
m_animation->clear();
m_listPixmapProp.clear();
int timeMs = QuteTools::randInt(MIN_DURATION, MAX_DURATION);
//Recuperation des bornes
QRectF sceneRect = scene()->sceneRect();
float maxX = sceneRect.width() - boundingRect().width();
float maxY = sceneRect.height() - boundingRect().height();
//Et du point initial
QPointF curPos = pos();
//Calcul du nouveau vecteur vitesse
float angle = (((float) qrand()) / INT_MAX) * M_PI_2;
angle -= M_PI_4;
QQMatrix2x2 rotMatrix;
rotMatrix(0, 0) = qCos(angle);
rotMatrix(0, 1) = qSin(angle);
rotMatrix(1, 0) = 0.0 - rotMatrix(0,1);
rotMatrix(1, 1) = rotMatrix(0,0);
m_speedVec = rotMatrix * m_speedVec;
//Decoupage du temps d'animation en tranche selon les rencontres avec les bords.
while(timeMs > 0)
{
QPropertyAnimation *pAnimation = new QPropertyAnimation(this, "pos");
pAnimation->setStartValue(curPos);
connect(pAnimation, SIGNAL(finished()), this, SLOT(loadNextPixMap()));
float angle = qAcos(m_speedVec(X_VALUE)); // 0 <= angle <= Pi
QQPixmapProp pixmapProp = animPixmapProp(angle);
m_listPixmapProp.append(pixmapProp);
QQMatrix1x2 resSpeedVec = m_speedVec * ((float) SPEED_FACTOR)
* (timeMs / (float) (MAX_DURATION - MIN_DURATION));
float destPosX = curPos.x() + resSpeedVec(X_VALUE);
float destPosY = curPos.y() + resSpeedVec(Y_VALUE);
float xFactor = 1;
if(destPosX < 0)
xFactor = (0.0 - curPos.x() / (destPosX - curPos.x()));
else if(destPosX > maxX)
xFactor = (maxX - curPos.x()) / (destPosX - curPos.x());
float yFactor = 1;
if(destPosY < 0)
yFactor = (0.0 - curPos.y() / (destPosY - curPos.y()));
else if(destPosY > maxY)
yFactor = (maxY - curPos.y()) / (destPosY - curPos.y());
//qDebug() << "xFactor" << xFactor << "yFactor" << yFactor;
//Collision de bord detectee
if(xFactor < 1 || yFactor < 1)
{
float realtime = 0;
if(xFactor <= yFactor) // on touche gauche/droite avant haut/bas
{
realtime = timeMs * xFactor;
curPos = QPointF(curPos.x() + (destPosX - curPos.x()) * xFactor,
curPos.y() + (destPosY - curPos.y()) * xFactor);
m_speedVec(X_VALUE) = 0.0 - m_speedVec(X_VALUE);
if(xFactor == yFactor)
m_speedVec(Y_VALUE) = 0.0 - m_speedVec(Y_VALUE);
}
else if(xFactor > yFactor) // on touche haut/bas avant gauche/droite
{
realtime = timeMs * yFactor;
curPos = QPointF(curPos.x() + (destPosX - curPos.x()) * yFactor,
curPos.y() + (destPosY - curPos.y()) * yFactor);
m_speedVec(Y_VALUE) = 0.0 - m_speedVec(Y_VALUE);
}
pAnimation->setDuration(realtime);
timeMs -= realtime;
pAnimation->setEndValue(curPos);
}
else
{
pAnimation->setDuration(timeMs);
timeMs = 0;
pAnimation->setEndValue(QPointF(destPosX, destPosY));
}
m_animation->addAnimation(pAnimation);
}
loadNextPixMap();
m_animation->start(QAbstractAnimation::KeepWhenStopped);
}
示例12: main
int main(int argc, char* argv[])
{
QGuiApplication app(argc, argv);
Qt3D::QWindow view;
Qt3D::QInputAspect *input = new Qt3D::QInputAspect;
view.registerAspect(input);
// Root entity
Qt3D::QEntity *rootEntity = new Qt3D::QEntity();
// Camera
Qt3D::QCamera *cameraEntity = view.defaultCamera();
cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
cameraEntity->setPosition(QVector3D(0, 0, -40.0f));
cameraEntity->setUpVector(QVector3D(0, 1, 0));
cameraEntity->setViewCenter(QVector3D(0, 0, 0));
input->setCamera(cameraEntity);
// Material
Qt3D::QMaterial *material = new Qt3D::QPhongMaterial(rootEntity);
// Torus
Qt3D::QEntity *torusEntity = new Qt3D::QEntity(rootEntity);
Qt3D::QTorusMesh *torusMesh = new Qt3D::QTorusMesh;
torusMesh->setRadius(5);
torusMesh->setMinorRadius(1);
torusMesh->setRings(100);
torusMesh->setSlices(20);
Qt3D::QTransform *torusTransform = new Qt3D::QTransform;
Qt3D::QScaleTransform *torusScaleTransform = new Qt3D::QScaleTransform;
torusScaleTransform->setScale3D(QVector3D(1.5, 1, 0.5));
Qt3D::QRotateTransform *torusRotateTransform = new Qt3D::QRotateTransform;
torusRotateTransform->setAxis(QVector3D(1, 0, 0));
torusRotateTransform->setAngleDeg(45);
torusTransform->addTransform(torusScaleTransform);
torusTransform->addTransform(torusRotateTransform);
torusEntity->addComponent(torusMesh);
torusEntity->addComponent(torusTransform);
torusEntity->addComponent(material);
// Sphere
Qt3D::QEntity *sphereEntity = new Qt3D::QEntity(rootEntity);
Qt3D::QSphereMesh *sphereMesh = new Qt3D::QSphereMesh;
sphereMesh->setRadius(3);
Qt3D::QTransform *sphereTransform = new Qt3D::QTransform;
Qt3D::QTranslateTransform *sphereTranslateTransform = new Qt3D::QTranslateTransform;
sphereTranslateTransform->setTranslation(QVector3D(20, 0, 0));
Qt3D::QRotateTransform *sphereRotateTransform = new Qt3D::QRotateTransform;
QPropertyAnimation *sphereRotateTransformAnimation = new QPropertyAnimation(sphereRotateTransform);
sphereRotateTransformAnimation->setTargetObject(sphereRotateTransform);
sphereRotateTransformAnimation->setPropertyName("angle");
sphereRotateTransformAnimation->setStartValue(QVariant::fromValue(0));
sphereRotateTransformAnimation->setEndValue(QVariant::fromValue(360));
sphereRotateTransformAnimation->setDuration(10000);
sphereRotateTransformAnimation->setLoopCount(-1);
sphereRotateTransformAnimation->start();
sphereRotateTransform->setAxis(QVector3D(0, 1, 0));
sphereRotateTransform->setAngleDeg(0);
sphereTransform->addTransform(sphereTranslateTransform);
sphereTransform->addTransform(sphereRotateTransform);
sphereEntity->addComponent(sphereMesh);
sphereEntity->addComponent(sphereTransform);
sphereEntity->addComponent(material);
view.setRootEntity(rootEntity);
view.show();
return app.exec();
}
示例13: QDialog
RocketStorageSelectionDialog::RocketStorageSelectionDialog(RocketPlugin *plugin, MeshmoonStorage *storage, const QStringList &suffixFilters,
bool allowChangingFolder, MeshmoonStorageItem &startDirectory, QWidget *parent) :
QDialog(parent),
plugin_(plugin),
storage_(storage),
suffixFilters_(suffixFilters),
allowChangingFolder_(allowChangingFolder),
startDirectory_(startDirectory),
currentFolder_(0)
{
// Setup UI
ui_.setupUi(this);
ui_.scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
ui_.lineEditFilter->installEventFilter(this);
ui_.buttonSelect->setAutoDefault(false);
ui_.buttonCancel->setAutoDefault(false);
view_ = new RocketStorageListWidget(this, plugin_);
view_->SetPreviewFileOnMouse(true);
view_->setSelectionMode(QAbstractItemView::SingleSelection);
QVBoxLayout *l = new QVBoxLayout(ui_.scrollAreaWidgetContents);
l->setSpacing(0);
l->setContentsMargins(0,0,0,0);
l->addWidget(view_);
ui_.scrollAreaWidgetContents->setLayout(l);
// Connections
connect(view_, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(OnItemClicked(QListWidgetItem*)));
connect(view_, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(OnItemDoubleClicked(QListWidgetItem*)));
connect(ui_.buttonSelect, SIGNAL(clicked()), SLOT(OnSelect()), Qt::QueuedConnection);
connect(ui_.buttonCancel, SIGNAL(clicked()), SLOT(reject()), Qt::QueuedConnection);
connect(this, SIGNAL(rejected()), SLOT(OnCancel()));
connect(ui_.lineEditFilter, SIGNAL(textChanged(const QString&)), SLOT(OnFilterChanged(const QString&)));
// Dialog setup
setAttribute(Qt::WA_DeleteOnClose, true);
setWindowModality(parent != 0 ? Qt::WindowModal : Qt::ApplicationModal);
setWindowFlags(parent != 0 ? Qt::Tool : Qt::SplashScreen);
setWindowTitle(parent != 0 ? "Meshmoon Storage Picker" : "");
setModal(true);
// Center to main window or to parent window.
if (!parent)
{
plugin_->Notifications()->DimForeground();
plugin_->Notifications()->CenterToMainWindow(this);
}
else
plugin_->Notifications()->CenterToWindow(parent, this);
// Show and activate
show();
setFocus(Qt::ActiveWindowFocusReason);
activateWindow();
// If this is a splash dialog animate opacity
if (!parent)
{
setWindowOpacity(0.0);
QPropertyAnimation *showAnim = new QPropertyAnimation(this, "windowOpacity", this);
showAnim->setStartValue(0.0);
showAnim->setEndValue(1.0);
showAnim->setDuration(300);
showAnim->setEasingCurve(QEasingCurve(QEasingCurve::InOutQuad));
showAnim->start();
}
if (!plugin_ || !storage_)
{
view_->addItem(new QListWidgetItem("Failed to list storage content"));
return;
}
if (storage_->RootDirectory().IsNull())
view_->addItem(new QListWidgetItem("Loading..."));
MeshmoonStorageAuthenticationMonitor *auth = storage_->Authenticate();
connect(auth, SIGNAL(Completed()), SLOT(OnStorageAuthCompleted()), Qt::QueuedConnection);
connect(auth, SIGNAL(Canceled()), SLOT(reject()), Qt::QueuedConnection);
connect(auth, SIGNAL(Failed(const QString&)), SLOT(reject()), Qt::QueuedConnection);
}
示例14: hauptlichtOn
EinstellungHauptlicht::EinstellungHauptlicht(QWidget *parent, steuerungThreadLicht *s, ModelThreadLicht *m) :
QDialog(parent),
ui(new Ui::EinstellungHauptlicht)
{
ui->setupUi(this);
ui->pushButton_back->setVisible(false);
if(SlinderarduinoEnable == true)
{
Slider = new thread_Slider(this);
}
sThread = s;
mThread = m;
//slide in animation
QPropertyAnimation *animation = new QPropertyAnimation(this, "geometry");
connect(animation, SIGNAL(finished()), this, SLOT(afterAnimation()));
animation->setDuration(500);
animation->setStartValue(QRect(-800,0,800,480));
animation->setEndValue(QRect(0,0,800,480));
animation->setEasingCurve(QEasingCurve::OutExpo);
animation->start();
//put all PushButtons in Array to be able to loop through them
ArrayOfPushButtons.append(ui->pushButton_1);
ArrayOfPushButtons.append(ui->pushButton_2);
ArrayOfPushButtons.append(ui->pushButton_3);
ArrayOfPushButtons.append(ui->pushButton_4);
ArrayOfPushButtons.append(ui->pushButton_5);
ArrayOfPushButtons.append(ui->pushButton_6);
ArrayOfPushButtons.append(ui->pushButton_7);
ArrayOfPushButtons.append(ui->pushButton_8);
ArrayOfPushButtons.append(ui->pushButton_9);
//Setup Sliders
if(SlinderarduinoEnable == true){
Slider->init(sThread->Hauptlicht_Data[0]/2.55, 0,0,0);
Slider->start();
}
//setup backgrounds, borders
for (int i = 0; i < ArrayOfPushButtons.length(); i++)
{
ArrayOfPushButtons[i]->setStyleSheet("border: 2px solid black; border-radius: 10px;");
ArrayOfPushButtons[i]->setChecked(false);
}
SetAllButtonsColor();
ui->horizontalSlider->setSliderPosition(sThread->Hauptlicht_Data[0]/2.55);
//connect(ui->horizontalSlider, SIGNAL(sliderMoved(int)), this, SLOT(SliderHellChanged(int)));//<----for testing
//setup button AnAus
if (sThread->getStatusHauptlicht()) ui->pushButton_AnAus->setText("Aus");
else ui->pushButton_AnAus->setText("An");
//Communication between Threads
//Slider -> UI
if(SlinderarduinoEnable == true) connect(Slider, SIGNAL(Slider1_Changed(int)), this, SLOT(SliderHellChanged(int)));
//UI -> steuerungThreadLicht
connect(this, SIGNAL(HelligkeitChanged(int)), sThread, SLOT(SetHauptlicht(int)));
connect(this,SIGNAL(toggelhauptlicht()), sThread,SLOT(hauptlichtNetzteilOnOff()));
connect(this,SIGNAL(hauptlichtOn(int)),sThread,SLOT(SetHauptlicht(int)));
emit hauptlichtOn(1);
}
示例15: Start
void GlanceShower::Start ()
{
if (!TabWidget_)
{
qWarning () << Q_FUNC_INFO
<< "no tab widget set";
return;
}
const int count = TabWidget_->count ();
if (count < 2)
{
emit finished (true);
return;
}
QAnimationGroup *animGroup = new QParallelAnimationGroup;
const int sqr = std::sqrt ((double)count);
int rows = sqr;
int cols = sqr;
if (rows * cols < count)
++cols;
if (rows * cols < count)
++rows;
const QRect& screenGeom = QApplication::desktop ()->
screenGeometry (Core::Instance ().GetReallyMainWindow ());
const int width = screenGeom.width ();
const int height = screenGeom.height ();
const int singleW = width / cols;
const int singleH = height / rows;
const int wW = singleW * 4 / 5;
const int wH = singleH * 4 / 5;
qreal scaleFactor = 0;
QSize sSize;
const int animLength = 400;
QProgressDialog pg;
pg.setMinimumDuration (1000);
pg.setRange (0, count);
for (int row = 0; row < rows; ++row)
for (int column = 0;
column < cols && column + row * cols < count;
++column)
{
const int idx = column + row * cols;
pg.setValue (idx);
QWidget *w = TabWidget_->widget (idx);
if (!sSize.isValid ())
sSize = w->size () / 2;
if (sSize != w->size ())
w->resize (sSize * 2);
if (std::fabs (scaleFactor) < std::numeric_limits<qreal>::epsilon ())
scaleFactor = std::min (static_cast<qreal> (wW) / sSize.width (),
static_cast<qreal> (wH) / sSize.height ());
QPixmap pixmap (sSize * 2);
w->render (&pixmap);
pixmap = pixmap.scaled (sSize,
Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
{
QPainter p (&pixmap);
QPen pen (Qt::black);
pen.setWidth (2 / scaleFactor + 1);
p.setPen (pen);
p.drawRect (QRect (QPoint (0, 0), sSize));
}
GlanceItem *item = new GlanceItem (pixmap);
item->SetIndex (idx);
connect (item,
SIGNAL (clicked (int)),
this,
SLOT (handleClicked (int)));
Scene_->addItem (item);
item->setTransformOriginPoint (sSize.width () / 2, sSize.height () / 2);
item->setScale (scaleFactor);
item->SetIdealScale (scaleFactor);
item->setOpacity (0);
item->moveBy (column * singleW, row * singleH);
QAnimationGroup *pair = new QParallelAnimationGroup;
QPropertyAnimation *posAnim = new QPropertyAnimation (item, "Pos");
posAnim->setDuration (animLength);
posAnim->setStartValue (QPointF (0, 0));
posAnim->setEndValue (QPointF (column * singleW, row * singleH));
posAnim->setEasingCurve (QEasingCurve::OutSine);
pair->addAnimation (posAnim);
//.........这里部分代码省略.........