MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); statusLebelL = new QLabel(); statusLabelR = new QLabel(); // setup UI ui.statusBar->addWidget(statusLebelL, 1); ui.statusBar->addWidget(statusLabelR, 0); // setup the docking widgets controlWidget = new ControlWidget(this); // register the menu's "AboutToShow" handlers connect(ui.menuEdit, SIGNAL(aboutToShow()), this, SLOT(onMenuEdit())); // register the menu's action handlers connect(ui.actionNew, SIGNAL(triggered()), this, SLOT(onNew())); connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(onOpen())); connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(onSave())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.actionSelectAll, SIGNAL(triggered()), this, SLOT(onSelectAll())); connect(ui.actionUndo, SIGNAL(triggered()), this, SLOT(onUndo())); connect(ui.actionCut, SIGNAL(triggered()), this, SLOT(onCut())); connect(ui.actionDeleteEdge, SIGNAL(triggered()), this, SLOT(onDeleteEdge())); connect(ui.actionControlWidget, SIGNAL(triggered()), this, SLOT(onShowControlWidget())); // setup the GL widget glWidget = new GLWidget(this); setCentralWidget(glWidget); // setup the event filter glWidget->installEventFilter(this); controlWidget->installEventFilter(this); }
MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags) { ui.setupUi(this); // setup the docking widgets controlWidget = new ControlWidget(this); // setup the toolbar ui.fileToolBar->addAction(ui.actionNew); ui.fileToolBar->addAction(ui.actionOpen); ui.areaToolBar->addAction(ui.actionHintLine); // register the menu's action handlers connect(ui.actionNew, SIGNAL(triggered()), this, SLOT(onNew())); connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(onOpen())); connect(ui.actionLoadArea, SIGNAL(triggered()), this, SLOT(onLoadArea())); connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui.actionCreateArea, SIGNAL(triggered()), this, SLOT(onCreateArea())); connect(ui.actionHintLine, SIGNAL(triggered()), this, SLOT(onHintLine())); connect(ui.actionControlWidget, SIGNAL(triggered()), this, SLOT(onShowControlWidget())); // setup the GL widget glWidget = new GLWidget(this); setCentralWidget(glWidget); controlWidget->show(); addDockWidget(Qt::LeftDockWidgetArea, controlWidget); mode = MODE_AREA_CREATE; }
void App::loadFile(QString f) { filename = f; root->clear(); root->uninstallWatcher(view_scene); QFile file(f); if (!file.open(QIODevice::ReadOnly)) { QMessageBox::critical(NULL, "Loading error", "<b>Loading error:</b><br>" "File does not exist."); onNew(); return; } SceneDeserializer::Info ds; const bool success = SceneDeserializer::run( QJsonDocument::fromJson(file.readAll()).object(), root, &ds); if (!success) { QMessageBox::critical(NULL, "Loading error", "<b>Loading error:</b><br>" + ds.error_message); onNew(); } else { // If there's a warning message, show it in a box. if (!ds.warning_message.isNull()) QMessageBox::information(NULL, "Loading information", "<b>Loading information:</b><br>" + ds.warning_message); graph_scene->setInspectorPositions(ds.inspectors); emit(windowTitleChanged(getWindowTitle())); } root->installWatcher(view_scene); view_scene->trigger(root->getState()); }
void HTAppQt::makeConnections() { //setup qt signals/slots here to communicate to/from main GUI window connect(mQtGUI->ui.actionNew, SIGNAL(triggered()), this, SLOT(onNew())); connect(mQtGUI->ui.action_Open, SIGNAL(triggered()), this, SLOT(onOpen())); connect(mQtGUI->ui.action_Save, SIGNAL(triggered()), this, SLOT(onSave())); connect(mQtGUI->ui.action_Path_planning, SIGNAL(triggered(bool)), this, SLOT(onPathPlanning(bool))); connect(mQtGUI->formationGroup, SIGNAL(triggered(QAction*)), this, SLOT(onFormation(QAction*))); connect(mQtGUI->manoeuvreGroup, SIGNAL(triggered(QAction*)), this, SLOT(onManoeuvre(QAction*))); connect(mQtGUI, SIGNAL(unitSelected(QString)), this, SLOT(unitSelected(QString))); connect(mQtGUI->ui.action_Launch, SIGNAL(triggered()), this, SLOT(onLaunchHypotheses())); connect(mQtGUI->ui.action_Save_2, SIGNAL(triggered()), this, SLOT(onSaveAll())); }
void BaseEditor::actionNew() { static int postfix = 1; const auto name(pImpl_->defaultResourceName_ + std::to_string(postfix++)); IDocument* doc = nullptr; auto editor = pImpl_->get<IEditor>(); TF_ASSERT(editor != nullptr); if (editor) { doc = editor->create(name.c_str(), pImpl_->defaultResourceType_.c_str()); bindDocument(doc); } onNew(name, doc); }
ChessWidget::ChessWidget(QWidget * parent) : QMainWindow(parent), upleft_(20, 50), depth_(0), bs_count_(0), moves_avg_base_(0), depth_avg_(0), movesCount_(0), moves_base_(0), thread_(this), goingToClose_(false), changed_(false), autoPlay_(false), useTimer_(true), timelimit_(1000), depthMax_(2), infoHeight_(60), onNewAction_(0), onLoadAction_(0), onSaveAction_(0), onNextAction_(0), onPrevAction_(0), onGoAction_(0), onTurnBoardAction_(0), onHumanVsHumanAction_(0), onOpenBookAction_(0), onSettingsAction_(0) { g_chesswidget = this; QSettings settings(tr("Dimock"), tr("qchess")); timelimit_ = settings.value(tr("step_time"), 1).toInt()*1000; depthMax_ = settings.value(tr("max_depth"), 16).toInt(); //setFixedSize(450, 600); pv_str_[0] = 0; setAttribute(Qt::WA_DeleteOnClose); setWindowIcon(QIcon(":/images/chess.png")); upleft_.setY(cpos_.getDiffHeight() + 50); cpos_.setUpLeft(upleft_); setFixedSize(cpos_.getBoardWidth() + upleft_.x()*2, cpos_.getBoardHeight() + infoHeight_ + upleft_.y()); createMenu(); onNew(); obook_.load( "debut.tbl", cpos_.getBoard() ); cpos_.setUpdateCallback(&updateCallback); connect(&thread_, SIGNAL(finished()), this, SLOT(onMoveFound())); connect(this, SIGNAL(pvUpdated()), this, SLOT(onPvUpdated())); }
void ChessWidget::createMenu() { QMenu * gameMenu = menuBar()->addMenu(tr("&Game")); onNewAction_ = new QAction(tr("&New"), this); onNewAction_->setStatusTip(tr("Start new game")); onLoadAction_ = new QAction(tr("&Load"), this); onLoadAction_->setStatusTip(tr("Load previously saved game")); onSaveAction_ = new QAction(tr("&Save"), this); onSaveAction_->setStatusTip(tr("Save current game")); onPrevAction_ = new QAction(tr("&Undo move"), this); onPrevAction_->setStatusTip(tr("Undo last move. (only step of one color will be undone)")); onNextAction_ = new QAction(tr("&Redo move"), this); onNextAction_->setStatusTip(tr("Restore undone move")); onGoAction_ = new QAction(tr("&Go"), this); onGoAction_->setStatusTip(tr("Lets program make move")); onTurnBoardAction_ = new QAction(tr("&Turn board"), this); onTurnBoardAction_->setStatusTip(tr("Turn board to play another color")); onTurnBoardAction_->setCheckable(true); onTurnBoardAction_->setChecked(false); onHumanVsHumanAction_ = new QAction(tr("&Human vs. Human"), this); onHumanVsHumanAction_->setStatusTip(tr("Switch to Human with Human mode")); onHumanVsHumanAction_->setCheckable(true); onHumanVsHumanAction_->setChecked(false); QSettings settings(tr("Dimock"), tr("qchess")); onOpenBookAction_ = new QAction(tr("&Open book"), this); onOpenBookAction_->setStatusTip(tr("Use open book")); onOpenBookAction_->setCheckable(true); onOpenBookAction_->setChecked( settings.value(tr("open_book"), true).toBool() ); onSettingsAction_ = new QAction(tr("Settin&gs"), this); onSettingsAction_->setStatusTip(tr("Change game settings")); gameMenu->addAction(onNewAction_); gameMenu->addAction(onLoadAction_); gameMenu->addAction(onSaveAction_); gameMenu->addAction(onPrevAction_); gameMenu->addAction(onNextAction_); gameMenu->addAction(onGoAction_); gameMenu->addAction(onTurnBoardAction_); gameMenu->addAction(onOpenBookAction_); gameMenu->addSeparator(); gameMenu->addAction(onHumanVsHumanAction_); gameMenu->addSeparator(); gameMenu->addAction(onSettingsAction_); connect(onNewAction_, SIGNAL(triggered()), this, SLOT(onNew())); connect(onLoadAction_, SIGNAL(triggered()), this, SLOT(onLoad())); connect(onSaveAction_, SIGNAL(triggered()), this, SLOT(onSave())); connect(onPrevAction_, SIGNAL(triggered()), this, SLOT(onPrev())); connect(onNextAction_, SIGNAL(triggered()), this, SLOT(onNext())); connect(onGoAction_, SIGNAL(triggered()), this, SLOT(onGo())); connect(onTurnBoardAction_, SIGNAL(toggled(bool)), this, SLOT(onTurnBoard(bool))); connect(onHumanVsHumanAction_, SIGNAL(toggled(bool)), this, SLOT(onHumanWithHumanMode(bool))); connect(onOpenBookAction_, SIGNAL(toggled(bool)), this, SLOT(onUseOpenBook(bool))); connect(onSettingsAction_, SIGNAL(triggered()), this, SLOT(onSettings())); }
void TpresetsPage::onNewMenu(void) { onNew(0); }
void TpresetsPage::onNewBt(void) { onNew(ID_MNI_PRESET_NEWFROMDEFAULT); }