GameEngine::GameEngine(QObject *parent) : QObject(parent) { s_dlg = new SetUp(); m_talker = new Talker(this); //setup_dlg and talker connect(s_dlg, SIGNAL(toDiscoverServer(QString,QString,QString)), m_talker, SLOT(discoverServer(QString,QString,QString))); connect(m_talker, SIGNAL(connected(QString, QString, QString)), s_dlg, SLOT(hideThis(QString, QString, QString))); connect(m_talker, SIGNAL(problemwithInput(QString)), s_dlg, SLOT(displayErrorMessage(QString))); // talker and this connect(m_talker, SIGNAL(matchReceived(QString)), this, SLOT(playMatch(QString))); connect(m_talker, SIGNAL(moveReceived(int,int,QString)), this, SLOT(playMove(int,int,QString))); connect(this, SIGNAL(ready()), m_talker, SLOT(sendReady())); connect(m_talker, SIGNAL(newGame()), this, SLOT(reset())); connect(m_talker, SIGNAL(startSatup()), this, SLOT(showSatup())); s_dlg->show(); m_dlg = new InfoDialog(); connect(m_talker, SIGNAL(connected(QString,QString,QString)), this, SLOT(startInfodialog(QString,QString,QString))); connect(m_dlg, SIGNAL(authenticateRequest(QString, int, int)), m_talker, SLOT(identify(QString, int, int))); connect(m_talker, SIGNAL(authenticated(bool)), m_dlg, SLOT(updateLabelAuthenticated(bool))); qmlView = 0; //reset(); }
void Server::connectionTimeout() { if (!is_config_mode) { getRemoteSocket(); if (remote_server_socket) { SendData("DS=" + QString::number(device_id) + "\r\n"); sendSensorsInfo(); sendActionsInfo(); sendReady(); shotTimer->start(); sendingTimeout(); } if (!remote_server_socket) connectionTimer->start(); } }
void Client::afterContentReceived(IrrlichtDevice *device) { infostream<<"Client::afterContentReceived() started"<<std::endl; assert(m_itemdef_received); // pre-condition assert(m_nodedef_received); // pre-condition assert(mediaReceived()); // pre-condition const wchar_t* text = wgettext("Loading textures..."); // Clear cached pre-scaled 2D GUI images, as this cache // might have images with the same name but different // content from previous sessions. guiScalingCacheClear(device->getVideoDriver()); // Rebuild inherited images and recreate textures infostream<<"- Rebuilding images and textures"<<std::endl; draw_load_screen(text,device, guienv, 0, 70); m_tsrc->rebuildImagesAndTextures(); delete[] text; // Rebuild shaders infostream<<"- Rebuilding shaders"<<std::endl; text = wgettext("Rebuilding shaders..."); draw_load_screen(text, device, guienv, 0, 71); m_shsrc->rebuildShaders(); delete[] text; // Update node aliases infostream<<"- Updating node aliases"<<std::endl; text = wgettext("Initializing nodes..."); draw_load_screen(text, device, guienv, 0, 72); m_nodedef->updateAliases(m_itemdef); std::string texture_path = g_settings->get("texture_path"); if (texture_path != "" && fs::IsDir(texture_path)) m_nodedef->applyTextureOverrides(texture_path + DIR_DELIM + "override.txt"); m_nodedef->setNodeRegistrationStatus(true); m_nodedef->runNodeResolveCallbacks(); delete[] text; // Update node textures and assign shaders to each tile infostream<<"- Updating node textures"<<std::endl; TextureUpdateArgs tu_args; tu_args.device = device; tu_args.guienv = guienv; tu_args.last_time_ms = getTimeMs(); tu_args.last_percent = 0; tu_args.text_base = wgettext("Initializing nodes"); m_nodedef->updateTextures(this, texture_update_progress, &tu_args); delete[] tu_args.text_base; // Preload item textures and meshes if configured to if(g_settings->getBool("preload_item_visuals")) { verbosestream<<"Updating item textures and meshes"<<std::endl; text = wgettext("Item textures..."); draw_load_screen(text, device, guienv, 0, 0); std::set<std::string> names = m_itemdef->getAll(); size_t size = names.size(); size_t count = 0; int percent = 0; for(std::set<std::string>::const_iterator i = names.begin(); i != names.end(); ++i) { // Asking for these caches the result m_itemdef->getInventoryTexture(*i, this); m_itemdef->getWieldMesh(*i, this); count++; percent = (count * 100 / size * 0.2) + 80; draw_load_screen(text, device, guienv, 0, percent); } delete[] text; } // Start mesh update thread after setting up content definitions infostream<<"- Starting mesh update thread"<<std::endl; m_mesh_update_thread.start(); m_state = LC_Ready; sendReady(); text = wgettext("Done!"); draw_load_screen(text, device, guienv, 0, 100); infostream<<"Client::afterContentReceived() done"<<std::endl; delete[] text; }
void Client::afterContentReceived() { infostream<<"Client::afterContentReceived() started"<<std::endl; assert(m_itemdef_received); // pre-condition assert(m_nodedef_received); // pre-condition assert(mediaReceived()); // pre-condition const wchar_t* text = wgettext("Loading textures..."); // Clear cached pre-scaled 2D GUI images, as this cache // might have images with the same name but different // content from previous sessions. guiScalingCacheClear(); // Rebuild inherited images and recreate textures infostream<<"- Rebuilding images and textures"<<std::endl; RenderingEngine::draw_load_screen(text, guienv, m_tsrc, 0, 70); m_tsrc->rebuildImagesAndTextures(); delete[] text; // Rebuild shaders infostream<<"- Rebuilding shaders"<<std::endl; text = wgettext("Rebuilding shaders..."); RenderingEngine::draw_load_screen(text, guienv, m_tsrc, 0, 71); m_shsrc->rebuildShaders(); delete[] text; // Update node aliases infostream<<"- Updating node aliases"<<std::endl; text = wgettext("Initializing nodes..."); RenderingEngine::draw_load_screen(text, guienv, m_tsrc, 0, 72); m_nodedef->updateAliases(m_itemdef); std::string texture_path = g_settings->get("texture_path"); if (!texture_path.empty() && fs::IsDir(texture_path)) m_nodedef->applyTextureOverrides(texture_path + DIR_DELIM + "override.txt"); m_nodedef->setNodeRegistrationStatus(true); m_nodedef->runNodeResolveCallbacks(); delete[] text; // Update node textures and assign shaders to each tile infostream<<"- Updating node textures"<<std::endl; TextureUpdateArgs tu_args; tu_args.guienv = guienv; tu_args.last_time_ms = porting::getTimeMs(); tu_args.last_percent = 0; tu_args.text_base = wgettext("Initializing nodes"); tu_args.tsrc = m_tsrc; m_nodedef->updateTextures(this, texture_update_progress, &tu_args); delete[] tu_args.text_base; // Start mesh update thread after setting up content definitions infostream<<"- Starting mesh update thread"<<std::endl; m_mesh_update_thread.start(); m_state = LC_Ready; sendReady(); if (g_settings->getBool("enable_client_modding")) { m_script->on_client_ready(m_env.getLocalPlayer()); m_script->on_connect(); } text = wgettext("Done!"); RenderingEngine::draw_load_screen(text, guienv, m_tsrc, 0, 100); infostream<<"Client::afterContentReceived() done"<<std::endl; delete[] text; }
KCMInit::~KCMInit() { sendReady(); }
KCMInit::KCMInit( KCmdLineArgs* args ) { QDBusConnection::sessionBus().registerObject("/kcminit", this, QDBusConnection::ExportScriptableSlots|QDBusConnection::ExportScriptableSignals); QString arg; if (args->count() == 1) { arg = args->arg(0); } if (args->isSet("list")) { list = KServiceTypeTrader::self()->query( "KCModuleInit" ); for(KService::List::Iterator it = list.begin(); it != list.end(); ++it) { KService::Ptr service = (*it); if (service->library().isEmpty()) continue; // Skip printf("%s\n", QFile::encodeName(service->desktopEntryName()).data()); } return; } if (!arg.isEmpty()) { QString module = arg; if (!module.endsWith(".desktop")) module += ".desktop"; KService::Ptr serv = KService::serviceByStorageId( module ); if ( !serv || serv->library().isEmpty() ) { kError(1208) << i18n("Module %1 not found", module) << endl; return; } else list.append(serv); } else { // locate the desktop files list = KServiceTypeTrader::self()->query( "KCModuleInit" ); } // This key has no GUI apparently KConfig _config( "kcmdisplayrc" ); KConfigGroup config(&_config, "X11"); #ifdef Q_WS_X11 bool multihead = !config.readEntry( "disableMultihead", false) && (ScreenCount(QX11Info::display()) > 1); #else bool multihead = false; #endif // Pass env. var to kdeinit. QString name = "KDE_MULTIHEAD"; QString value = multihead ? "true" : "false"; KToolInvocation::klauncher()->setLaunchEnv(name, value); setenv( name.toLatin1().constData(), value.toLatin1().constData(), 1 ); // apply effect also to itself if( startup ) { runModules( 0 ); XEvent e; e.xclient.type = ClientMessage; e.xclient.message_type = XInternAtom( QX11Info::display(), "_KDE_SPLASH_PROGRESS", False ); e.xclient.display = QX11Info::display(); e.xclient.window = QX11Info::appRootWindow(); e.xclient.format = 8; strcpy( e.xclient.data.b, "kcminit" ); XSendEvent( QX11Info::display(), QX11Info::appRootWindow(), False, SubstructureNotifyMask, &e ); sendReady(); QTimer::singleShot( 300 * 1000, qApp, SLOT(quit())); // just in case qApp->exec(); // wait for runPhase1() and runPhase2() } else runModules( -1 ); // all phases }
scannerwindow::scannerwindow(QList<int> parameters, QMainWindow *parent, bool load, QTextStream* stream): QObject(parent) { this->parameters=parameters; widget = new QWidget(); widget->setAttribute(Qt::WA_DeleteOnClose); graph = new Q3DSurface(); container = QWidget::createWindowContainer(graph, widget); container->setAttribute(Qt::WA_AcceptTouchEvents); widget->setGeometry( QStyle::alignedRect( Qt::LeftToRight, Qt::AlignTop, widget->size(), qApp->desktop()->availableGeometry() ) ); bitmapForward=new QCustomPlot(widget); bitmapBackward=new QCustomPlot(widget); bitmapCombined=new QCustomPlot(widget); bitmapForward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setContextMenuPolicy(Qt::CustomContextMenu); bitmapCombined->setContextMenuPolicy(Qt::CustomContextMenu); bitmapBackward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapForward->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); bitmapCombined->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); initializeBitmapForward(bitmapForward); initializeBitmapBackward(bitmapBackward); initializeBitmapCombined(bitmapCombined); if (!graph->hasContext()) { QMessageBox msgBox; msgBox.setText("Couldn't initialize the OpenGL context."); msgBox.exec(); } QSize screenSize = graph->screen()->size(); container->setMinimumSize(QSize(screenSize.width() / 3, screenSize.height()/4)); container->setMaximumSize(screenSize); container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); container->setFocusPolicy(Qt::StrongFocus); bitmapBackward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapForward->setMinimumSize(screenSize.width()/4, screenSize.height()/4); bitmapCombined->setMinimumSize(screenSize.width()/4, screenSize.height()/4); QHBoxLayout *hLayout = new QHBoxLayout(widget); QVBoxLayout *vLayout = new QVBoxLayout(); QSplitter *hSplitterMain = new QSplitter(); QSplitter *vSplitterRight = new QSplitter(); hLayout->setSizeConstraint(QBoxLayout::SizeConstraint::SetMinimumSize); vSplitterRight->addWidget(bitmapForward); vSplitterRight->addWidget(bitmapBackward); vSplitterRight->addWidget(bitmapCombined); vSplitterRight->setOrientation(Qt::Orientation::Vertical); vSplitterRight->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); hSplitterMain->setOrientation(Qt::Orientation::Horizontal); hSplitterMain->addWidget(container); hSplitterMain->addWidget(vSplitterRight); hSplitterMain->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); vSplitterRight->setStyleSheet("QSplitter::handle {background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0,stop:0 rgba(255, 255, 255, 0),stop:0.407273 rgba(200, 200, 200, 255),stop:0.4825 rgba(101, 104, 113, 235), stop:0.6 rgba(255, 255, 255, 0));}"); hLayout->addWidget(hSplitterMain); hLayout->addLayout(vLayout); vLayout->setAlignment(Qt::AlignTop); widget->setWindowTitle(QStringLiteral("AFM Scan")); QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Scan")); if(!load){ AFM_Scan_3D_RB = new QPushButton(widget); AFM_Scan_3D_RB->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); AFM_Scan_3D_RB->setText(QStringLiteral("Start Scan")); AFM_Scan_3D_RB->setCheckable(true); AFM_Scan_3D_RB->setChecked(false); } SaveSurface = new QPushButton(widget); SaveSurface->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); SaveSurface->setText(QStringLiteral("Save Data")); BitmapView = new QPushButton(widget); BitmapView->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); BitmapView->setText(QStringLiteral("Save BMP")); QVBoxLayout *modelVBox = new QVBoxLayout; if(!load){ modelVBox->addWidget(AFM_Scan_3D_RB); } modelVBox->addWidget(BitmapView); modelVBox->addWidget(SaveSurface); modelGroupBox->setLayout(modelVBox); QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode")); selectionGroupBox->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); QCheckBox *piezoMove = new QCheckBox(widget); piezoMove->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); piezoMove->setText(QStringLiteral("Piezo")); piezoMove->setChecked(true); modelVBox->addWidget(piezoMove); QRadioButton *modeNoneRB = new QRadioButton(widget); modeNoneRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeNoneRB->setText(QStringLiteral("No selection")); modeNoneRB->setChecked(false); QRadioButton *modeItemRB = new QRadioButton(widget); modeItemRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeItemRB->setText(QStringLiteral("Item")); modeItemRB->setChecked(false); QRadioButton *modeSliceRowRB = new QRadioButton(widget); modeSliceRowRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceRowRB->setText(QStringLiteral("Row Slice")); modeSliceRowRB->setChecked(false); QRadioButton *modeSliceColumnRB = new QRadioButton(widget); modeSliceColumnRB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); modeSliceColumnRB->setText(QStringLiteral("Column Slice")); modeSliceColumnRB->setChecked(false); QVBoxLayout *selectionVBox = new QVBoxLayout; selectionVBox->addWidget(modeNoneRB); selectionVBox->addWidget(modeItemRB); selectionVBox->addWidget(modeSliceRowRB); selectionVBox->addWidget(modeSliceColumnRB); selectionGroupBox->setLayout(selectionVBox); QSlider *axisCameraSliderZ = new QSlider(Qt::Horizontal, widget); axisCameraSliderZ->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderZ->setMinimum(0); axisCameraSliderZ->setMaximum(179); axisCameraSliderZ->setTickInterval(1); axisCameraSliderZ->setEnabled(true); QSlider *axisCameraSliderY = new QSlider(Qt::Horizontal, widget); axisCameraSliderY->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); axisCameraSliderY->setMinimum(0); axisCameraSliderY->setMaximum(180); axisCameraSliderY->setTickInterval(0); axisCameraSliderY->setEnabled(true); QComboBox *themeList = new QComboBox(widget); themeList->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); themeList->addItem(QStringLiteral("Qt")); themeList->addItem(QStringLiteral("Primary Colors")); themeList->addItem(QStringLiteral("Digia")); themeList->addItem(QStringLiteral("Stone Moss")); themeList->addItem(QStringLiteral("Army Blue")); themeList->addItem(QStringLiteral("Retro")); themeList->addItem(QStringLiteral("Ebony")); themeList->addItem(QStringLiteral("Isabelle")); QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient")); QLinearGradient grBtoY(0, 0, 1, 100); grBtoY.setColorAt(1.0, Qt::black); grBtoY.setColorAt(0.67, Qt::blue); grBtoY.setColorAt(0.33, Qt::red); grBtoY.setColorAt(0.0, Qt::yellow); QPixmap pm(24, 100); QPainter pmp(&pm); pmp.setBrush(QBrush(grBtoY)); pmp.setPen(Qt::NoPen); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientBtoYPB = new QPushButton(widget); gradientBtoYPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientBtoYPB->setIcon(QIcon(pm)); gradientBtoYPB->setIconSize(QSize(24, 100)); QLinearGradient grGtoR(0, 0, 1, 100); grGtoR.setColorAt(1.0, Qt::darkGreen); grGtoR.setColorAt(0.5, Qt::yellow); grGtoR.setColorAt(0.2, Qt::red); grGtoR.setColorAt(0.0, Qt::darkRed); pmp.setBrush(QBrush(grGtoR)); pmp.drawRect(0, 0, 24, 100); QPushButton *gradientGtoRPB = new QPushButton(widget); gradientGtoRPB->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); gradientGtoRPB->setIcon(QIcon(pm)); gradientGtoRPB->setIconSize(QSize(24, 100)); QHBoxLayout *colorHBox = new QHBoxLayout; colorHBox->addWidget(gradientBtoYPB); colorHBox->addWidget(gradientGtoRPB); colorGroupBox->setLayout(colorHBox); vLayout->addWidget(modelGroupBox); vLayout->addWidget(selectionGroupBox); vLayout->addWidget(new QLabel(QStringLiteral("Camera Position"))); vLayout->addWidget(axisCameraSliderZ); vLayout->addWidget(axisCameraSliderY); vLayout->addWidget(new QLabel(QStringLiteral("Theme"))); vLayout->addWidget(themeList); vLayout->addWidget(colorGroupBox); widget->show(); modifier= new SurfaceGraph(graph, widget,parameters); if(!load){ QObject::connect(parent, SIGNAL(plotDataReceived(QList <QByteArray>)), modifier, SLOT(dataHandler(QList <QByteArray>))); QObject::connect(AFM_Scan_3D_RB, SIGNAL (toggled(bool)), this, SLOT(AFMButtonHandler(bool))); QObject::connect(this, SIGNAL (AFMStart()), modifier, SLOT (enableAFMModel())); QObject::connect(this, SIGNAL (AFMDone()), parent, SLOT (sendDone())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT (sendGo())); QObject::connect(this, SIGNAL (AFMStart()), parent, SLOT(sendReady()));}
tResult DriverFilter::OnPinEvent(IPin *source, tInt eventCore, tInt param1, tInt param2, IMediaSample *mediaSample) { RETURN_IF_POINTER_NULL(source); RETURN_IF_POINTER_NULL(mediaSample); if (eventCore == IPinEventSink::PE_MediaSampleReceived) { if (source == &this->juryStatePin) { static tInt8 actionId; static tInt16 maneuverId; RETURN_IF_FAILED_AND_LOG_ERROR_STR(getManeuver(mediaSample, actionId, maneuverId), "Cant get Maneuver from Jury"); switch (actionId) { case STOP: LOG_INFO(cString::Format("Jury sends stop in %d", maneuverId)); this->isFirstTimeRun = true; RETURN_IF_FAILED(sendError(maneuverId)); if (this->stopCounter <= 3) { RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, MANEUVER_STOP, mediaSample->GetTime())); this->stopCounter++; } break; case READY: LOG_INFO(cString::Format("Jury sends ready in %d", maneuverId)); RETURN_IF_FAILED(sendReady(maneuverId)); this->stopCounter = 0; break; case RUN: LOG_INFO(cString::Format("Jury sends run in %d", maneuverId)); if (this->isFirstTimeRun) { LOG_INFO("First time run!"); this->isFirstTimeRun = false; this->stopCounter = 0; getManeuverFromId(maneuverId, this->currentManeuver); this->currentManeuverId = maneuverId; LOG_INFO("Sending Manuever"); RETURN_IF_FAILED_AND_LOG_ERROR_STR(sendManeuver(this->currentManeuverPin, this->currentManeuver, mediaSample->GetTime()), "Cant send maneuver"); } RETURN_IF_FAILED(sendRunning(maneuverId)); break; } } else if (source == &this->maneuverFinishedPin) { LOG_WARNING("Got maneuver finished state"); this->stopCounter = 0; // lese den Zustand des aktuellen Befehls aus static tUInt16 maneuverValue; static tTimeStamp timeStamp; RETURN_IF_FAILED_AND_LOG_ERROR_STR(getManeuver(mediaSample, maneuverValue, timeStamp), "Cant get Maneuver from ManeuverFinishedPin"); if (isManeuverFinished(maneuverValue)) { // hole neuen befehl und sende ihn an das Juri modul und an den Befehlsauswerter if (getNextManeuver(this->currentManeuverId, this->currentManeuver)) { LOG_WARNING(cString::Format("next maneuver id: %d", this->currentManeuverId)); RETURN_IF_FAILED(sendRunning(this->currentManeuverId)); RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, this->currentManeuver, mediaSample->GetTime())); } else { LOG_INFO(cString::Format("send complete to jury in %d", this->currentManeuverId)); RETURN_IF_FAILED(sendComplete(this->currentManeuverId)); RETURN_IF_FAILED(sendManeuver(this->currentManeuverPin, MANEUVER_STOP, mediaSample->GetTime())); } } else { RETURN_IF_FAILED(sendRunning(this->currentManeuverId)); } } } RETURN_NOERROR; }