void tst_QScriptEngineDebugger::standardObjects() { #if defined(Q_OS_WINCE) && _WIN32_WCE < 0x600 QSKIP("skipped due to high mem usage until task 261062 is fixed", SkipAll); #endif QScriptEngine engine; QScriptEngineDebugger debugger; debugger.attachTo(&engine); QMainWindow *win = debugger.standardWindow(); QCOMPARE(static_cast<QWidget *>(win->parent()), (QWidget*)0); QMenu *menu = debugger.createStandardMenu(); QCOMPARE(static_cast<QWidget *>(menu->parent()), (QWidget*)0); QToolBar *toolBar = debugger.createStandardToolBar(); QCOMPARE(static_cast<QWidget *>(toolBar->parent()), (QWidget*)0); QMenu *menu2 = debugger.createStandardMenu(win); QCOMPARE(static_cast<QWidget *>(menu2->parent()), (QWidget*)win); QVERIFY(menu2 != menu); QToolBar *toolBar2 = debugger.createStandardToolBar(win); QCOMPARE(static_cast<QWidget *>(toolBar2->parent()), (QWidget*)win); QVERIFY(toolBar2 != toolBar); delete menu; delete toolBar; }
MainWindow::MainWindow(QWidget* parent) : CGAL::Qt::DemosMainWindow(parent) { ui = new Ui::MainWindow; ui->setupUi(this); // remove the Load Script menu entry, when the demo has not been compiled with QT_SCRIPT_LIB #if !defined(QT_SCRIPT_LIB) ui->menuBar->removeAction(ui->actionLoad_Script); #endif // Save some pointers from ui, for latter use. sceneView = ui->sceneView; viewer = ui->viewer; // do not save the state of the viewer (anoying) viewer->setStateFileName(QString::null); // setup scene scene = new Scene(this); viewer->setScene(scene); { QShortcut* shortcut = new QShortcut(QKeySequence(Qt::ALT+Qt::Key_Q), this); connect(shortcut, SIGNAL(activated()), this, SLOT(setFocusToQuickSearch())); } proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(scene); connect(ui->searchEdit, SIGNAL(textChanged(QString)), proxyModel, SLOT(setFilterFixedString(QString))); sceneView->setModel(proxyModel); // setup the sceneview: delegation and columns sizing... sceneView->setItemDelegate(new SceneDelegate(this)); sceneView->header()->setStretchLastSection(false); sceneView->header()->setSectionResizeMode(Scene::NameColumn, QHeaderView::Stretch); sceneView->header()->setSectionResizeMode(Scene::NameColumn, QHeaderView::Stretch); sceneView->header()->setSectionResizeMode(Scene::ColorColumn, QHeaderView::ResizeToContents); sceneView->header()->setSectionResizeMode(Scene::RenderingModeColumn, QHeaderView::Fixed); sceneView->header()->setSectionResizeMode(Scene::ABColumn, QHeaderView::Fixed); sceneView->header()->setSectionResizeMode(Scene::VisibleColumn, QHeaderView::Fixed); sceneView->resizeColumnToContents(Scene::ColorColumn); sceneView->resizeColumnToContents(Scene::RenderingModeColumn); sceneView->resizeColumnToContents(Scene::ABColumn); sceneView->resizeColumnToContents(Scene::VisibleColumn); // setup connections connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )), this, SLOT(updateInfo())); connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )), this, SLOT(updateDisplayInfo())); connect(scene, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex & )), viewer, SLOT(updateGL())); connect(scene, SIGNAL(updated()), viewer, SLOT(updateGL())); connect(scene, SIGNAL(updated()), this, SLOT(selectionChanged())); connect(scene, SIGNAL(itemAboutToBeDestroyed(Scene_item*)), this, SLOT(removeManipulatedFrame(Scene_item*))); connect(scene, SIGNAL(updated_bbox()), this, SLOT(updateViewerBBox())); connect(scene, SIGNAL(selectionChanged(int)), this, SLOT(selectSceneItem(int))); connect(sceneView->selectionModel(), SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ), this, SLOT(updateInfo())); connect(sceneView->selectionModel(), SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ), this, SLOT(updateDisplayInfo())); connect(sceneView->selectionModel(), SIGNAL(selectionChanged ( const QItemSelection & , const QItemSelection & ) ), this, SLOT(selectionChanged())); sceneView->setContextMenuPolicy(Qt::CustomContextMenu); connect(sceneView, SIGNAL(customContextMenuRequested(const QPoint & )), this, SLOT(showSceneContextMenu(const QPoint &))); connect(viewer, SIGNAL(selected(int)), this, SLOT(selectSceneItem(int))); connect(viewer, SIGNAL(selectedPoint(double, double, double)), this, SLOT(showSelectedPoint(double, double, double))); connect(viewer, SIGNAL(selectionRay(double, double, double, double, double, double)), scene, SIGNAL(selectionRay(double, double, double, double, double, double))); connect(viewer, SIGNAL(requestContextMenu(QPoint)), this, SLOT(contextMenuRequested(QPoint))); // The contextMenuPolicy of infoLabel is now the default one, so that one // can easily copy-paste its text. // connect(ui->infoLabel, SIGNAL(customContextMenuRequested(const QPoint & )), // this, SLOT(showSceneContextMenu(const QPoint &))); connect(ui->actionRecenterScene, SIGNAL(triggered()), viewer, SLOT(update())); connect(ui->actionAntiAliasing, SIGNAL(toggled(bool)), viewer, SLOT(setAntiAliasing(bool))); connect(ui->actionDraw_two_sides, SIGNAL(toggled(bool)), viewer, SLOT(setTwoSides(bool))); // add the "About CGAL..." and "About demo..." entries this->addAboutCGAL(); this->addAboutDemo(":/cgal/Polyhedron_3/about.html"); // Connect the button "addButton" with actionLoad ui->addButton->setDefaultAction(ui->actionLoad); // Same with "removeButton" and "duplicateButton" ui->removeButton->setDefaultAction(ui->actionErase); ui->duplicateButton->setDefaultAction(ui->actionDuplicate); // Connect actionQuit (Ctrl+Q) and qApp->quit() connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit())); // Connect "Select all items" connect(ui->actionSelect_all_items, SIGNAL(triggered()), this, SLOT(selectAll())); // Recent files menu this->addRecentFiles(ui->menuFile, ui->actionQuit); connect(this, SIGNAL(openRecentFile(QString)), this, SLOT(open(QString))); // Reset the "Operation menu" clearMenu(ui->menuOperations); #ifdef QT_SCRIPT_LIB std::cerr << "Enable scripts.\n"; script_engine = new QScriptEngine(this); qScriptRegisterMetaType<Scene_item*>(script_engine, myScene_itemToScriptValue, myScene_itemFromScriptValue); # ifdef QT_SCRIPTTOOLS_LIB QScriptEngineDebugger* debugger = new QScriptEngineDebugger(this); debugger->setObjectName("qt script debugger"); QAction* debuggerMenuAction = menuBar()->addMenu(debugger->createStandardMenu()); debuggerMenuAction->setText(tr("Qt Script &debug")); for(unsigned int i = 0; i < 9; ++i) { QDockWidget* dock = new QDockWidget(debug_widgets_names[i], this); dock->setObjectName(debug_widgets_names[i]); dock->setWidget(debugger->widget(debug_widgets[i])); this->addDockWidget(Qt::BottomDockWidgetArea, dock); dock->hide(); } debugger->setAutoShowStandardWindow(false); debugger->attachTo(script_engine); # endif // QT_SCRIPTTOOLS_LIB QScriptValue fun = script_engine->newFunction(myPrintFunction); script_engine->globalObject().setProperty("print", fun); // evaluate_script("print('hello', 'world', 'from QtScript!')"); QScriptValue mainWindowObjectValue = script_engine->newQObject(this); script_engine->globalObject().setProperty("main_window", mainWindowObjectValue); QScriptValue sceneObjectValue = script_engine->newQObject(scene); mainWindowObjectValue.setProperty("scene", sceneObjectValue); script_engine->globalObject().setProperty("scene", sceneObjectValue); QScriptValue viewerObjectValue = script_engine->newQObject(viewer); mainWindowObjectValue.setProperty("viewer", viewerObjectValue); script_engine->globalObject().setProperty("viewer", viewerObjectValue); QScriptValue cameraObjectValue = script_engine->newQObject(viewer->camera()); viewerObjectValue.setProperty("camera", cameraObjectValue); script_engine->globalObject().setProperty("camera", cameraObjectValue); evaluate_script("var plugins = new Array();"); # ifdef QT_SCRIPTTOOLS_LIB QScriptValue debuggerObjectValue = script_engine->newQObject(debugger); script_engine->globalObject().setProperty("debugger", debuggerObjectValue); # endif #endif readSettings(); // Among other things, the column widths are stored. // Load plugins, and re-enable actions that need it. loadPlugins(); // Setup the submenu of the View menu that can toggle the dockwidgets Q_FOREACH(QDockWidget* widget, findChildren<QDockWidget*>()) { ui->menuDockWindows->addAction(widget->toggleViewAction()); }