bool QtFileIconView::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setDirectory((const QString&)static_QUType_QString.get(_o+1)); break; case 1: setDirectory((const QDir&)*((const QDir*)static_QUType_ptr.get(_o+1))); break; case 2: newDirectory(); break; case 3: currentDir(); break; case 4: itemDoubleClicked((QIconViewItem*)static_QUType_ptr.get(_o+1)); break; case 5: slotDropped((QDropEvent*)static_QUType_ptr.get(_o+1),(const QValueList<QIconDragItem>&)*((const QValueList<QIconDragItem>*)static_QUType_ptr.get(_o+2))); break; case 6: viewLarge(); break; case 7: viewSmall(); break; case 8: viewBottom(); break; case 9: viewRight(); break; case 10: flowEast(); break; case 11: flowSouth(); break; case 12: itemTextTruncate(); break; case 13: itemTextWordWrap(); break; case 14: sortAscending(); break; case 15: sortDescending(); break; case 16: arrangeItemsInGrid(); break; case 17: slotRightPressed((QIconViewItem*)static_QUType_ptr.get(_o+1)); break; case 18: openFolder(); break; default: return QIconView::qt_invoke( _id, _o ); } return TRUE; }
void QtFileIconView::slotRightPressed( QIconViewItem *item ) { if ( !item ) { // right pressed on viewport QPopupMenu menu( this ); menu.insertItem( "&Large view", this, SLOT( viewLarge() ) ); menu.insertItem( "&Small view", this, SLOT( viewSmall() ) ); menu.insertSeparator(); menu.insertItem( "Text at the &bottom", this, SLOT( viewBottom() ) ); menu.insertItem( "Text at the &right", this, SLOT( viewRight() ) ); menu.insertSeparator(); menu.insertItem( "Arrange l&eft to right", this, SLOT( flowEast() ) ); menu.insertItem( "Arrange t&op to bottom", this, SLOT( flowSouth() ) ); menu.insertSeparator(); menu.insertItem( "&Truncate item text", this, SLOT( itemTextTruncate() ) ); menu.insertItem( "&Wordwrap item text", this, SLOT( itemTextWordWrap() ) ); menu.insertSeparator(); menu.insertItem( "Arrange items in &grid", this, SLOT( arrangeItemsInGrid() ) ); menu.insertSeparator(); menu.insertItem( "Sort &ascending", this, SLOT( sortAscending() ) ); menu.insertItem( "Sort &descending", this, SLOT( sortDescending() ) ); menu.setMouseTracking( TRUE ); menu.exec( QCursor::pos() ); } else { // on item QPopupMenu menu( this ); int RENAME_ITEM = menu.insertItem( "Rename Item" ); int REMOVE_ITEM = menu.insertItem( "Remove Item" ); menu.setMouseTracking( TRUE ); int id = menu.exec( QCursor::pos() ); if ( id == -1 ) return; if ( id == RENAME_ITEM && item->renameEnabled() ) { item->rename(); } else if ( id == REMOVE_ITEM ) { delete item; QMessageBox::information( this, "Not implemented!", "Deleting files not implemented yet,\n" "The item has only been removed from the view! " ); } } }
void QoccHarnessWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setShortcut(tr("Ctrl+N")); newAction->setStatusTip(tr("Create a new file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setShortcut(tr("Ctrl+O")); openAction->setStatusTip(tr("Open an existing file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(tr("&Save"), this); saveAction->setShortcut(tr("Ctrl+S")); saveAction->setStatusTip(tr("Save the document to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); printAction = new QAction(tr("&Print..."), this); printAction->setShortcut(tr("Ctrl+P")); printAction->setStatusTip(tr("Print the document")); connect(printAction, SIGNAL(triggered()), this, SLOT(print())); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+X")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); undoAction = new QAction(tr("&Undo"), this); undoAction->setShortcut(tr("Ctrl+Z")); undoAction->setStatusTip(tr("Undo the last operation")); connect(undoAction, SIGNAL(triggered()), this, SLOT(undo())); redoAction = new QAction(tr("&Redo"), this); redoAction->setShortcut(tr("Ctrl+Y")); redoAction->setStatusTip(tr("Redo the last operation")); connect(redoAction, SIGNAL(triggered()), this, SLOT(redo())); cutAction = new QAction(tr("Cu&t"), this); cutAction->setShortcut(tr("Ctrl+X")); cutAction->setStatusTip(tr("Cut the current selection's contents to the clipboard")); connect(cutAction, SIGNAL(triggered()), this, SLOT(cut())); copyAction = new QAction(tr("&Copy"), this); copyAction->setShortcut(tr("Ctrl+C")); copyAction->setStatusTip(tr("Copy the current selection's contents to the clipboard")); connect(copyAction, SIGNAL(triggered()), this, SLOT(copy())); pasteAction = new QAction(tr("&Paste"), this); pasteAction->setShortcut(tr("Ctrl+V")); pasteAction->setStatusTip(tr("Paste the clipboard's contents into the current selection")); connect(pasteAction, SIGNAL(triggered()), this, SLOT(paste())); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt())); // Now for the QtOCCViewWidget slots. /* fitAction = new QAction(tr("&Fit Window"), this); fitAction->setShortcut(tr("Ctrl+F")); fitAction->setStatusTip(tr("Fit to window")); connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents())); */ fitAllAction = new QAction(tr("&Fit All"), this); fitAllAction->setShortcut(tr("Ctrl+F")); fitAllAction->setStatusTip(tr("Fit contents to viewport")); connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll())); zoomAction = new QAction(tr("&Zoom"), this); zoomAction->setStatusTip(tr("Zoom in window")); connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea())); panAction = new QAction(tr("&Pan"), this); panAction->setStatusTip(tr("Window panning")); connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan())); rotAction = new QAction(tr("&Rotate"), this); rotAction->setShortcut(tr("Ctrl+R")); rotAction->setStatusTip(tr("Window rotation")); connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation())); gridToggleAction = new QAction(tr("Toggle &Grid"), this); gridToggleAction->setShortcut(tr("Ctrl+G")); gridToggleAction->setStatusTip(tr("Turn the grid on or off")); connect(gridToggleAction, SIGNAL(triggered()), myVC, SLOT(gridToggle())); /* gridOffAction = new QAction(tr("Gri&d Off"), this); gridOffAction->setShortcut(tr("Ctrl+D")); gridOffAction->setStatusTip(tr("Turn the grid on")); connect(gridOffAction, SIGNAL(triggered()), myVC, SLOT(gridOff())); */ gridXYAction = new QAction(tr("XY Grid"), this); gridXYAction->setStatusTip(tr("Grid on XY Plane")); //gridOffAction->setShortcut(tr("Ctrl+Z")); connect(gridXYAction, SIGNAL(triggered()), myVC, SLOT(gridXY())); gridXZAction = new QAction(tr("XZ Grid"), this); gridXZAction->setStatusTip(tr("Grid on XZ Plane")); //gridXZAction->setShortcut(tr("Ctrl+Y")); connect(gridXZAction, SIGNAL(triggered()), myVC, SLOT(gridXZ())); gridYZAction = new QAction(tr("YZ Grid"), this); gridYZAction->setStatusTip(tr("Grid on YZ Plane")); //gridOffAction->setShortcut(tr("Ctrl+Z")); connect(gridYZAction, SIGNAL(triggered()), myVC, SLOT(gridYZ())); gridRectAction = new QAction(tr("Rectangular"), this); gridRectAction->setStatusTip(tr("Retangular grid")); //gridOffAction->setShortcut(tr("Ctrl+Z")); connect(gridRectAction, SIGNAL(triggered()), myVC, SLOT(gridRect())); gridCircAction = new QAction(tr("Circular"), this); gridCircAction->setStatusTip(tr("Circular grid")); //gridOffAction->setShortcut(tr("Ctrl+Z")); connect(gridCircAction, SIGNAL(triggered()), myVC, SLOT(gridCirc())); // Standard View viewFrontAction = new QAction(tr("Front"), this); viewFrontAction->setStatusTip(tr("View From Front")); connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront())); viewBackAction = new QAction(tr("Back"), this); viewBackAction->setStatusTip(tr("View From Back")); connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack())); viewTopAction = new QAction(tr("Top"), this); viewTopAction->setStatusTip(tr("View From Top")); connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop())); viewBottomAction = new QAction(tr("Bottom"), this); viewBottomAction->setStatusTip(tr("View From Bottom")); connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom())); viewLeftAction = new QAction(tr("Left"), this); viewLeftAction->setStatusTip(tr("View From Left")); connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft())); viewRightAction = new QAction(tr("Right"), this); viewRightAction->setStatusTip(tr("View From Right")); connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight())); viewAxoAction = new QAction(tr("&Axonometric Fit"), this); viewAxoAction->setStatusTip(tr("Axonometric view and fit all")); viewAxoAction->setShortcut(tr("Ctrl+A")); connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo())); viewGridAction = new QAction(tr("Grid"), this); viewGridAction->setStatusTip(tr("View from grid")); connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid())); viewResetAction = new QAction(tr("Reset"), this); viewResetAction->setStatusTip(tr("Reset the view")); connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset())); backgroundAction = new QAction( tr("&Background"), this ); backgroundAction->setStatusTip(tr("Change the background colour")); connect(backgroundAction, SIGNAL(triggered()), myOCC, SLOT(background())); // The co-ordinates from the view connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); // Add a point from the view connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT (addPoint (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); connect( myOCC, SIGNAL(sendStatus(const QString)), this, SLOT (statusMessage(const QString)) ); // And the bottle example bottleAction = new QAction(tr("Load &Bottle"), this); bottleAction->setShortcut(tr("Ctrl+B")); bottleAction->setStatusTip(tr("Bottle sample.")); connect(bottleAction, SIGNAL(triggered()), this, SLOT(bottle())); }
void TIGLViewerWindow::connectSignals() { connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); connect(openScriptAction, SIGNAL(triggered()), this, SLOT(openScript())); connect(closeAction, SIGNAL(triggered()), this, SLOT(closeConfiguration())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); connect(saveScreenshotAction, SIGNAL(triggered()), this, SLOT(makeScreenShot())); connect(setBackgroundAction, SIGNAL(triggered()), this, SLOT(setBackgroundImage())); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(aboutQtAction, SIGNAL(triggered()), this, SLOT(aboutQt())); // Misc drawing actions connect(drawPointAction, SIGNAL(triggered()), this, SLOT(drawPoint())); connect(drawVectorAction, SIGNAL(triggered()), this, SLOT(drawVector())); // view->actions menu connect(fitAction, SIGNAL(triggered()), myOCC, SLOT(fitExtents())); connect(fitAllAction, SIGNAL(triggered()), myOCC, SLOT(fitAll())); //connect(zoomAction, SIGNAL(triggered()), myOCC, SLOT(fitArea())); connect(zoomAction, SIGNAL(triggered()),myOCC, SLOT(zoom())); connect(panAction, SIGNAL(triggered()), myOCC, SLOT(pan())); connect(rotAction, SIGNAL(triggered()), myOCC, SLOT(rotation())); connect(selectAction, SIGNAL(triggered()), myOCC, SLOT(selecting())); // view->grid menu connect(gridOnAction, SIGNAL(toggled(bool)), myScene, SLOT(toggleGrid(bool))); connect(gridXYAction, SIGNAL(triggered()), myScene, SLOT(gridXY())); connect(gridXZAction, SIGNAL(triggered()), myScene, SLOT(gridXZ())); connect(gridYZAction, SIGNAL(triggered()), myScene, SLOT(gridYZ())); connect(gridRectAction, SIGNAL(triggered()), myScene, SLOT(gridRect())); connect(gridCircAction, SIGNAL(triggered()), myScene, SLOT(gridCirc())); // Standard View connect(viewFrontAction, SIGNAL(triggered()), myOCC, SLOT(viewFront())); connect(viewBackAction, SIGNAL(triggered()), myOCC, SLOT(viewBack())); connect(viewTopAction, SIGNAL(triggered()), myOCC, SLOT(viewTop())); connect(viewBottomAction, SIGNAL(triggered()), myOCC, SLOT(viewBottom())); connect(viewLeftAction, SIGNAL(triggered()), myOCC, SLOT(viewLeft())); connect(viewRightAction, SIGNAL(triggered()), myOCC, SLOT(viewRight())); connect(viewAxoAction, SIGNAL(triggered()), myOCC, SLOT(viewAxo())); connect(viewGridAction, SIGNAL(triggered()), myOCC, SLOT(viewGrid())); connect(viewResetAction, SIGNAL(triggered()), myOCC, SLOT(viewReset())); connect(viewZoomInAction, SIGNAL(triggered()), myOCC, SLOT(zoomIn())); connect(viewZoomOutAction, SIGNAL(triggered()), myOCC, SLOT(zoomOut())); connect(showConsoleAction, SIGNAL(toggled(bool)), consoleDockWidget, SLOT(setVisible(bool))); connect(consoleDockWidget, SIGNAL(visibilityChanged(bool)), showConsoleAction, SLOT(setChecked(bool))); connect(showWireframeAction, SIGNAL(toggled(bool)), myScene, SLOT(wireFrame(bool))); connect(openTimer, SIGNAL(timeout()), this, SLOT(reopenFile())); // The co-ordinates from the view connect( myOCC, SIGNAL(mouseMoved(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT(xyzPosition(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); // Add a point from the view connect( myOCC, SIGNAL(pointClicked(V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)), this, SLOT (addPoint (V3d_Coordinate,V3d_Coordinate,V3d_Coordinate)) ); connect( myOCC, SIGNAL(sendStatus(const QString)), this, SLOT (statusMessage(const QString)) ); connect(stdoutStream, SIGNAL(sendString(QString)), console, SLOT(output(QString))); connect(errorStream , SIGNAL(sendString(QString)), console, SLOT(output(QString))); connect(logDirect.get(), SIGNAL(newMessage(QString)), console, SLOT(output(QString))); connect(scriptEngine, SIGNAL(scriptResult(QString)), console, SLOT(output(QString))); connect(scriptEngine, SIGNAL(scriptError(QString)), console, SLOT(outputError(QString))); connect(scriptEngine, SIGNAL(evalDone()), console, SLOT(endCommand())); connect(console, SIGNAL(onChange(QString)), scriptEngine, SLOT(textChanged(QString))); connect(console, SIGNAL(onCommand(QString)), scriptEngine, SLOT(eval(QString))); connect(settingsAction, SIGNAL(triggered()), this, SLOT(changeSettings())); }
//! [1] void MainWidget::timerEvent(QTimerEvent *) { float alpha = .05; float d = cameraPosition.length(); for (unsigned idx = 0; idx < planets.size(); ++idx) d = std::min(d, cameraPosition.distanceToPoint(planets[idx]->statePosition)); float delta = std::max(d / 10, .000001f); QVector3D direct = getDirection(); if (holdedKeys.count(Qt::Key_W)) viewForward(delta); if (holdedKeys.count(Qt::Key_S)) viewForward(-delta); if (holdedKeys.count(Qt::Key_D)) { QVector3D d = QVector3D::normal(direct, direct + QVector3D(0, 1, 0)); cameraPosition += d * delta; } if (holdedKeys.count(Qt::Key_A)) { QVector3D d = QVector3D::normal(direct, direct + QVector3D(0, 1, 0)); cameraPosition -= d * delta; } if (holdedKeys.count(Qt::Key_Up)) viewUp(alpha); if (holdedKeys.count(Qt::Key_Down)) viewUp(-alpha); if (holdedKeys.count(Qt::Key_Right)) viewRight(alpha); if (holdedKeys.count(Qt::Key_Left)) viewRight(-alpha); for (char num = '0'; num <= '9'; ++num) if (holdedKeys.count(num)) { QVector3D move = -cameraPosition; float soNear = theSun->radius; if (PlanetConfig::modeSurvey) soNear = aSun->radius; if (num != '0') { move = planets[num - '1']->statePosition - cameraPosition; soNear = planets[num - '1']->radius; } float x = std::atan2(move.x(), -move.z()); float y = std::atan2(move.y(), std::pow(move.x() * move.x() + move.z() * move.z(), .5f)); if (x == cameraDirection.x() && y == cameraDirection.y()) { viewForward(delta); } else { viewRight(x - cameraDirection.x()); viewUp(y - cameraDirection.y()); } } if (modeFps) { QPoint pos = QCursor::pos() - mapToGlobal(QPoint(width() / 2, height() / 2)); viewUp(-pos.y() * .01); viewRight(pos.x() * .01); QCursor::setPos(mapToGlobal(QPoint(width() / 2, height() / 2))); } if (holdedKeys.count(Qt::Key_Plus)) modifyAngle(1); if (holdedKeys.count(Qt::Key_Minus)) modifyAngle(-1); if (holdedKeys.count('/')) modifyAngle(viewAngle - 45); if (holdedKeys.count(Qt::Key_C)) changeDeltaTime(deltaTime * 2); if (holdedKeys.count(Qt::Key_Z)) changeDeltaTime(deltaTime / 2); if (holdedKeys.count(Qt::Key_X)) changeDeltaTime(0); // // Decrease angular speed (friction) // angularSpeed *= 0.99; // // Stop rotation when speed goes below threshold // if (angularSpeed < 0.01) { // angularSpeed = 0.0; // } else { // // Update rotation // rotation = QQuaternion::fromAxisAndAngle(rotationAxis, angularSpeed) * rotation; // // Update scene // } QDateTime now = QDateTime::currentDateTimeUtc(); if (action) shiftedTime = shiftedTime.addMSecs(deltaTime * prevTime.msecsTo(now)); for (unsigned idx = 0; idx < planets.size(); ++idx) planets[idx]->changeTime(shiftedTime); prevTime = now; updateGL(); }