示例#1
0
	void UiManager::mousePressEvent(QMouseEvent *event)
	{
		QWidget *pressedWidget = NULL;
	
		// get the clicked item through the view (respects view and item transformations)
		QGraphicsItem* itemAt = mWidgetView->itemAt(event->pos());
		if ((itemAt) && (itemAt->isWidget()))
		{
			QGraphicsProxyWidget *proxyWidget = qgraphicsitem_cast<QGraphicsProxyWidget *>(itemAt);
			if (proxyWidget)
			{
				QWidget *embeddedWidget = proxyWidget->widget();
	
				// if the widget has children, use them, otherwise use the widget directly
				if (embeddedWidget->children().size() > 0)
				{
					QPoint widgetPoint = proxyWidget->mapFromScene(mWidgetView->mapToScene(event->pos())).toPoint();
					pressedWidget = embeddedWidget->childAt(widgetPoint);
				}
				else
				{
					pressedWidget = embeddedWidget;
				}
			}
		}
	
		// if there was a focused widget and there is none or a different one now, defocus
		if (mFocusedWidget && (!pressedWidget || pressedWidget != mFocusedWidget))
		{
			QEvent foe(QEvent::FocusOut);
			QApplication::sendEvent(mFocusedWidget, &foe);
			mFocusedWidget = NULL;
			mTopLevelWidget->setFocus();
		}
	
		// set the new focus
		if (pressedWidget)
		{
			QEvent fie(QEvent::FocusIn);
			QApplication::sendEvent(pressedWidget, &fie);
			pressedWidget->setFocus(Qt::MouseFocusReason);
			mFocusedWidget = pressedWidget;
		}
	
		QApplication::sendEvent(mWidgetView->viewport(), event);
	}
void OpenExistingMap::createUi()
{
    QWidget* widget = new QWidget();
    QVBoxLayout* layout = new QVBoxLayout();
    layout->setMargin(10);
    layout->addWidget(m_button);
    widget->setPalette(QPalette(QPalette::Base));
    widget->setLayout(layout);

    QGraphicsProxyWidget *proxy = m_mapView->scene()->addWidget(widget);
    proxy->setPos(10, 10);
    proxy->setOpacity(0.95);

    QVBoxLayout* vBoxLayout = new QVBoxLayout();
    vBoxLayout->addWidget(m_mapView);
    setLayout(vBoxLayout);
}
示例#3
0
Window::Window()
: QGraphicsWidget(0, Qt::Window)
{
    FlowLayout *lay = new FlowLayout;
    QLatin1String wiseWords("I am not bothered by the fact that I am unknown."
    " I am bothered when I do not know others. (Confucius)");
    QString sentence(wiseWords);
    QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts);
    for (int i = 0; i < words.count(); ++i) {
        QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this);
        QLabel *label = new QLabel(words.at(i));
        label->setFrameStyle(QFrame::Box | QFrame::Plain);
        proxy->setWidget(label);
        lay->addItem(proxy);
    }
    setLayout(lay);
}
示例#4
0
    bool event(QEvent* event) override
    {
        if (event->type() == QEvent::UpdateRequest) {
            proxyItem->update();
        }

        return QWebEngineView::event(event);
    }
void CopyFilterGUIConnectionItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
	QString text = QString("%1").arg(factor);
	if (isDecibel)
		text += " dB";

	ResizingLineEdit* lineEdit = new ResizingLineEdit("");
	connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(lineEditEditingFinished()));
	QGraphicsProxyWidget* proxyItem = scene()->addWidget(lineEdit);
	QLineF l = line();
	QPointF center = (l.p1() + l.p2()) / 2;
	QRectF rect;
	rect.setSize(lineEdit->size());
	rect.moveCenter(center);
	proxyItem->setPos(rect.topLeft());
	proxyItem->setZValue(10);
	lineEdit->setFocus();
}
示例#6
0
void ImageProxyItem::Private::onFinished(int /*id*/, QMovie * movie) {
    QLabel * label = new QLabel;
    label->setMovie(movie);
    movie->setParent(label);
    movie->start();
    label->resize(movie->frameRect().size());
    QGraphicsProxyWidget * item = new QGraphicsProxyWidget(this->owner);
    item->setWidget(label);
    // HACK workaround for https://bugreports.qt.io/browse/QTBUG-55070
    item->setOpacity(0.99);

    this->movie = movie;
    this->item = item;

    this->activity = Activity::Activated;

    emit this->owner->activated(this->owner);
}
示例#7
0
MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    // create a scene with items,
    // use the view to show the scene
    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView(this);
    gv->setScene(scene);
    if (gv->scene())
    {
        printf("renc: scene is not null.\n");

        // these two lines are at scene origin pos.
        scene->addLine(0, 0, 100, 0, QPen(Qt::red));
        scene->addLine(0, 0, 0, 100, QPen(Qt::green));

        /*QGraphicsRectItem *rect = */
        scene->addRect(QRectF(0,0,50,50), QPen(Qt::red), QBrush(Qt::green));

        // svg image
        QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(svgFile2);
        scene->addItem((svgItem));
        svgItem->setPos(400, 0);
        bool rValid1 = svgItem->renderer()->isValid();
        printf("--%d--\n", rValid1);

        // QWidget to scene
        QPushButton *btn = new QPushButton("button 1");// at (0,0) by default.
        QGraphicsProxyWidget *btnWidget = scene->addWidget(btn);
        btnWidget->setPos(0, 400);

        //
        {
            SvgPushButton *btn2 = new SvgPushButton(svgFile1);
            QGraphicsProxyWidget *btnWidget2 = scene->addWidget(btn2);
            btnWidget2->setPos(400, 400);
        }
    }
    else
        printf("renc: scene is null.\n");

    //setCentralWidget(gv); setWindowTitle("Demo: graphics view");//QMainWindow
    setStyleSheet("background-color: rgb(100,120,50);");
}
void QtFallbackWebPopup::show(const QWebSelectData& data)
{
    if (!pageClient())
        return;

#if ENABLE(SYMBIAN_DIALOG_PROVIDERS)
    TRAP_IGNORE(showS60BrowserDialog());
#else

    destroyPopup();
    m_combo = new QtFallbackWebPopupCombo(*this);
    connect(m_combo, SIGNAL(activated(int)),
            SLOT(activeChanged(int)), Qt::QueuedConnection);

    populate(data);

    QColor backgroundColor = data.backgroundColor();
    QColor foregroundColor = data.foregroundColor();

    QPalette palette = m_combo->palette();
    if (backgroundColor.isValid())
        palette.setColor(QPalette::Background, backgroundColor);
    if (foregroundColor.isValid())
        palette.setColor(QPalette::Foreground, foregroundColor);
    m_combo->setPalette(palette);


    QRect rect = geometry();
    if (QGraphicsWebView *webView = qobject_cast<QGraphicsWebView*>(pageClient()->pluginParent())) {
        QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget(webView);
        proxy->setWidget(m_combo);
        proxy->setGeometry(rect);
    } else {
        m_combo->setParent(pageClient()->ownerWidget());
        m_combo->setGeometry(QRect(rect.left(), rect.top(),
                               rect.width(), m_combo->sizeHint().height()));

    }

    QMouseEvent event(QEvent::MouseButtonPress, QCursor::pos(), Qt::LeftButton,
                      Qt::LeftButton, Qt::NoModifier);
    QCoreApplication::sendEvent(m_combo, &event);
#endif
}
MessageViewAdapter::MessageViewAdapter()
: d(new MessageViewAdapterPrivate)
{
    QWidget* widget = new QWidget;
    widget->installEventFilter(this);
    d->setupUi(widget);
    d->mMessageWidget->setCloseButtonVisible(false);
    d->mMessageWidget->setWordWrap(true);

    setInfoMessage(i18n("No document selected"));

    widget->setAutoFillBackground(true);
    widget->setBackgroundRole(QPalette::Base);
    widget->setForegroundRole(QPalette::Text);

    QGraphicsProxyWidget* proxy = new QGraphicsProxyWidget;
    proxy->setWidget(widget);
    setWidget(proxy);
}
示例#10
0
MvScene::MvScene(QObject *parent) : QGraphicsScene(parent)
{
    QBrush Brush;
    Brush.setColor(QColor(150,100,150));
    Brush.setStyle(Qt::DiagCrossPattern);
    setBackgroundBrush(Brush);

    QFont font;
    font.setPixelSize(16);
    lineEdit = new QLineEdit();
    QGraphicsProxyWidget * item = addWidget(lineEdit);
    lineEdit->setGeometry(-380, 300, 400, 35);
    lineEdit->setFont(font);
    item = addWidget(lineEdit);
    lineEdit->show();

    textEdit = new QTextEdit();
    item = addWidget(textEdit);
    textEdit->setGeometry(-380, 0, 400, 300);\
    textEdit->setFont(font);
    item = addWidget(textEdit);
    textEdit->show();

    QPushButton * button = new QPushButton(trUtf8("Speek!"), 0);
    item = addWidget(button);
    QTransform transform = item->transform();
    transform.translate(-500., 200.);
    transform.rotate(45.0);
    transform.scale(2., 2.);
    item->setTransform(transform);
    item = addWidget(button);
    button->show();

    connect(button,SIGNAL(clicked()),this,SLOT(btnClicked()));

    educationStatus = Free;

    UserName = "******";
    BotName = "Slave";

    InitializeBase();
}
示例#11
0
WebPreviewItem::WebPreviewItem(const QString &url)
  : QGraphicsItem(0), // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines
    _boundingRect(0, 0, 400, 300)
{
  qreal frameWidth = 5;

  QWebView *webView = new QWebView;
  webView->load(url);
  webView->resize(1000, 750);
  QGraphicsProxyWidget *proxyItem = new QGraphicsProxyWidget(this);
  proxyItem->setWidget(webView);
  proxyItem->setAcceptHoverEvents(false);

  qreal xScale = (_boundingRect.width() - 2 * frameWidth) / webView->width();
  qreal yScale = (_boundingRect.height() - 2 * frameWidth) / webView->height();
  proxyItem->scale(xScale, yScale);
  proxyItem->setPos(frameWidth, frameWidth);

  setZValue(30);
}
示例#12
0
void LLWebPage::javaScriptAlert(QWebFrame* frame, const QString& msg)
{
    Q_UNUSED(frame);
    QMessageBox *msgBox = new QMessageBox;
    msgBox->setWindowTitle(tr("JavaScript Alert - %1").arg(mainFrame()->url().host()));
    msgBox->setText(msg);
    msgBox->addButton(QMessageBox::Ok);

    QGraphicsProxyWidget *proxy = webView->scene()->addWidget(msgBox);
    proxy->setWindowFlags(Qt::Window); // this makes the item a panel (and will make it get a window 'frame')
    proxy->setPanelModality(QGraphicsItem::SceneModal);
    proxy->setPos((webView->boundingRect().width() - msgBox->sizeHint().width())/2,
                  (webView->boundingRect().height() - msgBox->sizeHint().height())/2);
    proxy->setActive(true); // make it the active item

    connect(msgBox, SIGNAL(finished(int)), proxy, SLOT(deleteLater()));
    msgBox->show();

    webView->scene()->setFocusItem(proxy);
}
示例#13
0
void HomeScreen::initSprite()
{
	_sprite = new QGraphicsWidget();

	QGraphicsItem* item;
	QGraphicsSimpleTextItem* text;
	QGraphicsProxyWidget* proxy;
	QLabel* label;
	QFont font;

	item = new QGraphicsPixmapItem();
	item->setParentItem(_sprite);
	item->setPos((BACKGROUND_W - (400.0f / 0.75f)) * 0.5f, BACKGROUND_H - 400.0f);
	_avatar = static_cast<QGraphicsPixmapItem*>(item);

	item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_TITLE));
	item->setParentItem(_sprite);
	item->setPos(232.0f, 128.0f);

	font = QFont("Arial");
	font.setPixelSize(12);
	font.setWeight(QFont::Normal);
	font.setStretch(80);

	text = new QGraphicsSimpleTextItem("http://conanchen.com/Kinetris");
	text->setBrush(QColor::fromRgb(0xFF, 0xFF, 0xFF));
	text->setFont(font);
	text->setParentItem(_sprite);
	text->setPos(248.0f, 264.0f - 3.0f);

	label = new QLabel();
	label->resize(784, 24);
	label->setStyleSheet("background-color: transparent; color: #FFFFFF;");
	label->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
	proxy = new QGraphicsProxyWidget();
	proxy->setParentItem(_sprite);
	proxy->setWidget(label);
	proxy->setPos(248.0f, 592.0f - 6.0f);
	_sprite_status = proxy;
	_status = label;
}
示例#14
0
void HGView::setAlignment(Qt::Alignment align)
{
    HGWidget* widget = parentGWidget();
    if (widget) {
        QObject* p = NULL;
        QGraphicsProxyWidget* proxy = graphicsProxyWidget();
        if (!proxy || !(p = proxy->parent()))
            return;
        if (p->property("isHGWidget").toBool())
            static_cast<HGWidget*>(p)->layout()->setAlignment(proxy,align);
    }
    else {
        QObject* p = parent();
        if (p->property("isHQWidget").toBool()) {
            static_cast<HQWidget*>(p)->layout()->setAlignment(this,align);
        }
        else if(p->property("isHGView").toBool()) {
            static_cast<HGView*>(p)->layout()->setAlignment(this,align);
        }
    }
}
示例#15
0
const void GSquare::createMySquare()
{
    // Window

    // Creer les bouttons + Case
    group_pions = new QButtonGroup(this);

    flag_opt = 1;
    displayOptionGame();
    for (int y = 0; y < nb_col; ++y)
    {
        for (int x = 0; x < nb_col; ++x)
        {
            // Creer la case
            if (x < nb_col - 1 && y < nb_col - 1)
            {
                QPixmap tmp_pix("case.png");
                QGraphicsPixmapItem *pix = new QGraphicsPixmapItem(tmp_pix, fond, scene);
                pix->setPos( 50 + x * 50, 50 + y * 50);
                pix->scale(1.1, 1.1);

				
			}

			// Creer le Bouton
			GCase *btn = new GCase(NULL, x, y);
			btn->setGeometry(25 + x * 50, 25 + y * 50, 50, 50);
			btn->setFlat(true);
			btn->setAutoFillBackground(false);
			btn->setTaken(false);

			group_pions->addButton(btn, x * 100 + y);
           
			QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(fond);
			proxy->setWidget(btn);
			proxy->setPalette(QPalette(QColor(0, 0, 0, 0)));
		}
	  }
	 QObject::connect(group_pions, SIGNAL(buttonClicked(QAbstractButton*)), this, SLOT(button_released(QAbstractButton *)));
}
WebPreviewItem::WebPreviewItem(const QUrl &url)
    : QGraphicsItem(0), // needs to be a top level item as we otherwise cannot guarantee that it's on top of other chatlines
    _boundingRect(0, 0, 400, 300)
{
    qreal frameWidth = 5;

    QWebView *webView = new QWebView;
    webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
    webView->load(url);
    webView->setDisabled(true);
    webView->resize(1000, 750);
    QGraphicsProxyWidget *proxyItem = new QGraphicsProxyWidget(this);
    proxyItem->setWidget(webView);
    proxyItem->setAcceptHoverEvents(false);

    qreal xScale = (_boundingRect.width() - 2 * frameWidth) / webView->width();
    qreal yScale = (_boundingRect.height() - 2 * frameWidth) / webView->height();
    proxyItem->setTransform(QTransform::fromScale(xScale, yScale), true);
    proxyItem->setPos(frameWidth, frameWidth);

    setZValue(30);
}
示例#17
0
	// Move Action
	ThymioMoveAction::ThymioMoveAction( QGraphicsItem *parent ) :
		ThymioButton(false, 0.2, false, false, parent)
	{
		setData(0, "action");
		setData(1, "move");

		QTransform transMatrix(2.0,0.0,0.0,0.0,2.3,0.0,0.0,0.0,1.0);
				
		for(int i=0; i<2; i++)
		{
			QSlider *s = new QSlider(Qt::Vertical);
			s->setRange(-500,500);
			s->setStyleSheet("QSlider::groove:vertical { width: 14px; border: 2px solid #000000; "
							  "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #00FF00, stop:0.25 #FFFF00, stop:0.5 #FF0000, stop:0.75 #FFFF00, stop:1 #00FF00 ); }"
						      "QSlider::handle:vertical { "
						      "background: #FFFFFF; "
						      "border: 2px solid #000000; height: 10px; width: 20px; margin: 0px 0; }");
			s->setSliderPosition(0);

			QGraphicsProxyWidget *w = new QGraphicsProxyWidget(this);
			w->setWidget(s);
			w->setPos(10+i*200, 15);
			w->setTransform(transMatrix);
			
			sliders.push_back(s);
			widgets.push_back(w);
			
			connect(s, SIGNAL(valueChanged(int)), this, SLOT(valueChangeDetected()));
			connect(s, SIGNAL(valueChanged(int)), this, SLOT(updateIRButton()));
		}		

		timer = new QTimeLine(2000);
		timer->setFrameRange(0, 100);
		timer->setCurveShape(QTimeLine::LinearCurve);
		animation = new QGraphicsItemAnimation(this);
		animation->setItem(thymioBody);
		animation->setTimeLine(timer);				
		thymioBody->setTransformOriginPoint(0,-14);//(pt[1]+pt[0]) == 0 ? 0 : (abs(pt[1])-abs(pt[0]))/(abs(pt[1])+abs(pt[0]))*22.2,-25);
	}
示例#18
0
文件: Dial.cpp 项目: Archie3d/qmusic
QGraphicsItem* Dial::graphicsItem()
{
    if (m_pDial == nullptr) {
        m_pDial = new QDial();
        QObject::connect(m_pDial, &QDial::valueChanged, [this](int pos) {
            onDialValueChanged(pos);
        });

        QRect r = m_pDial->geometry();
        r.setWidth(cDefaultSize);
        r.setHeight(cDefaultSize);
        m_pDial->setGeometry(r);
        m_pDial->setNotchesVisible(true);
        m_pDial->setWrapping(false);
        updateDialValues();
    }

    QGraphicsProxyWidget *pWidgetItem = new QGraphicsProxyWidget();
    pWidgetItem->setWidget(m_pDial);

    return pWidgetItem;
}
示例#19
0
void MenuManager::init(MainWindow *window)
{
    this->window = window;

    // Create div:
//    this->createTicker();
//    this->createUpnDownButtons();
//    this->createBackButton();

    this->bar = new TestBar(QSize(0,0),this->window->scene,0,QColor(0,0,0,200));
    QPushButton *testbtn = new QPushButton();
    testbtn->setText("xxxxx");
    QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this->bar);
    proxy->setWidget(testbtn);
    testbtn->setGeometry(10,10,50,50);

    // Create first level menu:
    QDomElement rootElement = this->contentsDoc->documentElement();
    this->createRootMenu(rootElement);

    // Create second level menus:
//    QDomNode level2MenuNode = rootElement.firstChild();
//    while (!level2MenuNode.isNull()){
//        QDomElement level2MenuElement = level2MenuNode.toElement();
//        this->createSubMenu(level2MenuElement);
//
//        // create leaf menu and example info:
//        QDomNode exampleNode = level2MenuElement.firstChild();
//        while (!exampleNode.isNull()){
//            QDomElement exampleElement = exampleNode.toElement();
//            this->readInfoAboutExample(exampleElement);
////            this->createLeafMenu(exampleElement);
//            exampleNode = exampleNode.nextSibling();
//        }
//
//        level2MenuNode = level2MenuNode.nextSibling();
//    }
}
void StartScene::switchToServer(Server *server) {
    // performs leaving animation
    QPropertyAnimation *logo_shift = new QPropertyAnimation(logo, "pos", this);
    QPropertyAnimation *logo_shrink = new QPropertyAnimation(logo, "scale", this);
    logo_shrink->setEndValue(0.5);

    QParallelAnimationGroup *group = new QParallelAnimationGroup(this);
    group->addAnimation(logo_shift);
    group->addAnimation(logo_shrink);
    group->start(QAbstractAnimation::DeleteWhenStopped);

    foreach (Button *button, buttons)
        delete button;
    buttons.clear();

    server_log = new QTextEdit();
    server_log->setReadOnly(true);
    server_log->resize(700, 420);
    QRectF startSceneRect = sceneRect();
    server_log->move(startSceneRect.width() / 2 - server_log->width() / 2,
        startSceneRect.height() / 2 - server_log->height() / 2 + logo->boundingRect().height() / 4);
    server_log->setFrameShape(QFrame::NoFrame);
    server_log->setFont(QFont("Verdana", 12));
    server_log->setTextColor(Config.TextEditColor);
    setServerLogBackground();
    QGraphicsProxyWidget *widget = addWidget(server_log);
    widget->setParent(this);

    QScrollBar *logBoxVScrollBar = server_log->verticalScrollBar();
    if (NULL != logBoxVScrollBar) {
        logBoxVScrollBar->setObjectName("sgsVSB");
        logBoxVScrollBar->setStyleSheet(Settings::getQSSFileContent());
    }

    printServerInfo();
    connect(server, SIGNAL(server_message(QString)), server_log, SLOT(append(QString)));
    update();
}
示例#21
0
	// Color Action
	ThymioColorAction::ThymioColorAction( QGraphicsItem *parent ) :
		ThymioButton(false, 1.0, true, false, parent)
	{
		setData(0, "action");
		setData(1, "color");

		QTransform transMatrix(1.0,0.0,0.0,0.0,2.0,0.0,0.0,0.0,1.0);
		QString sliderColor("FF0000");
		
		for(int i=0; i<3; i++)
		{
			if( i == 1 ) sliderColor="00FF00";
			else if( i == 2 ) sliderColor="0000FF";

			QSlider *s = new QSlider(Qt::Horizontal);
			s->setRange(0,32);
			s->setStyleSheet(QString("QSlider::groove:horizontal { height: 14px; border: 2px solid #000000; "
							  "background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #000000, stop:1 #%0); }"
						      "QSlider::handle:horizontal { "
						      "background: #FFFFFF; "
						      "border: 5px solid #000000; width: 18px; margin: -2px 0; }").arg(sliderColor));
			s->setSliderPosition(0);

			QGraphicsProxyWidget *w = new QGraphicsProxyWidget(this);
			w->setWidget(s);
			w->setPos(27, 70+i*60);
			w->setTransform(transMatrix);
			
			
			sliders.push_back(s);
			widgets.push_back(w);
			
			connect(s, SIGNAL(valueChanged(int)), this, SLOT(valueChangeDetected()));
			connect(s, SIGNAL(valueChanged(int)), this, SLOT(updateIRButton()));
		}

	}
void
RoutingStatsScene::reloadContent(bool force)
{
    if(m_nodeIdProxyWidgets.empty())
    {
        return;
    }

    m_lastX = 0;
    m_lastY = 0;
    m_bottomY = 0;
    qreal currentTime = StatsMode::getInstance()->getCurrentTime();

    qreal currentMaxHeight = 0;
    for(NodeIdProxyWidgetMap_t::const_iterator i = m_nodeIdProxyWidgets.begin();
        i != m_nodeIdProxyWidgets.end();
        ++i)
    {
        QGraphicsProxyWidget * pw = i->second;

        if((force) || (!m_lastTime) || (m_lastTime != currentTime))
        {
            updateContent(i->first, pw);
        }


        bool nodeIsActive = StatsMode::getInstance()->isNodeActive(i->first);
        pw->setVisible(nodeIsActive);
        if(nodeIsActive)
        {
            qreal newX = m_lastX + pw->size().width();
            currentMaxHeight = qMax(currentMaxHeight, pw->size().height());
            if(newX >= sceneRect().right())
            {
                m_lastX = 0;
                m_lastY += currentMaxHeight + INTERSTATS_SPACE;
                currentMaxHeight = 0;
            }
            pw->setPos(m_lastX, m_lastY);
            m_lastX = pw->pos().x() + pw->size().width() + INTERSTATS_SPACE;
            m_lastY = pw->pos().y();
            m_bottomY = m_lastY + currentMaxHeight;
            adjustRect();
        }

    }

    m_lastTime = currentTime;


}
示例#23
0
OverlayEditor::OverlayEditor(QWidget *p, QGraphicsItem *qgi, OverlaySettings *osptr) :
		QDialog(p),
		qgiPromote(qgi),
		oes(g.s.os) {
	setupUi(this);

	os = osptr ? osptr : &g.s.os;

	connect(qdbbBox->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply()));
	connect(qdbbBox->button(QDialogButtonBox::Reset), SIGNAL(clicked()), this, SLOT(reset()));

	QGraphicsProxyWidget *qgpw = graphicsProxyWidget();
	if (qgpw) {
		qgpw->setFlag(QGraphicsItem::ItemIgnoresParentOpacity);
		if (g.ocIntercept) {
			qgpw->setPos(iroundf(g.ocIntercept->uiWidth / 16.0f + 0.5f), iroundf(g.ocIntercept->uiHeight / 16.0f + 0.5f));
			qgpw->resize(iroundf(g.ocIntercept->uiWidth * 14.0f / 16.0f + 0.5f), iroundf(g.ocIntercept->uiHeight * 14.0f / 16.0f + 0.5f));
		}
	}

	qgvView->setScene(&oes);

	reset();
}
示例#24
0
void ImageView::setGifAnimation(QString fileName) {
  /* the built-in gif reader gives the first frame, which won't
     be shown but is used for tracking position and dimensions */
  image_ = QImage(fileName);
  if(image_.isNull()) {
    if(imageItem_) {
      imageItem_->hide();
      imageItem_->setBrush(QBrush());
    }
    scene_->setSceneRect(0, 0, 0, 0);
  }
  else {
    scene_->clear();
    imageItem_ = nullptr; // it's deleted by clear();
    if(gifMovie_) {
      delete gifMovie_;
      gifMovie_ = nullptr;
    }
    QPixmap pix(image_.size());
    pix.fill(Qt::transparent);
    QGraphicsItem *gifItem = new QGraphicsPixmapItem(pix);
    QLabel *gifLabel = new QLabel();
    gifMovie_ = new QMovie(fileName);
    QGraphicsProxyWidget* gifWidget = new QGraphicsProxyWidget(gifItem);
    gifLabel->setAttribute(Qt::WA_NoSystemBackground);
    gifLabel->setMovie(gifMovie_);
    gifWidget->setWidget(gifLabel);
    gifMovie_->start();
    scene_->addItem(gifItem);
    scene_->setSceneRect(gifItem->boundingRect());
  }

  if(autoZoomFit_)
    zoomFit();
  queueGenerateCache(); // deletes the cache timer in this case
}
示例#25
0
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, const QList<ServerInfo_Card *> &cardList)
	: QGraphicsWidget(0, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint/* | Qt::WindowCloseButtonHint*/), player(_player)
{
	setAttribute(Qt::WA_DeleteOnClose);
	setZValue(2000000006);
	
	QFont font;
	font.setPixelSize(10);
	setFont(font);

	QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
	
	if (numberCards < 0) {
		sortByNameCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
		sortByNameProxy->setWidget(sortByNameCheckBox);
		vbox->addItem(sortByNameProxy);

		sortByTypeCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
		sortByTypeProxy->setWidget(sortByTypeCheckBox);
		vbox->addItem(sortByTypeProxy);
	} else {
		sortByNameCheckBox = 0;
		sortByTypeCheckBox = 0;
	}
	
	if (_origZone->getIsShufflable() && (numberCards == -1)) {
		shuffleCheckBox = new QCheckBox;
		shuffleCheckBox->setChecked(true);
		QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
		shuffleProxy->setWidget(shuffleCheckBox);
		vbox->addItem(shuffleProxy);
	} else
		shuffleCheckBox = 0;
	
	extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
	resize(150, 150);

	zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, this);
	connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
	connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
	vbox->addItem(zone);
	zone->initializeCards(cardList);
	
	if (sortByNameCheckBox) {
		connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int)));
		connect(sortByTypeCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByType(int)));
		sortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName());
		sortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType());
	}

	setLayout(vbox);
	retranslateUi();
}
示例#26
0
static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
                                   const QSizeF &preferred = QSize(150.0, 100.0),
                                   const QSizeF &maximum = QSizeF(200.0, 100.0),
                                   const QString &name = "0")
{
    QGraphicsProxyWidget *w = new QGraphicsProxyWidget;
    w->setWidget(new QPushButton(name));
    w->setData(0, name);
    w->setMinimumSize(minimum);
    w->setPreferredSize(preferred);
    w->setMaximumSize(maximum);

    w->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    return w;
}
示例#27
0
ArtistWidget::ArtistWidget( const SimilarArtistPtr &artist,
                            QGraphicsWidget *parent, Qt::WindowFlags wFlags )
    : QGraphicsWidget( parent, wFlags )
    , m_artist( artist )
{
    setAttribute( Qt::WA_NoSystemBackground, true );

    m_image = new QLabel;
    m_image->setAttribute( Qt::WA_NoSystemBackground, true );
    m_image->setFixedSize( 128, 128 );
    m_image->setCursor( Qt::PointingHandCursor );
    QGraphicsProxyWidget *imageProxy = new QGraphicsProxyWidget( this );
    imageProxy->setWidget( m_image );
    m_image->installEventFilter( this );

    m_nameLabel = new QLabel;
    m_match     = new QLabel;
    m_tagsLabel = new QLabel;
    m_topTrackLabel = new QLabel;
    m_bio = new QGraphicsWidget( this );

    QGraphicsProxyWidget *nameProxy     = new QGraphicsProxyWidget( this );
    QGraphicsProxyWidget *matchProxy    = new QGraphicsProxyWidget( this );
    QGraphicsProxyWidget *topTrackProxy = new QGraphicsProxyWidget( this );
    QGraphicsProxyWidget *tagsProxy     = new QGraphicsProxyWidget( this );
    nameProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    matchProxy->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
    topTrackProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    tagsProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    imageProxy->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );

    nameProxy->setWidget( m_nameLabel );
    matchProxy->setWidget( m_match );
    topTrackProxy->setWidget( m_topTrackLabel );
    tagsProxy->setWidget( m_tagsLabel );

    m_nameLabel->setAttribute( Qt::WA_NoSystemBackground );
    m_match->setAttribute( Qt::WA_NoSystemBackground );
    m_topTrackLabel->setAttribute( Qt::WA_NoSystemBackground );
    m_tagsLabel->setAttribute( Qt::WA_NoSystemBackground );

    m_image->setAlignment( Qt::AlignCenter );
    m_match->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
    m_nameLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
    m_topTrackLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );
    m_tagsLabel->setAlignment( Qt::AlignLeft | Qt::AlignVCenter );

    m_nameLabel->setWordWrap( false );
    m_match->setWordWrap( false );
    m_topTrackLabel->setWordWrap( false );
    m_tagsLabel->setWordWrap( false );

    m_match->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    m_topTrackLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    m_match->setMinimumWidth( 10 );
    m_topTrackLabel->setMinimumWidth( 10 );
    m_nameLabel->setMinimumWidth( 10 );
    m_tagsLabel->setMinimumWidth( 10 );

    QFontMetricsF fm( font() );
    m_bio->setMinimumHeight( fm.lineSpacing() * 5 );
    m_bio->setMaximumHeight( fm.lineSpacing() * 5 );
    m_bio->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
    m_bioLayout.setCacheEnabled( true );

    QFont artistFont;
    artistFont.setPointSize( artistFont.pointSize() + 2 );
    artistFont.setBold( true );
    m_nameLabel->setFont( artistFont );
    m_topTrackLabel->setFont( KGlobalSettings::smallestReadableFont() );
    m_tagsLabel->setFont( KGlobalSettings::smallestReadableFont() );
    m_match->setFont( KGlobalSettings::smallestReadableFont() );

    m_navigateButton = new Plasma::PushButton( this );
    m_navigateButton->setMaximumSize( QSizeF( 22, 22 ) );
    m_navigateButton->setIcon( KIcon( "edit-find" ) );
    m_navigateButton->setToolTip( i18n( "Show in Media Sources" ) );
    connect( m_navigateButton, SIGNAL(clicked()), this, SLOT(navigateToArtist()) );
    
    m_lastfmStationButton = new Plasma::PushButton( this );
    m_lastfmStationButton->setMaximumSize( QSizeF( 22, 22 ) );
    m_lastfmStationButton->setIcon( KIcon("view-services-lastfm-amarok") );
    m_lastfmStationButton->setToolTip( i18n( "Add Last.fm artist station to the Playlist" ) );
    connect( m_lastfmStationButton, SIGNAL(clicked()), this, SLOT(addLastfmArtistStation()) );

    m_topTrackButton = new Plasma::PushButton( this );
    m_topTrackButton->setMaximumSize( QSizeF( 22, 22 ) );
    m_topTrackButton->setIcon( KIcon( "media-track-add-amarok" ) );
    m_topTrackButton->setToolTip( i18n( "Add top track to the Playlist" ) );
    m_topTrackButton->hide();
    connect( m_topTrackButton, SIGNAL(clicked()), this, SLOT(addTopTrackToPlaylist()) );

    m_similarArtistButton = new Plasma::PushButton( this );
    m_similarArtistButton->setMaximumSize( QSizeF( 22, 22 ) );
    m_similarArtistButton->setIcon( KIcon( "similarartists-amarok" ) );
    m_similarArtistButton->setToolTip( i18n( "Show Similar Artists of %1", m_artist->name() ) );
    connect( m_similarArtistButton, SIGNAL(clicked()), this, SIGNAL(showSimilarArtists()) );

    QGraphicsLinearLayout *buttonsLayout = new QGraphicsLinearLayout( Qt::Horizontal );
    buttonsLayout->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
    buttonsLayout->addItem( m_topTrackButton );
    buttonsLayout->addItem( m_navigateButton );
    buttonsLayout->addItem( m_lastfmStationButton );

    QString artistUrl = m_artist->url().url();
    if( !artistUrl.isEmpty() )
    {
        m_urlButton = new Plasma::PushButton( this );
        m_urlButton->setMaximumSize( QSizeF( 22, 22 ) );
        m_urlButton->setIcon( KIcon("applications-internet") );
        m_urlButton->setToolTip( i18n( "Open Last.fm webpage for this artist" ) );
        connect( m_urlButton, SIGNAL(clicked()), this, SLOT(openArtistUrl()) );
        buttonsLayout->addItem( m_urlButton );
    }

    buttonsLayout->addItem( m_similarArtistButton );

    // the image display is extended on two row
    m_layout = new QGraphicsGridLayout( this );
    m_layout->addItem( imageProxy, 0, 0, 4, 1 );
    m_layout->addItem( nameProxy, 0, 1 );
    m_layout->addItem( buttonsLayout, 0, 2, Qt::AlignRight );
    m_layout->addItem( topTrackProxy, 1, 1 );
    m_layout->addItem( matchProxy, 1, 2, Qt::AlignRight );
    m_layout->addItem( tagsProxy, 2, 1, 1, 2 );
    m_layout->addItem( m_bio, 3, 1, 1, 2 );

    m_match->setText( i18n( "Match: %1%", QString::number( m_artist->match() ) ) );
    m_nameLabel->setText( m_artist->name() );

    QTimer::singleShot( 0, this, SLOT(updateInfo()) );
}
示例#28
0
int main(int argc, char **argv)
{
    // Qt requires that we construct the global QApplication before creating any widgets.
    QApplication app(argc, argv);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // true = run osgViewer in a separate thread than Qt
    // false = interleave osgViewer and Qt in the main thread
    bool useFrameLoopThread = false;
    if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
    if (arguments.read("--frame-thread")) useFrameLoopThread = true;

    // true = use QWidgetImage
    // false = use QWebViewImage
    bool useWidgetImage = false;
    if (arguments.read("--useWidgetImage")) useWidgetImage = true;

    // true = use QWebView in a QWidgetImage to compare to QWebViewImage
    // false = make an interesting widget
    bool useBrowser = false;
    if (arguments.read("--useBrowser")) useBrowser = true;

    // true = use a QLabel for text
    // false = use a QTextEdit for text
    // (only applies if useWidgetImage == true and useBrowser == false)
    bool useLabel = false;
    if (arguments.read("--useLabel")) useLabel = true;

    // true = make a Qt window with the same content to compare to
    // QWebViewImage/QWidgetImage
    // false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
    bool sanityCheck = false;
    if (arguments.read("--sanityCheck")) sanityCheck = true;

    // Add n floating windows inside the QGraphicsScene.
    int numFloatingWindows = 0;
    while (arguments.read("--numFloatingWindows", numFloatingWindows));

    // true = Qt widgets will be displayed on a quad inside the 3D scene
    // false = Qt widgets will be an overlay over the scene (like a HUD)
    bool inScene = true;
    if (arguments.read("--fullscreen")) { inScene = false; }


    osg::ref_ptr<osg::Group> root = new osg::Group;

    if (!useWidgetImage)
    {
        //-------------------------------------------------------------------
        // QWebViewImage test
        //-------------------------------------------------------------------
        // Note: When the last few issues with QWidgetImage are fixed,
        // QWebViewImage and this if() {} section can be removed since
        // QWidgetImage can display a QWebView just like QWebViewImage. Use
        // --useWidgetImage --useBrowser to see that in action.

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

            if (arguments.argc()>1) image->navigateTo((arguments[1]));
            else image->navigateTo("http://www.openscenegraph.org/");

            osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
                                           osg::Vec3(1.0f,0.0f,0.0f),
                                           osg::Vec3(0.0f,0.0f,1.0f),
                                           osg::Vec4(1.0f,1.0f,1.0f,1.0f),
                                           osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

            osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
            browser->assign(image.get(), hints);

            root->addChild(browser.get());
        }
        else
        {
            // Sanity check, do the same thing as QGraphicsViewAdapter but in
            // a separate Qt window.
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.openscenegraph.org/"));

            QGraphicsScene* graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(webView);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            //mainWindow->setLayout(new QVBoxLayout);
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }
    }
    else
    {
        //-------------------------------------------------------------------
        // QWidgetImage test
        //-------------------------------------------------------------------
        // QWidgetImage still has some issues, some examples are:
        //
        // 1. Editing in the QTextEdit doesn't work. Also when started with
        //    --useBrowser, editing in the search field on YouTube doesn't
        //    work. But that same search field when using QWebViewImage
        //    works... And editing in the text field in the pop-up getInteger
        //    dialog works too. All these cases use QGraphicsViewAdapter
        //    under the hood, so why do some work and others don't?
        //
        //    <<< FIXED, need TextEditorInteraction >>>
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen] (optional)
        //    b) Try to click in the QTextEdit and type, or to select text
        //       and drag-and-drop it somewhere else in the QTextEdit. These
        //       don't work.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operations in b), they all work.
        //    e) osgQtBrowser --useWidgetImage --useBrowser [--fullscreen]
        //    f) Try to click in the search field and type, it doesn't work.
        //    g) osgQtBrowser
        //    h) Try the operation in f), it works.
        //
        // 2. Operations on floating windows (--numFloatingWindows 1 or more).
        //    Moving by dragging the titlebar, clicking the close button,
        //    resizing them, none of these work. I wonder if it's because the
        //    OS manages those functions (they're functions of the window
        //    decorations) so we need to do something special for that? But
        //    in --sanityCheck mode they work.
        //
        //    a) osgQtBrowser --useWidgetImage --numFloatingWindows 1 [--fullscreen]
        //    b) Try to drag the floating window, click the close button, or
        //       drag its sides to resize it. None of these work.
        //    c) osgQtBrowser --useWidgetImage --numFloatingWindows 1 --sanityCheck
        //    d) Try the operations in b), all they work.
        //    e) osgQtBrowser --useWidgetImage [--fullscreen]
        //    f) Click the button so that the getInteger() dialog is
        //       displayed, then try to move that dialog or close it with the
        //       close button, these don't work.
        //    g) osgQtBrowser --useWidgetImage --sanityCheck
        //    h) Try the operation in f), it works.
        //
        // 3. (Minor) The QGraphicsView's scrollbars don't appear when
        //    using QWidgetImage or QWebViewImage. QGraphicsView is a
        //    QAbstractScrollArea and it should display scrollbars as soon as
        //    the scene is too large to fit the view.
        //
        //    <<< FIXED >>>
        //
        //    a) osgQtBrowser --useWidgetImage --fullscreen
        //    b) Resize the OSG window so it's smaller than the QTextEdit.
        //       Scrollbars should appear but don't.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operation in b), scrollbars appear. Even if you have
        //       floating windows (by clicking the button or by adding
        //       --numFloatingWindows 1) and move them outside the view,
        //       scrollbars appear too. You can't test that case in OSG for
        //       now because of problem 2 above, but that's pretty cool.
        //
        // 4. (Minor) In sanity check mode, the widget added to the
        //    QGraphicsView is centered. With QGraphicsViewAdapter, it is not.
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen]
        //    b) The QTextEdit and button are not in the center of the image
        //       generated by the QGraphicsViewAdapter.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) The QTextEdit and button are in the center of the
        //       QGraphicsView.


        QWidget* widget = 0;
        if (useBrowser)
        {
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            widget = webView;
        }
        else
        {
            widget = new QWidget;
            widget->setLayout(new QVBoxLayout);

            QString text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit turpis, euismod ac ultrices et, molestie non nisi. Nullam egestas dignissim enim, quis placerat nulla suscipit sed. Donec molestie elementum risus sit amet sodales. Nunc consectetur congue neque, at viverra massa pharetra fringilla. Integer vitae mi sem. Donec dapibus semper elit nec sollicitudin. Vivamus egestas ultricies felis, in mollis mi facilisis quis. Nam suscipit bibendum eros sed cursus. Suspendisse mollis suscipit hendrerit. Etiam magna eros, convallis non congue vel, faucibus ac augue. Integer ante ante, porta in ornare ullamcorper, congue nec nibh. Etiam congue enim vitae enim sollicitudin fringilla. Mauris mattis, urna in fringilla dapibus, ipsum sem feugiat purus, ac hendrerit felis arcu sed sapien. Integer id velit quam, sit amet dignissim tortor. Sed mi tortor, placerat ac luctus id, tincidunt et urna. Nulla sed nunc ante.Sed ut sodales enim. Ut sollicitudin ultricies magna, vel ultricies ante venenatis id. Cras luctus mi in lectus rhoncus malesuada. Sed ac sollicitudin nisi. Nunc venenatis congue quam, et suscipit diam consectetur id. Donec vel enim ac enim elementum bibendum ut quis augue. Nulla posuere suscipit dolor, id convallis tortor congue eu. Vivamus sagittis consectetur dictum. Duis a ante quis dui varius fermentum. In hac habitasse platea dictumst. Nam dapibus dolor eu felis eleifend in scelerisque dolor ultrices. Donec arcu lectus, fringilla ut interdum non, tristique id dolor. Morbi sagittis sagittis volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis venenatis ultrices euismod.Nam sit amet convallis libero. Integer lectus urna, eleifend et sollicitudin non, porttitor vel erat. Vestibulum pulvinar egestas leo, a porttitor turpis ullamcorper et. Vestibulum in ornare turpis. Ut nec libero a sem mattis iaculis quis id purus. Praesent ante neque, dictum vitae pretium vel, iaculis luctus dui. Etiam luctus tellus vel nunc suscipit a ullamcorper nisl semper. Nunc dapibus, eros in sodales dignissim, orci lectus egestas felis, sit amet vehicula tortor dolor eu quam. Vivamus pellentesque convallis quam aliquet pellentesque. Phasellus facilisis arcu ac orci fringilla aliquet. Donec sed euismod augue. Duis eget orci sit amet neque tempor fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Duis sollicitudin, lacus ac pellentesque lacinia, lacus magna pulvinar purus, pulvinar porttitor est nibh quis augue.Duis eleifend, massa sit amet mattis fringilla, elit turpis venenatis libero, sed convallis turpis diam sit amet ligula. Morbi non dictum turpis. Integer porttitor condimentum elit, sit amet sagittis nibh ultrices sit amet. Mauris ac arcu augue, id aliquet mauris. Donec ultricies urna id enim accumsan at pharetra dui adipiscing. Nunc luctus rutrum molestie. Curabitur libero ipsum, viverra at pulvinar ut, porttitor et neque. Aliquam sit amet dolor et purus sagittis adipiscing. Nam sit amet hendrerit sem. Etiam varius, ligula non ultricies dignissim, sapien dui commodo urna, eu vehicula enim nunc molestie augue. Fusce euismod, erat vitae pharetra tempor, quam eros tincidunt lorem, ut iaculis ligula erat vitae nibh. Aenean eu ultricies dolor. Curabitur suscipit viverra bibendum.Sed egestas adipiscing mi in egestas. Proin in neque in nibh blandit consequat nec quis tortor. Vestibulum sed interdum justo. Sed volutpat velit vitae elit pulvinar aliquam egestas elit rutrum. Proin lorem nibh, bibendum vitae sollicitudin condimentum, pulvinar ut turpis. Maecenas iaculis, mauris in consequat ultrices, ante erat blandit mi, vel fermentum lorem turpis eget sem. Integer ultrices tristique erat sit amet volutpat. In sit amet diam et nunc congue pellentesque at in dolor. Mauris eget orci orci. Integer posuere augue ornare tortor tempus elementum. Quisque iaculis, nunc ac cursus fringilla, magna elit cursus eros, id feugiat diam eros et tellus. Etiam consectetur ultrices erat quis rhoncus. Mauris eu lacinia neque. Curabitur suscipit feugiat tellus in dictum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed aliquam tempus ante a tempor. Praesent viverra erat quis sapien pretium rutrum. Praesent dictum scelerisque venenatis.Proin bibendum lectus eget nisl lacinia porta. Morbi eu erat in sapien malesuada vulputate. Cras non elit quam. Ut dictum urna quis nisl feugiat ac sollicitudin libero luctus. Donec leo mauris, varius at luctus eget, placerat quis arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam tristique, mauris ut lacinia elementum, mauris erat consequat massa, ac gravida nisi tellus vitae purus. Curabitur consectetur ultricies commodo. Cras pulvinar orci nec enim adipiscing tristique. Ut ornare orci id est fringilla sit amet blandit libero pellentesque. Vestibulum tincidunt sapien ut enim venenatis vestibulum ultricies ipsum tristique. Mauris tempus eleifend varius. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vitae dui ac quam gravida semper. In ac enim ac ligula rutrum porttitor.Integer dictum sagittis leo, at convallis sapien facilisis eget. Etiam cursus bibendum tortor, faucibus aliquam lectus ullamcorper sed. Nulla pulvinar posuere quam, ut sagittis ligula tincidunt ut. Nulla convallis velit ut enim condimentum pulvinar. Quisque gravida accumsan scelerisque. Proin pellentesque nisi cursus tortor aliquet dapibus. Duis vel eros orci. Sed eget purus ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ullamcorper porta congue. Nunc id velit ut neque malesuada consequat in eu nisi. Nulla facilisi. Quisque pellentesque magna vitae nisl euismod ac accumsan tellus feugiat.Nulla facilisi. Integer quis orci lectus, non aliquam nisi. Vivamus varius porta est, ac porttitor orci blandit mattis. Sed dapibus facilisis dapibus. Duis tincidunt leo ac tortor faucibus hendrerit. Morbi sit amet sapien risus, vel luctus enim. Aliquam sagittis nunc id purus aliquam lobortis. Duis posuere viverra dui, sit amet convallis sem vulputate at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque, lectus id imperdiet commodo, diam diam faucibus lectus, sit amet vestibulum tortor lacus viverra eros.Maecenas nec augue lectus. Duis nec arcu eget lorem tempus sollicitudin suscipit vitae arcu. Nullam vitae mauris lectus. Vivamus id risus neque, dignissim vehicula diam. Cras rhoncus velit sed velit iaculis ac dignissim turpis luctus. Suspendisse potenti. Sed vitae ligula a ligula ornare rutrum sit amet ut quam. Duis tincidunt, nibh vitae iaculis adipiscing, dolor orci cursus arcu, vel congue tortor quam eget arcu. Suspendisse tellus felis, blandit ac accumsan vitae, fringilla id lorem. Duis tempor lorem mollis est congue ut imperdiet velit laoreet. Nullam interdum cursus mollis. Pellentesque non mauris accumsan elit laoreet viverra ut at risus. Proin rutrum sollicitudin sem, vitae ultricies augue sagittis vel. Cras quis vehicula neque. Aliquam erat volutpat. Aliquam erat volutpat. Praesent non est erat, accumsan rutrum lacus. Pellentesque tristique molestie aliquet. Cras ullamcorper facilisis faucibus. In non lorem quis velit lobortis pulvinar.Phasellus non sem ipsum. Praesent ut libero quis turpis viverra semper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Donec at velit tellus. Fusce commodo pharetra tincidunt. Proin lacus enim, fringilla a fermentum ut, vestibulum ut nibh. Duis commodo dolor vel felis vehicula at egestas neque bibendum. Phasellus malesuada dictum ante in aliquam. Curabitur interdum semper urna, nec placerat justo gravida in. Praesent quis mauris massa. Pellentesque porttitor lacinia tincidunt. Phasellus egestas viverra elit vel blandit. Sed dapibus nisi et lectus pharetra dignissim. Mauris hendrerit lectus nec purus dapibus condimentum. Sed ac eros nulla. Aenean semper sapien a nibh aliquam lobortis. Aliquam elementum euismod sapien, in dapibus leo dictum et. Pellentesque augue neque, ultricies non viverra eu, tincidunt ac arcu. Morbi ut porttitor lectus.");

            if (useLabel)
            {
                QLabel* label = new QLabel(text);
                label->setWordWrap(true);
                label->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = label->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                label->setPalette(palette);

                QScrollArea* scrollArea = new QScrollArea;
                scrollArea->setWidget(label);

                widget->layout()->addWidget(scrollArea);
            }
            else
            {
                QTextEdit* textEdit = new QTextEdit(text);
                textEdit->setReadOnly(false);
                textEdit->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = textEdit->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                textEdit->setPalette(palette);

                widget->layout()->addWidget(textEdit);
            }

            QPushButton* button = new MyPushButton("Button");
            widget->layout()->addWidget(button);

            widget->setGeometry(0, 0, 800, 600);
        }

        QGraphicsScene* graphicsScene = 0;

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new osgQt::QWidgetImage(widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
            widgetImage->getQWidget()->setAttribute(Qt::WA_TranslucentBackground);
#endif
            widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0, 0, 0, 0));
            //widgetImage->getQGraphicsViewAdapter()->resize(800, 600);
            graphicsScene = widgetImage->getQGraphicsViewAdapter()->getQGraphicsScene();

            osg::Camera* camera = 0;        // Will stay NULL in the inScene case.
            osg::Geometry* quad = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0), osg::Vec3(1,0,0), osg::Vec3(0,1,0), 1, 1);
            osg::Geode* geode = new osg::Geode;
            geode->addDrawable(quad);

            osg::MatrixTransform* mt = new osg::MatrixTransform;

            osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
            texture->setResizeNonPowerOfTwoHint(false);
            texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
            texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
            texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
            mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);

            osgViewer::InteractiveImageHandler* handler;
            if (inScene)
            {
                mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
                mt->addChild(geode);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get());
            }
            else    // fullscreen
            {
                // The HUD camera's viewport needs to follow the size of the
                // window. MyInteractiveImageHandler will make sure of this.
                // As for the quad and the camera's projection, setting the
                // projection resize policy to FIXED takes care of them, so
                // they can stay the same: (0,1,0,1) with a quad that fits.

                // Set the HUD camera's projection and viewport to match the screen.
                camera = new osg::Camera;
                camera->setProjectionResizePolicy(osg::Camera::FIXED);
                camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
                camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
                camera->setViewMatrix(osg::Matrix::identity());
                camera->setClearMask(GL_DEPTH_BUFFER_BIT);
                camera->setRenderOrder(osg::Camera::POST_RENDER);
                camera->addChild(geode);
                camera->setViewport(0, 0, 1024, 768);

                mt->addChild(camera);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
            }

            mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
            mt->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
            mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            mt->getOrCreateStateSet()->setAttribute(new osg::Program);

            osg::Group* overlay = new osg::Group;
            overlay->addChild(mt);

            root->addChild(overlay);

            quad->setEventCallback(handler);
            quad->setCullCallback(handler);
        }
        else
        {
            // Sanity check, do the same thing as QWidgetImage and
            // QGraphicsViewAdapter but in a separate Qt window.

            graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(widget);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }

        // Add numFloatingWindows windows to the graphicsScene.
        for (unsigned int i = 0; i < (unsigned int)numFloatingWindows; ++i)
        {
            QWidget* window = new QWidget(0, Qt::Window);
            window->setWindowTitle(QString("Window %1").arg(i));
            window->setLayout(new QVBoxLayout);
            window->layout()->addWidget(new QLabel(QString("This window %1").arg(i)));
            window->layout()->addWidget(new MyPushButton(QString("Button in window %1").arg(i)));
            window->setGeometry(100, 100, 300, 300);

            QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window);
            proxy->setWidget(window);
            proxy->setFlag(QGraphicsItem::ItemIsMovable, true);

            graphicsScene->addItem(proxy);
        }

    }

    root->addChild(osgDB::readNodeFile("cow.osg.(15,0,5).trans.(0.1,0.1,0.1).scale"));

    osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(arguments);
    viewer->setSceneData(root.get());
    viewer->setCameraManipulator(new osgGA::TrackballManipulator());
    viewer->addEventHandler(new osgGA::StateSetManipulator(root->getOrCreateStateSet()));
    viewer->addEventHandler(new osgViewer::StatsHandler);
    viewer->addEventHandler(new osgViewer::WindowSizeHandler);

    viewer->setUpViewInWindow(50, 50, 1024, 768);
    viewer->getEventQueue()->windowResize(0, 0, 1024, 768);

    if (useFrameLoopThread)
    {
        // create a thread to run the viewer's frame loop
        ViewerFrameThread viewerThread(viewer.get(), true);
        viewerThread.startThread();

        // now start the standard Qt event loop, then exists when the viewerThead sends the QApplication::exit() signal.
        return QApplication::exec();

    }
    else
    {
        // run the frame loop, interleaving Qt and the main OSG frame loop
        while(!viewer->done())
        {
            // process Qt events - this handles both events and paints the browser image
            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

            viewer->frame();
        }

        return 0;
    }
}
示例#29
0
DraggableItemBase::DraggableItemBase()
{
	m_draggableItemWidget = new DraggableItemWidget();
	QGraphicsProxyWidget* pProxyWidget = new QGraphicsProxyWidget(this);
	pProxyWidget->setWidget(m_draggableItemWidget);
}
示例#30
0
//! [0]
PadNavigator::PadNavigator(const QSize &size, QWidget *parent)
    : QGraphicsView(parent)
{
//! [0]
//! [1]
    // Splash item
    SplashItem *splash = new SplashItem;
    splash->setZValue(1);
//! [1]

//! [2]
    // Pad item
    FlippablePad *pad = new FlippablePad(size);
    QGraphicsRotation *flipRotation = new QGraphicsRotation(pad);
    QGraphicsRotation *xRotation = new QGraphicsRotation(pad);
    QGraphicsRotation *yRotation = new QGraphicsRotation(pad);
    flipRotation->setAxis(Qt::YAxis);
    xRotation->setAxis(Qt::YAxis);
    yRotation->setAxis(Qt::XAxis);
    pad->setTransformations(QList<QGraphicsTransform *>()
                            << flipRotation
                            << xRotation << yRotation);
//! [2]

//! [3]
    // Back (proxy widget) item
    QGraphicsProxyWidget *backItem = new QGraphicsProxyWidget(pad);
    QWidget *widget = new QWidget;
    form.setupUi(widget);
    form.hostName->setFocus();
    backItem->setWidget(widget);
    backItem->setVisible(false);
    backItem->setFocus();
    backItem->setCacheMode(QGraphicsItem::ItemCoordinateCache);
    const QRectF r = backItem->rect();
    backItem->setTransform(QTransform()
                           .rotate(180, Qt::YAxis)
                           .translate(-r.width()/2, -r.height()/2));
//! [3]

//! [4]
    // Selection item
    RoundRectItem *selectionItem = new RoundRectItem(QRectF(-60, -60, 120, 120), Qt::gray, pad);
    selectionItem->setZValue(0.5);
//! [4]

//! [5]
    // Splash animations
    QPropertyAnimation *smoothSplashMove = new QPropertyAnimation(splash, "y");
    QPropertyAnimation *smoothSplashOpacity = new QPropertyAnimation(splash, "opacity");
    smoothSplashMove->setEasingCurve(QEasingCurve::InQuad);
    smoothSplashMove->setDuration(250);
    smoothSplashOpacity->setDuration(250);
//! [5]

//! [6]
    // Selection animation
    QPropertyAnimation *smoothXSelection = new QPropertyAnimation(selectionItem, "x");
    QPropertyAnimation *smoothYSelection = new QPropertyAnimation(selectionItem, "y");
    QPropertyAnimation *smoothXRotation = new QPropertyAnimation(xRotation, "angle");
    QPropertyAnimation *smoothYRotation = new QPropertyAnimation(yRotation, "angle");
    smoothXSelection->setDuration(125);
    smoothYSelection->setDuration(125);
    smoothXRotation->setDuration(125);
    smoothYRotation->setDuration(125);
    smoothXSelection->setEasingCurve(QEasingCurve::InOutQuad);
    smoothYSelection->setEasingCurve(QEasingCurve::InOutQuad);
    smoothXRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothYRotation->setEasingCurve(QEasingCurve::InOutQuad);
//! [6]

//! [7]
    // Flip animation setup
    QPropertyAnimation *smoothFlipRotation = new QPropertyAnimation(flipRotation, "angle");
    QPropertyAnimation *smoothFlipScale = new QPropertyAnimation(pad, "scale");
    QPropertyAnimation *smoothFlipXRotation = new QPropertyAnimation(xRotation, "angle");
    QPropertyAnimation *smoothFlipYRotation = new QPropertyAnimation(yRotation, "angle");
    QParallelAnimationGroup *flipAnimation = new QParallelAnimationGroup(this);
    smoothFlipScale->setDuration(500);
    smoothFlipRotation->setDuration(500);
    smoothFlipXRotation->setDuration(500);
    smoothFlipYRotation->setDuration(500);
    smoothFlipScale->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipXRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipYRotation->setEasingCurve(QEasingCurve::InOutQuad);
    smoothFlipScale->setKeyValueAt(0, qvariant_cast<qreal>(1.0));
    smoothFlipScale->setKeyValueAt(0.5, qvariant_cast<qreal>(0.7));
    smoothFlipScale->setKeyValueAt(1, qvariant_cast<qreal>(1.0));
    flipAnimation->addAnimation(smoothFlipRotation);
    flipAnimation->addAnimation(smoothFlipScale);
    flipAnimation->addAnimation(smoothFlipXRotation);
    flipAnimation->addAnimation(smoothFlipYRotation);
//! [7]

//! [8]
    // Flip animation delayed property assignment
    QSequentialAnimationGroup *setVariablesSequence = new QSequentialAnimationGroup;
    QPropertyAnimation *setFillAnimation = new QPropertyAnimation(pad, "fill");
    QPropertyAnimation *setBackItemVisibleAnimation = new QPropertyAnimation(backItem, "visible");
    QPropertyAnimation *setSelectionItemVisibleAnimation = new QPropertyAnimation(selectionItem, "visible");
    setFillAnimation->setDuration(0);
    setBackItemVisibleAnimation->setDuration(0);
    setSelectionItemVisibleAnimation->setDuration(0);
    setVariablesSequence->addPause(250);
    setVariablesSequence->addAnimation(setBackItemVisibleAnimation);
    setVariablesSequence->addAnimation(setSelectionItemVisibleAnimation);
    setVariablesSequence->addAnimation(setFillAnimation);
    flipAnimation->addAnimation(setVariablesSequence);
//! [8]

//! [9]
    // Build the state machine
    QStateMachine *stateMachine = new QStateMachine(this);
    QState *splashState = new QState(stateMachine);
    QState *frontState = new QState(stateMachine);
    QHistoryState *historyState = new QHistoryState(frontState);
    QState *backState = new QState(stateMachine);
//! [9]
//! [10]
    frontState->assignProperty(pad, "fill", false);
    frontState->assignProperty(splash, "opacity", 0.0);
    frontState->assignProperty(backItem, "visible", false);
    frontState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(0.0));
    frontState->assignProperty(selectionItem, "visible", true);
    backState->assignProperty(pad, "fill", true);
    backState->assignProperty(backItem, "visible", true);
    backState->assignProperty(xRotation, "angle", qvariant_cast<qreal>(0.0));
    backState->assignProperty(yRotation, "angle", qvariant_cast<qreal>(0.0));
    backState->assignProperty(flipRotation, "angle", qvariant_cast<qreal>(180.0));
    backState->assignProperty(selectionItem, "visible", false);
    stateMachine->addDefaultAnimation(smoothXRotation);
    stateMachine->addDefaultAnimation(smoothYRotation);
    stateMachine->addDefaultAnimation(smoothXSelection);
    stateMachine->addDefaultAnimation(smoothYSelection);
    stateMachine->setInitialState(splashState);
//! [10]

//! [11]
    // Transitions
    QEventTransition *anyKeyTransition = new QEventTransition(this, QEvent::KeyPress, splashState);
    anyKeyTransition->setTargetState(frontState);
    anyKeyTransition->addAnimation(smoothSplashMove);
    anyKeyTransition->addAnimation(smoothSplashOpacity);
//! [11]

//! [12]
    QKeyEventTransition *enterTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                   Qt::Key_Enter, backState);
    QKeyEventTransition *returnTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                    Qt::Key_Return, backState);
    QKeyEventTransition *backEnterTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                       Qt::Key_Enter, frontState);
    QKeyEventTransition *backReturnTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                        Qt::Key_Return, frontState);
    enterTransition->setTargetState(historyState);
    returnTransition->setTargetState(historyState);
    backEnterTransition->setTargetState(backState);
    backReturnTransition->setTargetState(backState);
    enterTransition->addAnimation(flipAnimation);
    returnTransition->addAnimation(flipAnimation);
    backEnterTransition->addAnimation(flipAnimation);
    backReturnTransition->addAnimation(flipAnimation);
//! [12]

//! [13]
    // Create substates for each icon; store in temporary grid.
    int columns = size.width();
    int rows = size.height();
    QVector< QVector< QState * > > stateGrid;
    stateGrid.resize(rows);
    for (int y = 0; y < rows; ++y) {
        stateGrid[y].resize(columns);
        for (int x = 0; x < columns; ++x)
            stateGrid[y][x] = new QState(frontState);
    }
    frontState->setInitialState(stateGrid[0][0]);
    selectionItem->setPos(pad->iconAt(0, 0)->pos());
//! [13]

//! [14]
    // Enable key navigation using state transitions
    for (int y = 0; y < rows; ++y) {
        for (int x = 0; x < columns; ++x) {
            QState *state = stateGrid[y][x];
            QKeyEventTransition *rightTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                           Qt::Key_Right, state);
            QKeyEventTransition *leftTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                          Qt::Key_Left, state);
            QKeyEventTransition *downTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                          Qt::Key_Down, state);
            QKeyEventTransition *upTransition = new QKeyEventTransition(this, QEvent::KeyPress,
                                                                        Qt::Key_Up, state);
            rightTransition->setTargetState(stateGrid[y][(x + 1) % columns]);
            leftTransition->setTargetState(stateGrid[y][((x - 1) + columns) % columns]);
            downTransition->setTargetState(stateGrid[(y + 1) % rows][x]);
            upTransition->setTargetState(stateGrid[((y - 1) + rows) % rows][x]);
//! [14]
//! [15]
            RoundRectItem *icon = pad->iconAt(x, y);
            state->assignProperty(xRotation, "angle", -icon->x() / 6.0);
            state->assignProperty(yRotation, "angle", icon->y() / 6.0);
            state->assignProperty(selectionItem, "x", icon->x());
            state->assignProperty(selectionItem, "y", icon->y());
            frontState->assignProperty(icon, "visible", true);
            backState->assignProperty(icon, "visible", false);

            QPropertyAnimation *setIconVisibleAnimation = new QPropertyAnimation(icon, "visible");
            setIconVisibleAnimation->setDuration(0);
            setVariablesSequence->addAnimation(setIconVisibleAnimation);
        }
    }
//! [15]

//! [16]
    // Scene
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->setBackgroundBrush(QPixmap(":/images/blue_angle_swirl.jpg"));
    scene->setItemIndexMethod(QGraphicsScene::NoIndex);
    scene->addItem(pad);
    scene->setSceneRect(scene->itemsBoundingRect());
    setScene(scene);
//! [16]

//! [17]
    // Adjust splash item to scene contents
    const QRectF sbr = splash->boundingRect();
    splash->setPos(-sbr.width() / 2, scene->sceneRect().top() - 2);
    frontState->assignProperty(splash, "y", splash->y() - 100.0);
    scene->addItem(splash);
//! [17]

//! [18]
    // View
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setMinimumSize(50, 50);
    setViewportUpdateMode(FullViewportUpdate);
    setCacheMode(CacheBackground);
    setRenderHints(QPainter::Antialiasing
                   | QPainter::SmoothPixmapTransform
                   | QPainter::TextAntialiasing);
#ifndef QT_NO_OPENGL
    setViewport(new QOpenGLWidget);
#endif

    stateMachine->start();
//! [18]
}