void GameplayLayer::_handleActionDiceDragStarted(EventCustom* event) { auto data = (ActionDiceDragData*) event->getUserData(); auto sprite = data->getSprite(); auto dice = sprite->getDice(); sprite->startDragging(); auto room = Game::getInstance()->getRoomForCharacterCoordinate(); auto hasMonstersInRoom = room->getMonsters().size() > 0; auto handler = DiceDragHandlerFactory::getHandler(dice); handler->dragStarted(data, this, this->_getDockableContainer()); }
void PokemonBoxButton::startDrag() { QMimeData * data = new QMimeData(); data->setProperty("TeamSlot", num); data->setImageData(px); QDrag * drag = new QDrag(this); drag->setMimeData(data); drag->setPixmap(px); drag->setHotSpot(QPoint(px.width()/2,px.height()/2)); drag->exec(Qt::MoveAction); emit dragStarted(num); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void PipelineFilterWidget::mouseMoveEvent(QMouseEvent* event) { if(!(event->buttons() & Qt::LeftButton)) { return; } if((event->pos() - dragStartPosition).manhattanLength() < QApplication::startDragDistance()) { return; } // The user is dragging the filter widget so we should set it as selected. setIsSelected(true); QPixmap pixmap = grab(); // Create new picture for transparent QPixmap transparent(pixmap.size()); // Do transparency transparent.fill(Qt::transparent); #if 1 QPainter p; p.begin(&transparent); p.setOpacity(0.70); p.drawPixmap(0, 0, pixmap); p.end(); #endif QByteArray itemData; QDataStream dataStream(&itemData, QIODevice::WriteOnly); dataStream << transparent << QPoint(event->pos()); QMimeData* mimeData = new QMimeData; mimeData->setData("application/x-dnditemdata", itemData); QDrag* drag = new QDrag(this); drag->setMimeData(mimeData); drag->setPixmap(transparent); drag->setHotSpot(event->pos()); emit dragStarted(this); // if(drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction) == Qt::MoveAction) // { // qDebug() << "Drag should close the widget because it was MOVE" << "\n"; // } // else // { // qDebug() << "Drag should leave Widget alone because it was COPY" << "\n"; // } drag->exec(Qt::MoveAction); }
void DeclarativeDragArea::mouseMoveEvent(QGraphicsSceneMouseEvent *event) { if ( !m_enabled || QLineF(event->screenPos(), event->buttonDownScreenPos(Qt::LeftButton)).length() < m_startDragDistance) { return; } emit dragStarted(); QDrag *drag = new QDrag(event->widget()); DeclarativeMimeData* dataCopy = new DeclarativeMimeData(m_data); //Qt will take ownership of this copy and delete it. drag->setMimeData(dataCopy); if (!m_delegateImage.isNull()) { drag->setPixmap(QPixmap::fromImage(m_delegateImage)); } else if (m_delegate) { // Render the delegate to a Pixmap QDeclarativeItem* item = qobject_cast<QDeclarativeItem *>(m_delegate->create(m_delegate->creationContext())); QGraphicsScene scene; scene.addItem(item); QPixmap pixmap(scene.sceneRect().width(), scene.sceneRect().height()); pixmap.fill(Qt::transparent); QPainter painter(&pixmap); painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::SmoothPixmapTransform); scene.render(&painter); painter.end(); delete item; drag->setPixmap(pixmap); } drag->setHotSpot(QPoint(drag->pixmap().width()/2, drag->pixmap().height()/2)); // TODO: Make a property for that //setCursor(Qt::OpenHandCursor); //TODO? Make a property for the cursor Qt::DropAction action = drag->exec(m_supportedActions, m_defaultAction); emit drop(action); }
//============================================================================== // Timer Event //============================================================================== void FileListWidget::timerEvent(QTimerEvent* aEvent) { QQuickWidget::timerEvent(aEvent); // Check Event if (aEvent) { // Check Event ID if (aEvent->timerId() == dragTimerID) { // Stop Timer stopDragTimer(); // Set Drag On dragOn = true; qDebug() << "FileListWidget::timerEvent - dragOn: " << dragOn; // Emit Drag Started Signal emit dragStarted(dragPosX, dragPosY); } } }
/*! \brief Constructor of the class. * * \param title the title of the plotter * \param gridx the x pos in the grid * \param gridy the y pos in the grid * \param hspan the horizonatl span * \param vspan the vertical span * \param minval the minimum scale value * \param maxval the maximium scale value * \param size number of sample of datas in plotter * \param bgcolor the background color of the plotter * \param autorescale not used */ Plotter::Plotter(const QString &title, int gridx, int gridy, int hspan, int vspan, float minval, float maxval, int size, const QString &bgcolor, bool autorescale, QObject *parent) : QObject(parent) { Q_UNUSED(autorescale); this->title = title; this->gridx = gridx; this->gridy = gridy; this->hspan = hspan; this->vspan = vspan; this->minval = minval; this->maxval = maxval; this->size = size; initialSize = size; start = 0; this->bgcolor = bgcolor; interact = false; connect(customPlot.axisRect(),SIGNAL(zoomRequest()),this,SLOT(onInteract())); connect(customPlot.axisRect(),SIGNAL(dragStarted()),this,SLOT(onInteract())); customPlot.axisRect()->setBackground(QBrush(QColor(bgcolor))); customPlot.axisRect()->setupFullAxesBox(true); customPlot.axisRect()->axis(QCPAxis::atBottom)->setTickLabelType(QCPAxis::ltNumber); customPlot.axisRect()->axis(QCPAxis::atBottom)->setAutoTickStep(false); customPlot.axisRect()->axis(QCPAxis::atBottom)->setTickStep(25); customPlot.axisRect()->axis(QCPAxis::atBottom)->setRange(0,size); customPlot.axisRect()->axis(QCPAxis::atLeft)->setRange(minval, maxval); customPlot.setInteractions( QCP::iRangeDrag | QCP::iRangeZoom ); QCPItemText *textLabel = new QCPItemText(&customPlot); customPlot.addItem(textLabel); textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter); textLabel->position->setType(QCPItemPosition::ptAxisRectRatio); textLabel->position->setCoords(0.5, 0); // place position at center/top of axis rect textLabel->setText(title); connect(customPlot.xAxis, SIGNAL(rangeChanged(QCPRange)), customPlot.xAxis2, SLOT(setRange(QCPRange))); connect(customPlot.yAxis, SIGNAL(rangeChanged(QCPRange)), customPlot.yAxis2, SLOT(setRange(QCPRange))); }
void KasBar::mouseMoveEvent(QMouseEvent *ev) { if ( detached && (!pressPos.isNull()) ) { QPoint moved = ev->globalPos() - pressPos; if ( !inDrag ) { if ( moved.manhattanLength() > 6 ) { inDrag = true; emit dragStarted(); } } if ( inDrag ) { if ( itemUnderMouse_ ) itemUnderMouse_->hidePopup(); move( pos() + moved ); pressPos = ev->globalPos(); } } else { updateMouseOver( ev->pos() ); } }
MainWindow::MainWindow() : QMainWindow(0) , ui(new Ui::MainWindow) , m_isKKeyPressed(false) { // Create the UI. ui->setupUi(this); #ifndef Q_WS_X11 ui->mainToolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); #endif setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea); setDockNestingEnabled(true); // These use the icon theme on Linux, with fallbacks to the icons specified in QtDesigner for other platforms. ui->actionOpen->setIcon(QIcon::fromTheme("document-open", ui->actionOpen->icon())); ui->actionSave->setIcon(QIcon::fromTheme("document-save", ui->actionSave->icon())); ui->actionEncode->setIcon(QIcon::fromTheme("media-record", ui->actionEncode->icon())); // Connect UI signals. connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(openVideo())); connect(ui->actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); // Accept drag-n-drop of files. this->setAcceptDrops(true); // Add the player widget. QLayout* layout = new QVBoxLayout(ui->playerPage); layout->setObjectName("centralWidgetLayout"); layout->setMargin(0); m_player = new Player(this); layout->addWidget(m_player); connect(this, SIGNAL(producerOpened()), m_player, SLOT(onProducerOpened())); connect(m_player, SIGNAL(showStatusMessage(QString)), this, SLOT(showStatusMessage(QString))); connect(m_player, SIGNAL(inChanged(int)), this, SLOT(onCutModified())); connect(m_player, SIGNAL(outChanged(int)), this, SLOT(onCutModified())); // Add the docks. m_propertiesDock = new QDockWidget(tr("Properties")); m_propertiesDock->hide(); m_propertiesDock->setObjectName("propertiesDock"); m_propertiesDock->setWindowIcon(QIcon((":/icons/icons/view-form.png"))); m_propertiesDock->toggleViewAction()->setIcon(QIcon::fromTheme("view-form", m_propertiesDock->windowIcon())); addDockWidget(Qt::LeftDockWidgetArea, m_propertiesDock); ui->menuView->addAction(m_propertiesDock->toggleViewAction()); ui->mainToolBar->addAction(m_propertiesDock->toggleViewAction()); connect(m_propertiesDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onPropertiesDockTriggered(bool))); m_recentDock = new RecentDock(this); m_recentDock->hide(); addDockWidget(Qt::LeftDockWidgetArea, m_recentDock); ui->menuView->addAction(m_recentDock->toggleViewAction()); ui->mainToolBar->addAction(m_recentDock->toggleViewAction()); connect(m_recentDock, SIGNAL(itemActivated(QString)), this, SLOT(open(QString))); connect(m_recentDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onRecentDockTriggered(bool))); m_playlistDock = new PlaylistDock(this); m_playlistDock->hide(); addDockWidget(Qt::LeftDockWidgetArea, m_playlistDock); ui->menuView->addAction(m_playlistDock->toggleViewAction()); ui->mainToolBar->addAction(m_playlistDock->toggleViewAction()); connect(m_playlistDock->toggleViewAction(), SIGNAL(triggered(bool)), this, SLOT(onPlaylistDockTriggered(bool))); connect(m_playlistDock, SIGNAL(clipOpened(void*,int,int)), this, SLOT(openCut(void*, int, int))); connect(m_playlistDock, SIGNAL(itemActivated(int)), this, SLOT(seekPlaylist(int))); connect(m_playlistDock, SIGNAL(showStatusMessage(QString)), this, SLOT(showStatusMessage(QString))); connect(m_playlistDock->model(), SIGNAL(created()), this, SLOT(onPlaylistCreated())); connect(m_playlistDock->model(), SIGNAL(cleared()), this, SLOT(onPlaylistCleared())); connect(m_playlistDock->model(), SIGNAL(closed()), this, SLOT(onPlaylistClosed())); connect(m_playlistDock->model(), SIGNAL(modified()), this, SLOT(onPlaylistModified())); connect(m_playlistDock->model(), SIGNAL(loaded()), this, SLOT(updateMarkers())); connect(m_playlistDock->model(), SIGNAL(modified()), this, SLOT(updateMarkers())); tabifyDockWidget(m_recentDock, m_propertiesDock); tabifyDockWidget(m_propertiesDock, m_playlistDock); m_recentDock->raise(); m_encodeDock = new EncodeDock(this); m_encodeDock->hide(); addDockWidget(Qt::RightDockWidgetArea, m_encodeDock); ui->menuView->addAction(m_encodeDock->toggleViewAction()); ui->mainToolBar->addAction(ui->actionEncode); connect(this, SIGNAL(producerOpened()), m_encodeDock, SLOT(onProducerOpened())); connect(m_encodeDock, SIGNAL(visibilityChanged(bool)), ui->actionEncode, SLOT(setChecked(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_player, SLOT(onCaptureStateChanged(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_propertiesDock, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), m_recentDock, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionOpen, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionOpenOther, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), ui->actionExit, SLOT(setDisabled(bool))); connect(m_encodeDock, SIGNAL(captureStateChanged(bool)), this, SLOT(onCaptureStateChanged(bool))); m_jobsDock = new JobsDock(this); m_jobsDock->hide(); addDockWidget(Qt::RightDockWidgetArea, m_jobsDock); tabifyDockWidget(m_encodeDock, m_jobsDock); ui->menuView->addAction(m_jobsDock->toggleViewAction()); connect(&JOBS, SIGNAL(jobAdded()), m_jobsDock, SLOT(show())); connect(&JOBS, SIGNAL(jobAdded()), m_jobsDock, SLOT(raise())); connect(m_jobsDock, SIGNAL(visibilityChanged(bool)), this, SLOT(onJobsVisibilityChanged(bool))); // Connect signals. connect(this, SIGNAL(producerOpened()), this, SLOT(onProducerOpened())); // connect video widget signals #if defined(Q_WS_MAC) || defined(Q_WS_WIN) Mlt::GLWidget* videoWidget = (Mlt::GLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); #else if (m_settings.value("player/opengl", true).toBool()) { Mlt::GLWidget* videoWidget = (Mlt::GLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); } else { Mlt::SDLWidget* videoWidget = (Mlt::SDLWidget*) &(MLT); connect(videoWidget, SIGNAL(dragStarted()), m_playlistDock, SLOT(onPlayerDragStarted())); connect(videoWidget, SIGNAL(seekTo(int)), m_player, SLOT(seek(int))); } #endif readSettings(); setFocus(); setCurrentFile(""); }