WebPreviewItem::WebPreviewItem(const QUrl& url) : QGraphicsItem(nullptr) , // 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; QGraphicsProxyWidget* proxyItem = new QGraphicsProxyWidget(this); # ifdef HAVE_WEBENGINE QWebEngineView* webView = new CustomWebView(proxyItem); webView->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false); # elif defined HAVE_WEBKIT QWebView* webView = new QWebView; webView->settings()->setAttribute(QWebSettings::JavascriptEnabled, false); # endif webView->load(url); webView->setDisabled(true); webView->resize(1000, 750); 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); }
QAbstractAnimation *QSanRoomSkin::createHuaShenAnimation(QPixmap &huashenAvatar, QPoint topLeft, QGraphicsItem *parent, QGraphicsItem *&huashenAvatarCreated) const { QLabel *avatar = new QLabel; avatar->setStyleSheet("QLabel { background-color: transparent; }"); avatar->setPixmap(huashenAvatar); QGraphicsProxyWidget *widget = new QGraphicsProxyWidget(parent); widget->setWidget(avatar); widget->setPos(topLeft); QPropertyAnimation *animation = new QPropertyAnimation(widget, "opacity"); animation->setLoopCount(2000); JsonArray huashenConfig = _m_animationConfig["huashen"].value<JsonArray>(); int duration; if (tryParse(huashenConfig[0], duration) && huashenConfig[1].canConvert<JsonArray>()) { animation->setDuration(duration); JsonArray keyValues = huashenConfig[1].value<JsonArray>(); for (int i = 0; i < keyValues.size(); i++) { QVariant keyValue = keyValues[i]; if (!keyValue.canConvert<JsonArray>() || keyValue.value<JsonArray>().length() != 2) continue; double step; double val; JsonArray keyArr = keyValue.value<JsonArray>(); if (!tryParse(keyArr[0], step) || !tryParse(keyArr[1], val)) continue; animation->setKeyValueAt(step, val); } } huashenAvatarCreated = widget; return animation; }
KGVisualItemGroup::KGVisualItemGroup(QGraphicsWidget *parent) : QGraphicsWidget(parent, Qt::Widget), m_isFiltered(0) { FlowLayout *layout = new FlowLayout; layout->setSpacing(Qt::Horizontal, 40); layout->setSpacing(Qt::Vertical, 40); layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); layout->setContentsMargins(40,40,20,10); setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); setLayout(layout); KGVisualAppendItem *appendItem = new KGVisualAppendItem(KGVisualAppendItem::APPEND, this); appendItem->setPreferredSize(225, 155); layout->addItem(appendItem); p_visualInsertItem = new KGVisualAppendItem(KGVisualAppendItem::INSERT, this); p_visualInsertItem->setPreferredSize(40, 155); p_visualInsertItem->setVisible(false); setAcceptHoverEvents(true); setAcceptDrops(false); QGraphicsProxyWidget *w = createButton(); w->setPos(0, 40); w->setParentItem(this); //setFlags(QGraphicsItem::ItemHasNoContents); }
void RoutingStatsScene::addToProxyWidgetsMap(uint32_t nodeId, QString title, QString content) { if(m_nodeIdProxyWidgets.find(nodeId) == m_nodeIdProxyWidgets.end()) { TextBubble * tb = new TextBubble (title, content); QFont f(tb->font()); f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize()); tb->setFont(f); QGraphicsProxyWidget * pw = addWidget(tb); QFontMetrics fm(f); pw->setMaximumHeight(fm.height() * tb->text().count("\n")); pw->adjustSize(); showInfoWidget(false); m_nodeIdProxyWidgets[nodeId] = pw; qreal newX = m_lastX + pw->widget()->width(); if(newX >= sceneRect().right()) { m_lastX = 0; m_lastY += pw->widget()->height() + INTERSTATS_SPACE; } pw->setPos(m_lastX, m_lastY); m_lastX = pw->pos().x() + pw->widget()->width() + INTERSTATS_SPACE; m_lastY = pw->pos().y(); m_bottomY = m_lastY + pw->widget()->height(); //qDebug(QString("Last X" + QString::number(m_lastX) + " w:" + QString::number(pw->widget()->width()))); adjustRect(); return; } }
ParticipantInfoDialog::ParticipantInfoDialog(Participant* participant, QWidget* parent, bool showRemove) : PopupDialog( parent ), m_participant(participant) { setMinimumWidth(400); setMinimumHeight(160); this->setSizeGripEnabled(false); QGraphicsPixmapItem* image = new QGraphicsPixmapItem( participant->pixmap().scaled(80, 80, Qt::IgnoreAspectRatio, Qt::SmoothTransformation), widget() ); image->setPos( 8, 8 ); QGraphicsLineItem* line = new QGraphicsLineItem( widget() ); line->setPen( QPen( QColor( 100, 100, 100 ) ) ); line->setLine( 8, 110, width() - 2 * 8, 110 ); int buttonRight = width() - 10; QPushButton* button = new QPushButton(); button->setText(tr("New Wave")); QGraphicsProxyWidget* item = scene()->addWidget(button); item->setParentItem( widget() ); item->setPos( buttonRight - item->preferredWidth(), height() - 10 - item->preferredHeight() ); buttonRight -= item->preferredWidth() + 10; //Adds remove button if parent is a waveview if (showRemove) { QPushButton* removeFromWaveButton = new QPushButton(); removeFromWaveButton->setText(tr("Remove")); QGraphicsProxyWidget* removeItem = scene()->addWidget(removeFromWaveButton); removeItem->setParentItem( widget() ); removeItem->setPos( buttonRight - removeItem->preferredWidth(), height() - 10 - removeItem->preferredHeight() ); buttonRight -= removeItem->preferredWidth() + 10; connect( removeFromWaveButton, SIGNAL(clicked()),SLOT(removeParticipant())); } QPushButton* button2 = new QPushButton(); button2->setText(tr("Close")); QGraphicsProxyWidget* item2 = scene()->addWidget(button2); item2->setParentItem( widget() ); item2->setPos( buttonRight - item2->preferredWidth(), height() - 10 - item2->preferredHeight() ); QGraphicsTextItem* text = new QGraphicsTextItem( participant->name(), widget() ); text->setPos( 110, 10 ); text->setFont( QFont( "Arial", 18, QFont::Bold ) ); text = new QGraphicsTextItem( tr("Address") + ": " + participant->address(), widget() ); text->setPos( 110, 50 ); text->setFont( QFont( "Arial", 11 ) ); connect( button, SIGNAL(clicked()), SLOT(newWave())); connect( button2, SIGNAL(clicked()), SLOT(close())); }
bool ScalableWrapper::eventFilter(QObject* _object, QEvent* _event) { bool needShowMenu = false; QPoint cursorPos = QCursor::pos(); switch (_event->type()) { case QEvent::ContextMenu: { QContextMenuEvent* contextMenuEvent = static_cast<QContextMenuEvent*>(_event); cursorPos = m_editor->viewport()->mapFromGlobal(contextMenuEvent->globalPos()); needShowMenu = true; break; } case QEvent::MouseButtonPress: { QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(_event); if (mouseEvent->button() == Qt::RightButton) { cursorPos = m_editor->viewport()->mapFromGlobal(mouseEvent->globalPos()); needShowMenu = true; } break; } default: { break; } } bool result = false; // // Если необходимо, то показываем контекстное меню в отдельном прокси элементе, // предварительно вернув ему 100% масштаб // if (needShowMenu) { QMenu* menu = m_editor->createStandardContextMenu(); QGraphicsProxyWidget* menuProxy = m_editorProxy->createProxyForChildWidget(menu); const qreal antiZoom = 1. / m_zoomRange; menuProxy->setScale(antiZoom); menuProxy->setPos(QCursor::pos()); menu->exec(); delete menu; // // Событие перехвачено // result = true; } // // Если нет, то стандартная обработка события // else { result = QGraphicsView::eventFilter(_object, _event); } return result; }
SublevelNodeItem::SublevelNodeItem(Node *node, QGraphicsItem *parent) : NodeItem(node, parent) { m_sublevelNode = dynamic_cast<SublevelNode *>(node); m_rangeMeter = new RangeMeter(); CHECKED_CONNECT(m_sublevelNode, SIGNAL(levelChanged(qreal)), m_rangeMeter, SLOT(levelChanged(qreal))); QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(this); proxy->setWidget(m_rangeMeter); proxy->setPos(0, (m_node->getParams().size()+1)*guisettings->m_PIheight); }
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; }
void GameWidget::setRefuse() { count_ref ++; Refuse *ref = new Refuse(NULL); connect(ref, SIGNAL(deleted(Refuse*)),this, SLOT(destroyRefuse(Refuse *))); QGraphicsProxyWidget *proxy = m_scene->addWidget(ref); int x = rand()%370; int y = rand()%40+160; proxy->setPos(x,y); m_pet->refuseExists(); if(!ref) emit sendMes("Ugh, there is dirty! It would not hurt to clean."); }
QProgressBar *Dashboard::addProgressBar(){ QProgressBar *progress_bar = new QProgressBar; progress_bar->setMinimum(0); progress_bar->setMaximum(100); progress_bar->setFixedSize(300, 15); progress_bar->setTextVisible(false); QGraphicsProxyWidget *widget = new QGraphicsProxyWidget(right); widget->setWidget(progress_bar); widget->setParentItem(middle); widget->setPos(300, - 25); progress_bar->hide(); return progress_bar; }
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); }
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(); }
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 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); }
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); }
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; }
// 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); }
// 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())); } }
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(); }
void VisualMatrix::initSprite() { _sprite = new QGraphicsWidget(); QGraphicsItem* item; QGraphicsWidget* widget; QGraphicsRectItem* rect; QGraphicsColorizeEffect* effect; QGraphicsSimpleTextItem* text; QGraphicsProxyWidget* proxy; QLabel* label; QFont font; // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_BG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_MG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Avatar { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); item = new QGraphicsPixmapItem(); item->setParentItem(widget); item->setPos(((BLOCK_LARGE * 10) - (320.0f / 0.75f)) * 0.5f, (BLOCK_LARGE * 20) - 320.0f); _avatar = widget; } // Help { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); font = QApplication::font(); font.setFamily("Arial"); font.setPixelSize(16); font.setWeight(QFont::Bold); font.setStretch(80); text = new QGraphicsSimpleTextItem(tr("Slide left and right: Move.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 217.0f - 6.0f); text = new QGraphicsSimpleTextItem(tr("Swipe up: Hold. Swipe down: Drop.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 237.0f - 6.0f); text = new QGraphicsSimpleTextItem(tr("Pull back, and make circles: Rotate.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 257.0f - 6.0f); // widget->setVisible(false); _sprite_help = widget; } // Lines { rect = new QGraphicsRectItem(120.0f - 1.0f, 220.0f - 1.0f, 8.0f + 2.0f, 144.0f + 2.0f); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_LINES_PROGRESS))); rect->setParentItem(_sprite); _sprite_lines = rect; } // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_FG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Field { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); _sprite_field = widget; _sprite_space.fill(NULL, _rows * _cols); } // Ghost { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4); widget->setParentItem(_sprite_field); widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3)); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_BLOCK_GHOST)); item->setParentItem(widget); } _sprite_ghost = widget; } // Tetromino { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4); widget->setParentItem(_sprite_field); widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3)); widget->setZValue(1.0f); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_tetromino = widget; } // Hold { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(56.0f, 108.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_hold = widget; } // Hold fail { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FAIL)); item->setScale(BLOCK_SMALL / BLOCK_LARGE); item->setParentItem(_sprite); item->setPos(56.0f + (BLOCK_SMALL * 3), 108.0f + (BLOCK_SMALL * 3)); item->setVisible(false); _sprite_holdFail = item; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 108.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 228.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 292.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Font { font = QApplication::font(); font.setCapitalization(QFont::AllUppercase); } // Hold { text = new QGraphicsSimpleTextItem(tr("Hold")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(56.0f, 80.0f - 6.0f); } // Next { text = new QGraphicsSimpleTextItem(tr("Next")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(526.0f - text->boundingRect().width(), 80.0f - 6.0f); } // Level { text = new QGraphicsSimpleTextItem(tr("Level")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(56.0f, 316.0f - 6.0f); } // Level { label = new QLabel(); label->resize(48, 24); label->setStyleSheet("background-color: transparent; color: #FFFFFF;"); label->setAlignment(Qt::AlignTop | Qt::AlignLeft); proxy = new QGraphicsProxyWidget(); proxy->setParentItem(_sprite); proxy->setWidget(label); proxy->setPos(56.0f, 344.0f - 6.0f); _sprite_level = label; } // Score { text = new QGraphicsSimpleTextItem(tr("Score")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(176.0f, 564.0f - 6.0f); } // Score { label = new QLabel(); label->resize(148, 24); label->setStyleSheet("background-color: transparent; color: #FFFFFF;"); label->setAlignment(Qt::AlignTop | Qt::AlignRight); proxy = new QGraphicsProxyWidget(); proxy->setParentItem(_sprite); proxy->setWidget(label); proxy->setPos(256.0f, 564.0f - 6.0f); _sprite_score = label; } // Countdown { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[0])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[1])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[2])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; widget->setVisible(false); _sprite_countdown = widget; } // Game over { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); widget->setZValue(8.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_OVER)); item->setParentItem(widget); item->setPos(4.0f, 172.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0xFF, 0xFF, 0xFF))); rect->setParentItem(widget); _sprite_overFlash = rect; widget->setVisible(false); _sprite_over = widget; } }
void ScheduleScreen::createScheduleScene() { QPen pen(Qt::blue); QBrush brush(Qt::black); QFont font = this->font(); font.setBold(true); QFontMetrics fm(font); weekHeight = (scene->height()/7.0)-(scene->height()*.025); pointArea.setRect(fm.boundingRect("Wed").width()+20, 15, scene->width(), weekHeight*7); timeWidth = ((pointArea.width() - pointArea.left())/4.0)-((pointArea.width() - pointArea.left())/4.0)/16; timeBlockWidth = timeWidth/24.0; //15 min increments pointArea.adjust(0,0,-timeBlockWidth, 0); QDate date = QDate::fromString("Sun", "ddd"); for(int a = 0;a<7;a++) { pen.setColor(QColor(110+40*(a%2),110+40*(a%2),110+40*(a%2))); brush.setColor(QColor(120+40*(a%2),120+40*(a%2),120+40*(a%2))); scene->addRect(0,pointArea.top()+a*weekHeight,pointArea.width(),weekHeight, pen, brush); pen.setColor(QColor(150,150,150)); brush.setColor(QColor(180,180,180)); scene->addRect(0,pointArea.top()+a*weekHeight,pointArea.left(),weekHeight-1, pen, brush); date = date.addDays(1); QString dateString = date.toString("ddd"); pen.setColor(QColor(50,50,50)); QPushButton* b = new QPushButton; connect(b, SIGNAL(clicked(bool)), this, SLOT(disableRow(bool))); b->setFlat(true); b->setFont(font); b->setFocusPolicy(Qt::NoFocus); b->setMaximumWidth(pointArea.left()-4); b->setMaximumHeight(weekHeight-4); QPalette buttonPalette(QColor(180,180,180)); //buttonPalette.setColor(QPalette::Active, QPalette::Button, QColor(180,180,180)); b->setPalette(buttonPalette); b->setCheckable(true); b->setChecked(true); b->setText(dateString); b->setProperty("dayNumber", date.dayOfWeek()-1); QGraphicsProxyWidget* textItem = new QGraphicsProxyWidget; textItem->setWidget(b); scene->addItem(textItem); textItem->setPos(pointArea.left()/2 - textItem->boundingRect().width()/2, pointArea.top()+ a*weekHeight + weekHeight/2 - textItem->boundingRect().height()/2); } scene->addLine(pointArea.left(), pointArea.top()+1, pointArea.left(), scene->height()-1); for(int a = 0;a<5;a++) { pen.setColor(QColor(110+40*(a%2),110+40*(a%2),110+40*(a%2))); brush.setColor(QColor(120+40*(a%2),120+40*(a%2),120+40*(a%2))); QString timeString = formatHourString(QTime(((a)*6)%24,0), m_globalSettings->timeFormat()); pen.setColor(QColor(200,200,200)); brush.setColor(QColor(200,200,200)); QGraphicsSimpleTextItem* textItem = scene->addSimpleText(timeString, font); textItem->setBrush(brush); textItem->setPos(timeBlockWidth*3+pointArea.left()+timeWidth*a - textItem->boundingRect().width()/2, pointArea.bottom() +6); pen.setColor(QColor(188,188,188)); pen.setStyle(Qt::DashLine); scene->addLine(timeBlockWidth*3+pointArea.left()+timeWidth*a, pointArea.top()+1, timeBlockWidth*3+pointArea.left()+timeWidth*a, pointArea.bottom()+3, pen); } }
void InterfaceStatsScene::add (uint32_t nodeId, QString pointADescription, uint32_t otherNodeId, QString pointBDescription, QString linkDescription) { if (!StatsMode::getInstance ()->isNodeActive (nodeId)) { return; } if (!pointADescription.contains ("~")) { return; } showInfoWidget (false); QStringList parts = pointADescription.split ('~'); //qDebug (pointADescription); QString IP = parts.at (0); //qDebug (IP); QString MAC = parts.at (1); QString otherIP = ""; QString otherMAC = ""; if (pointBDescription != "") { parts = pointBDescription.split ('~'); otherIP = parts.at (0); otherMAC = parts.at (1); } QString title = "Node:" + QString::number (nodeId); QString content = "IP:" + IP ; content += "\nMAC:" + MAC ; if (pointBDescription != "") { content += "\nOther Node:" + QString::number (otherNodeId) ; content += "\nOther IP:" + otherIP; content += "\nOther MAC:" + otherMAC; content += "\nInfo:" + linkDescription; } TextBubble * tb = new TextBubble (title, content); QGraphicsProxyWidget * pw = addWidget (tb); QFont f (tb->font ()); f.setPointSizeF (StatsMode::getInstance ()->getCurrentFontSize ()); tb->setFont (f); QFontMetrics fm (f); pw->setMaximumHeight (fm.height () * tb->text ().count ("\n")); addToProxyWidgetsMap (nodeId, pw); qreal newX = m_lastX + pw->widget ()->width (); m_currentMaxHeight = qMax (m_currentMaxHeight, pw->size ().height ()); if (newX >= sceneRect ().right ()) { m_lastX = 0; m_lastY += m_currentMaxHeight + INTERSTATS_SPACE; m_currentMaxHeight = 0; } pw->setPos (m_lastX, m_lastY); m_lastX = pw->pos ().x () + pw->widget ()->width () + INTERSTATS_SPACE; m_lastY = pw->pos ().y (); m_bottomY = m_lastY + m_currentMaxHeight; //qDebug (QString ("Last X" + QString::number (m_lastX) + " w:" + QString::number (pw->widget ()->width ()))); adjustRect (); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); ui->setupUi(this); mPacState = 0; xAxis = yAxis = 0; mLastPt.setX(0); mLastPt.setY(0); mPause = false; // declare the accelerometer mAccelerometer = new QAccelerometer(this); mAccelerometer->start(); QSize screenSize = this->size(); mScene = new QGraphicsScene(); QRect sceneRect = ui->mainGraphicsView->rect(); mScene->setSceneRect(sceneRect); // scene->setBackgroundBrush (QBrush(Qt::blue)); // now set up the boundries setupBoundries(); QPixmap mazeImage(":/media/maze.jpg"); int width = screenSize.width(); mazeImage = mazeImage.scaledToWidth(width); QGraphicsPixmapItem *backGround = mScene->addPixmap(mazeImage); backGround->setPos(-140,-200); mPacCollider = new QGraphicsEllipseItem(0, 0, 18, 18); mPacCollider->setBrush(QBrush(Qt::transparent)); mScene->addItem(mPacCollider); mPacman = new QGraphicsEllipseItem(0, 0, 18, 18); mPacman->setBrush(QBrush(Qt::yellow)); mPacman->setSpanAngle(4500); mScene->addItem(mPacman); // lets place a pause button in the view pauseButton = new QPushButton("Pause"); connect(pauseButton, SIGNAL(clicked()), this, SLOT(pause())); pauseButton->setMaximumHeight(40); QGraphicsProxyWidget *buttonProxy = mScene->addWidget(pauseButton); buttonProxy->setPos(0, -220); ui->mainGraphicsView->setScene(mScene); ui->mainGraphicsView->show(); mPacman->setPos(20,-8); mPacCollider->setPos(20, -8); // declare our update timer mUpdateTimer = new QTimer(this); connect(mUpdateTimer, SIGNAL(timeout()), this, SLOT(updateGraphics())); mUpdateTimer->start(250); // connect the accelerometer to the readingChanged signal connect(mAccelerometer, SIGNAL(readingChanged()), this, SLOT(updateReading())); mNumHits = 1; }
void FlowMonStatsScene::align() { m_lastX = 0; m_lastY = 0; m_bottomY = 0; qreal currentMaxHeight = 0; for(FlowIdProxyWidgetMap_t::const_iterator i = m_flowIdProxyWidgets.begin(); i != m_flowIdProxyWidgets.end(); ++i) { QGraphicsProxyWidget * pw = i->second; bool flowIsActive = StatsMode::getInstance()->isNodeActive(i->first); pw->setVisible(flowIsActive); if(flowIsActive) { TextBubble * tb = (TextBubble *) pw->widget(); QFont f(tb->font()); f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize()); tb->setFont(f); QFontMetrics fm(f); pw->setMaximumHeight(fm.height() * tb->text().count("\n")); pw->adjustSize(); 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(); } } if(m_flowProbeWidget) { QGraphicsProxyWidget * pw = m_flowProbeWidget; TextBubble * tb = (TextBubble *) pw->widget(); QFont f(tb->font()); f.setPointSizeF(StatsMode::getInstance()->getCurrentFontSize()); tb->setFont(f); QFontMetrics fm(f); pw->setMaximumHeight(fm.height() * tb->text().count("\n")); pw->adjustSize(); 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(); } }
MainWindow::MainWindow(AmViewerState *state) : _state(state) { _state->recon_tree = NULL; _state->amEvent = NULL; _state->show_dBm = false; _state->filtered = true; _state->sumpols = false; _state->resetSearch(); // couldn't hurt? setWindowTitle("AmViewer"); // creat dialogs _searchWindow = new SearchWindow(this,_state); _visWindow = new VisWindow(this,_state); _fovWindow = new FovWindow(this,_state); _filterWindow = NULL; _infoWindow = NULL; QWidget *centralWidget = new QWidget(); setCentralWidget(centralWidget); QVBoxLayout *bigLayout = new QVBoxLayout(centralWidget); // File menu QAction *quitMenu = new QAction("&Exit",this); quitMenu->setShortcut(tr("Ctrl+Q")); connect(quitMenu,SIGNAL(triggered()),qApp,SLOT(quit())); QAction *openMenu = new QAction("&Open ROOT file...",this); openMenu->setShortcut(tr("Ctrl+O")); connect(openMenu,SIGNAL(triggered()),this,SLOT(openFile())); _saveMenu = new QAction("&Save event candidates...",this); connect(_saveMenu,SIGNAL(triggered()),this,SLOT(saveFile())); QMenu *fileDrop; fileDrop = menuBar()->addMenu("&File"); fileDrop->addAction(openMenu); fileDrop->addAction(_saveMenu); fileDrop->addAction(quitMenu); _saveMenu->setEnabled(false); // View menu _unitsMenu = new QAction("&Display dBm",this); _unitsMenu->setCheckable(true); _unitsMenu->setChecked(false); connect(_unitsMenu,SIGNAL(triggered()),this,SLOT(applyUnits())); // Filter dialog _filterMenu = new QAction("&Filter Settings",this); connect(_filterMenu,SIGNAL(triggered()),this,SLOT(openFilter())); // Polarization checkbox _polMenu = new QAction("&Sum Polarizations",this); _polMenu->setCheckable(true); _polMenu->setChecked(false); _polMenu->setEnabled(false); connect(_polMenu,SIGNAL(triggered()),this,SLOT(applySumPol())); QMenu *viewDrop; viewDrop = menuBar()->addMenu("&View"); viewDrop->addAction(_unitsMenu); viewDrop->addAction(_polMenu); viewDrop->addAction(_filterMenu); _filterMenu->setEnabled(false); // Analysis menu QAction *infoMenu = new QAction("&Event Info",this); connect(infoMenu,SIGNAL(triggered()),this,SLOT(openInfo())); _analysisDrop = menuBar()->addMenu("&Analysis"); _analysisDrop->addAction(infoMenu); QAction *searchMenu = new QAction("&Search Parameters",this); connect(searchMenu,SIGNAL(triggered()),this,SLOT(openSearch())); _analysisDrop->addAction(searchMenu); _analysisDrop->setEnabled(false); QAction *visMenu = new QAction("&Event Visualization",this); connect(visMenu,SIGNAL(triggered()),this,SLOT(openVis())); _analysisDrop->addAction(visMenu); QAction*fovMenu = new QAction("&AMBER Field of View",this); connect(fovMenu,SIGNAL(triggered()),this,SLOT(openFov())); _analysisDrop->addAction(fovMenu); // Set up layout for event browser, pixel windows, graphs QHBoxLayout *hbox = new QHBoxLayout(); bigLayout->addLayout(hbox); // Event list stuff _eventList = new QTreeWidget(this); _eventList->setColumnCount(2); _eventList->setColumnHidden(1,true); //'true' valid in C++? QTreeWidgetItem *_source0 = new QTreeWidgetItem(_eventList); _source0->setText(0,"Source:0 (LTRIG)"); QTreeWidgetItem *_source1 = new QTreeWidgetItem(_eventList); _source1->setText(0,"Source:1 (PPS)"); QTreeWidgetItem *_source2 = new QTreeWidgetItem(_eventList); _source2->setText(0,"Source:2 (Auger)"); _eventList->setHeaderLabel("Events"); hbox->addWidget(_eventList); // Some gross stuff concerning the clickable horns _hornDisplay = new HornDisplay(this,1); CenterHorns *centerLegend = new CenterHorns("center",true); QGraphicsProxyWidget *centerLegendProxy = new QGraphicsProxyWidget(); centerLegendProxy->setWidget(centerLegend->widget); _hornDisplay->hornScene->addItem(centerLegendProxy); centerLegendProxy->rotate(45); centerLegendProxy->setPos(0,-50); centerLegendProxy->setZValue(0.0); AmHorn *ppsHorn[4]; int i; stringstream out; QToolButton *b; for(i=0; i<4; i++) { b = new QToolButton(); b->setFixedSize(25,25); out.str(""); out << (i+1); ppsHorn[i] = new AmHorn(b,"PPS" + out.str()); ppsHorn[i]->proxyWidget = new QGraphicsProxyWidget(); ppsHorn[i]->proxyWidget->setWidget(ppsHorn[i]->_button); _hornDisplay->hornScene->addItem(ppsHorn[i]->proxyWidget); ppsHorn[i]->proxyWidget->setPos(25*i-145,375); // probably stupid, delete //ppsHorn[i]->trigger_color = "blue"; //ppsHorn[i]->updateStyle(); //delete b; } QGraphicsSimpleTextItem *item; for(i=0; i<4; i++) { item = new QGraphicsSimpleTextItem(); _hornDisplay->hornScene->addItem(item); if(i==0) { item->setText("CH"); item->setPos(-7,-31); item->setZValue(1.0); } if(i==1) { item->setText("CV"); item->setPos(-7,5); item->setZValue(1.0); } if(i==2) { item->setText("KH"); item->setPos(-24,-15); item->setZValue(1.0); } if(i==3) { item->setText("KV"); item->setPos(12,-15); item->setZValue(1.0); } //delete item; } // CRUFT ALERT // THIS WHOLE NEXT LOOP IS HIGHLY SUSPECT, I DOUBT IT DOES ANYTHING QString qstr; for(i=0; i<16; i++) { out.str(""); out << (i+1); qstr = QString::fromStdString(out.str()); item = new QGraphicsSimpleTextItem(qstr); _hornDisplay->hornScene->addItem(item); if(i==0) item->setPos(-2.5,75.0); else if(i==1) item->setPos(-105.0,177.5); else if(i==2) item->setPos(-2.5,280.0); else if(i==3) item->setPos(102.5,177.5); else if(i==4) item->setPos(-70.0,55.0); else if(i==5) item->setPos(-95.0,80.0); else if(i==6) item->setPos(-120.0,105.0); else if(i==7) item->setPos(-125.0,250.0); else if(i==8) item->setPos(-100.0,275.5); else if(i==9) item->setPos(-75.0,300.0); else if(i==10) item->setPos(60.0,300.0); else if(i==11) item->setPos(85.0,275.0); else if(i==12) item->setPos(110.0,250.0); else if(i==13) item->setPos(120.0,110.0); else if(i==14) item->setPos(95.0,85.0); else if(i==15) item->setPos(70.0,60.0); } QVBoxLayout *evVbox = new QVBoxLayout(); hbox->addLayout(evVbox); QGridLayout *evInfoGrid = new QGridLayout(); evVbox->addLayout(evInfoGrid); _evIdLabel = new QLabel(""); _evSourceLabel = new QLabel(""); _evSecLabel = new QLabel(""); _evNsLabel = new QLabel(""); _evInfoLabel = new QLabel(""); evInfoGrid->addWidget(_evIdLabel,0,0); evInfoGrid->addWidget(_evSourceLabel,0,1); evInfoGrid->addWidget(_evSecLabel,1,0); evInfoGrid->addWidget(_evNsLabel,1,1); evInfoGrid->addWidget(_evInfoLabel,2,0); evVbox->addWidget(_hornDisplay); QVBoxLayout *pixelVbox = new QVBoxLayout(); hbox->addLayout(pixelVbox); for(i=0; i<4; i++) { pixelWindow[i] = new PixelWindow(this,i); pixelWindow[i]->setMinimumHeight(100); pixelWindow[i]->setMinimumWidth(300); pixelVbox->addWidget(pixelWindow[i]); } for(i=0; i<28; i++) { _hornDisplay->channel[i]->setHornClickFunction(this); connect(_hornDisplay->channel[i]->_button,SIGNAL(clicked()),_hornDisplay->channel[i],SLOT(hornClick())); } for(i=0; i<4; i++) { //ppsHorn[i]->setHornClickFunction(clickHornSetPixel); ppsHorn[i]->setHornClickFunction(this); connect(ppsHorn[i]->_button,SIGNAL(clicked()),ppsHorn[i],SLOT(hornClick())); } }
void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) { QGraphicsScene::contextMenuEvent(e); if (e->isAccepted()) return; if (! e->widget()) return; QGraphicsPixmapItem *item = childAt(e->scenePos()); QMenu qm(e->widget()); QMenu *qmLayout = qm.addMenu(tr("Layout preset")); QAction *qaLayoutLargeAvatar = qmLayout->addAction(tr("Large square avatar")); QAction *qaLayoutText = qmLayout->addAction(tr("Avatar and Name")); QMenu *qmTrans = qm.addMenu(tr("User Opacity")); QActionGroup *qagUser = new QActionGroup(&qm); QAction *userOpacity[8]; for (int i=0;i<8;++i) { qreal o = (i + 1) / 8.0; userOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagUser); userOpacity[i]->setCheckable(true); userOpacity[i]->setData(o); if (qFuzzyCompare(qgiGroup->opacity(), o)) userOpacity[i]->setChecked(true); qmTrans->addAction(userOpacity[i]); } QAction *color = NULL; QAction *fontAction = NULL; QAction *objectOpacity[8]; for (int i=0;i<8;++i) objectOpacity[i] = NULL; QAction *boxpen[4] = { NULL, NULL, NULL, NULL}; QAction *boxpad[4] = { NULL, NULL, NULL, NULL}; QAction *boxpencolor = NULL; QAction *boxfillcolor = NULL; QAction *align[6]; for (int i=0;i<6;++i) align[i] = NULL; if (item) { qm.addSeparator(); QMenu *qmObjTrans = qm.addMenu(tr("Object Opacity")); QActionGroup *qagObject = new QActionGroup(&qm); for (int i=0;i<8;++i) { qreal o = i + 1 / 8.0; objectOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagObject); objectOpacity[i]->setCheckable(true); objectOpacity[i]->setData(o); if (qFuzzyCompare(item->opacity(), o)) objectOpacity[i]->setChecked(true); qmObjTrans->addAction(objectOpacity[i]); } QMenu *qmObjAlign = qm.addMenu(tr("Alignment")); Qt::Alignment a; if (item == qgpiAvatar) a = os.qaAvatar; else if (item == qgpiChannel) a = os.qaChannel; else if (item == qgpiMuted) a = os.qaMutedDeafened; else a = os.qaUserName; align[0] = qmObjAlign->addAction(tr("Left")); align[0]->setCheckable(true); align[0]->setData(Qt::AlignLeft); if (a & Qt::AlignLeft) align[0]->setChecked(true); align[1] = qmObjAlign->addAction(tr("Center")); align[1]->setCheckable(true); align[1]->setData(Qt::AlignHCenter); if (a & Qt::AlignHCenter) align[1]->setChecked(true); align[2] = qmObjAlign->addAction(tr("Right")); align[2]->setCheckable(true); align[2]->setData(Qt::AlignRight); if (a & Qt::AlignRight) align[2]->setChecked(true); qmObjAlign->addSeparator(); align[3] = qmObjAlign->addAction(tr("Top")); align[3]->setCheckable(true); align[3]->setData(Qt::AlignTop); if (a & Qt::AlignTop) align[3]->setChecked(true); align[4] = qmObjAlign->addAction(tr("Center")); align[4]->setCheckable(true); align[4]->setData(Qt::AlignVCenter); if (a & Qt::AlignVCenter) align[4]->setChecked(true); align[5] = qmObjAlign->addAction(tr("Bottom")); align[5]->setCheckable(true); align[5]->setData(Qt::AlignBottom); if (a & Qt::AlignBottom) align[5]->setChecked(true); if ((item != qgpiAvatar) && (item != qgpiMuted)) { color = qm.addAction(tr("Color...")); fontAction = qm.addAction(tr("Font...")); } } if (qgpiBox->isVisible()) { qm.addSeparator(); QMenu *qmBox = qm.addMenu(tr("Bounding box")); QMenu *qmPen = qmBox->addMenu(tr("Pen width")); QMenu *qmPad = qmBox->addMenu(tr("Padding")); boxpencolor = qmBox->addAction(tr("Pen color")); boxfillcolor = qmBox->addAction(tr("Fill color")); QActionGroup *qagPen = new QActionGroup(qmPen); QActionGroup *qagPad = new QActionGroup(qmPad); for (int i=0;i<4;++i) { qreal v = (i) ? powf(2.0f, static_cast<float>(-10 + i)) : 0.0f; boxpen[i] = new QAction(QString::number(i), qagPen); boxpen[i]->setData(v); boxpen[i]->setCheckable(true); if (qFuzzyCompare(os.fBoxPenWidth, v)) boxpen[i]->setChecked(true); qmPen->addAction(boxpen[i]); boxpad[i] = new QAction(QString::number(i), qagPad); boxpad[i]->setData(v); boxpad[i]->setCheckable(true); if (qFuzzyCompare(os.fBoxPad, v)) boxpad[i]->setChecked(true); qmPad->addAction(boxpad[i]); } } QAction *act = qm.exec(e->screenPos()); if (! act) return; for (int i=0;i<8;++i) { if (userOpacity[i] == act) { float o = static_cast<float>(act->data().toReal()); os.fUser[tsColor] = o; qgiGroup->setOpacity(o); } } for (int i=0;i<8;++i) { if (objectOpacity[i] == act) { qreal o = act->data().toReal(); if (item == qgpiMuted) os.fMutedDeafened = o; else if (item == qgpiAvatar) os.fAvatar = o; else if (item == qgpiChannel) os.fChannel = o; else if (item == qgpiName) os.fUserName = o; item->setOpacity(o); } } for (int i=0;i<4;++i) { if (boxpen[i] == act) { os.fBoxPenWidth = act->data().toReal(); moveBox(); } else if (boxpad[i] == act) { os.fBoxPad = act->data().toReal(); moveBox(); } } for (int i=0;i<6;++i) { if (align[i] == act) { Qt::Alignment *aptr; if (item == qgpiAvatar) aptr = & os.qaAvatar; else if (item == qgpiChannel) aptr = & os.qaChannel; else if (item == qgpiMuted) aptr = & os.qaMutedDeafened; else aptr = & os.qaUserName; Qt::Alignment a = static_cast<Qt::Alignment>(act->data().toInt()); if (a & Qt::AlignHorizontal_Mask) { *aptr = (*aptr & ~Qt::AlignHorizontal_Mask) | a; } else { *aptr = (*aptr & ~Qt::AlignVertical_Mask) | a; } updateSelected(); } } if (act == boxpencolor) { QColor qc = QColorDialog::getColor(os.qcBoxPen, e->widget(), tr("Pick pen color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); if (! qc.isValid()) return; os.qcBoxPen = qc; moveBox(); } else if (act == boxfillcolor) { QColor qc = QColorDialog::getColor(os.qcBoxFill, e->widget(), tr("Pick fill color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel); if (! qc.isValid()) return; os.qcBoxFill = qc; moveBox(); } else if (act == color) { QColor *col = NULL; if (item == qgpiChannel) col = & os.qcChannel; else if (item == qgpiName) col = & os.qcUserName[tsColor]; if (! col) return; QColor qc = QColorDialog::getColor(*col, e->widget(), tr("Pick color"), QColorDialog::DontUseNativeDialog); if (! qc.isValid()) return; qc.setAlpha(255); if (qc == *col) return; *col = qc; updateSelected(); } else if (act == fontAction) { QFont *fontptr = (item == qgpiChannel) ? &os.qfChannel : &os.qfUserName; qgpiSelected = NULL; qgriSelected->hide(); // QFontDialog doesn't really like graphics view. At all. QFontDialog qfd; qfd.setOptions(QFontDialog::DontUseNativeDialog); qfd.setCurrentFont(*fontptr); qfd.setWindowTitle(tr("Pick font")); int ret; if (g.ocIntercept) { QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(NULL, Qt::Window); qgpw->setWidget(&qfd); addItem(qgpw); qgpw->setZValue(3.0f); qgpw->setPanelModality(QGraphicsItem::PanelModal); qgpw->setPos(- qgpw->boundingRect().width() / 2.0f, - qgpw->boundingRect().height() / 2.0f); qgpw->show(); ret = qfd.exec(); qgpw->hide(); qgpw->setWidget(NULL); delete qgpw; } else { Qt::WindowFlags wf = g.mw->windowFlags(); if (wf.testFlag(Qt::WindowStaysOnTopHint)) qfd.setWindowFlags(qfd.windowFlags() | Qt::WindowStaysOnTopHint); ret = qfd.exec(); } if (! ret) return; *fontptr = qfd.selectedFont(); resync(); } else if (act == qaLayoutLargeAvatar) { os.setPreset(OverlaySettings::LargeSquareAvatar); resync(); } else if (act == qaLayoutText) { os.setPreset(OverlaySettings::AvatarAndName); resync(); } }
/* 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; }
FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) : QWidget( _parent ), m_mv( _mv ), m_channelIndex( _channelIndex ), m_backgroundActive( Qt::SolidPattern ), m_strokeOuterActive( 0, 0, 0 ), m_strokeOuterInactive( 0, 0, 0 ), m_strokeInnerActive( 0, 0, 0 ), m_strokeInnerInactive( 0, 0, 0 ), m_inRename( false ) { if( !s_sendBgArrow ) { s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) ); } if( !s_receiveBgArrow ) { s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) ); } setFixedSize( 33, FxLineHeight ); setAttribute( Qt::WA_OpaquePaintEvent, true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); // mixer sends knob m_sendKnob = new Knob( knobBright_26, this, tr( "Channel send amount" ) ); m_sendKnob->move( 3, 22 ); m_sendKnob->setVisible( false ); // send button indicator m_sendBtn = new SendButtonIndicator( this, this, m_mv ); m_sendBtn->move( 2, 2 ); // channel number m_lcd = new LcdWidget( 2, this ); m_lcd->setValue( m_channelIndex ); m_lcd->move( 4, 58 ); m_lcd->setMarginWidth( 1 ); setWhatsThis( tr( "The FX channel receives input from one or more instrument tracks.\n " "It in turn can be routed to multiple other FX channels. LMMS automatically " "takes care of preventing infinite loops for you and doesn't allow making " "a connection that would result in an infinite loop.\n\n" "In order to route the channel to another channel, select the FX channel " "and click on the \"send\" button on the channel you want to send to. " "The knob under the send button controls the level of signal that is sent " "to the channel.\n\n" "You can remove and move FX channels in the context menu, which is accessed " "by right-clicking the FX channel.\n" ) ); QString name = Engine::fxMixer()->effectChannel( m_channelIndex )->m_name; setToolTip( name ); m_renameLineEdit = new QLineEdit(); m_renameLineEdit->setText( name ); m_renameLineEdit->setFixedWidth( 65 ); m_renameLineEdit->setFont( pointSizeF( font(), 7.5f ) ); m_renameLineEdit->setReadOnly( true ); QGraphicsScene * scene = new QGraphicsScene(); scene->setSceneRect( 0, 0, 33, FxLineHeight ); m_view = new QGraphicsView( this ); m_view->setStyleSheet( "border-style: none; background: transparent;" ); m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_view->setScene( scene ); QGraphicsProxyWidget * proxyWidget = scene->addWidget( m_renameLineEdit ); proxyWidget->setRotation( -90 ); proxyWidget->setPos( 8, 145 ); connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); }
FxLine::FxLine( QWidget * _parent, FxMixerView * _mv, int _channelIndex ) : QWidget( _parent ), m_mv( _mv ), m_channelIndex( _channelIndex ), m_backgroundActive( Qt::SolidPattern ), m_strokeOuterActive( 0, 0, 0 ), m_strokeOuterInactive( 0, 0, 0 ), m_strokeInnerActive( 0, 0, 0 ), m_strokeInnerInactive( 0, 0, 0 ), m_inRename( false ) { if( !s_sendBgArrow ) { s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) ); } if( !s_receiveBgArrow ) { s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) ); } setFixedSize( 33, FxLineHeight ); setAttribute( Qt::WA_OpaquePaintEvent, true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); // mixer sends knob m_sendKnob = new Knob( knobBright_26, this, tr( "Channel send amount" ) ); m_sendKnob->move( 3, 22 ); m_sendKnob->setVisible( false ); // send button indicator m_sendBtn = new SendButtonIndicator( this, this, m_mv ); m_sendBtn->move( 2, 2 ); // channel number m_lcd = new LcdWidget( 2, this ); m_lcd->setValue( m_channelIndex ); m_lcd->move( 4, 58 ); m_lcd->setMarginWidth( 1 ); QString name = Engine::fxMixer()->effectChannel( m_channelIndex )->m_name; setToolTip( name ); m_renameLineEdit = new QLineEdit(); m_renameLineEdit->setText( name ); m_renameLineEdit->setFixedWidth( 65 ); m_renameLineEdit->setFont( pointSizeF( font(), 7.5f ) ); m_renameLineEdit->setReadOnly( true ); m_renameLineEdit->installEventFilter( this ); QGraphicsScene * scene = new QGraphicsScene(); scene->setSceneRect( 0, 0, 33, FxLineHeight ); m_view = new QGraphicsView( this ); m_view->setStyleSheet( "border-style: none; background: transparent;" ); m_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); m_view->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_view->setScene( scene ); QGraphicsProxyWidget * proxyWidget = scene->addWidget( m_renameLineEdit ); proxyWidget->setRotation( -90 ); proxyWidget->setPos( 8, 145 ); connect( m_renameLineEdit, SIGNAL( editingFinished() ), this, SLOT( renameFinished() ) ); }