Exemple #1
0
void MainWindow::createActs()
{
    newAct = new QAction(tr("New"), this);
    newAct->setShortcut(QKeySequence::New);
    connect(newAct, SIGNAL(triggered()), m_field, SLOT(newGame()));

    pauseAct = new QAction(tr("Pause"), this);
    pauseAct->setCheckable(true);
    pauseAct->setShortcut(Qt::Key_P);
    connect(pauseAct, SIGNAL(toggled(bool)), m_field, SLOT(pause(bool)));

    showHighScoreAct = new QAction(tr("Show High Scores"), this);
    connect(showHighScoreAct, SIGNAL(triggered()), SLOT(showHighScore()));

    quitAct = new QAction(tr("Quit"), this);
    quitAct->setShortcut(QKeySequence::Quit);
    connect(quitAct, SIGNAL(triggered()), SLOT(close()));

    showToolbarAct = new QAction(tr("Show Toolbar"), this);
    showToolbarAct->setCheckable(true);
    showToolbarAct->setChecked(true);

    showStatusbarAct = new QAction(tr("Show Statusbar"), this);
    showStatusbarAct->setCheckable(true);
    showStatusbarAct->setChecked(true);

    easyAct = new QAction(tr("Easy"), this);
    easyAct->setCheckable(true);
    easyAct->setData(1);
    connect(easyAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    mediumAct = new QAction(tr("Medium"), this);
    mediumAct->setCheckable(true);
    mediumAct->setData(2);
    connect(mediumAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    hardAct = new QAction(tr("Hard"), this);
    hardAct->setCheckable(true);
    hardAct->setData(3);
    connect(hardAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    customAct = new QAction(tr("Custom"), this);
    customAct->setCheckable(true);
    customAct->setData(4);
    connect(customAct, SIGNAL(triggered()), m_field, SLOT(setDifficulty()));

    QActionGroup *actGroup = new QActionGroup(this);
    actGroup->addAction(easyAct);
    actGroup->addAction(mediumAct);
    actGroup->addAction(hardAct);
    actGroup->addAction(customAct);
    easyAct->setChecked(true);

    aboutAct = new QAction(tr("About"), this);
    aboutAct->setShortcut(QKeySequence::HelpContents);
    connect(aboutAct, SIGNAL(triggered()), SLOT(aboutSlot()));
}
Exemple #2
0
void FFCP::createActions()
{
	newAct = new QAction( tr("新建"), this);  //QIcon("./images/open.png"), 暂时不设置图片
	newAct->setShortcut(tr("N"));   
	connect(newAct, SIGNAL(triggered()), this, SLOT(newSlot()));

	openAct = new QAction(tr("打开"), this);
	openAct->setShortcut(tr("O"));   
	connect(openAct, SIGNAL(triggered()), this, SLOT(openSlot()));

	saveAct = new QAction(tr("保存"), this);
	saveAct->setShortcut(tr("S"));
	connect(saveAct, SIGNAL(triggered()), this, SLOT(saveSlot()));

	quitAct = new QAction(tr("退出"), this);
	quitAct->setShortcut(tr("Q"));
	connect(quitAct, SIGNAL(triggered()), this, SLOT(close()));

	aboutAct = new QAction(tr("关于"), this);
	aboutAct->setShortcut(tr("A"));
	connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutSlot()));

	compileAct = new QAction(tr("编译"), this);
	compileAct->setShortcut(tr("F7"));
	connect(compileAct, SIGNAL(triggered()), this, SLOT(compileSlot()));

	simulationAct = new QAction(tr("仿真"), this);
	simulationAct->setShortcut(tr("F6"));
	connect(simulationAct, SIGNAL(triggered()), this, SLOT(simulationSlot()));

	downloadAct = new QAction(tr("下载"), this);
	downloadAct->setShortcut(tr("F5"));
	connect(downloadAct, SIGNAL(triggered()), this, SLOT(downloadSlot()));

	clearAct = new QAction(tr("清除"), this);
	clearAct->setShortcut(tr("F8"));
	connect(clearAct, SIGNAL(triggered()), this, SLOT(clearSlot()));

	//在工具中添加变量定义
	defineAct = new QAction(tr("变量定义"),this);
	defineAct->setShortcut(tr("F1"));
	connect(defineAct, SIGNAL(triggered()), this, SLOT(defineSlot()));

	hardwareAct = new QAction(tr("硬件结构图"), this);
	defineAct->setShortcut(tr("F3"));
	connect(hardwareAct, SIGNAL(triggered()), this, SLOT(hardwareSlot()));

	softwareAct = new QAction(tr("软件流程图"), this);
	defineAct->setShortcut(tr("F2"));
	connect(softwareAct, SIGNAL(triggered()), this, SLOT(softwareSlot()));
}
void MainWindow::createActions(){
    this->newGameAction=new QAction(tr("&New Game"),this);
    this->newGameAction->setStatusTip(tr("start a new game"));
    this->newGameAction->setShortcut(tr("Ctrl+n"));
    //this->newGameAction->setIcon(QIcon(":/images/img/new.png"));  //doesn't work?
    connect(this->newGameAction,SIGNAL(triggered()),this,SLOT(newGameSlot()));

    this->quitAction=new QAction(tr("&Quit"),this);
    this->quitAction->setStatusTip(tr("quit QMineSweeper"));
    this->quitAction->setShortcut(tr("Ctrl+q"));
    //this->quitAction->setIcon(QIcon(":/images/img/quit.png"));    //doesn't work?
    connect(this->quitAction,SIGNAL(triggered()),this,SLOT(close()));

    this->aboutAction=new QAction(tr("&About"),this);
    this->aboutAction->setShortcut(tr("Ctrl+h"));
    connect(this->aboutAction,SIGNAL(triggered()),this,SLOT(aboutSlot()));
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: newGameSlot(); break;
        case 1: aboutSlot(); break;
        case 2: winSlot(); break;
        case 3: loseSlot(); break;
        case 4: updateGUISlot((*reinterpret_cast< bool(*)>(_a[1]))); break;
        default: ;
        }
        _id -= 5;
    }
    return _id;
}
bool mainWidget::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: slotLoadMainConfig((const QString&)static_QUType_QString.get(_o+1)); break;
    case 1: slotFileOpen(); break;
    case 2: chooseOpenFile(); break;
    case 3: slotClickedListViewItem((QListViewItem*)static_QUType_ptr.get(_o+1)); break;
    case 4: slotFileSave(); break;
    case 5: aboutSlot(); break;
    case 6: slotReloadMainConfig(); break;
    case 7: slotAskForSave(); break;
    case 8: commentLine(); break;
    case 9: closeClicked(); break;
    case 10: languageChange(); break;
    default:
	return QMainWindow::qt_invoke( _id, _o );
    }
    return TRUE;
}
Exemple #6
0
/**
 * @brief MainWindow::MainWindow Initialize the main window and everything else
 * @param parent
 */
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
  // Initialize the interface
  ui->setupUi(this);
  ui->glWidget->addAction(ui->actionFullscreen);
  ui->glWidget->addAction(ui->actionExit);

  connect(ui->actionExit,SIGNAL(triggered()),this,SLOT(close()));
  connect(ui->actionFullscreen,SIGNAL(triggered()),this,SLOT(toggleFullscreenSlot()));

  // The test script runs a simple experiment
  experimentScript = new TestScript(this,this);

  // Add a cosmetic line to the splitter handle
  // so that it's easier to grab with the mouse
  QSplitterHandle *handle = ui->splitter->handle(1);
  QVBoxLayout *layout = new QVBoxLayout(handle);
  layout->setSpacing(0);
  layout->setMargin(0);
  QFrame *line = new QFrame(handle);
  line->setFrameShape(QFrame::VLine);
  line->setFrameShadow(QFrame::Sunken);
  layout->addWidget(line);

  // In a future revision, we'll move the SimWorld
  // to a more intelligent place.  It doesn't
  // belong as a child to the graphics widget.
  SimWorld* world = ui->glWidget->getWorld();
  CapBody* capBody = world->getBody();
#if defined( BOARD_DATA )
  BoardMarkerData* md = ui->glWidget->getWorld()->getMarkerData();
#elif defined( POKE_DATA )
  PokeMarkerData* md = ui->glWidget->getWorld()->getMarkerData();
#else
  MarkerData* md = world->getMarkerData();
#endif

  // We populate a ScrollArea with the same number of
  // MarkerWidgets as there are markers in the data file.
  QScrollArea* sa = new QScrollArea;
  QWidget* wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);

  // This part needs to become part of a function
  // that is called everytime a new data file is
  // loaded.
  int markCnt = md->marker_count;
  ui->markerCountLineEdit->setText(QString::number(markCnt));
  ui->frameCountLineEdit->setText(QString::number(md->size()));
  ui->markerFileLineEdit->setText("data.c3d");
  ui->markerFrameStartBox->setValue(0);
  setDataRange(md->size());

  QHBoxLayout* innerLayout = new QHBoxLayout;
  QPushButton* connectButton = new QPushButton("Connect");
  QPushButton* releaseButton = new QPushButton("Release");
  QPushButton* updateButton = new QPushButton("Update Anchors");
  innerLayout->addWidget(connectButton);
  innerLayout->addWidget(releaseButton);
  innerLayout->addWidget(updateButton);
  connect(connectButton,SIGNAL(clicked()),this,SLOT(connectMarkers()));
  connect(releaseButton,SIGNAL(clicked()),this,SLOT(releaseMarkers()));
  connect(updateButton,SIGNAL(clicked()),this,SLOT(updateMarkerAnchors()));
  layout->addLayout(innerLayout);

  markerWidgetArray.resize(markCnt);
  for (int ii=0;ii<markCnt;++ii) {
    markerWidgetArray[ii] = new MarkerWidget(ii,0);
    layout->addWidget(markerWidgetArray[ii]);
  }
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Markers");

  // Joint control tab
  sa = new QScrollArea;
  wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);

  // A couple buttons at the top of the joint tab make it possible
  // to rapidly change all the force limits
  innerLayout = new QHBoxLayout;
  QPushButton* zeroButton = new QPushButton("Zero");
  QPushButton* lightButton = new QPushButton("Light");
  QPushButton* resetButton = new QPushButton("Strong");
  innerLayout->addWidget(zeroButton);
  innerLayout->addWidget(lightButton);
  innerLayout->addWidget(resetButton);
  layout->addLayout(innerLayout);
  connect(zeroButton,SIGNAL(clicked()),this,SLOT(zeroForces()));
  connect(lightButton,SIGNAL(clicked()),this,SLOT(lightForces()));
  connect(resetButton,SIGNAL(clicked()),this,SLOT(strongForces()));

  // Fill the tab with hard-coded data about the model...
  populateJointTab(capBody,layout);
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Joints");

  // Body dimensions widget
  sa = new QScrollArea;
  wid = new QWidget;
  layout = new QVBoxLayout;
  layout->setContentsMargins(0,0,0,0);
  QCheckBox* keepBodyRel = new QCheckBox("Body Rel");
  layout->addWidget(keepBodyRel);

  // Fill the tab with model-specific widgets
  populateBodyTab(capBody,layout);
  wid->setLayout(layout);
  sa->setWidget(wid);
  ui->controlTabWidget->addTab(sa,"Model dimensions");

  // Hook up the interface elements to their respecitve functionality
  connect(ui->saveButton,SIGNAL(clicked()),capBody,SLOT(saveBody()));
  connect(ui->loadButton,SIGNAL(clicked()),capBody,SLOT(loadBody()));
  connect(ui->testButton,SIGNAL(clicked()),this,SLOT(experimentSlot()));

  // When a the CapBody loads the marker map, tell the interface
  // how and where the markers are connected.
  connect(capBody,SIGNAL(markMap(int,int)),this,SLOT(setMarkMap(int,int)));
  connect(capBody,SIGNAL(markPoint(int,double,double,double)),
          this,SLOT(setMarkPoint(int,double,double,double)));

  // *****
  // (Each MarkerWidget informs the capBody when the interface
  //  changes).
  for (int ii=0;ii<markCnt;++ii) {
    connect(markerWidgetArray[ii],SIGNAL(markBodySet(int,int)),md,SLOT(changeBodyConnect(int,int)));
    connect(markerWidgetArray[ii],SIGNAL(markConnect(int,bool)),md,SLOT(changeBodyLink(int,bool)));
    connect(markerWidgetArray[ii],SIGNAL(markPosSet(int,double,double,double)),
            md,SLOT(changeLinkPos(int,double,double,double)));
    connect(markerWidgetArray[ii],SIGNAL(markGrab(int)),this, SLOT(grabMarkPos(int)));
  }

  connect(ui->clearPlotButton,SIGNAL(clicked()),this,SLOT(clearData()));
  connect(ui->glWidget->getWorld(),SIGNAL(useMarkers(bool)),this,SLOT(usingMarkers(bool)));
  connect(ui->frictionSpinBox,SIGNAL(valueChanged(double)),world,SLOT(setGroundFriction(double)));
  connect(ui->terrainSpinBox,SIGNAL(valueChanged(double)),world,SLOT(setTerrainSoftness(double)));
  connect(ui->zBox,SIGNAL(valueChanged(double)),ui->glWidget->getWorld(),SLOT(setTerrainZ(double)));
  connect(ui->forceLinesCheckBox,SIGNAL(clicked(bool)),ui->glWidget,SLOT(setDrawLines(bool)));
  connect(ui->camFollowCheckBox,SIGNAL(clicked(bool)),ui->glWidget,SLOT(setFollowCamera(bool)));
  connect(ui->timeSlider,SIGNAL(valueChanged(int)),world->getMarkerData(),SLOT(setFrame(int)));
  connect(ui->glWidget->getWorld()->getMarkerData(),SIGNAL(frameChanged(int)),ui->timeSlider,SLOT(setValue(int)));
  connect(ui->bodyAlpha,SIGNAL(valueChanged(double)),ui->glWidget,SLOT(setBodyAlpha(double)));
  connect(ui->showMarkBox,SIGNAL(toggled(bool)),ui->glWidget,SLOT(setShowMarkers(bool)));
  connect(ui->selfCollideBox,SIGNAL(toggled(bool)),world,SLOT(setSelfCollide(bool)));
  connect(ui->saveStateButton,SIGNAL(clicked()),this,SLOT(saveModel()));
  connect(ui->restoreButton,SIGNAL(clicked()),this,SLOT(restoreModel()));

  connect(ui->markerRadio,SIGNAL(toggled(bool)),this,SLOT(useMarkers(bool)));
  connect(ui->torqueRadio,SIGNAL(toggled(bool)),this,SLOT(useTorques(bool)));
  connect(ui->altRadio,SIGNAL(toggled(bool)),this,SLOT(useAltForces(bool)));

  connect(ui->playAllButton,SIGNAL(clicked(bool)),this,SLOT(playPauseAll(bool)));
  connect(ui->playPauseDataButton,SIGNAL(clicked(bool)),this,SLOT(playPauseData(bool)));
  connect(ui->playPauseSimButton,SIGNAL(clicked(bool)),this,SLOT(playPauseSim(bool)));

  connect(ui->stepAllButton,SIGNAL(clicked()),this,SLOT(stepAll()));
  connect(ui->stepDataButton,SIGNAL(clicked()),this,SLOT(stepData()));
  connect(ui->stepSimButton,SIGNAL(clicked()),this,SLOT(stepSim()));


  connect(ui->selectFileToolButton,SIGNAL(clicked()),this,SLOT(markerFileDialog()));
  connect(ui->dataStepBox,SIGNAL(valueChanged(int)),this,SLOT(setDataStep(int)));
  connect(ui->dataFrameBox,SIGNAL(valueChanged(int)),this,SLOT(setDataFrame(int)));
  connect(ui->timeSlider,SIGNAL(valueChanged(int)),ui->dataFrameBox,SLOT(setValue(int)));

  connect(ui->actionAbout,SIGNAL(triggered()),this,SLOT(aboutSlot()));

  // Monitor and manipulate recorded angle data
  connect(world->angle_sequence,SIGNAL(lengthChanged(int)),this,SLOT(setAngleFrameCount(int)));
  connect(ui->angleDataFrameBox,SIGNAL(valueChanged(int)),this,SLOT(setAngleCurrentFrame(int)));
  connect(world,SIGNAL(angleFrame(int)),this,SLOT(setAngleCurrentFrame(int)));
  connect(ui->saveAnglesButton,SIGNAL(clicked()),this,SLOT(writeSavedAngles()));
  connect(ui->loadAnglesButton,SIGNAL(clicked()),this,SLOT(loadSavedAngles()));
  connect(ui->clearAnglesButton,SIGNAL(clicked()),this,SLOT(clearSavedAngles()));

  // Monitor and manipulate recorded torque data
  connect(world->torque_sequence,SIGNAL(lengthChanged(int)),this,SLOT(setTorqueFrameCount(int)));
  connect(ui->torqueDataFrameBox,SIGNAL(valueChanged(int)),this,SLOT(setTorqueCurrentFrame(int)));
  connect(world,SIGNAL(torqueFrame(int)),this,SLOT(setTorqueCurrentFrame(int)));
  connect(ui->saveTorquesButton,SIGNAL(clicked()),this,SLOT(writeSavedTorques()));
  connect(ui->loadTorquesButton,SIGNAL(clicked()),this,SLOT(loadSavedTorques()));
  connect(ui->clearTorquesButton,SIGNAL(clicked()),this,SLOT(clearSavedTorques()));

  // *****
  // Need to dynamically change this
  ui->timeSlider->setRange(0,world->getMarkerData()->size()-1);
  connect(ui->globalBox,SIGNAL(toggled(bool)),this,SLOT(useGlobalForces(bool)));

#if defined( BOARD_DATA )
  bd = new BoardData(this);
  bd->loadData("boardData.dat");
  ui->glWidget->setBoardData(bd);
#endif

  // Start the timer for updating the data, sim, and graphics
  updateTimer.setSingleShot(false);
  connect(&updateTimer,SIGNAL(timeout()),this,SLOT(updateLoop()));

  connect(ui->frameTimeBox,SIGNAL(valueChanged(double)),this,SLOT(setFrameTime(double)));
  ui->frameTimeBox->setValue(1/60.0);
  ui->dataStepBox->setValue(2);

  capBody->loadBody();
  useMarkers(true);
  saveModel();
}