PictureContent::PictureContent(QGraphicsScene * scene, QGraphicsItem * parent) : AbstractContent(scene, parent, false) , m_photo(0) , m_opaquePhoto(false) , m_progress(0) , m_netWidth(0) , m_netHeight(0) , m_netReply(0) { // enable frame text setFrameTextEnabled(true); setFrameText(tr("...")); // add flipping buttons ButtonItem * bFlipH = new ButtonItem(ButtonItem::FlipH, Qt::blue, QIcon(":/data/action-flip-horizontal.png"), this); bFlipH->setToolTip(tr("Flip horizontally")); bFlipH->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); connect(bFlipH, SIGNAL(clicked()), this, SIGNAL(flipHorizontally())); addButtonItem(bFlipH); ButtonItem * bFlipV = new ButtonItem(ButtonItem::FlipV, Qt::blue, QIcon(":/data/action-flip-vertical.png"), this); bFlipV->setToolTip(tr("Flip vertically")); bFlipV->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); addButtonItem(bFlipV); connect(bFlipV, SIGNAL(clicked()), this, SIGNAL(flipVertically())); /*ButtonItem * bCrop = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-scale.png"), this); bCrop->setToolTip(tr("")); bCrop->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); addButtonItem(bCrop); connect(bCrop, SIGNAL(clicked()), this, SIGNAL(toggleCropMode()));*/ }
WebcamContent::WebcamContent(int input, QGraphicsScene * scene, QGraphicsItem * parent) : AbstractContent(scene, parent, false) , m_input(input) , m_still(false) { // enable frame text setFrameTextEnabled(true); setFrameText(tr("This is a mirror ;-)")); // initial pixmap setPixmap(QPixmap(":/data/insert-camera.png")); // add swap button ButtonItem * bSwap = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-flip-horizontal.png"), this); bSwap->setToolTip(tr("Mirror Video")); connect(bSwap, SIGNAL(clicked()), this, SLOT(slotToggleSwap())); addButtonItem(bSwap); // add snapshot button ButtonItem * bStill = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-snapshot.png"), this); bStill->setToolTip(tr("Still picture")); connect(bStill, SIGNAL(clicked()), this, SLOT(slotToggleStill())); addButtonItem(bStill); // start the video flow VideoProvider::instance()->connectInput(input, this, SLOT(setPixmap(const QPixmap &))); }
PictureContent::PictureContent(bool spontaneous, QGraphicsScene * scene, QGraphicsItem * parent) : AbstractContent(scene, spontaneous, false, parent) , m_photo(0) , m_opaquePhoto(false) , m_progress(0) , m_netWidth(0) , m_netHeight(0) , m_netReply(0) , m_watcher(0) , m_watcherTimer(0) { // enable frame text setFrameTextEnabled(true); setFrameText(tr("...")); // allow dropping setAcceptDrops(true); // add flipping buttons ButtonItem * bFlipH = new ButtonItem(ButtonItem::FlipH, Qt::blue, QIcon(":/data/action-flip-horizontal.png"), this); bFlipH->setToolTip(tr("Flip horizontally")); bFlipH->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); connect(bFlipH, SIGNAL(clicked()), this, SIGNAL(flipHorizontally())); addButtonItem(bFlipH); ButtonItem * bFlipV = new ButtonItem(ButtonItem::FlipV, Qt::blue, QIcon(":/data/action-flip-vertical.png"), this); bFlipV->setToolTip(tr("Flip vertically")); bFlipV->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); addButtonItem(bFlipV); connect(bFlipV, SIGNAL(clicked()), this, SIGNAL(flipVertically())); #if 0 // add cropping button (TODO: enable this?) ButtonItem * bCrop = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-scale.png"), this); bCrop->setToolTip(tr("")); bCrop->setFlag(QGraphicsItem::ItemIgnoresTransformations, false); addButtonItem(bCrop); connect(bCrop, SIGNAL(clicked()), this, SIGNAL(requestCrop())); #endif }
AbstractContent::AbstractContent(QGraphicsScene *scene, bool fadeIn, bool noRescale, QGraphicsItem * parent) : AbstractDisposeable(fadeIn, parent) , m_contentRect(-100, -75, 200, 150) , m_frame(0) , m_frameTextItem(0) , m_controlsVisible(false) , m_dirtyTransforming(false) , m_transformRefreshTimer(0) , m_gfxChangeTimer(0) , m_mirrorItem(0) #if QT_VERSION < 0x040600 , m_rotationAngle(0) #endif , m_fxIndex(0) { // the buffered graphics changes timer m_gfxChangeTimer = new QTimer(this); m_gfxChangeTimer->setInterval(0); m_gfxChangeTimer->setSingleShot(true); // customize item's behavior setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemIsSelectable); #if QT_VERSION >= 0x040600 setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); #endif // allow some items (eg. the shape controls for text) to be shown setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); setAcceptHoverEvents(true); // create child controls createCorner(Qt::TopLeftCorner, noRescale); createCorner(Qt::TopRightCorner, noRescale); createCorner(Qt::BottomLeftCorner, noRescale); createCorner(Qt::BottomRightCorner, noRescale); //ButtonItem * bFront = new ButtonItem(ButtonItem::Control, Qt::blue, QIcon(":/data/action-order-front.png"), this); //bFront->setToolTip(tr("Raise")); //connect(bFront, SIGNAL(clicked()), this, SLOT(slotStackRaise())); //addButtonItem(bFront); ButtonItem * bConf = new ButtonItem(ButtonItem::Control, Qt::green, QIcon(":/data/action-configure.png"), this); bConf->setToolTip(tr("Change properties...")); connect(bConf, SIGNAL(clicked()), this, SLOT(slotConfigure())); addButtonItem(bConf); ButtonItem * bPersp = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-perspective.png"), this); bPersp->setToolTip(tr("Drag around to change the perspective.\nHold SHIFT to move faster.\nUse CTRL to cancel the transformations.")); connect(bPersp, SIGNAL(dragging(const QPointF&,Qt::KeyboardModifiers)), this, SLOT(slotSetPerspective(const QPointF&,Qt::KeyboardModifiers))); connect(bPersp, SIGNAL(doubleClicked()), this, SLOT(slotClearPerspective())); addButtonItem(bPersp); ButtonItem * bDelete = new ButtonItem(ButtonItem::Control, Qt::red, QIcon(":/data/action-delete.png"), this); bDelete->setSelectsParent(false); bDelete->setToolTip(tr("Remove")); connect(bDelete, SIGNAL(clicked()), this, SIGNAL(requestRemoval())); addButtonItem(bDelete); // create default frame Frame * frame = FrameFactory::defaultPictureFrame(); setFrame(frame); // hide and layoutChildren buttons layoutChildren(); // add to the scene scene->addItem(this); // display mirror #if QT_VERSION >= 0x040600 // WORKAROUND with Qt 4.6-tp1 there are crashes activating a mirror before setting the scene // need to rethink this anyway setMirrored(false); #else setMirrored(RenderOpts::LastMirrored); #endif }