QSizeF Types::paperSize(const QString &format, QPrinter::Orientation orientation, UnitsOfLength unit) { QSizeF result = paperFormats().value(format); if (orientation == QPrinter::Landscape) result.transpose(); return convertBetweenUnitsOfLength(result, UnitOfLengthCentimeter, unit); }
void VideoRecorder::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) { Q_UNUSED(oldGeometry); QSizeF size = newGeometry.size(); size.transpose(); m_viewFinder->setSize(size); m_viewFinder->setTransformOriginPoint(newGeometry.width()/2, m_viewFinder->size().height()/2); m_viewFinder->setRotation(90); }
static PyObject *meth_QSizeF_transpose(PyObject *sipSelf, PyObject *sipArgs) { PyObject *sipParseErr = NULL; { QSizeF *sipCpp; if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QSizeF, &sipCpp)) { sipCpp->transpose(); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QSizeF, sipName_transpose, doc_QSizeF_transpose); return NULL; }
QImage RenderWorker::renderPage(int sheetNum, const QRectF pageRect, int pageNum) { if (!mPopplerDoc) return QImage(); mBusy = true; QImage img = doRenderSheet(mPopplerDoc, sheetNum, mResolution); QSizeF printerSize = project->printer()->paperRect().size(); if (isLandscape(project->rotation())) printerSize.transpose(); double scale = qMin(img.width() * 1.0 / printerSize.width(), img.height() * 1.0 / printerSize.height()); QSize size = QSize(pageRect.width() * scale, pageRect.height() * scale); if (isLandscape(project->rotation())) size.transpose(); QRect rect(QPoint(0, 0), size); if (isLandscape(project->rotation())) { rect.moveRight(img.width() - pageRect.top() * scale); rect.moveTop(pageRect.left() * scale); } else { rect.moveLeft(pageRect.left() * scale); rect.moveTop(pageRect.top() * scale); } img = img.copy(rect); emit pageReady(img, pageNum); mBusy = false; return img; }
void KItemListViewLayouter::doLayout() { if (m_dirty) { #ifdef KITEMLISTVIEWLAYOUTER_DEBUG QElapsedTimer timer; timer.start(); #endif m_visibleIndexesDirty = true; QSizeF itemSize = m_itemSize; QSizeF itemMargin = m_itemMargin; QSizeF size = m_size; const bool grouped = createGroupHeaders(); const bool horizontalScrolling = (m_scrollOrientation == Qt::Horizontal); if (horizontalScrolling) { // Flip everything so that the layout logically can work like having // a vertical scrolling itemSize.transpose(); itemMargin.transpose(); size.transpose(); if (grouped) { // In the horizontal scrolling case all groups are aligned // at the top, which decreases the available height. For the // flipped data this means that the width must be decreased. size.rwidth() -= m_groupHeaderHeight; } } m_columnWidth = itemSize.width() + itemMargin.width(); const qreal widthForColumns = size.width() - itemMargin.width(); m_columnCount = qMax(1, int(widthForColumns / m_columnWidth)); m_xPosInc = itemMargin.width(); const int itemCount = m_model->count(); if (itemCount > m_columnCount && m_columnWidth >= 32) { // Apply the unused width equally to each column const qreal unusedWidth = widthForColumns - m_columnCount * m_columnWidth; if (unusedWidth > 0) { const qreal columnInc = unusedWidth / (m_columnCount + 1); m_columnWidth += columnInc; m_xPosInc += columnInc; } } int rowCount = itemCount / m_columnCount; if (itemCount % m_columnCount != 0) { ++rowCount; } m_itemInfos.resize(itemCount); qreal y = m_headerHeight + itemMargin.height(); int row = 0; int index = 0; while (index < itemCount) { qreal x = m_xPosInc; qreal maxItemHeight = itemSize.height(); if (grouped) { if (horizontalScrolling) { // All group headers will always be aligned on the top and not // flipped like the other properties x += m_groupHeaderHeight; } if (m_groupItemIndexes.contains(index)) { // The item is the first item of a group. // Increase the y-position to provide space // for the group header. if (index > 0) { // Only add a margin if there has been added another // group already before y += m_groupHeaderMargin; } else if (!horizontalScrolling) { // The first group header should be aligned on top y -= itemMargin.height(); } if (!horizontalScrolling) { y += m_groupHeaderHeight; } } } int column = 0; while (index < itemCount && column < m_columnCount) { qreal requiredItemHeight = itemSize.height(); if (m_sizeHintResolver) { const QSizeF sizeHint = m_sizeHintResolver->sizeHint(index); const qreal sizeHintHeight = horizontalScrolling ? sizeHint.width() : sizeHint.height(); if (sizeHintHeight > requiredItemHeight) { requiredItemHeight = sizeHintHeight; } } ItemInfo& itemInfo = m_itemInfos[index]; itemInfo.rect = QRectF(x, y, itemSize.width(), requiredItemHeight); itemInfo.column = column; itemInfo.row = row; if (grouped && horizontalScrolling) { // When grouping is enabled in the horizontal mode, the header alignment // looks like this: // Header-1 Header-2 Header-3 // Item 1 Item 4 Item 7 // Item 2 Item 5 Item 8 // Item 3 Item 6 Item 9 // In this case 'requiredItemHeight' represents the column-width. We don't // check the content of the header in the layouter to determine the required // width, hence assure that at least a minimal width of 15 characters is given // (in average a character requires the halve width of the font height). // // TODO: Let the group headers provide a minimum width and respect this width here const qreal headerWidth = minimumGroupHeaderWidth(); if (requiredItemHeight < headerWidth) { requiredItemHeight = headerWidth; } } maxItemHeight = qMax(maxItemHeight, requiredItemHeight); x += m_columnWidth; ++index; ++column; if (grouped && m_groupItemIndexes.contains(index)) { // The item represents the first index of a group // and must aligned in the first column break; } } y += maxItemHeight + itemMargin.height(); ++row; } if (itemCount > 0) { // Calculate the maximum y-range of the last row for m_maximumScrollOffset m_maximumScrollOffset = m_itemInfos.last().rect.bottom(); const qreal rowY = m_itemInfos.last().rect.y(); int index = m_itemInfos.count() - 2; while (index >= 0 && m_itemInfos[index].rect.bottom() >= rowY) { m_maximumScrollOffset = qMax(m_maximumScrollOffset, m_itemInfos[index].rect.bottom()); --index; } m_maximumScrollOffset += itemMargin.height(); m_maximumItemOffset = m_columnCount * m_columnWidth; } else { m_maximumScrollOffset = 0; m_maximumItemOffset = 0; } #ifdef KITEMLISTVIEWLAYOUTER_DEBUG kDebug() << "[TIME] doLayout() for " << m_model->count() << "items:" << timer.elapsed(); #endif m_dirty = false; } updateVisibleIndexes(); }
void PreviewWidget::paintEvent(QPaintEvent *event) { //#define DEBUG_LAYOUT #ifdef DEBUG_LAYOUT { if (mImage.isNull()) return; if (mSheetNum < 0) return; Sheet *sheet = project->previewSheet(mSheetNum); if (!sheet) return; QPainter painter(this); QRectF rect = project->printer()->paperRect(); painter.fillRect(rect, Qt::white); for (int i=0; i< sheet->count(); ++i) { QPen pen = painter.pen(); pen.setStyle(Qt::DotLine); pen.setColor(Qt::darkGray); painter.setPen(pen); TransformSpec spec = project->layout()->transformSpec(sheet, i, project->rotation()); painter.drawRect(spec.rect); QFont font = painter.font(); font.setPixelSize(spec.rect.height() / 2 ); painter.setFont(font); painter.drawText(spec.rect, Qt::AlignCenter, QString("%1").arg(i+1)); pen.setStyle(Qt::SolidLine); pen.setColor(Qt::red); painter.setPen(pen); switch (spec.rotation) { case NoRotate: painter.drawLine(spec.rect.topLeft(), spec.rect.topRight()); break; case Rotate90: painter.drawLine(spec.rect.topRight(), spec.rect.bottomRight()); break; case Rotate180: painter.drawLine(spec.rect.bottomLeft(), spec.rect.bottomRight()); break; case Rotate270: painter.drawLine(spec.rect.topLeft(), spec.rect.bottomLeft()); break; } } return; } #endif if (mImage.isNull()) return; QSizeF printerSize = project->printer()->paperRect().size(); Rotation rotation = project->rotation(); if (isLandscape(rotation)) printerSize.transpose(); mScaleFactor = qMin((this->geometry().width() - 2.0 * MARGIN_H) * 1.0 / printerSize.width(), (this->geometry().height() - 2.0 * MARGIN_V) * 1.0 / printerSize.height()); if (mScaleFactor == 0) { mDrawRect = QRect(); return; } QSize size = QSize(printerSize.width() * mScaleFactor, printerSize.height() * mScaleFactor); mDrawRect = QRect(QPoint(0, 0), size); mDrawRect.moveCenter(QPoint(0, 0)); QRectF clipRect = mDrawRect; if (mHints.testFlag(Sheet::HintOnlyLeft)) { switch (rotation) { case NoRotate: clipRect.setBottom(0); break; case Rotate90: clipRect.setRight(0); break; case Rotate180: clipRect.setBottom(0); break; case Rotate270: clipRect.setRight(0); break; } } if (mHints.testFlag(Sheet::HintOnlyRight)) { switch (rotation) { case NoRotate: clipRect.setTop(0); break; case Rotate90: clipRect.setLeft(0); break; case Rotate180: clipRect.setTop(0); break; case Rotate270: clipRect.setLeft(0); break; } } QImage img = mImage.scaled(mDrawRect.size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); // Draw ..................................... QPainter painter(this); painter.save(); QPoint center = QRect(0, 0, geometry().width(), geometry().height()).center(); painter.translate(center); if (mHints.testFlag(Sheet::HintSubBooklet)) { painter.save(); QPoint center = mDrawRect.center(); QRectF imgRect; clipRect = mDrawRect; clipRect.setRight(center.x()); clipRect.adjust(-MARGIN_BOOKLET, 0, -MARGIN_BOOKLET, 0); painter.setClipRect(clipRect); imgRect = img.rect(); imgRect.setRight(img.rect().center().x()); painter.drawImage(clipRect, img, imgRect); drawShadow(painter, clipRect); clipRect = mDrawRect; clipRect.setLeft(center.x()); clipRect.adjust(MARGIN_BOOKLET, 0, MARGIN_BOOKLET, 0); painter.setClipRect(clipRect); imgRect = img.rect(); imgRect.setLeft(img.rect().center().x()); painter.drawImage(clipRect, img, imgRect); drawShadow(painter, clipRect); painter.restore(); } else { painter.save(); painter.setClipRect(clipRect); painter.drawImage(mDrawRect, img); drawShadow(painter, clipRect); painter.restore(); } if (mHints.testFlag(Sheet::HintDrawFold) && !mHints.testFlag(Sheet::HintSubBooklet)) { QPen pen = painter.pen(); pen.setStyle(Qt::SolidLine); pen.setColor(Qt::lightGray); painter.setPen(pen); if (isLandscape(rotation)) painter.drawLine(0, mDrawRect.top(), 0, mDrawRect.bottom()); else painter.drawLine(mDrawRect.left(), 0, mDrawRect.right(), 0); } painter.restore(); mDrawRect.moveCenter(center); // Draw current page rect ................... Sheet *sheet = project->currentSheet(); if (sheet) { ProjectPage *curPage = project->currentPage(); if (curPage) { painter.save(); QPen pen = painter.pen(); pen.setStyle(Qt::DashLine); //pen.setColor(QColor(142, 188, 226, 128)); pen.setColor(QColor(105, 101, 98, 70)); painter.setPen(pen); painter.drawRect(this->pageRect(sheet->indexOfPage(curPage))); painter.restore(); } } //#define DEBUG_CLICK_RECT #ifdef DEBUG_CLICK_RECT { Sheet *sheet = project->currentSheet(); if (sheet) { ProjectPage *curPage = project->currentPage(); painter.save(); for (int i=0; i< sheet->count(); ++i) { QPen pen = painter.pen(); pen.setStyle(Qt::DotLine); if (sheet->page(i) == curPage) pen.setColor(Qt::red); else pen.setColor(QColor(142, 188, 226)); painter.setPen(pen); painter.drawRect(this->pageRect(i)); painter.drawText(this->pageRect(i).translated(10, 10), QString("%1").arg(i)); } painter.restore(); } } #endif }
void TouchDefine_Dialog::ModifyItem_Item(QListWidget *parent, QListWidgetItem *item) { iButtonAdded_list.clear(); iParent = parent; iItem = item; if(parent) { if(iItem) { for(int i=0; i<((TouchInfo*)item)->iButtonInfoList.count(); i++) { TouchDefine_Dialog_Pad_Button* button = new TouchDefine_Dialog_Pad_Button((QWidget*)(iModelPad->iScreen)); button->iButtonAdded_list = &iButtonAdded_list; button->iStatus = TouchDefine_Dialog_Pad_Button::ButtonStatus_Screen; if(((TouchInfo*)item)->iButtonInfoList.at(i)->iLongPress=="true") button->SetButtonLock(TouchDefine_Dialog_Pad_Button::ButtonLock_ON); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iLongPress=="false") button->SetButtonLock(TouchDefine_Dialog_Pad_Button::ButtonLock_OFF); button->iOrg = ((TouchInfo*)item)->iButtonInfoList.at(i)->iOrg.toInt(); button->iButtonPos.setX(((TouchInfo*)item)->iButtonInfoList.at(i)->iHorPos.toInt()); button->iButtonPos.setY(((TouchInfo*)item)->iButtonInfoList.at(i)->iVerPos.toInt()); button->iButtonLockTime = ((TouchInfo*)item)->iButtonInfoList.at(i)->iLockTime.toInt(); button->iButtonMapto = ((TouchInfo*)item)->iButtonInfoList.at(i)->iMapto; if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="up") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_Up); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="down") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_Down); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="left") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_Left); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="right") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_Right); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="a") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_A); else if(((TouchInfo*)item)->iButtonInfoList.at(i)->iButtonName=="b") button->SetButtonType(TouchDefine_Dialog_Pad_Button::Button_B); iButtonAdded_list.append(button); connect(this, SIGNAL(signalChangeZoom(float)), button, SLOT(slotChangeZoom(float))); if(iZoom_list->currentIndex()==0) button->iZoom = 1.0; else if(iZoom_list->currentIndex()==1) button->iZoom = 0.75; else if(iZoom_list->currentIndex()==2) button->iZoom = 0.5; QPointF pos; QSizeF size = this->iModelPad->iScreen->iScreenSize; if(iDir==Dir_CW90 || iDir==Dir_ACW90) size.transpose(); if(button->iOrg==0) { pos = button->iButtonPos.toPoint(); } else if(button->iOrg==1) { pos.rx() = size.width() - button->iButtonPos.toPoint().x() - button->iButtonSize.width(); pos.ry() = button->iButtonPos.toPoint().y(); } else if(button->iOrg==3) { pos.rx() = size.width() - button->iButtonPos.toPoint().x() - button->iButtonSize.width(); pos.ry() = size.height() - button->iButtonPos.toPoint().y() - button->iButtonSize.height(); } else if(button->iOrg==2) { pos.rx() = button->iButtonPos.toPoint().x(); pos.ry() = size.height() - button->iButtonPos.toPoint().y() - button->iButtonSize.height(); } button->move((pos*button->iZoom).toPoint()); } } else { iButtonAdded_list.clear(); } this->exec(); }
Q_FOREACH(QSizeF size, ratioList) { size.transpose(); addRatioToComboBox(size); }