void tst_MacNativeEvents::testMouseDragToNonClientArea() { // Check that if we drag the mouse from inside the // widget, and release it on the title bar, we still get mouse move // and release events when the mouse is on the title bar QWidget w; w.show(); QPoint inside1 = w.geometry().center(); QPoint inside2 = inside1 - QPoint(10, 0); QPoint titlebar1 = w.geometry().topLeft() - QPoint(-100, 10); QPoint titlebar2 = titlebar1 - QPoint(10, 0); NativeEventList native; native.append(new QNativeMouseButtonEvent(inside1, Qt::LeftButton, 1, Qt::NoModifier)); native.append(new QNativeMouseDragEvent(inside2, Qt::LeftButton, Qt::NoModifier)); native.append(new QNativeMouseDragEvent(titlebar1, Qt::LeftButton, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(titlebar2, Qt::LeftButton, 0, Qt::NoModifier)); ExpectedEventList expected(&w); expected.append(new QMouseEvent(QEvent::MouseButtonPress, w.mapFromGlobal(inside1), inside1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(inside2), inside2, Qt::NoButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(titlebar1), titlebar1, Qt::NoButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonRelease, w.mapFromGlobal(titlebar2), titlebar2, Qt::LeftButton, Qt::NoButton, Qt::NoModifier)); native.play(); QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); }
void GridLayout::buildGrid() { QWidget* w; QRect br; for ( w = widgets.first(); w; w = widgets.next() ) br = br.unite( w->geometry() ); delete grid; grid = new Grid( br.height() / resolution.height() + 1, br.width() / resolution.width() + 1 ); int r,c; for ( r = 0; r < grid->numRows(); r++ ) { for ( c = 0; c < grid->numCols(); c++ ) { QPoint p( br.left() + c * resolution.width(), br.top() + r* resolution.height() ); QRect cr( p, resolution ); for ( w = widgets.first(); w; w = widgets.next() ) { // check that the overlap is significant QRect intersect = cr.intersect( w->geometry() ); if ( intersect.size().width() > resolution.width()/2 && intersect.size().height() > resolution.height()/2 ) { grid->setCell( r, c, w ); } } } } grid->simplify(); }
void CTariffSetting::CalculatePos( ) { move( 123, 177 ); #if 0 QRect rectWnd = this->geometry( ); QString strName = "widget"; QWidget* pWg = findChild< QWidget* >( strName ); QRect rectWg = pWg->geometry( ); pWg->setGeometry( ( rectWnd.width( ) - rectWg.width( ) - 2 ) / 2, ( rectWnd.height( ) - rectWg.height( ) - 2 ) / 2, rectWg.width( ), rectWg.height( ) ); /////////////////////////////////////////////////////////// QRect rectTabWidget = ui->tabWidget->geometry( ); strName.clear( ); strName.append( "wgTime" ); QWidget* pWgTime = findChild< QWidget* >( strName ); QRect rectWgTime = pWgTime->geometry( ); pWgTime->setGeometry( ( rectTabWidget.width( ) - 2 - rectWgTime.width( ) ) / 2, ( rectTabWidget.height( ) - 26 - rectWgTime.height( ) ) / 2, rectWgTime.width( ), rectWgTime.height( ) ); strName.clear( ); strName.append( "wgRate" ); QWidget* pWgRate = findChild< QWidget* >( strName ); QRect rectWgRate = pWgRate->geometry( ); pWgRate->setGeometry( ( rectTabWidget.width( ) - 2 - rectWgRate.width( ) ) / 2, ( rectTabWidget.height( ) - 26 - rectWgRate.height( ) ) / 2, rectWgRate.width( ), rectWgRate.height( ) ); #endif }
void JumpDialog::setType(PositionJump position) { QWidget *parent = qobject_cast<QWidget *>(this->parent()); int left = (parent->width() - this->width()) / 2; int top = (parent->height() - this->height()) / 2; move(parent->geometry().left() + left, parent->geometry().top() + top); if ((type = position) == TimeJump) ui->label->setText(tr("Time:")); else ui->label->setText(tr("Frame:")); ui->position->clear(); }
void FloatingStatusBar::Reposition() { QWidget* p = parentWidget(); QSize s = p->size() - this->size(); #ifdef Q_WS_MAC this->move(p->geometry().topLeft() + QPoint(0, s.height()) + QPoint(1,-1)); #elif defined(Q_CYGWIN_WIN) this->move(p->geometry().topLeft() + QPoint(0, s.height()) + QPoint(0, -6)); #else this->move(p->geometry().topLeft() + QPoint(0, s.height())); #endif }
void takeScreenshot() { QDateTime createdDate = QDateTime::currentDateTime(); //QPixmap originalPixmap = QPixmap::grabWindow(QApplication::activeWindow()->winId()); QWidget *widget = QApplication::activeWindow(); QPixmap originalPixmap = QPixmap::grabWindow(QApplication::desktop()->winId()); QPixmap windowPixmap = originalPixmap.copy(widget->geometry().x(), widget->geometry().y(), widget->width(), widget->height()); QString format = "png"; QString fileName = getAppPath() + "/" + createdDate.toString("yyyyMMdd_HHmmss") + "_gideros." + format; windowPixmap.save(fileName, format.toAscii()); onMediaReceived(fileName.toStdString().c_str()); }
int FlowLayout::doLayout(const QRect &rect, bool testOnly) const { int left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); QLayoutItem *item; int lsize = 0; foreach (item, itemList) { QWidget *wid = item->widget(); if ((rect.width()-left-right)<lsize+wid->geometry().width()) break; lsize=lsize+wid->geometry().width(); }
void MyVis::showControls() { QWidget *mQ = QLib->getParent( QMP_MINI ); if ( !mQ->isVisible() ) { QSize s; do { s = mQ->geometry().size(); QLib->MiniQmp( true, QPoint( qdw.width()/2 - s.width()/2, qdw.height() - s.height() ), qApp->desktop()->width()/2 ); } while ( s != mQ->geometry().size() ); } }
QWidget *FormWindowBase::widgetUnderMouse(const QPoint &formPos, WidgetUnderMouseMode /* wum */) { // widget_under_mouse might be some temporary thing like the dropLine. We need // the actual widget that's part of the edited GUI. QWidget *rc = widgetAt(formPos); if (!rc || qobject_cast<ConnectionEdit*>(rc)) return 0; if (rc == mainContainer()) { // Refuse main container areas if the main container has a container extension, // for example when hitting QToolBox/QTabWidget empty areas. if (qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), rc)) return 0; return rc; } // If we hit on container extension type container, make sure // we use the top-most current page if (QWidget *container = findContainer(rc, false)) if (QDesignerContainerExtension *c = qt_extension<QDesignerContainerExtension*>(core()->extensionManager(), container)) { // For container that do not have a "stacked" nature (QToolBox, QMdiArea), // make sure the position is within the current page const int ci = c->currentIndex(); if (ci < 0) return 0; QWidget *page = c->widget(ci); QRect pageGeometry = page->geometry(); pageGeometry.moveTo(page->mapTo(this, pageGeometry.topLeft())); if (!pageGeometry.contains(formPos)) return 0; return page; } return rc; }
QRect QcLayoutItem::geometry () { QWidget *widget = qLayoutItem->widget(); if( widget ) return widget->geometry(); else return qLayoutItem->geometry(); }
void BubbleManager::consumeEntities() { if (!m_currentNotify.isNull()) { m_currentNotify->deleteLater(); m_currentNotify = nullptr; } if (m_entities.isEmpty()) { m_currentNotify = nullptr; return; } m_currentNotify = m_entities.dequeue(); QDesktopWidget *desktop = QApplication::desktop(); int pointerScreen = desktop->screenNumber(QCursor::pos()); int primaryScreen = desktop->primaryScreen(); QWidget *pScreenWidget = desktop->screen(primaryScreen); if (checkDockExistence()) { m_dockGeometry = m_dbusdockinterface->geometry(); } if (checkControlCenterExistence()) m_ccGeometry = m_dbusControlCenter->rect(); if (checkControlCenterExistence() && pointerScreen == primaryScreen) bindControlCenterX(); if (pointerScreen != primaryScreen) pScreenWidget = desktop->screen(pointerScreen); m_bubble->setBasePosition(getX(), getY(), pScreenWidget->geometry()); m_bubble->setEntity(m_currentNotify); }
/*! \reimp */ int QAccessibleWidget::childAt(int x, int y) const { QWidget *w = widget(); if (!w->isVisible()) return -1; QPoint gp = w->mapToGlobal(QPoint(0, 0)); if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) return -1; QWidgetList list = childWidgets(w); int ccount = childCount(); // a complex child if (list.size() < ccount) { for (int i = 1; i <= ccount; ++i) { if (rect(i).contains(x, y)) return i; } return 0; } QPoint rp = w->mapFromGlobal(QPoint(x, y)); for (int i = 0; i<list.size(); ++i) { QWidget *child = list.at(i); if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) { return i + 1; } } return 0; }
QPixmap QVNCIntegration::grabWindow(WId window, int x, int y, int width, int height) const { // qDebug() << "QVNCIntegration::grabWindow" << window << x << y << width << height; if (window == 0) { //desktop QImage *desktopImage = mPrimaryScreen->image(); if (x==0 && y == 0 && width < 0 && height < 0) { return QPixmap::fromImage(*desktopImage); } if (width < 0) width = desktopImage->width() - x; if (height < 0) height = desktopImage->height() - y; int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp QImage img(desktopImage->scanLine(y) + bytesPerPixel*x, width, height, desktopImage->bytesPerLine(), desktopImage->format()); return QPixmap::fromImage(img); } QWidget *win = QWidget::find(window); if (win) { QRect r = win->geometry(); if (width < 0) width = r.width() - x; if (height < 0) height = r.height() - y; QImage *desktopImage = mPrimaryScreen->image(); int bytesPerPixel = desktopImage->depth()/8; //We don't support 1, 2, or 4 bpp QImage img(desktopImage->scanLine(r.top() + y) + bytesPerPixel*(r.left()+x), width, height, desktopImage->bytesPerLine(), desktopImage->format()); return QPixmap::fromImage(img); } return QPixmap(); }
void DialogController::closeDialog() { QWidget *dialog = m_dialog; m_dialog = nullptr; m_widget = nullptr; if(!dialog) return; QRect geom = dialog->geometry(); int w = geom.width() + m_dialogOffsetLeft; QPropertyAnimation *animation = new QPropertyAnimation(dialog, "geometry"); animation->setStartValue(visibleGeometry(dialog)); animation->setEndValue(hiddenGeometry(dialog)); animation->setDuration(300); animation->setEasingCurve(QEasingCurve::OutExpo); animation->start(); connect(animation, &QPropertyAnimation::finished, [=]{ animation->deleteLater(); dialog->close(); dialog->deleteLater(); }); emit dialogClosed(); }
void updatePosition() { int x, y; QRect widgetRect = mWidget->geometry(); int splitterWidth = mSplitter->width(); int handleWidth = mSplitter->handleWidth(); int width = q->width(); if (!isVertical()) { // FIXME: Make this configurable y = 30; if (mDirection == LTR) { if (isVisible()) { x = widgetRect.right() + handleWidth; } else { x = 0; } } else { // RTL if (isVisible()) { x = widgetRect.left() - handleWidth - width; } else { x = splitterWidth - handleWidth - width; } } } else { // FIXME x = 0; y = 0; } q->move(x, y); }
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected() { QLabel *label = new QLabel("Qt uses standard C++, but makes extensive use of the C pre-processor to enrich the language. Qt can also be used in several other programming languages via language bindings. It runs on all major platforms, and has extensive internationalization support. Non-GUI features include SQL database access, XML parsing, thread management, network support and a unified cross-platform API for file handling."); label->setWordWrap(true); label->setFixedWidth(200); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(label); layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding)); QWidget widget; widget.setLayout(layout); widget.show(); QTest::qWaitForWindowShown(&widget); int height = label->height(); QRect g = widget.geometry(); g.setWidth(600); widget.setGeometry(g); QTest::qWait(50); QCOMPARE(label->height(), height); }
void QWidget::setMicroFocusHint(int x, int y, int width, int height, bool text, QFont *) { if (QRect(x, y, width, height) != microFocusHint()) { d->createExtra(); d->extra->micro_focus_hint.setRect(x, y, width, height); } #ifndef QT_NO_QWS_INPUTMETHODS if (text) { QWidget *tlw = window(); int winid = tlw->internalWinId(); QPoint p(x, y + height); QPoint gp = mapToGlobal(p); QRect r = QRect(mapToGlobal(QPoint(0,0)), size()); r.setBottom(tlw->geometry().bottom()); //qDebug("QWidget::setMicroFocusHint %d %d %d %d", r.x(), // r.y(), r.width(), r.height()); QInputContext::setMicroFocusWidget(this); qwsDisplay()->setIMInfo(winid, gp.x(), gp.y(), r); //send font info, ###if necessary qwsDisplay()->setInputFont(winid, font()); } #endif }
ColorDialog::ColorDialog(QWidget *parent, LPlugins *plugs, QString colorFilePath) : QDialog(parent), ui(new Ui::ColorDialog){ ui->setupUi(this); //load the designer file filepath = colorFilePath; this->setWindowIcon( LXDG::findIcon("format-stroke-color","") ); ui->line_name->setText( colorFilePath.section("/",-1).section(".qss",0,0) ); //Load the icons for the window ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") ); ui->push_save->setIcon( LXDG::findIcon("document-save","") ); ui->tool_getcolor->setIcon( LXDG::findIcon("color-picker","") ); ui->tool_editcolor->setIcon( LXDG::findIcon("edit-rename","") ); //Now create entries for the available colors in the database ui->tree_color->clear(); QStringList colors = plugs->colorItems(); colors.sort(); for(int i=0; i<colors.length(); i++){ LPI info = plugs->colorInfo(colors[i]); QTreeWidgetItem *it = new QTreeWidgetItem(QStringList() << info.name); it->setWhatsThis(0,info.ID); it->setToolTip(0,info.description); ui->tree_color->addTopLevelItem(it); } //Now load the given file loadColors(); //Now center the window on the parent if(parent!=0){ QWidget *top = parent; while(!top->isWindow()){ top = top->parentWidget(); } QPoint center = top->geometry().center(); this->move(center.x()-(this->width()/2), center.y()-(this->height()/2) ); } }
void tst_MacNativeEvents::testMouseDragInside() { // Check that a mouse drag inside a widget // will cause press-move-release events to be delivered QWidget w; w.show(); QPoint p1 = w.geometry().center(); QPoint p2 = p1 - QPoint(10, 0); QPoint p3 = p1 - QPoint(20, 0); QPoint p4 = p1 - QPoint(30, 0); NativeEventList native; native.append(new QNativeMouseButtonEvent(p1, Qt::LeftButton, 1, Qt::NoModifier)); native.append(new QNativeMouseDragEvent(p2, Qt::LeftButton, Qt::NoModifier)); native.append(new QNativeMouseDragEvent(p3, Qt::LeftButton, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(p4, Qt::LeftButton, 0, Qt::NoModifier)); ExpectedEventList expected(&w); expected.append(new QMouseEvent(QEvent::MouseButtonPress, w.mapFromGlobal(p1), p1, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(p2), p2, Qt::NoButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseMove, w.mapFromGlobal(p3), p3, Qt::NoButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonRelease, w.mapFromGlobal(p4), p4, Qt::LeftButton, Qt::NoButton, Qt::NoModifier)); native.play(); QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); }
void tst_MacNativeEvents::stressTestMouseLeftDoubleClick() { // Check that multiple, fast, double clicks makes // the test widget receive correct click events QWidget w; w.show(); QPoint p = w.geometry().center(); NativeEventList native; ExpectedEventList expected(&w); for (int i=0; i<10; ++i){ native.append(new QNativeMouseButtonEvent(p, Qt::LeftButton, 1, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(p, Qt::LeftButton, 0, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(p, Qt::LeftButton, 2, Qt::NoModifier)); native.append(new QNativeMouseButtonEvent(p, Qt::LeftButton, 0, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonPress, w.mapFromGlobal(p), p, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonRelease, w.mapFromGlobal(p), p, Qt::LeftButton, Qt::NoButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonDblClick, w.mapFromGlobal(p), p, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier)); expected.append(new QMouseEvent(QEvent::MouseButtonRelease, w.mapFromGlobal(p), p, Qt::LeftButton, Qt::NoButton, Qt::NoModifier)); } native.play(); QVERIFY2(expected.waitForAllEvents(), "the test did not receive all expected events!"); }
void DetailsWidget::paintEvent(QPaintEvent *paintEvent) { QWidget::paintEvent(paintEvent); QPainter p(this); QWidget *topLeftWidget = d->m_useCheckBox ? static_cast<QWidget *>(d->m_summaryCheckBox) : static_cast<QWidget *>(d->m_summaryLabelIcon); QPoint topLeft(topLeftWidget->geometry().left() - MARGIN, contentsRect().top()); const QRect paintArea(topLeft, contentsRect().bottomRight()); int topHeight = d->m_useCheckBox ? d->m_summaryCheckBox->height() : d->m_summaryLabel->height(); if (d->m_state == DetailsWidget::Expanded || d->m_state == DetailsWidget::Collapsed) // Details Button is shown topHeight = qMax(d->m_detailsButton->height(), topHeight); if (d->m_state == Collapsed) { if (d->m_collapsedPixmap.isNull() || d->m_collapsedPixmap.size() != size()) d->m_collapsedPixmap = createBackground(paintArea.size(), topHeight, this); p.drawPixmap(paintArea, d->m_collapsedPixmap); } else { if (d->m_expandedPixmap.isNull() || d->m_expandedPixmap.size() != size()) d->m_expandedPixmap = createBackground(paintArea.size(), topHeight, this); p.drawPixmap(paintArea, d->m_expandedPixmap); } }
void QSplitter::moveAfter( int pos, int id, bool upLeft ) { QSplitterLayoutStruct *s = id < int(data->list.count()) ? data->list.at(id) : 0; if ( !s ) return; QWidget *w = s->wid; if ( w->isHidden() ) { moveAfter( pos, id+1, upLeft ); } else if ( pick( w->pos() ) == pos ) { //No need to do anything if it's already there. return; } else if ( s->isSplitter ) { int dd = s->sizer; if ( upLeft ) { setG( w, pos, dd ); moveAfter( pos+dd, id+1, upLeft ); } else { moveAfter( pos+dd, id+1, upLeft ); setG( w, pos, dd ); } } else { int right = pick( w->geometry().bottomRight() ); int dd = right - pos + 1; dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); int newRight = pos+dd-1; setG( w, pos, dd ); moveAfter( newRight+1, id+1, upLeft ); } }
void KisFilterDialog::resizeEvent(QResizeEvent* event) { QDialog::resizeEvent(event); // Workaround, after the initalisation don't center the dialog anymore if(d->resizeCount < 2) { QWidget* canvas = d->view->canvas(); QRect rect(canvas->mapToGlobal(canvas->geometry().topLeft()), size()); int deltaX = (canvas->geometry().width() - geometry().width())/2; int deltaY = (canvas->geometry().height() - geometry().height())/2; rect.translate(deltaX, deltaY); setGeometry(rect); d->resizeCount++; } }
void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e) { if (e->tlw.isNull()) return; QWidget *tlw = e->tlw.data(); if (!tlw->isWindow()) return; //geo of native child widgets is controlled by lighthouse //so we already have sent the events; besides this new rect //is not mapped to parent QRect newRect = e->newGeometry; QRect cr(tlw->geometry()); bool isResize = cr.size() != newRect.size(); bool isMove = cr.topLeft() != newRect.topLeft(); tlw->data->crect = newRect; if (isResize) { QResizeEvent e(tlw->data->crect.size(), cr.size()); QApplication::sendSpontaneousEvent(tlw, &e); tlw->update(); } if (isMove) { //### frame geometry QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft()); QApplication::sendSpontaneousEvent(tlw, &e); } }
void PageLabelWidget::hide() { if(this->pos().y() >= 0 && animation->state()!=QPropertyAnimation::Running) { QWidget * parent = dynamic_cast<QWidget *>(this->parent()); if(parent == 0) { return; } //connect(animation,SIGNAL(finished()),this,SLOT(setHidden())); animation->setStartValue(QPoint((parent->geometry().size().width()-this->width()),0)); animation->setEndValue(QPoint((parent->geometry().size().width()-this->width()),-this->height())); animation->start(); } }
void Container::drawCopiedWidgetRect(QMouseEvent *mev) { // We've been dragging a widget, but Ctrl was hold, so we start copy if(m_state == MovingWidget) { //FormManager::self()->undo(); // undo last moving //m_moving->move(m_initialPos); if(m_form->formWidget()) { m_container->repaint(); m_form->formWidget()->initBuffer(); } m_state = CopyingWidget; } //m_copyRect.moveTopLeft(m_container->mapFromGlobal( mev->globalPos()) - m_grab); if(m_form->formWidget()) { QValueList<QRect> rectList; for(QWidget *w = m_form->selectedWidgets()->first(); w; w = m_form->selectedWidgets()->next()) { QRect drawRect = w->geometry(); QPoint p = mev->pos() - m_grab; drawRect.moveBy(p.x(), p.y()); p = m_container->mapTo(m_form->widget(), QPoint(0, 0)); //drawRect = QRect( ((QWidget*)s)->mapTo(m_form->widget(), drawRect.topLeft()), drawRect.size()); drawRect.moveBy(p.x(), p.y()); rectList.append(drawRect); } m_form->formWidget()->drawRects(rectList, 2); } }
void QSkinObject::paintEvent(QPaintEvent *event) { if(skinWidget) { updateStyle(); QPainter p(&widgetMask); QObjectList ol = skinWidget->children(); foreach(QObject *o, ol) { if(o->isWidgetType()) { QWidget* child = dynamic_cast<QWidget*>(o); p.drawPixmap(child->geometry(),drawCtrl(child )); } } p.end(); #ifdef WIN32 updateAlpha(); #else p.begin(skinWidget); p.setRenderHint(QPainter::Antialiasing); p.drawPixmap(0,0,widgetMask); p.end(); #endif } }
void Container::drawSelectionRect(QMouseEvent *mev) { //finish drawing unclipped selection rectangle: clear the surface if(m_form->formWidget()) m_form->formWidget()->clearForm(); int topx = (m_insertBegin.x() < mev->x()) ? m_insertBegin.x() : mev->x(); int topy = (m_insertBegin.y() < mev->y()) ? m_insertBegin.y() : mev->y(); int botx = (m_insertBegin.x() > mev->x()) ? m_insertBegin.x() : mev->x(); int boty = (m_insertBegin.y() > mev->y()) ? m_insertBegin.y() : mev->y(); QRect r = QRect(QPoint(topx, topy), QPoint(botx, boty)); setSelectedWidget(m_container, false); QWidget *widgetToSelect = 0; // We check which widgets are in the rect and select them for(ObjectTreeItem *item = m_tree->children()->first(); item; item = m_tree->children()->next()) { QWidget *w = item->widget(); if(!w) continue; if(w->geometry().intersects(r) && w != m_container) { if (widgetToSelect) setSelectedWidget(widgetToSelect, true/*add*/, false/*raise*/, true/*moreWillBeSelected*/); widgetToSelect = w; //select later } } if (widgetToSelect) //the last one left setSelectedWidget(widgetToSelect, true/*add*/, false/*raise*/, false/*!moreWillBeSelected*/); m_insertRect = QRect(); m_state = DoingNothing; m_container->repaint(); }
QString LayoutDumper::getWidgetInfo(const QWidget& w) { const QRect& geom = w.geometry(); QSize sizehint = w.sizeHint(); QSize minsizehint = w.minimumSizeHint(); // Can't have >9 arguments to QString arg() system. // Using QStringBuilder with % leads to more type faff. QStringList elements; elements.append(QString("%1 %2 ('%3')") .arg(w.metaObject()->className()) .arg(toString((void*)&w)) .arg(w.objectName())); elements.append(QString("pos (%1, %2)") .arg(geom.x()) .arg(geom.y())); elements.append(QString("size (%1 x %2)") .arg(geom.width()) .arg(geom.height())); // elements.append(QString("minimumSize (%1 x %2)") // .arg(w.minimumSize().width()) // .arg(w.minimumSize().height())); // elements.append(QString("maximumSize (%1 x %2)") // .arg(w.maximumSize().width()) // .arg(w.maximumSize().height())); elements.append(QString("sizeHint (%1 x %2), minimumSizeHint (%3 x %4), policy %5") .arg(sizehint.width()) .arg(sizehint.height()) .arg(minsizehint.width()) .arg(minsizehint.height()) .arg(toString(w.sizePolicy()))); elements.append(QString("stylesheet=%1") .arg(w.styleSheet().isEmpty() ? "false" : "true")); elements.append(w.isVisible() ? "visible" : "HIDDEN"); return elements.join(", "); }
static void paint_children(QWidget * p,const QRegion& r, bool post) { if(!p) return; QObjectList * childObjects=(QObjectList*)p->children(); if(childObjects) { QObject * o; for(o=childObjects->first();o!=0;o=childObjects->next()) { if( o->isWidgetType() ) { QWidget *w = (QWidget *)o; if ( w->testWState(Qt::WState_Visible) ) { QRegion wr( QRegion(w->geometry()) & r ); if ( !wr.isEmpty() ) { wr.translate(-w->x(),-w->y()); if ( post ) QApplication::postEvent(w,new QPaintEvent(wr, !w->testWFlags(QWidget::WRepaintNoErase) ) ); else w->repaint(wr, !w->testWFlags(QWidget::WRepaintNoErase)); paint_children(w,wr,post); } } } } } }