//----------------------------------------------------------------------------- // Function: ColumnFreezableTable::setModel() //----------------------------------------------------------------------------- void ColumnFreezableTable::setModel(QAbstractItemModel* model) { QTableView::setModel(model); init(); connect(horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(updateSectionWidth(int, int, int))); connect(verticalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(updateSectionHeight(int, int, int))); connect(frozenColumns_->verticalScrollBar(), SIGNAL(valueChanged(int)), verticalScrollBar(), SLOT(setValue(int))); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), frozenColumns_->verticalScrollBar(), SLOT(setValue(int))); connect(frozenColumns_.data(), SIGNAL(addItem(const QModelIndex&)), this, SIGNAL(addItem(const QModelIndex&)), Qt::UniqueConnection); connect(frozenColumns_.data(), SIGNAL(removeItem(const QModelIndex&)), this, SIGNAL(removeItem(const QModelIndex&)), Qt::UniqueConnection); connect(frozenColumns_.data(), SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)), this, SIGNAL(moveItem(const QModelIndex&, const QModelIndex&)), Qt::UniqueConnection); connect(frozenColumns_->horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(closeSortingSection(int))); connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(closeSortingSection(int))); }
WebTab::WebTab(QupZilla* mainClass, LocationBar* locationBar) : QWidget() , p_QupZilla(mainClass) , m_locationBar(locationBar) , m_pinned(false) , m_inspectorVisible(false) { m_layout = new QVBoxLayout(this); m_layout->setContentsMargins(0, 0, 0, 0); m_layout->setSpacing(0); m_view = new WebView(p_QupZilla, this); m_view.data()->setLocationBar(locationBar); m_layout->addWidget(m_view.data()); setLayout(m_layout); setAutoFillBackground(true); // We don't want this transparent connect(m_view.data(), SIGNAL(showNotification(QWidget*)), this, SLOT(showNotification(QWidget*))); connect(m_view.data(), SIGNAL(iconChanged()), m_locationBar.data(), SLOT(siteIconChanged())); connect(m_view.data(), SIGNAL(loadStarted()), m_locationBar.data(), SLOT(clearIcon())); connect(m_view.data(), SIGNAL(loadFinished(bool)), m_locationBar.data(), SLOT(siteIconChanged())); connect(m_view.data(), SIGNAL(showUrl(QUrl)), m_locationBar.data(), SLOT(showUrl(QUrl))); connect(m_view.data(), SIGNAL(rssChanged(bool)), m_locationBar.data(), SLOT(showRSSIcon(bool))); connect(m_view.data()->webPage(), SIGNAL(privacyChanged(bool)), m_locationBar.data(), SLOT(setPrivacy(bool))); connect(m_locationBar.data(), SIGNAL(loadUrl(QUrl)), m_view.data(), SLOT(load(QUrl))); }
Q_DECL_EXPORT int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setApplicationName("QDL"); app.setApplicationVersion(VERSION_NUMBER); app.setWindowIcon(QIcon::fromTheme("qdl2")); app.setQuitOnLastWindowClosed(false); const QStringList args = app.arguments(); if (args.contains("--log")) { Logger::setVerbosity(10); } QScopedPointer<Categories> categories(Categories::instance()); QScopedPointer<ClipboardUrlModel> clipboard(ClipboardUrlModel::instance()); QScopedPointer<DecaptchaPluginManager> decaptchaManager(DecaptchaPluginManager::instance()); QScopedPointer<Qdl> qdl(Qdl::instance()); QScopedPointer<RecaptchaPluginManager> recaptchaManager(RecaptchaPluginManager::instance()); QScopedPointer<ServicePluginManager> serviceManager(ServicePluginManager::instance()); QScopedPointer<Settings> settings(Settings::instance()); QScopedPointer<TransferModel> transfers(TransferModel::instance()); QScopedPointer<UrlCheckModel> checker(UrlCheckModel::instance()); QScopedPointer<UrlRetrievalModel> retriever(UrlRetrievalModel::instance()); QScopedPointer<WebServer> server(WebServer::instance()); clipboard.data()->setEnabled(Settings::clipboardMonitorEnabled()); server.data()->setPort(Settings::webInterfacePort()); server.data()->setUsername(Settings::webInterfaceUsername()); server.data()->setPassword(Settings::webInterfacePassword()); server.data()->setAuthenticationEnabled(Settings::webInterfaceAuthenticationEnabled()); decaptchaManager.data()->load(); recaptchaManager.data()->load(); serviceManager.data()->load(); clipboard.data()->restore(); transfers.data()->restore(); if (Settings::webInterfaceEnabled()) { server.data()->start(); } if (!args.contains("--nogui")) { Qdl::showWindow(); } QObject::connect(settings.data(), SIGNAL(clipboardMonitorEnabledChanged(bool)), clipboard.data(), SLOT(setEnabled(bool))); QObject::connect(settings.data(), SIGNAL(webInterfaceAuthenticationEnabledChanged(bool)), server.data(), SLOT(setAuthenticationEnabled(bool))); QObject::connect(settings.data(), SIGNAL(webInterfaceUsernameChanged(QString)), server.data(), SLOT(setUsername(QString))); QObject::connect(settings.data(), SIGNAL(webInterfacePasswordChanged(QString)), server.data(), SLOT(setPassword(QString))); QObject::connect(settings.data(), SIGNAL(webInterfacePortChanged(int)), server.data(), SLOT(setPort(int))); QObject::connect(settings.data(), SIGNAL(webInterfaceEnabledChanged(bool)), server.data(), SLOT(setRunning(bool))); return app.exec(); }
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent) : QObject(parent), data(new QDeclarativeViewInspectorPrivate(this)) { data->view = view; data->manipulatorLayer = new LiveLayerItem(view->scene()); data->selectionTool = new LiveSelectionTool(this); data->zoomTool = new ZoomTool(this); data->colorPickerTool = new ColorPickerTool(this); data->boundingRectHighlighter = new BoundingRectHighlighter(this); data->currentTool = data->selectionTool; // to capture ChildRemoved event when viewport changes data->view->installEventFilter(this); data->setViewport(data->view->viewport()); data->debugService = QDeclarativeInspectorService::instance(); connect(data->debugService, SIGNAL(designModeBehaviorChanged(bool)), SLOT(setDesignModeBehavior(bool))); connect(data->debugService, SIGNAL(showAppOnTopChanged(bool)), SLOT(setShowAppOnTop(bool))); connect(data->debugService, SIGNAL(reloadRequested()), data.data(), SLOT(_q_reloadView())); connect(data->debugService, SIGNAL(currentObjectsChanged(QList<QObject*>)), data.data(), SLOT(_q_onCurrentObjectsChanged(QList<QObject*>))); connect(data->debugService, SIGNAL(animationSpeedChangeRequested(qreal)), SLOT(animationSpeedChangeRequested(qreal))); connect(data->debugService, SIGNAL(executionPauseChangeRequested(bool)), SLOT(animationPausedChangeRequested(bool))); connect(data->debugService, SIGNAL(colorPickerToolRequested()), data.data(), SLOT(_q_changeToColorPickerTool())); connect(data->debugService, SIGNAL(selectMarqueeToolRequested()), data.data(), SLOT(_q_changeToMarqueeSelectTool())); connect(data->debugService, SIGNAL(selectToolRequested()), data.data(), SLOT(_q_changeToSingleSelectTool())); connect(data->debugService, SIGNAL(zoomToolRequested()), data.data(), SLOT(_q_changeToZoomTool())); connect(data->debugService, SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString,int)), data.data(), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString,int))); connect(data->debugService, SIGNAL(objectDeletionRequested(QObject *)), data.data(), SLOT(_q_deleteQmlObject(QObject *))); connect(data->debugService, SIGNAL(objectReparentRequested(QObject *, QObject *)), data.data(), SLOT(_q_reparentQmlObject(QObject *, QObject *))); connect(data->debugService, SIGNAL(clearComponentCacheRequested()), data.data(), SLOT(_q_clearComponentCache())); connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)), data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status))); connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), SIGNAL(selectedColorChanged(QColor))); connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)), data->debugService, SLOT(selectedColorChanged(QColor))); data->_q_changeToSingleSelectTool(); }
void HumanPlayer::installFleet() { setFleetHealth(myField->getFleet()); connect(plrFieldView.data(), SIGNAL(placeShip(int,int)), myField.data(), SLOT(setShip(int,int))); connect(plrFieldView.data(), SIGNAL(deleteShip(int)), myField.data(), SLOT(deleteShip(int))); connect(infoTab.data(), SIGNAL(readyToFight()), myField.data(), SLOT(checkIsFleetReady())); connect(myField.data(), SIGNAL(fleetInstalled()), this, SLOT(reEmitFleetInstalled())); /* connect(fleetInstaller, SIGNAL(shipPlacedSuccesfully(NameOfShips, int)) , view, SLOT(changeCounter(NameOfShips,int))); */ }
Context::ToolbarView::ToolbarView( Plasma::Containment* containment, QGraphicsScene* scene, QWidget* parent ) : QGraphicsView( scene, parent ) , m_height( 36 ) , m_cont( containment ) { setObjectName( "ContextToolbarView" ); setFixedHeight( m_height ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ); setAutoFillBackground( true ); setContentsMargins( 0, 0, 0, 0 ); setFrameStyle( QFrame::NoFrame ); applyStyleSheet(); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(applyStyleSheet()) ); //Padding required to prevent view scrolling, probably caused by the 1px ridge setSceneRect( TOOLBAR_X_OFFSET, 0, size().width()-TOOLBAR_SCENE_PADDING, size().height()-TOOLBAR_SCENE_PADDING ); setInteractive( true ); setAcceptDrops( true ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); // now we create the toolbar m_toolbar = new AppletToolbar(0); scene->addItem(m_toolbar.data()); m_toolbar.data()->setContainment( qobject_cast<Context::Containment *>(containment) ); m_toolbar.data()->setZValue( m_toolbar.data()->zValue() + 1000 ); m_toolbar.data()->setPos( TOOLBAR_X_OFFSET, 0 ); connect( m_toolbar.data(), SIGNAL(configModeToggled()), SLOT(toggleConfigMode()) ); connect( m_toolbar.data(), SIGNAL(hideAppletExplorer()), SIGNAL(hideAppletExplorer()) ); connect( m_toolbar.data(), SIGNAL(showAppletExplorer()), SIGNAL(showAppletExplorer()) ); Context::Containment* cont = dynamic_cast< Context::Containment* >( containment ); if( cont ) { connect( cont, SIGNAL(appletAdded(Plasma::Applet*,int)), m_toolbar.data(), SLOT(appletAdded(Plasma::Applet*,int)) ); connect( m_toolbar.data(), SIGNAL(appletAddedToToolbar(Plasma::Applet*,int)), this, SLOT(appletAdded(Plasma::Applet*,int)) ); connect( cont, SIGNAL(appletRemoved(Plasma::Applet*)), this, SLOT(appletRemoved(Plasma::Applet*)) ); connect( m_toolbar.data(), SIGNAL(showApplet(Plasma::Applet*)), cont, SLOT(showApplet(Plasma::Applet*)) ); connect( m_toolbar.data(), SIGNAL(moveApplet(Plasma::Applet*,int,int)), cont, SLOT(moveApplet(Plasma::Applet*,int,int)) ); } }
void MainWindow::openFile(const QString& fileName) { QApplication::setOverrideCursor(Qt::WaitCursor); _timeBar->stopClicked(); QFileInfo fileInfo(fileName); ReaderWriterILDA reader; _lastDirectory = fileInfo.absoluteFilePath(); _sequence = reader.readFile(fileName); _sequence->setPalette(*_currentPalette); // Fill file statistics fileNameLabel->setText(fileInfo.fileName()); fileSizeLabel->setText(getFileSize(fileInfo.size())); ildaFormatLabel->setText(reader.version()); numberOfFramesLabel->setText(QString::number(_sequence->frameCount())); // Set the current drawing mode (FIXME: Do not query the GUI for such infos) drawModeChanged(); // Setup timeline _timeBar->setRange(0, _sequence->frameCount() / 1000.0 * 30); _timeLine = _timeBar->timeLine(); _timeLine->setDuration(30 * _sequence->frameCount()); _timeLine->setFrameRange(0, _sequence->frameCount()); _timeLine->setCurveShape(QTimeLine::LinearCurve); _timeLine->setLoopCount(0); // Build the connections connect(_timeLine, SIGNAL(frameChanged(int)), _sequence.data(), SLOT(setActiveFrame(int))); connect(_sequence.data(), SIGNAL(frameChanged(Frame*)), SLOT(frameChanged(Frame*))); // Create scene and attach to graphics view QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(_sequence.data()); graphicsView->setScene(scene); frameChanged(_sequence->frame(0)); _timeBar->update(); // FIXME: Need to call this until a resize event happens. resizeEvent(0); QApplication::restoreOverrideCursor(); }
/*! * \brief Creates the new menu view based on a QMenu object. * \param parent The parent object of the menu. */ QMenuView::QMenuView(QWidget* parent) : ClickableMenu(parent), d(new QMenuViewPrivate(this)) { connect(this, SIGNAL(triggered(QAction*)), d.data(), SLOT(triggered(QAction*))); connect(this, SIGNAL(hovered(QAction*)), d.data(), SLOT(hovered(QAction*))); connect(this, SIGNAL(aboutToShow()), d.data(), SLOT(aboutToShow())); }
void MainWindow::fileOpen() { QFileDialog ofd(this, tr("Open ILDA file"), ""); ofd.setFileMode(QFileDialog::AnyFile); ofd.setFilter(tr("ILDA files (*.ild);;All files (*.*)")); ofd.setViewMode(QFileDialog::Detail); if (ofd.exec()) { QString fileName = ofd.selectedFiles().at(0); QFileInfo fileInfo(fileName); if (fileInfo.exists()) { ReaderWriterILDA reader; _sequence = QSharedPointer<Sequence>(reader.readFile(fileName)); _sequence->setPalette(*_currentPalette); // Fill file statistics fileNameLabel->setText(fileInfo.fileName()); fileSizeLabel->setText(getFileSize(fileInfo.size())); ildaFormatLabel->setText(reader.version()); numberOfFramesLabel->setText(QString::number(_sequence->frameCount())); // Set the current drawing mode (FIXME: Do not query the GUI for such infos) if (normalRadioButton->isChecked()) _sequence->setDrawMode(Sequence::DrawModeNormal); else if (diagnosticRadioButton->isChecked()) _sequence->setDrawMode(Sequence::DrawModeDiagnostic); // Setup frame slider frameSlider->setRange(0, _sequence->frameCount()-1); // Build the connections connect(_sequence.data(), SIGNAL(frameChanged(Frame*)), this, SLOT(frameChanged(Frame*))); connect(firstFrameButton, SIGNAL(clicked()), _sequence.data(), SLOT(gotoFirstFrame())); connect(lastFrameButton, SIGNAL(clicked()), _sequence.data(), SLOT(gotoLastFrame())); connect(stopButton, SIGNAL(clicked()), _sequence.data(), SLOT(stopPlayback())); connect(playButton, SIGNAL(clicked()), _sequence.data(), SLOT(startPlayback())); connect(frameSlider, SIGNAL(valueChanged(int)), _sequence.data(), SLOT(setActiveFrame(int))); connect(normalRadioButton, SIGNAL(clicked()), this, SLOT(drawModeChanged())); connect(diagnosticRadioButton, SIGNAL(clicked()), this, SLOT(drawModeChanged())); QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(_sequence.data()); graphicsView->setScene(scene); // FIXME: Need to call this until a resize event happens. resizeEvent(NULL); }
void WebTab::createPreviewSelectorBar(int index) { if(m_previewSelectorBar.isNull()) { m_previewSelectorBar = new PreviewSelectorBar(index, this); qobject_cast<QVBoxLayout *>(layout())->insertWidget(0, m_previewSelectorBar.data()); } else { disconnect(m_previewSelectorBar.data()); m_previewSelectorBar.data()->setIndex(index); m_previewSelectorBar.data()->notifyUser(); } connect(page(), SIGNAL(loadStarted()), m_previewSelectorBar.data(), SLOT(loadProgress()), Qt::UniqueConnection); connect(page(), SIGNAL(loadProgress(int)), m_previewSelectorBar.data(), SLOT(loadProgress()), Qt::UniqueConnection); connect(page(), SIGNAL(loadFinished(bool)), m_previewSelectorBar.data(), SLOT(loadFinished()), Qt::UniqueConnection); connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), m_previewSelectorBar.data(), SLOT(verifyUrl()), Qt::UniqueConnection); }
void StatesEditorWidget::reloadQmlSource() { QString statesListQmlFilePath = qmlSourcesPath() + QStringLiteral("/StatesList.qml"); QTC_ASSERT(QFileInfo::exists(statesListQmlFilePath), return); engine()->clearComponentCache(); setSource(QUrl::fromLocalFile(statesListQmlFilePath)); QTC_ASSERT(rootObject(), return); connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget())); connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState())); connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int))); m_statesEditorView.data()->synchonizeCurrentStateFromWidget(); setFixedHeight(initialSize().height()); connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(changeHeight())); }
QSharedPointer<LiveStream> DVRCamera::liveStream() { if (m_liveStream && m_currentConnectionType == data().server()->configuration().connectionType()) return m_liveStream.toStrongRef(); m_currentConnectionType = (DVRServerConnectionType::Type)data().server()->configuration().connectionType(); QSharedPointer<LiveStream> result; if (m_currentConnectionType == DVRServerConnectionType::MJPEG) result = QSharedPointer<LiveStream>(new MJpegStream(this)); else result = QSharedPointer<LiveStream>(new RtspStream(this)); m_liveStream = result.toWeakRef(); connect(this, SIGNAL(onlineChanged(bool)), m_liveStream.data(), SLOT(setOnline(bool))); m_liveStream.data()->setOnline(isOnline()); return result; }
ShibbolethWebView::ShibbolethWebView(AccountPtr account, QWidget* parent) : QWebView(parent) , _account(account) , _accepted(false) , _cursorOverriden(false) { // no minimize setWindowFlags(Qt::Dialog); setAttribute(Qt::WA_DeleteOnClose); QWebPage* page = new QWebPage(this); connect(page, SIGNAL(loadStarted()), this, SLOT(slotLoadStarted())); connect(page, SIGNAL(loadFinished(bool)), this, SLOT(slotLoadFinished(bool))); // Make sure to accept the same SSL certificate issues as the regular QNAM we use for syncing QObject::connect(page->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)), _account.data(), SLOT(slotHandleSslErrors(QNetworkReply*,QList<QSslError>))); // The Account keeps ownership of the cookie jar, it must outlive this webview. account->lendCookieJarTo(page->networkAccessManager()); connect(page->networkAccessManager()->cookieJar(), SIGNAL(newCookiesForUrl (QList<QNetworkCookie>, QUrl)), this, SLOT(onNewCookiesForUrl (QList<QNetworkCookie>, QUrl))); page->mainFrame()->load(account->url()); this->setPage(page); setWindowTitle(tr("%1 - Authenticate").arg(Theme::instance()->appNameGUI())); // If we have a valid cookie, it's most likely expired. We can use this as // as a criteria to tell the user why the browser window pops up QNetworkCookie shibCookie = ShibbolethCredentials::findShibCookie(_account.data(), ShibbolethCredentials::accountCookies(_account.data())); if (shibCookie != QNetworkCookie()) { Logger::instance()->postOptionalGuiLog(tr("Reauthentication required"), tr("Your session has expired. You need to re-login to continue to use the client.")); } ConfigFile config; QSettings settings(config.configFile()); resize(900, 700); // only effective the first time, later overridden by restoreGeometry restoreGeometry(settings.value(ShibbolethWebViewGeometryC).toByteArray()); }
ItemLibraryWidget::ItemLibraryWidget(QWidget *parent) : QFrame(parent), m_iconProvider(m_resIconSize), m_itemIconSize(24, 24), m_resIconSize(24, 24), m_itemsView(new QDeclarativeView(this)), m_resourcesView(new Internal::ItemLibraryTreeView(this)), m_filterFlag(QtBasic) { setWindowTitle(tr("Library", "Title of library view")); /* create Items view and its model */ m_itemsView->setAttribute(Qt::WA_OpaquePaintEvent); m_itemsView->setAttribute(Qt::WA_NoSystemBackground); m_itemsView->setAcceptDrops(false); m_itemsView->setFocusPolicy(Qt::ClickFocus); m_itemsView->setResizeMode(QDeclarativeView::SizeRootObjectToView); m_itemLibraryModel = new Internal::ItemLibraryModel(QDeclarativeEnginePrivate::getScriptEngine(m_itemsView->engine()), this); m_itemLibraryModel->setItemIconSize(m_itemIconSize); QDeclarativeContext *rootContext = m_itemsView->rootContext(); rootContext->setContextProperty(QLatin1String("itemLibraryModel"), m_itemLibraryModel.data()); rootContext->setContextProperty(QLatin1String("itemLibraryIconWidth"), m_itemIconSize.width()); rootContext->setContextProperty(QLatin1String("itemLibraryIconHeight"), m_itemIconSize.height()); QColor highlightColor = palette().highlight().color(); if (0.5*highlightColor.saturationF()+0.75-highlightColor.valueF() < 0) highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF()); m_itemsView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor); // loading the qml has to come after all needed context properties are set m_itemsView->setSource(QUrl("qrc:/ItemLibrary/qml/ItemsView.qml")); QDeclarativeItem *rootItem = qobject_cast<QDeclarativeItem*>(m_itemsView->rootObject()); connect(rootItem, SIGNAL(itemSelected(int)), this, SLOT(showItemInfo(int))); connect(rootItem, SIGNAL(itemDragged(int)), this, SLOT(startDragAndDrop(int))); connect(this, SIGNAL(scrollItemsView(QVariant)), rootItem, SLOT(scrollView(QVariant))); connect(this, SIGNAL(resetItemsView()), rootItem, SLOT(resetView())); /* create Resources view and its model */ m_resourcesFileSystemModel = new QFileSystemModel(this); m_resourcesFileSystemModel->setIconProvider(&m_iconProvider); m_resourcesView->setModel(m_resourcesFileSystemModel.data()); m_resourcesView->setIconSize(m_resIconSize); /* create image provider for loading item icons */ m_itemsView->engine()->addImageProvider(QLatin1String("qmldesigner_itemlibrary"), new Internal::ItemLibraryImageProvider); /* other widgets */ QTabBar *tabBar = new QTabBar(this); tabBar->addTab(tr("Items", "Title of library items view")); tabBar->addTab(tr("Resources", "Title of library resources view")); tabBar->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_lineEdit = new Utils::FilterLineEdit(this); m_lineEdit->setObjectName(QLatin1String("itemLibrarySearchInput")); m_lineEdit->setPlaceholderText(tr("<Filter>", "Library search input hint text")); m_lineEdit->setDragEnabled(false); m_lineEdit->setMinimumWidth(75); m_lineEdit->setTextMargins(0, 0, 20, 0); QWidget *lineEditFrame = new QWidget(this); lineEditFrame->setObjectName(QLatin1String("itemLibrarySearchInputFrame")); QGridLayout *lineEditLayout = new QGridLayout(lineEditFrame); lineEditLayout->setMargin(2); lineEditLayout->setSpacing(0); lineEditLayout->addItem(new QSpacerItem(5, 3, QSizePolicy::Fixed, QSizePolicy::Fixed), 0, 0, 1, 3); lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0); lineEditLayout->addWidget(m_lineEdit.data(), 1, 1, 1, 1); lineEditLayout->addItem(new QSpacerItem(5, 5, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 2); connect(m_lineEdit.data(), SIGNAL(filterChanged(QString)), this, SLOT(setSearchFilter(QString))); m_stackedWidget = new QStackedWidget(this); m_stackedWidget->addWidget(m_itemsView.data()); m_stackedWidget->addWidget(m_resourcesView.data()); connect(tabBar, SIGNAL(currentChanged(int)), m_stackedWidget.data(), SLOT(setCurrentIndex(int))); connect(tabBar, SIGNAL(currentChanged(int)), this, SLOT(updateSearch())); QWidget *spacer = new QWidget(this); spacer->setObjectName(QLatin1String("itemLibrarySearchInputSpacer")); spacer->setFixedHeight(4); QGridLayout *layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(tabBar, 0, 0, 1, 1); layout->addWidget(spacer, 1, 0); layout->addWidget(lineEditFrame, 2, 0, 1, 1); layout->addWidget(m_stackedWidget.data(), 3, 0, 1, 1); setResourcePath(QDir::currentPath()); setSearchFilter(QString()); /* style sheets */ setStyleSheet(QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))); m_resourcesView->setStyleSheet( QLatin1String(Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css"))); }
void Agent::executeScript() { _scriptEngine = scriptEngineFactory(ScriptEngine::AGENT_SCRIPT, _scriptContents, _payload); DependencyManager::get<RecordingScriptingInterface>()->setScriptEngine(_scriptEngine); // setup an Avatar for the script to use auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>(); connect(_scriptEngine.data(), SIGNAL(update(float)), scriptedAvatar.data(), SLOT(update(float)), Qt::ConnectionType::QueuedConnection); scriptedAvatar->setForceFaceTrackerConnected(true); // call model URL setters with empty URLs so our avatar, if user, will have the default models scriptedAvatar->setSkeletonModelURL(QUrl()); // force lazy initialization of the head data for the scripted avatar // since it is referenced below by computeLoudness and getAudioLoudness scriptedAvatar->getHeadOrientation(); // give this AvatarData object to the script engine _scriptEngine->registerGlobalObject("Avatar", scriptedAvatar.data()); // give scripts access to the Users object _scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data()); auto player = DependencyManager::get<recording::Deck>(); connect(player.data(), &recording::Deck::playbackStateChanged, [=] { if (player->isPlaying()) { auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>(); if (recordingInterface->getPlayFromCurrentLocation()) { scriptedAvatar->setRecordingBasis(); } } else { scriptedAvatar->clearRecordingBasis(); } }); using namespace recording; static const FrameType AVATAR_FRAME_TYPE = Frame::registerFrameType(AvatarData::FRAME_NAME); Frame::registerFrameHandler(AVATAR_FRAME_TYPE, [scriptedAvatar](Frame::ConstPointer frame) { auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>(); bool useFrameSkeleton = recordingInterface->getPlayerUseSkeletonModel(); // FIXME - the ability to switch the avatar URL is not actually supported when playing back from a recording if (!useFrameSkeleton) { static std::once_flag warning; std::call_once(warning, [] { qWarning() << "Recording.setPlayerUseSkeletonModel(false) is not currently supported."; }); } AvatarData::fromFrame(frame->data, *scriptedAvatar); }); using namespace recording; static const FrameType AUDIO_FRAME_TYPE = Frame::registerFrameType(AudioConstants::getAudioFrameName()); Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this, &scriptedAvatar](Frame::ConstPointer frame) { static quint16 audioSequenceNumber{ 0 }; QByteArray audio(frame->data); if (_isNoiseGateEnabled) { int16_t* samples = reinterpret_cast<int16_t*>(audio.data()); int numSamples = AudioConstants::NETWORK_FRAME_SAMPLES_PER_CHANNEL; _audioGate.render(samples, samples, numSamples); } computeLoudness(&audio, scriptedAvatar); // state machine to detect gate opening and closing bool audioGateOpen = (scriptedAvatar->getAudioLoudness() != 0.0f); bool openedInLastBlock = !_audioGateOpen && audioGateOpen; // the gate just opened bool closedInLastBlock = _audioGateOpen && !audioGateOpen; // the gate just closed _audioGateOpen = audioGateOpen; Q_UNUSED(openedInLastBlock); // the codec must be flushed to silence before sending silent packets, // so delay the transition to silent packets by one packet after becoming silent. auto packetType = PacketType::MicrophoneAudioNoEcho; if (!audioGateOpen && !closedInLastBlock) { packetType = PacketType::SilentAudioFrame; } Transform audioTransform; auto headOrientation = scriptedAvatar->getHeadOrientation(); audioTransform.setTranslation(scriptedAvatar->getWorldPosition()); audioTransform.setRotation(headOrientation); QByteArray encodedBuffer; if (_encoder) { _encoder->encode(audio, encodedBuffer); } else { encodedBuffer = audio; } AbstractAudioInterface::emitAudioPacket(encodedBuffer.data(), encodedBuffer.size(), audioSequenceNumber, false, audioTransform, scriptedAvatar->getWorldPosition(), glm::vec3(0), packetType, _selectedCodecName); }); auto avatarHashMap = DependencyManager::set<AvatarHashMap>(); _scriptEngine->registerGlobalObject("AvatarList", avatarHashMap.data()); auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver(); packetReceiver.registerListener(PacketType::BulkAvatarData, avatarHashMap.data(), "processAvatarDataPacket"); packetReceiver.registerListener(PacketType::KillAvatar, avatarHashMap.data(), "processKillAvatar"); packetReceiver.registerListener(PacketType::AvatarIdentity, avatarHashMap.data(), "processAvatarIdentityPacket"); // register ourselves to the script engine _scriptEngine->registerGlobalObject("Agent", this); _scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); _scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCache>().data()); QScriptValue webSocketServerConstructorValue = _scriptEngine->newFunction(WebSocketServerClass::constructor); _scriptEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); _scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer); _scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter, LocationScriptingInterface::locationSetter); auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>(); _scriptEngine->registerGlobalObject("Recording", recordingInterface.data()); entityScriptingInterface->init(); _entityViewer.init(); entityScriptingInterface->setEntityTree(_entityViewer.getTree()); DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree()); QMetaObject::invokeMethod(&_avatarAudioTimer, "start"); // Agents should run at 45hz static const int AVATAR_DATA_HZ = 45; static const int AVATAR_DATA_IN_MSECS = MSECS_PER_SECOND / AVATAR_DATA_HZ; QTimer* avatarDataTimer = new QTimer(this); connect(avatarDataTimer, &QTimer::timeout, this, &Agent::processAgentAvatar); avatarDataTimer->setSingleShot(false); avatarDataTimer->setInterval(AVATAR_DATA_IN_MSECS); avatarDataTimer->setTimerType(Qt::PreciseTimer); avatarDataTimer->start(); _scriptEngine->run(); Frame::clearFrameHandler(AUDIO_FRAME_TYPE); Frame::clearFrameHandler(AVATAR_FRAME_TYPE); DependencyManager::destroy<RecordingScriptingInterface>(); setFinished(true); }
void Agent::executeScript() { _scriptEngine = std::unique_ptr<ScriptEngine>(new ScriptEngine(_scriptContents, _payload)); _scriptEngine->setParent(this); // be the parent of the script engine so it gets moved when we do // setup an Avatar for the script to use auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>(); connect(_scriptEngine.get(), SIGNAL(update(float)), scriptedAvatar.data(), SLOT(update(float)), Qt::ConnectionType::QueuedConnection); scriptedAvatar->setForceFaceTrackerConnected(true); // call model URL setters with empty URLs so our avatar, if user, will have the default models scriptedAvatar->setSkeletonModelURL(QUrl()); // give this AvatarData object to the script engine _scriptEngine->registerGlobalObject("Avatar", scriptedAvatar.data()); using namespace recording; static const FrameType AVATAR_FRAME_TYPE = Frame::registerFrameType(AvatarData::FRAME_NAME); // FIXME how to deal with driving multiple avatars locally? Frame::registerFrameHandler(AVATAR_FRAME_TYPE, [this, scriptedAvatar](Frame::ConstPointer frame) { AvatarData::fromFrame(frame->data, *scriptedAvatar); }); using namespace recording; static const FrameType AUDIO_FRAME_TYPE = Frame::registerFrameType(AudioConstants::getAudioFrameName()); Frame::registerFrameHandler(AUDIO_FRAME_TYPE, [this, &scriptedAvatar](Frame::ConstPointer frame) { const QByteArray& audio = frame->data; static quint16 audioSequenceNumber{ 0 }; Transform audioTransform; audioTransform.setTranslation(scriptedAvatar->getPosition()); audioTransform.setRotation(scriptedAvatar->getOrientation()); AbstractAudioInterface::emitAudioPacket(audio.data(), audio.size(), audioSequenceNumber, audioTransform, PacketType::MicrophoneAudioNoEcho); }); auto avatarHashMap = DependencyManager::set<AvatarHashMap>(); _scriptEngine->registerGlobalObject("AvatarList", avatarHashMap.data()); auto& packetReceiver = DependencyManager::get<NodeList>()->getPacketReceiver(); packetReceiver.registerListener(PacketType::BulkAvatarData, avatarHashMap.data(), "processAvatarDataPacket"); packetReceiver.registerListener(PacketType::KillAvatar, avatarHashMap.data(), "processKillAvatar"); packetReceiver.registerListener(PacketType::AvatarIdentity, avatarHashMap.data(), "processAvatarIdentityPacket"); packetReceiver.registerListener(PacketType::AvatarBillboard, avatarHashMap.data(), "processAvatarBillboardPacket"); // register ourselves to the script engine _scriptEngine->registerGlobalObject("Agent", this); // FIXME -we shouldn't be calling this directly, it's normally called by run(), not sure why // viewers would need this called. //_scriptEngine->init(); // must be done before we set up the viewers _scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCache>().data()); QScriptValue webSocketServerConstructorValue = _scriptEngine->newFunction(WebSocketServerClass::constructor); _scriptEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); _scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer); // we need to make sure that init has been called for our EntityScriptingInterface // so that it actually has a jurisdiction listener when we ask it for it next entityScriptingInterface->init(); _entityViewer.setJurisdictionListener(entityScriptingInterface->getJurisdictionListener()); _entityViewer.init(); entityScriptingInterface->setEntityTree(_entityViewer.getTree()); DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree()); // wire up our additional agent related processing to the update signal QObject::connect(_scriptEngine.get(), &ScriptEngine::update, this, &Agent::processAgentAvatarAndAudio); _scriptEngine->run(); Frame::clearFrameHandler(AUDIO_FRAME_TYPE); Frame::clearFrameHandler(AVATAR_FRAME_TYPE); setFinished(true); }