void ImageEditorScene::setup() { // Crop rectangle border color QColor color(Qt::black); color.setAlpha(99); m_brush.setColor(color); m_brush.setStyle(Qt::SolidPattern); m_pen = QPen(m_brush, 0); // Create crop rectangles QRectF blank_rect(0,0,0,0); for (int i=0; i<4; i++) { m_border_rects.append(addRect(blank_rect, m_pen, m_brush)); m_border_rects[i]->setZValue(4); } m_crop_rect = addRect(blank_rect, QPen(), QBrush()); m_crop_rect->setAcceptDrops(true); m_crop_rect->setFlag(QGraphicsItem::ItemIsMovable, true); m_crop_rect->setZValue(6); hideEditingControls(); connect(this, SIGNAL(imageScaleChanged(const QRectF &)), SLOT(updateBorderRects())); connect(this, SIGNAL(imageScaleChanged(const QRectF &)), SLOT(updateImageScale())); connect(this, SIGNAL(imageScaleChanged(const QRectF &)), SLOT(updateSceneSize())); connect(this, SIGNAL(cropRectMoved(const QRectF&)), SLOT(updateBorderRects())); connect(this, SIGNAL(newImageLoaded()), SLOT(updateImageScale())); connect(this, SIGNAL(newImageLoaded()), SLOT(updateCropView())); connect(this, SIGNAL(newImageLoaded()), SLOT(updateSceneSize())); connect(this, SIGNAL(newImageLoaded()), SLOT(showEditingControls())); }
void PatienceView::resizeEvent( QResizeEvent * e ) { QGraphicsView::resizeEvent( e ); setRenderSize( e->size() ); resetCachedContent(); updateSceneSize(); }
void ImageEditorScene::setImage(QString path) { QPixmap pixmap(path); if (m_pixmap) { removeItem(m_pixmap); DELETE(m_pixmap); } if (pixmap.isNull()) { hideEditingControls(); return; } m_pixmap = addPixmap(pixmap); m_pixmap->setZValue(2); m_image_path = path; emit newImageLoaded(); updateImageScale(); updateCropView(); updateSceneSize(); }
void PatienceView::setScene( QGraphicsScene * scene ) { QGraphicsView::setScene( scene ); updateSceneSize(); }