void Knob::contextMenuEvent( QContextMenuEvent * ) { // for the case, the user clicked right while pressing left mouse- // button, the context-menu appears while mouse-cursor is still hidden // and it isn't shown again until user does something which causes // an QApplication::restoreOverrideCursor()-call... mouseReleaseEvent( NULL ); CaptionMenu contextMenu( model()->displayName(), this ); addDefaultActions( &contextMenu ); contextMenu.addAction( QPixmap(), model()->isScaleLogarithmic() ? tr( "Set linear" ) : tr( "Set logarithmic" ), this, SLOT( toggleScale() ) ); contextMenu.addSeparator(); contextMenu.addHelpAction(); contextMenu.exec( QCursor::pos() ); }
QWzmViewer::QWzmViewer(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow()), psModel(NULL), timer(new QTimer(this)) { QSettings settings; ui->setupUi(this); connectorsModel.setColumnCount(4); connectorsModel.setHeaderData(0, Qt::Horizontal, QString("X")); connectorsModel.setHeaderData(1, Qt::Horizontal, QString("Y")); connectorsModel.setHeaderData(2, Qt::Horizontal, QString("Z")); connectorsModel.setHeaderData(3, Qt::Horizontal, QString(tr("Type"))); animationModel.setColumnCount(8); animationModel.setHeaderData(0, Qt::Horizontal, QString(tr("Time"))); animationModel.setHeaderData(1, Qt::Horizontal, QString("Tex")); animationModel.setHeaderData(2, Qt::Horizontal, QString("Trs X")); animationModel.setHeaderData(3, Qt::Horizontal, QString("Trs Y")); animationModel.setHeaderData(4, Qt::Horizontal, QString("Trs Z")); animationModel.setHeaderData(5, Qt::Horizontal, QString("Rot X")); animationModel.setHeaderData(6, Qt::Horizontal, QString("Rot Y")); animationModel.setHeaderData(7, Qt::Horizontal, QString("Rot Z")); fileNameLabel = new QLabel(tr("No file loaded"), ui->statusBar); selectedMeshComboBox = new QComboBox(ui->statusBar); selectedMeshComboBox->setToolTip(tr("Selected Mesh")); selectedMeshComboBox->setEnabled(false); visibleMeshComboBox = new QComboBox(ui->statusBar); visibleMeshComboBox->setEnabled(false); visibleMeshComboBox->setToolTip(tr("Visible Mesh")); visibleMeshComboBox->addItem(tr("All")); teamComboBox = new QComboBox(ui->statusBar); teamComboBox->setToolTip(tr("Team Colour")); teamComboBox->addItem(tr("Green")); teamComboBox->addItem(tr("Yellow")); teamComboBox->addItem(tr("Grey")); teamComboBox->addItem(tr("Black")); teamComboBox->addItem(tr("Red")); teamComboBox->addItem(tr("Blue")); teamComboBox->addItem(tr("Pink")); teamComboBox->addItem(tr("Cyan")); scaleSlider = new QSlider(ui->statusBar); scaleSlider->setToolTip(tr("Scale")); scaleSlider->setRange(1, 1000); scaleSlider->setValue(100); scaleSlider->setOrientation(Qt::Horizontal); scaleSlider->setEnabled(false); ui->statusBar->addPermanentWidget(fileNameLabel); ui->statusBar->addPermanentWidget(selectedMeshComboBox); ui->statusBar->addPermanentWidget(visibleMeshComboBox); ui->statusBar->addPermanentWidget(teamComboBox); ui->statusBar->addPermanentWidget(scaleSlider); ui->connectorTableView->setModel(&connectorsModel); ui->animationTableView->setModel(&animationModel); ui->animationDockWidget->hide(); ui->connectorDockWidget->hide(); connect(timer, SIGNAL(timeout()), this, SLOT(tick())); connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(actionOpen())); connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(actionSave())); connect(ui->actionSaveAs, SIGNAL(triggered()), this, SLOT(actionSaveAs())); connect(ui->actionQuit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); connect(ui->actionImport_3DS, SIGNAL(triggered()), this, SLOT(open3DS())); connect(ui->actionWireframe, SIGNAL(triggered()), this, SLOT(toggleWireframe())); connect(ui->actionHelpContents, SIGNAL(triggered()), ui->glView, SLOT(help())); connect(ui->actionAboutQt, SIGNAL(triggered()), QApplication::instance(), SLOT(aboutQt())); connect(ui->actionAboutApplication, SIGNAL(triggered()), this, SLOT(actionAboutApplication())); connect(ui->actionAxis, SIGNAL(triggered()), ui->glView, SLOT(toggleAxisIsDrawn())); connect(ui->actionCulling, SIGNAL(triggered()), this, SLOT(toggleCulling())); connect(ui->actionAnimation, SIGNAL(triggered()), this, SLOT(toggleAnimation())); connect(ui->actionScaleModel, SIGNAL(triggered()), this, SLOT(toggleScale())); connect(selectedMeshComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setMesh(int))); connect(visibleMeshComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setVisibleMesh(int))); connect(teamComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTeam(int))); connect(ui->actionSwapYZ, SIGNAL(triggered()), this, SLOT(toggleSwapYZ())); connect(ui->actionReverseWinding, SIGNAL(triggered()), this, SLOT(toggleReverseWinding())); connect(ui->actionFlipVerticalTexCoords, SIGNAL(triggered()), this, SLOT(toggleFlipVerticalTexCoords())); connect(ui->actionFramesEditor, SIGNAL(toggled(bool)), this, SLOT(toggleEditAnimation(bool))); connect(ui->actionConnectorsEditor, SIGNAL(toggled(bool)), this, SLOT(toggleEditConnectors(bool))); connect(ui->animationDockWidget, SIGNAL(visibilityChanged(bool)), ui->actionFramesEditor, SLOT(setChecked(bool))); connect(ui->connectorDockWidget, SIGNAL(visibilityChanged(bool)), ui->actionConnectorsEditor, SLOT(setChecked(bool))); connect(ui->prependFrameButton, SIGNAL(pressed()), this, SLOT(prependFrame())); connect(ui->appendFrameButton, SIGNAL(pressed()), this, SLOT(appendFrame())); connect(ui->removeFrameButton, SIGNAL(pressed()), this, SLOT(removeFrame())); // Set defaults toggleAnimation(); ui->actionSave->setEnabled(false); ui->actionSaveAs->setEnabled(false); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("windowState").toByteArray()); timer->start(25); }