void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const QUuid& sessionID, uint32_t step) { assert(_entity); assert(_entity->isKnownID()); bool active = _body->isActive(); if (!active) { // make sure all derivatives are zero glm::vec3 zero(0.0f); _entity->setVelocity(zero); _entity->setAngularVelocity(zero); _entity->setAcceleration(zero); _sentActive = false; } else { float gravityLength = glm::length(_entity->getGravity()); float accVsGravity = glm::abs(glm::length(_measuredAcceleration) - gravityLength); if (accVsGravity < ACCELERATION_EQUIVALENT_EPSILON_RATIO * gravityLength) { // acceleration measured during the most recent simulation step was close to gravity. if (getAccelerationNearlyGravityCount() < STEPS_TO_DECIDE_BALLISTIC) { // only increment this if we haven't reached the threshold yet. this is to avoid // overflowing the counter. incrementAccelerationNearlyGravityCount(); } } else { // acceleration wasn't similar to this entities gravity, so reset the went-ballistic counter resetAccelerationNearlyGravityCount(); } // if this entity has been accelerated at close to gravity for a certain number of simulation-steps, let // the entity server's estimates include gravity. if (getAccelerationNearlyGravityCount() >= STEPS_TO_DECIDE_BALLISTIC) { _entity->setAcceleration(_entity->getGravity()); } else { _entity->setAcceleration(glm::vec3(0.0f)); } const float DYNAMIC_LINEAR_VELOCITY_THRESHOLD = 0.05f; // 5 cm/sec const float DYNAMIC_ANGULAR_VELOCITY_THRESHOLD = 0.087266f; // ~5 deg/sec bool movingSlowly = glm::length2(_entity->getVelocity()) < (DYNAMIC_LINEAR_VELOCITY_THRESHOLD * DYNAMIC_LINEAR_VELOCITY_THRESHOLD) && glm::length2(_entity->getAngularVelocity()) < (DYNAMIC_ANGULAR_VELOCITY_THRESHOLD * DYNAMIC_ANGULAR_VELOCITY_THRESHOLD) && _entity->getAcceleration() == glm::vec3(0.0f); if (movingSlowly) { // velocities might not be zero, but we'll fake them as such, which will hopefully help convince // other simulating observers to deactivate their own copies glm::vec3 zero(0.0f); _entity->setVelocity(zero); _entity->setAngularVelocity(zero); } _sentActive = true; } // remember properties for local server prediction _serverPosition = _entity->getPosition(); _serverRotation = _entity->getRotation(); _serverVelocity = _entity->getVelocity(); _serverAcceleration = _entity->getAcceleration(); _serverAngularVelocity = _entity->getAngularVelocity(); EntityItemProperties properties = _entity->getProperties(); // explicitly set the properties that changed so that they will be packed properties.setPosition(_serverPosition); properties.setRotation(_serverRotation); properties.setVelocity(_serverVelocity); properties.setAcceleration(_serverAcceleration); properties.setAngularVelocity(_serverAngularVelocity); // we only update lastEdited when we're sending new physics data quint64 lastSimulated = _entity->getLastSimulated(); _entity->setLastEdited(lastSimulated); properties.setLastEdited(lastSimulated); #ifdef WANT_DEBUG quint64 now = usecTimestampNow(); qCDebug(physics) << "EntityMotionState::sendUpdate()"; qCDebug(physics) << " EntityItemId:" << _entity->getEntityItemID() << "---------------------------------------------"; qCDebug(physics) << " lastSimulated:" << debugTime(lastSimulated, now); #endif //def WANT_DEBUG if (sessionID == _entity->getSimulatorID()) { // we think we own the simulation if (!active) { // we own the simulation but the entity has stopped, so we tell the server that we're clearing simulatorID // but we remember that we do still own it... and rely on the server to tell us that we don't properties.setSimulatorID(QUuid()); } else { // explicitly set the property's simulatorID so that it is flagged as changed and will be packed properties.setSimulatorID(sessionID); } } else { // we don't own the simulation for this entity yet, but we're sending a bid for it properties.setSimulatorID(sessionID); } if (EntityItem::getSendPhysicsUpdates()) { EntityItemID id(_entity->getID()); EntityEditPacketSender* entityPacketSender = static_cast<EntityEditPacketSender*>(packetSender); #ifdef WANT_DEBUG qCDebug(physics) << "EntityMotionState::sendUpdate()... calling queueEditEntityMessage()..."; #endif entityPacketSender->queueEditEntityMessage(PacketTypeEntityAddOrEdit, id, properties); _entity->setLastBroadcast(usecTimestampNow()); } else { #ifdef WANT_DEBUG qCDebug(physics) << "EntityMotionState::sendUpdate()... NOT sending update as requested."; #endif } _lastStep = step; }
static void printByteArray(const QByteArray &data) { qCDebug(sshLog, "%s", data.toHex().constData()); }
bool Wallet::readSecurityImage(const QString& inputFilePath, unsigned char** outputBufferPtr, int* outputBufferSize) { unsigned char ivec[16]; unsigned char ckey[32]; initializeAESKeys(ivec, ckey, _salt); // read encrypted file QFile inputFile(inputFilePath); if (!inputFile.exists()) { qCDebug(commerce) << "cannot decrypt file" << inputFilePath << "it doesn't exist"; return false; } inputFile.open(QIODevice::ReadOnly | QIODevice::Text); bool foundHeader = false; bool foundFooter = false; QByteArray base64EncryptedBuffer; while (!inputFile.atEnd()) { QString line(inputFile.readLine()); if (!foundHeader) { foundHeader = (line == IMAGE_HEADER); } else { foundFooter = (line == IMAGE_FOOTER); if (!foundFooter) { base64EncryptedBuffer.append(line); } } } inputFile.close(); if (! (foundHeader && foundFooter)) { qCDebug(commerce) << "couldn't parse" << inputFilePath << foundHeader << foundFooter; return false; } // convert to bytes auto encryptedBuffer = QByteArray::fromBase64(base64EncryptedBuffer); // setup decrypted buffer unsigned char* outputBuffer = new unsigned char[encryptedBuffer.size()]; int tempSize; // TODO: add error handling EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); if (!EVP_DecryptInit_ex(ctx, EVP_des_ede3_cbc(), NULL, ckey, ivec)) { qCDebug(commerce) << "decrypt init failure"; delete[] outputBuffer; return false; } if (!EVP_DecryptUpdate(ctx, outputBuffer, &tempSize, (unsigned char*)encryptedBuffer.data(), encryptedBuffer.size())) { qCDebug(commerce) << "decrypt update failure"; delete[] outputBuffer; return false; } *outputBufferSize = tempSize; if (!EVP_DecryptFinal_ex(ctx, outputBuffer + tempSize, &tempSize)) { qCDebug(commerce) << "decrypt final failure"; delete[] outputBuffer; return false; } EVP_CIPHER_CTX_free(ctx); *outputBufferSize += tempSize; *outputBufferPtr = outputBuffer; qCDebug(commerce) << "decrypted buffer size" << *outputBufferSize; return true; }
void HttpDaemon::actionExecuted(const ActionTypeId &actionTypeId) { qCDebug(dcMockDevice) << "Log actions executed" << actionTypeId.toString(); m_actionList.append(qMakePair<ActionTypeId, QDateTime>(actionTypeId, QDateTime::currentDateTime())); }
// public slot virtual [base kpView] void kpUnzoomedThumbnailView::adjustToEnvironment () { if (!buddyView () || !buddyViewScrollableContainer () || !document ()) return; const int scrollViewContentsX = buddyViewScrollableContainer()->horizontalScrollBar()->value(); const int scrollViewContentsY = buddyViewScrollableContainer ()->verticalScrollBar()->value(); #if DEBUG_KP_UNZOOMED_THUMBNAIL_VIEW qCDebug(kpLogViews) << "kpUnzoomedThumbnailView(" << name () << ")::adjustToEnvironment(" << scrollViewContentsX << "," << scrollViewContentsY << ") width=" << width () << " height=" << height () << endl; #endif #if 1 int x; if (document ()->width () > width ()) { x = (int) buddyView ()->transformViewToDocX (scrollViewContentsX); const int rightMostAllowedX = qMax (0, document ()->width () - width ()); #if DEBUG_KP_UNZOOMED_THUMBNAIL_VIEW qCDebug(kpLogViews) << "\tdocX=" << x << " docWidth=" << document ()->width () << " rightMostAllowedX=" << rightMostAllowedX << endl; #endif if (x > rightMostAllowedX) x = rightMostAllowedX; } // Thumbnail width <= doc width else { // Center X (rather than flush left to be consistent with // kpZoomedThumbnailView) x = -(width () - document ()->width ()) / 2; } int y; if (document ()->height () > height ()) { y = (int) buddyView ()->transformViewToDocY (scrollViewContentsY); const int bottomMostAllowedY = qMax (0, document ()->height () - height ()); #if DEBUG_KP_UNZOOMED_THUMBNAIL_VIEW qCDebug(kpLogViews) << "\tdocY=" << y << " docHeight=" << document ()->height () << " bottomMostAllowedY=" << bottomMostAllowedY << endl; #endif if (y > bottomMostAllowedY) y = bottomMostAllowedY; } // Thumbnail height <= doc height else { // Center Y (rather than flush top to be consistent with // kpZoomedThumbnailView) y = -(height () - document ()->height ()) / 2; } // Prefer to keep visible area centred in thumbnail instead of flushed left. // Gives more editing context to the left and top. // But feels awkward for left-to-right users. So disabled for now. // Not totally tested. #else if (!buddyViewScrollableContainer ()) return; QRect docRect = buddyView ()->transformViewToDoc ( QRect (buddyViewScrollableContainer ()->horizontalScrollBar()->value(), buddyViewScrollableContainer ()->verticalScrollBar()->value(), qMin (buddyView ()->width (), buddyViewScrollableContainer ()->viewport()->width ()), qMin (buddyView ()->height (), buddyViewScrollableContainer ()->viewport()->height ()))); x = docRect.x () - (width () - docRect.width ()) / 2; qCDebug(kpLogViews) << "\tnew suggest x=" << x; const int rightMostAllowedX = qMax (0, document ()->width () - width ()); if (x < 0) x = 0; if (x > rightMostAllowedX) x = rightMostAllowedX; y = docRect.y () - (height () - docRect.height ()) / 2; qCDebug(kpLogViews) << "\tnew suggest y=" << y; const int bottomMostAllowedY = qMax (0, document ()->height () - height ()); if (y < 0) y = 0; if (y > bottomMostAllowedY) y = bottomMostAllowedY; #endif if (viewManager ()) { viewManager ()->setFastUpdates (); viewManager ()->setQueueUpdates (); } { // OPT: scrollView impl would be much, much faster setOrigin (QPoint (-x, -y)); setMaskToCoverDocument (); // Above might be a NOP even if e.g. doc size changed so force // update if (viewManager ()) viewManager ()->updateView (this); } if (viewManager ()) { viewManager ()->restoreQueueUpdates (); viewManager ()->restoreFastUpdates (); } }
void FilterActionFilter::filterImage() { d->appliedActions.clear(); d->errorMessage.clear(); const float progressIncrement = 1.0 / qMax(1, d->actions.size()); float progress = 0; postProgress(0); DImg img = m_orgImage; foreach(const FilterAction& action, d->actions) { qCDebug(DIGIKAM_DIMG_LOG) << "Replaying action" << action.identifier(); if (action.isNull()) { continue; } if (DImgBuiltinFilter::isSupported(action.identifier())) { DImgBuiltinFilter filter(action); if (!filter.isValid()) { d->errorMessage = i18n("Built-in transformation not supported"); if (d->continueOnError) { continue; } else { break; } } filter.apply(img); d->appliedActions << filter.filterAction(); } else { QScopedPointer<DImgThreadedFilter> filter (DImgFilterManager::instance()->createFilter(action.identifier(), action.version())); if (!filter) { d->errorMessage = i18n("Filter identifier or version is not supported"); if (d->continueOnError) { continue; } else { break; } } filter->readParameters(action); if (!filter->parametersSuccessfullyRead()) { d->errorMessage = filter->readParametersError(action); if (d->continueOnError) { continue; } else { break; } } // compute filter->setupAndStartDirectly(img, this, (int)progress, (int)(progress + progressIncrement)); img = filter->getTargetImage(); d->appliedActions << filter->filterAction(); } progress += progressIncrement; postProgress((int)progress); } m_destImage = img; }
void ScriptEngine::errorInLoadingScript(const QUrl& url) { qCDebug(scriptengine) << "ERROR Loading file:" << url.toString() << "line:" << __LINE__; emit errorLoadingScript(_fileNameString); // ?? }
QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat) { KeycodeAction result = None; bool first_press = pressed && !autorepeat; const QEvdevKeyboardMap::Mapping *map_plain = 0; const QEvdevKeyboardMap::Mapping *map_withmod = 0; quint8 modifiers = m_modifiers; // get a specific and plain mapping for the keycode and the current modifiers for (int i = 0; i < m_keymap_size && !(map_plain && map_withmod); ++i) { const QEvdevKeyboardMap::Mapping *m = m_keymap + i; if (m->keycode == keycode) { if (m->modifiers == 0) map_plain = m; quint8 testmods = m_modifiers; if (m_locks[0] /*CapsLock*/ && (m->flags & QEvdevKeyboardMap::IsLetter)) testmods ^= QEvdevKeyboardMap::ModShift; if (m->modifiers == testmods) map_withmod = m; } } if (m_locks[0] /*CapsLock*/ && map_withmod && (map_withmod->flags & QEvdevKeyboardMap::IsLetter)) modifiers ^= QEvdevKeyboardMap::ModShift; qCDebug(qLcEvdevKeyMap, "Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", keycode, modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, int(map_plain ? map_plain - m_keymap : -1), int(map_withmod ? map_withmod - m_keymap : -1), m_keymap_size); const QEvdevKeyboardMap::Mapping *it = map_withmod ? map_withmod : map_plain; if (!it) { // we couldn't even find a plain mapping qCDebug(qLcEvdevKeyMap, "Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, modifiers); return result; } bool skip = false; quint16 unicode = it->unicode; quint32 qtcode = it->qtcode; if ((it->flags & QEvdevKeyboardMap::IsModifier) && it->special) { // this is a modifier, i.e. Shift, Alt, ... if (pressed) m_modifiers |= quint8(it->special); else m_modifiers &= ~quint8(it->special); } else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) { // (Caps|Num|Scroll)Lock if (first_press) { quint8 &lock = m_locks[qtcode - Qt::Key_CapsLock]; lock ^= 1; switch (qtcode) { case Qt::Key_CapsLock : result = lock ? CapsLockOn : CapsLockOff; break; case Qt::Key_NumLock : result = lock ? NumLockOn : NumLockOff; break; case Qt::Key_ScrollLock: result = lock ? ScrollLockOn : ScrollLockOff; break; default : break; } } } else if ((it->flags & QEvdevKeyboardMap::IsSystem) && it->special && first_press) { switch (it->special) { case QEvdevKeyboardMap::SystemReboot: result = Reboot; break; case QEvdevKeyboardMap::SystemZap: if (!m_no_zap) qApp->quit(); break; case QEvdevKeyboardMap::SystemConsolePrevious: result = PreviousConsole; break; case QEvdevKeyboardMap::SystemConsoleNext: result = NextConsole; break; default: if (it->special >= QEvdevKeyboardMap::SystemConsoleFirst && it->special <= QEvdevKeyboardMap::SystemConsoleLast) { result = KeycodeAction(SwitchConsoleFirst + ((it->special & QEvdevKeyboardMap::SystemConsoleMask) & SwitchConsoleMask)); } break; } skip = true; // no need to tell Qt about it } else if ((qtcode == Qt::Key_Multi_key) && m_do_compose) { // the Compose key was pressed if (first_press) m_composing = 2; skip = true; } else if ((it->flags & QEvdevKeyboardMap::IsDead) && m_do_compose) { // a Dead key was pressed if (first_press && m_composing == 1 && m_dead_unicode == unicode) { // twice m_composing = 0; qtcode = Qt::Key_unknown; // otherwise it would be Qt::Key_Dead... } else if (first_press && unicode != 0xffff) { m_dead_unicode = unicode; m_composing = 1; skip = true; } else { skip = true; } } if (!skip) { // a normal key was pressed const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier; // we couldn't find a specific mapping for the current modifiers, // or that mapping didn't have special modifiers: // so just report the plain mapping with additional modifiers. if ((it == map_plain && it != map_withmod) || (map_withmod && !(map_withmod->qtcode & modmask))) { qtcode |= QEvdevKeyboardHandler::toQtModifiers(modifiers); } if (m_composing == 2 && first_press && !(it->flags & QEvdevKeyboardMap::IsModifier)) { // the last key press was the Compose key if (unicode != 0xffff) { int idx = 0; // check if this code is in the compose table at all for ( ; idx < m_keycompose_size; ++idx) { if (m_keycompose[idx].first == unicode) break; } if (idx < m_keycompose_size) { // found it -> simulate a Dead key press m_dead_unicode = unicode; unicode = 0xffff; m_composing = 1; skip = true; } else { m_composing = 0; } } else { m_composing = 0; } } else if (m_composing == 1 && first_press && !(it->flags & QEvdevKeyboardMap::IsModifier)) { // the last key press was a Dead key bool valid = false; if (unicode != 0xffff) { int idx = 0; // check if this code is in the compose table at all for ( ; idx < m_keycompose_size; ++idx) { if (m_keycompose[idx].first == m_dead_unicode && m_keycompose[idx].second == unicode) break; } if (idx < m_keycompose_size) { quint16 composed = m_keycompose[idx].result; if (composed != 0xffff) { unicode = composed; qtcode = Qt::Key_unknown; valid = true; } } } if (!valid) { unicode = m_dead_unicode; qtcode = Qt::Key_unknown; } m_composing = 0; } if (!skip) { // Up until now qtcode contained both the key and modifiers. Split it. Qt::KeyboardModifiers qtmods = Qt::KeyboardModifiers(qtcode & modmask); qtcode &= ~modmask; qCDebug(qLcEvdevKeyMap, "Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode, int(qtmods)); // If NumLockOff and keypad key pressed remap event sent if (!m_locks[1] && (qtmods & Qt::KeypadModifier) && keycode >= 71 && keycode <= 83 && keycode != 74 && keycode != 78) { unicode = 0xffff; switch (keycode) { case 71: //7 --> Home qtcode = Qt::Key_Home; break; case 72: //8 --> Up qtcode = Qt::Key_Up; break; case 73: //9 --> PgUp qtcode = Qt::Key_PageUp; break; case 75: //4 --> Left qtcode = Qt::Key_Left; break; case 76: //5 --> Clear qtcode = Qt::Key_Clear; break; case 77: //6 --> right qtcode = Qt::Key_Right; break; case 79: //1 --> End qtcode = Qt::Key_End; break; case 80: //2 --> Down qtcode = Qt::Key_Down; break; case 81: //3 --> PgDn qtcode = Qt::Key_PageDown; break; case 82: //0 --> Ins qtcode = Qt::Key_Insert; break; case 83: //, --> Del qtcode = Qt::Key_Delete; break; } } // Map SHIFT + Tab to SHIFT + Backtab, QShortcutMap knows about this translation if (qtcode == Qt::Key_Tab && (qtmods & Qt::ShiftModifier) == Qt::ShiftModifier) qtcode = Qt::Key_Backtab; // Generate the QPA event. processKeyEvent(keycode, unicode, qtcode, qtmods, pressed, autorepeat); } } return result; }
QString AbstractExtItem::tag(const QString &_type) const { qCDebug(LOG_LIB) << "Tag type" << _type; return QString("%1%2").arg(_type).arg(number()); }
void AudioMixerClientData::processStreamPacket(ReceivedMessage& message, ConcurrentAddedStreams &addedStreams) { if (!containsValidPosition(message)) { qDebug() << "Refusing to process audio stream from" << message.getSourceID() << "with invalid position"; return; } SharedStreamPointer matchingStream; auto packetType = message.getType(); bool newStream = false; if (packetType == PacketType::MicrophoneAudioWithEcho || packetType == PacketType::MicrophoneAudioNoEcho || packetType == PacketType::SilentAudioFrame) { auto micStreamIt = std::find_if(_audioStreams.begin(), _audioStreams.end(), [](const SharedStreamPointer& stream){ return stream->getStreamIdentifier().isNull(); }); if (micStreamIt == _audioStreams.end()) { // we don't have a mic stream yet, so add it // hop past the sequence number that leads the packet message.seek(sizeof(StreamSequenceNumber)); // pull the codec string from the packet auto codecString = message.readString(); // determine if the stream is stereo or not bool isStereo; if (packetType == PacketType::SilentAudioFrame || packetType == PacketType::ReplicatedSilentAudioFrame) { SilentSamplesBytes numSilentSamples; message.readPrimitive(&numSilentSamples); isStereo = numSilentSamples == AudioConstants::NETWORK_FRAME_SAMPLES_STEREO; } else { ChannelFlag channelFlag; message.readPrimitive(&channelFlag); isStereo = channelFlag == 1; } auto avatarAudioStream = new AvatarAudioStream(isStereo, AudioMixer::getStaticJitterFrames()); avatarAudioStream->setupCodec(_codec, _selectedCodecName, isStereo ? AudioConstants::STEREO : AudioConstants::MONO); if (_isIgnoreRadiusEnabled) { avatarAudioStream->enableIgnoreBox(); } else { avatarAudioStream->disableIgnoreBox(); } qCDebug(audio) << "creating new AvatarAudioStream... codec:" << _selectedCodecName << "isStereo:" << isStereo; connect(avatarAudioStream, &InboundAudioStream::mismatchedAudioCodec, this, &AudioMixerClientData::handleMismatchAudioFormat); matchingStream = SharedStreamPointer(avatarAudioStream); _audioStreams.push_back(matchingStream); newStream = true; } else { matchingStream = *micStreamIt; } } else if (packetType == PacketType::InjectAudio) { // this is injected audio // skip the sequence number and codec string and grab the stream identifier for this injected audio message.seek(sizeof(StreamSequenceNumber)); message.readString(); QUuid streamIdentifier = QUuid::fromRfc4122(message.readWithoutCopy(NUM_BYTES_RFC4122_UUID)); auto streamIt = std::find_if(_audioStreams.begin(), _audioStreams.end(), [&streamIdentifier](const SharedStreamPointer& stream) { return stream->getStreamIdentifier() == streamIdentifier; }); if (streamIt == _audioStreams.end()) { bool isStereo; message.readPrimitive(&isStereo); // we don't have this injected stream yet, so add it auto injectorStream = new InjectedAudioStream(streamIdentifier, isStereo, AudioMixer::getStaticJitterFrames()); #if INJECTORS_SUPPORT_CODECS injectorStream->setupCodec(_codec, _selectedCodecName, isStereo ? AudioConstants::STEREO : AudioConstants::MONO); qCDebug(audio) << "creating new injectorStream... codec:" << _selectedCodecName << "isStereo:" << isStereo; #endif matchingStream = SharedStreamPointer(injectorStream); _audioStreams.push_back(matchingStream); newStream = true; } else { matchingStream = *streamIt; } } // seek to the beginning of the packet so that the next reader is in the right spot message.seek(0); // check the overflow count before we parse data auto overflowBefore = matchingStream->getOverflowCount(); matchingStream->parseData(message); if (matchingStream->getOverflowCount() > overflowBefore) { qCDebug(audio) << "Just overflowed on stream" << matchingStream->getStreamIdentifier() << "from" << message.getSourceID(); } if (newStream) { // whenever a stream is added, push it to the concurrent vector of streams added this frame addedStreams.push_back(AddedStream(getNodeID(), getNodeLocalID(), matchingStream->getStreamIdentifier(), matchingStream.get())); } }
// ----------------------- Generic IO ------------------------- KGameIO::KGameIO() : d(new KGameIOPrivate) { QLoggingCategory::setFilterRules(QLatin1Literal("games.private.kgame.debug = true")); qCDebug(GAMES_PRIVATE_KGAME) << ": this=" << this << ", sizeof(this)" << sizeof(KGameIO); }
void StructViewDisplaySettingsWidget::setUnsignedDisplay(int index) { qCDebug(LOG_KASTEN_OKTETA_CONTROLLERS_STRUCTURES) << "byteOrder changed to " << index; handleMapping(index, ui.combo_UnsignedDisplayBase, ui.kcfg_UnsignedDisplayBase); }
void CanvasRenderer::paintVectorFrame( QPainter& painter, int layerId, int nFrame, bool colorize, bool useLastKeyFrame ) { Layer* layer = mObject->getLayer( layerId ); if ( !layer->visible() ) { return; } LayerVector* vectorLayer = dynamic_cast< LayerVector* >( layer ); if ( vectorLayer == nullptr ) { Q_ASSERT( vectorLayer ); return; } qCDebug( mLog ) << "Paint Onion skin vector, Frame = " << nFrame; VectorImage* vectorImage; if (useLastKeyFrame) { vectorImage = vectorLayer->getLastVectorImageAtFrame( nFrame, 0 ); } else { vectorImage = vectorLayer->getVectorImageAtFrame( nFrame ); } if ( vectorImage == nullptr ) { return; } QImage* pImage = new QImage( mCanvas->size(), QImage::Format_ARGB32_Premultiplied ); vectorImage->outputImage( pImage, mViewTransform, mOptions.bOutlines, mOptions.bThinLines, mOptions.bAntiAlias ); //painter.drawImage( QPoint( 0, 0 ), *pImage ); // Go through a Bitmap image to paint the onion skin colour // BitmapImage* tempBitmapImage = new BitmapImage(); tempBitmapImage->setImage(pImage); if ( colorize ) { QBrush colorBrush = QBrush(Qt::transparent); //no color for the current frame if (nFrame < mFrameNumber) { colorBrush = QBrush(Qt::red); } else if (nFrame > mFrameNumber) { colorBrush = QBrush(Qt::blue); } tempBitmapImage->drawRect( pImage->rect(), Qt::NoPen, colorBrush, QPainter::CompositionMode_SourceIn, false); } painter.setWorldMatrixEnabled( false ); //Don't tranform the image here as we used the viewTransform in the image output tempBitmapImage->paintImage( painter ); delete tempBitmapImage; }
void CanvasRenderer::paintBitmapFrame( QPainter& painter, int layerId, int nFrame, bool colorize, bool useLastKeyFrame ) { Layer* layer = mObject->getLayer( layerId ); if ( !layer->visible() ) { return; } LayerBitmap* bitmapLayer = dynamic_cast< LayerBitmap* >( layer ); if ( bitmapLayer == nullptr ) { Q_ASSERT( bitmapLayer ); return; } qCDebug( mLog ) << "Paint Onion skin bitmap, Frame = " << nFrame; BitmapImage* bitmapImage; if (useLastKeyFrame) { bitmapImage = bitmapLayer->getLastBitmapImageAtFrame( nFrame, 0 ); } else { bitmapImage = bitmapLayer->getBitmapImageAtFrame( nFrame ); } if ( bitmapImage == nullptr ) { return; } BitmapImage* tempBitmapImage = new BitmapImage; tempBitmapImage->paste(bitmapImage); if ( colorize ) { QBrush colorBrush = QBrush(Qt::transparent); //no color for the current frame if (nFrame < mFrameNumber) { colorBrush = QBrush(Qt::red); } else if (nFrame > mFrameNumber) { colorBrush = QBrush(Qt::blue); } tempBitmapImage->drawRect( bitmapImage->bounds(), Qt::NoPen, colorBrush, QPainter::CompositionMode_SourceIn, false); } // If the current frame on the current layer has a transformation, we apply it. // if (mRenderTransform && nFrame == mFrameNumber && layerId == mLayerIndex ) { tempBitmapImage->clear(mSelection); paintTransformedSelection(painter); } painter.setWorldMatrixEnabled( true ); if (mRenderTransform && nFrame) { painter.setOpacity( bitmapLayer->getOpacity() ); } tempBitmapImage->paintImage( painter ); delete tempBitmapImage; }
bool QDeviceDiscoveryStatic::checkDeviceType(const QString &device) { int fd = QT_OPEN(device.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0); if (Q_UNLIKELY(fd == -1)) { qWarning() << "Device discovery cannot open device" << device; return false; } qCDebug(lcDD) << "doing static device discovery for " << device; if ((m_types & Device_DRM) && device.contains(QLatin1String(QT_DRM_DEVICE_PREFIX))) { QT_CLOSE(fd); return true; } long bitsAbs[LONG_FIELD_SIZE(ABS_CNT)]; long bitsKey[LONG_FIELD_SIZE(KEY_CNT)]; long bitsRel[LONG_FIELD_SIZE(REL_CNT)]; memset(bitsAbs, 0, sizeof(bitsAbs)); memset(bitsKey, 0, sizeof(bitsKey)); memset(bitsRel, 0, sizeof(bitsRel)); ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(bitsAbs)), bitsAbs); ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(bitsKey)), bitsKey); ioctl(fd, EVIOCGBIT(EV_REL, sizeof(bitsRel)), bitsRel); QT_CLOSE(fd); if ((m_types & Device_Keyboard)) { if (testBit(KEY_Q, bitsKey)) { qCDebug(lcDD) << "Found keyboard at" << device; return true; } } if ((m_types & Device_Mouse)) { if (testBit(REL_X, bitsRel) && testBit(REL_Y, bitsRel) && testBit(BTN_MOUSE, bitsKey)) { qCDebug(lcDD) << "Found mouse at" << device; return true; } } if ((m_types & (Device_Touchpad | Device_Touchscreen))) { if (testBit(ABS_X, bitsAbs) && testBit(ABS_Y, bitsAbs)) { if ((m_types & Device_Touchpad) && testBit(BTN_TOOL_FINGER, bitsKey)) { qCDebug(lcDD) << "Found touchpad at" << device; return true; } else if ((m_types & Device_Touchscreen) && testBit(BTN_TOUCH, bitsKey)) { qCDebug(lcDD) << "Found touchscreen at" << device; return true; } else if ((m_types & Device_Tablet) && (testBit(BTN_STYLUS, bitsKey) || testBit(BTN_TOOL_PEN, bitsKey))) { qCDebug(lcDD) << "Found tablet at" << device; return true; } } else if (testBit(ABS_MT_POSITION_X, bitsAbs) && testBit(ABS_MT_POSITION_Y, bitsAbs)) { qCDebug(lcDD) << "Found new-style touchscreen at" << device; return true; } } if ((m_types & Device_Joystick)) { if (testBit(BTN_A, bitsKey) || testBit(BTN_TRIGGER, bitsKey) || testBit(ABS_RX, bitsAbs)) { qCDebug(lcDD) << "Found joystick/gamepad at" << device; return true; } } return false; }
void AbstractExtItem::setApiVersion(const int _apiVersion) { qCDebug(LOG_LIB) << "Version" << _apiVersion; m_apiVersion = _apiVersion; }
QDeviceDiscoveryStatic::QDeviceDiscoveryStatic(QDeviceTypes types, QObject *parent) : QDeviceDiscovery(types, parent) { qCDebug(lcDD) << "static device discovery for type" << types; }
void AbstractExtItem::setActive(const bool _state) { qCDebug(LOG_LIB) << "State" << _state; m_active = _state; }
void QMirClientInput::customEvent(QEvent* event) { Q_ASSERT(QThread::currentThread() == thread()); UbuntuEvent* ubuntuEvent = static_cast<UbuntuEvent*>(event); const MirEvent *nativeEvent = ubuntuEvent->nativeEvent; if ((ubuntuEvent->window == nullptr) || (ubuntuEvent->window->window() == nullptr)) { qCWarning(mirclient) << "Attempted to deliver an event to a non-existent window, ignoring."; return; } // Event filtering. long result; if (QWindowSystemInterface::handleNativeEvent( ubuntuEvent->window->window(), mEventFilterType, const_cast<void *>(static_cast<const void *>(nativeEvent)), &result) == true) { qCDebug(mirclient, "event filtered out by native interface"); return; } qCDebug(mirclientInput, "customEvent(type=%s)", nativeEventTypeToStr(mir_event_get_type(nativeEvent))); // Event dispatching. switch (mir_event_get_type(nativeEvent)) { case mir_event_type_input: dispatchInputEvent(ubuntuEvent->window, mir_event_get_input_event(nativeEvent)); break; case mir_event_type_resize: { auto resizeEvent = mir_event_get_resize_event(nativeEvent); // Enable workaround for Screen rotation auto const targetWindow = ubuntuEvent->window; if (targetWindow) { auto const screen = static_cast<QMirClientScreen*>(targetWindow->screen()); if (screen) { screen->handleWindowSurfaceResize( mir_resize_event_get_width(resizeEvent), mir_resize_event_get_height(resizeEvent)); } targetWindow->handleSurfaceResized( mir_resize_event_get_width(resizeEvent), mir_resize_event_get_height(resizeEvent)); } break; } case mir_event_type_surface: handleSurfaceEvent(ubuntuEvent->window, mir_event_get_surface_event(nativeEvent)); break; case mir_event_type_surface_output: handleSurfaceOutputEvent(ubuntuEvent->window, mir_event_get_surface_output_event(nativeEvent)); break; case mir_event_type_orientation: dispatchOrientationEvent(ubuntuEvent->window->window(), mir_event_get_orientation_event(nativeEvent)); break; case mir_event_type_close_surface: QWindowSystemInterface::handleCloseEvent(ubuntuEvent->window->window()); break; default: qCDebug(mirclient, "unhandled event type: %d", static_cast<int>(mir_event_get_type(nativeEvent))); } }
void AbstractExtItem::setComment(const QString &_comment) { qCDebug(LOG_LIB) << "Comment" << _comment; m_comment = _comment; }
void ScriptEngine::run() { // TODO: can we add a short circuit for _stoppingAllScripts here? What does it mean to not start running if // we're in the process of stopping? if (!_isInitialized) { init(); } _isRunning = true; _isFinished = false; emit runningStateChanged(); QScriptValue result = evaluate(_scriptContents); QElapsedTimer startTime; startTime.start(); int thisFrame = 0; auto nodeList = DependencyManager::get<NodeList>(); auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>(); qint64 lastUpdate = usecTimestampNow(); while (!_isFinished) { int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec if (usecToSleep > 0) { usleep(usecToSleep); } if (_isFinished) { break; } QCoreApplication::processEvents(); if (_isFinished) { break; } if (!_isFinished && entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { entityScriptingInterface->getEntityPacketSender()->process(); } } if (!_isFinished && _isAvatar && _avatarData) { const int SCRIPT_AUDIO_BUFFER_SAMPLES = floor(((SCRIPT_DATA_CALLBACK_USECS * AudioConstants::SAMPLE_RATE) / (1000 * 1000)) + 0.5); const int SCRIPT_AUDIO_BUFFER_BYTES = SCRIPT_AUDIO_BUFFER_SAMPLES * sizeof(int16_t); QByteArray avatarPacket = byteArrayWithPopulatedHeader(PacketTypeAvatarData); avatarPacket.append(_avatarData->toByteArray()); nodeList->broadcastToNodes(avatarPacket, NodeSet() << NodeType::AvatarMixer); if (_isListeningToAudioStream || _avatarSound) { // if we have an avatar audio stream then send it out to our audio-mixer bool silentFrame = true; int16_t numAvailableSamples = SCRIPT_AUDIO_BUFFER_SAMPLES; const int16_t* nextSoundOutput = NULL; if (_avatarSound) { const QByteArray& soundByteArray = _avatarSound->getByteArray(); nextSoundOutput = reinterpret_cast<const int16_t*>(soundByteArray.data() + _numAvatarSoundSentBytes); int numAvailableBytes = (soundByteArray.size() - _numAvatarSoundSentBytes) > SCRIPT_AUDIO_BUFFER_BYTES ? SCRIPT_AUDIO_BUFFER_BYTES : soundByteArray.size() - _numAvatarSoundSentBytes; numAvailableSamples = numAvailableBytes / sizeof(int16_t); // check if the all of the _numAvatarAudioBufferSamples to be sent are silence for (int i = 0; i < numAvailableSamples; ++i) { if (nextSoundOutput[i] != 0) { silentFrame = false; break; } } _numAvatarSoundSentBytes += numAvailableBytes; if (_numAvatarSoundSentBytes == soundByteArray.size()) { // we're done with this sound object - so set our pointer back to NULL // and our sent bytes back to zero _avatarSound = NULL; _numAvatarSoundSentBytes = 0; } } QByteArray audioPacket = byteArrayWithPopulatedHeader(silentFrame ? PacketTypeSilentAudioFrame : PacketTypeMicrophoneAudioNoEcho); QDataStream packetStream(&audioPacket, QIODevice::Append); // pack a placeholder value for sequence number for now, will be packed when destination node is known int numPreSequenceNumberBytes = audioPacket.size(); packetStream << (quint16) 0; if (silentFrame) { if (!_isListeningToAudioStream) { // if we have a silent frame and we're not listening then just send nothing and break out of here break; } // write the number of silent samples so the audio-mixer can uphold timing packetStream.writeRawData(reinterpret_cast<const char*>(&SCRIPT_AUDIO_BUFFER_SAMPLES), sizeof(int16_t)); // use the orientation and position of this avatar for the source of this audio packetStream.writeRawData(reinterpret_cast<const char*>(&_avatarData->getPosition()), sizeof(glm::vec3)); glm::quat headOrientation = _avatarData->getHeadOrientation(); packetStream.writeRawData(reinterpret_cast<const char*>(&headOrientation), sizeof(glm::quat)); } else if (nextSoundOutput) { // assume scripted avatar audio is mono and set channel flag to zero packetStream << (quint8)0; // use the orientation and position of this avatar for the source of this audio packetStream.writeRawData(reinterpret_cast<const char*>(&_avatarData->getPosition()), sizeof(glm::vec3)); glm::quat headOrientation = _avatarData->getHeadOrientation(); packetStream.writeRawData(reinterpret_cast<const char*>(&headOrientation), sizeof(glm::quat)); // write the raw audio data packetStream.writeRawData(reinterpret_cast<const char*>(nextSoundOutput), numAvailableSamples * sizeof(int16_t)); } // write audio packet to AudioMixer nodes auto nodeList = DependencyManager::get<NodeList>(); nodeList->eachNode([this, &nodeList, &audioPacket, &numPreSequenceNumberBytes](const SharedNodePointer& node){ // only send to nodes of type AudioMixer if (node->getType() == NodeType::AudioMixer) { // pack sequence number quint16 sequence = _outgoingScriptAudioSequenceNumbers[node->getUUID()]++; memcpy(audioPacket.data() + numPreSequenceNumberBytes, &sequence, sizeof(quint16)); // send audio packet nodeList->writeDatagram(audioPacket, node); } }); } } qint64 now = usecTimestampNow(); float deltaTime = (float) (now - lastUpdate) / (float) USECS_PER_SECOND; if (hasUncaughtException()) { int line = uncaughtExceptionLineNumber(); qCDebug(scriptengine) << "Uncaught exception at (" << _fileNameString << ") line" << line << ":" << uncaughtException().toString(); emit errorMessage("Uncaught exception at (" + _fileNameString + ") line" + QString::number(line) + ":" + uncaughtException().toString()); clearExceptions(); } if (!_isFinished) { emit update(deltaTime); } lastUpdate = now; } stopAllTimers(); // make sure all our timers are stopped if the script is ending emit scriptEnding(); // kill the avatar identity timer delete _avatarIdentityTimer; if (entityScriptingInterface->getEntityPacketSender()->serversExist()) { // release the queue of edit entity messages. entityScriptingInterface->getEntityPacketSender()->releaseQueuedMessages(); // since we're in non-threaded mode, call process so that the packets are sent if (!entityScriptingInterface->getEntityPacketSender()->isThreaded()) { entityScriptingInterface->getEntityPacketSender()->process(); } } // If we were on a thread, then wait till it's done if (thread()) { thread()->quit(); } emit finished(_fileNameString); _isRunning = false; emit runningStateChanged(); emit doneRunning(); _doneRunningThisScript = true; }
void AbstractExtItem::setName(const QString &_name) { qCDebug(LOG_LIB) << "Name" << _name; m_name = _name; }
QTreeView* OutputWidget::createListView(int id) { auto createHelper = [&]() -> QTreeView* { KDevelop::FocusedTreeView* listview = new KDevelop::FocusedTreeView(this); listview->setEditTriggers( QAbstractItemView::NoEditTriggers ); listview->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn); //Always enable the scrollbar, so it doesn't flash around listview->setHeaderHidden(true); listview->setUniformRowHeights(true); listview->setRootIsDecorated(false); listview->setSelectionMode( QAbstractItemView::ContiguousSelection ); if (data->outputdata.value(id)->behaviour & KDevelop::IOutputView::AutoScroll) { listview->setAutoScrollAtEnd(true); } connect(listview, &QTreeView::activated, this, &OutputWidget::activate); connect(listview, &QTreeView::clicked, this, &OutputWidget::activate); return listview; }; QTreeView* listview = 0; if( !views.contains(id) ) { bool newView = true; if( data->type & KDevelop::IOutputView::MultipleView || data->type & KDevelop::IOutputView::HistoryView ) { qCDebug(PLUGIN_STANDARDOUTPUTVIEW) << "creating listview"; listview = createHelper(); if( data->type & KDevelop::IOutputView::MultipleView ) { tabwidget->addTab( listview, data->outputdata.value(id)->title ); } else { stackwidget->addWidget( listview ); stackwidget->setCurrentWidget( listview ); } } else { if( views.isEmpty() ) { listview = createHelper(); layout()->addWidget( listview ); } else { listview = views.begin().value(); newView = false; } } views[id] = listview; changeModel( id ); changeDelegate( id ); if (newView) listview->scrollToBottom(); } else { listview = views.value(id); } enableActions(); return listview; }
LensFunIface::MetadataMatch LensFunIface::findFromMetadata(const DMetadata& meta) { MetadataMatch ret = MetadataNoMatch; d->settings = LensFunContainer(); d->usedCamera = 0; d->usedLens = 0; d->lensDescription.clear(); if (meta.isEmpty()) { qCDebug(DIGIKAM_DIMG_LOG) << "No metadata available"; return LensFunIface::MetadataUnavailable; } PhotoInfoContainer photoInfo = meta.getPhotographInformation(); d->makeDescription = photoInfo.make.trimmed(); d->modelDescription = photoInfo.model.trimmed(); bool exactMatch = true; if (d->makeDescription.isEmpty()) { qCDebug(DIGIKAM_DIMG_LOG) << "No camera maker info available"; exactMatch = false; } else { // NOTE: see bug #184156: // Some rules to wrap unknown camera device from Lensfun database, which have equivalent in fact. if (d->makeDescription == QLatin1String("Canon")) { if (d->modelDescription == QLatin1String("Canon EOS Kiss Digital X")) { d->modelDescription = QLatin1String("Canon EOS 400D DIGITAL"); } if (d->modelDescription == QLatin1String("G1 X")) { d->modelDescription = QLatin1String("G1X"); } } d->lensDescription = photoInfo.lens.trimmed(); // ------------------------------------------------------------------------------------------------ DevicePtr lfCamera = findCamera(d->makeDescription, d->modelDescription); if (lfCamera) { setUsedCamera(lfCamera); qCDebug(DIGIKAM_DIMG_LOG) << "Camera maker : " << d->settings.cameraMake; qCDebug(DIGIKAM_DIMG_LOG) << "Camera model : " << d->settings.cameraModel; // ------------------------------------------------------------------------------------------------ // -- Performing lens description searches. if (!d->lensDescription.isEmpty()) { LensList lensMatches; QString lensCutted; LensList lensList; // STAGE 1, search in LensFun database as well. lensList = findLenses(d->usedCamera, d->lensDescription); qCDebug(DIGIKAM_DIMG_LOG) << "* Check for lens by direct query (" << d->lensDescription << " : " << lensList.count() << ")"; lensMatches.append(lensList); // STAGE 2, Adapt exiv2 strings to lensfun strings for Nikon. lensCutted = d->lensDescription; if (lensCutted.contains(QLatin1String("Nikon"))) { lensCutted.remove(QLatin1String("Nikon ")); lensCutted.remove(QLatin1String("Zoom-")); lensCutted.replace(QLatin1String("IF-ID"), QLatin1String("ED-IF")); lensList = findLenses(d->usedCamera, lensCutted); qCDebug(DIGIKAM_DIMG_LOG) << "* Check for Nikon lens (" << lensCutted << " : " << lensList.count() << ")"; lensMatches.append(lensList); } // TODO : Add here more specific lens maker rules. // LAST STAGE, Adapt exiv2 strings to lensfun strings. Some lens description use something like that : // "10.0 - 20.0 mm". This must be adapted like this : "10-20mm" lensCutted = d->lensDescription; lensCutted.replace(QRegExp(QLatin1String("\\.[0-9]")), QLatin1String("")); //krazy:exclude=doublequote_chars lensCutted.replace(QLatin1String(" - "), QLatin1String("-")); lensCutted.replace(QLatin1String(" mm"), QLatin1String("mn")); lensList = findLenses(d->usedCamera, lensCutted); qCDebug(DIGIKAM_DIMG_LOG) << "* Check for no maker lens (" << lensCutted << " : " << lensList.count() << ")"; lensMatches.append(lensList); // Remove all duplicate lenses in the list by using QSet. lensMatches = lensMatches.toSet().toList(); // Display the results. if (lensMatches.isEmpty()) { qCDebug(DIGIKAM_DIMG_LOG) << "lens matches : NOT FOUND"; exactMatch &= false; } else { // Best case for an exact match is to have only one item returned by Lensfun searches. if(lensMatches.count() == 1) { setUsedLens(lensMatches.first()); qCDebug(DIGIKAM_DIMG_LOG) << "Lens found : " << d->settings.lensModel; qCDebug(DIGIKAM_DIMG_LOG) << "Crop Factor : " << d->settings.cropFactor; } else { qCDebug(DIGIKAM_DIMG_LOG) << "lens matches : more than one..."; const lfLens* exact = 0; Q_FOREACH(const lfLens* const l, lensMatches) { if(QLatin1String(l->Model) == d->lensDescription) { qCDebug(DIGIKAM_DIMG_LOG) << "found exact match from" << lensMatches.count() << "possitibilites:" << l->Model; exact = l; } } if(exact) { setUsedLens(exact); } else { exactMatch &= false; } } } } else { qCDebug(DIGIKAM_DIMG_LOG) << "Lens description string is empty"; exactMatch &= false; } }
ObjectConstraintBallSocket::~ObjectConstraintBallSocket() { #if WANT_DEBUG qCDebug(physics) << "ObjectConstraintBallSocket::~ObjectConstraintBallSocket"; #endif }
bool QmlCommerce::installApp(const QString& itemHref, const bool& alsoOpenImmediately) { if (!QDir(_appsPath).exists()) { if (!QDir().mkdir(_appsPath)) { qCDebug(commerce) << "Couldn't make _appsPath directory."; return false; } } QUrl appHref(itemHref); auto request = DependencyManager::get<ResourceManager>()->createResourceRequest(this, appHref, true, -1, "QmlCommerce::installApp"); if (!request) { qCDebug(commerce) << "Couldn't create resource request for app."; return false; } connect(request, &ResourceRequest::finished, this, [=]() { if (request->getResult() != ResourceRequest::Success) { qCDebug(commerce) << "Failed to get .app.json file from remote."; return false; } // Copy the .app.json to the apps directory inside %AppData%/High Fidelity/Interface auto requestData = request->getData(); QFile appFile(_appsPath + "/" + appHref.fileName()); if (!appFile.open(QIODevice::WriteOnly)) { qCDebug(commerce) << "Couldn't open local .app.json file for creation."; return false; } if (appFile.write(requestData) == -1) { qCDebug(commerce) << "Couldn't write to local .app.json file."; return false; } // Close the file appFile.close(); // Read from the returned datastream to know what .js to add to Running Scripts QJsonDocument appFileJsonDocument = QJsonDocument::fromJson(requestData); QJsonObject appFileJsonObject = appFileJsonDocument.object(); QString scriptUrl = appFileJsonObject["scriptURL"].toString(); // Don't try to re-load (install) a script if it's already running QStringList runningScripts = DependencyManager::get<ScriptEngines>()->getRunningScripts(); if (!runningScripts.contains(scriptUrl)) { if ((DependencyManager::get<ScriptEngines>()->loadScript(scriptUrl.trimmed())).isNull()) { qCDebug(commerce) << "Couldn't load script."; return false; } QFileInfo appFileInfo(appFile); emit appInstalled(appFileInfo.baseName()); } if (alsoOpenImmediately) { QmlCommerce::openApp(itemHref); } return true; }); request->send(); return true; }
QVariant NormalDeclarationCompletionItem::data(const QModelIndex& index, int role, const KDevelop::CodeCompletionModel* model) const { DUChainReadLocker lock(DUChain::lock(), 500); if(!lock.locked()) { qCDebug(LANGUAGE) << "Failed to lock the du-chain in time"; return QVariant(); } if(!m_declaration) return QVariant(); switch (role) { case Qt::DisplayRole: if (index.column() == CodeCompletionModel::Name) { return declarationName(); } else if(index.column() == CodeCompletionModel::Postfix) { if (FunctionType::Ptr functionType = m_declaration->type<FunctionType>()) { // Retrieve const/volatile string return functionType->AbstractType::toString(); } } else if(index.column() == CodeCompletionModel::Prefix) { if(m_declaration->kind() == Declaration::Namespace) return QStringLiteral("namespace"); if (m_declaration->abstractType()) { if(EnumeratorType::Ptr enumerator = m_declaration->type<EnumeratorType>()) { if(m_declaration->context()->owner() && m_declaration->context()->owner()->abstractType()) { if(!m_declaration->context()->owner()->identifier().isEmpty()) return shortenedTypeString(DeclarationPointer(m_declaration->context()->owner()), desiredTypeLength); else return "enum"; } } if (FunctionType::Ptr functionType = m_declaration->type<FunctionType>()) { ClassFunctionDeclaration* funDecl = dynamic_cast<ClassFunctionDeclaration*>(m_declaration.data()); if (functionType->returnType()) { QString ret = shortenedTypeString(m_declaration, desiredTypeLength); if(shortenArgumentHintReturnValues && argumentHintDepth() && ret.length() > maximumArgumentHintReturnValueLength) return QStringLiteral("..."); else return ret; } else if(argumentHintDepth()) { return QString();//Don't show useless prefixes in the argument-hints } else if(funDecl && funDecl->isConstructor() ) return "<constructor>"; else if(funDecl && funDecl->isDestructor() ) return "<destructor>"; else return "<incomplete type>"; } else { return shortenedTypeString(m_declaration, desiredTypeLength); } } else { return "<incomplete type>"; } } else if (index.column() == CodeCompletionModel::Arguments) { if (m_declaration->isFunctionDeclaration()) { auto functionType = declaration()->type<FunctionType>(); return functionType ? functionType->partToString(FunctionType::SignatureArguments) : QVariant(); } } break; case CodeCompletionModel::BestMatchesCount: return QVariant(normalBestMatchesCount); break; case CodeCompletionModel::IsExpandable: return QVariant(createsExpandingWidget()); case CodeCompletionModel::ExpandingWidget: { QWidget* nav = createExpandingWidget(model); Q_ASSERT(nav); model->addNavigationWidget(this, nav); QVariant v; v.setValue<QWidget*>(nav); return v; } case CodeCompletionModel::ScopeIndex: return static_cast<int>(reinterpret_cast<quintptr>(m_declaration->context())); case CodeCompletionModel::CompletionRole: return (int)completionProperties(); case CodeCompletionModel::ItemSelected: { NavigationContextPointer ctx(new AbstractDeclarationNavigationContext(DeclarationPointer(m_declaration), TopDUContextPointer())); return ctx->html(true); } case Qt::DecorationRole: { if( index.column() == CodeCompletionModel::Icon ) { CodeCompletionModel::CompletionProperties p = completionProperties(); lock.unlock(); return DUChainUtils::iconForProperties(p); } break; } } return QVariant(); }
Battery::~Battery() { qCDebug(BATTERY) << "Removed battery" << m_device.udi(); }
bool Wallet::changePassphrase(const QString& newPassphrase) { qCDebug(commerce) << "changing passphrase"; return writeWallet(newPassphrase); }
bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) { assert(_body); // if we've never checked before, our _lastStep will be 0, and we need to initialize our state if (_lastStep == 0) { btTransform xform = _body->getWorldTransform(); _serverPosition = bulletToGLM(xform.getOrigin()); _serverRotation = bulletToGLM(xform.getRotation()); _serverVelocity = bulletToGLM(_body->getLinearVelocity()); _serverAngularVelocity = bulletToGLM(_body->getAngularVelocity()); _lastStep = simulationStep; _sentActive = false; return false; } #ifdef WANT_DEBUG glm::vec3 wasPosition = _serverPosition; glm::quat wasRotation = _serverRotation; glm::vec3 wasAngularVelocity = _serverAngularVelocity; #endif int numSteps = simulationStep - _lastStep; float dt = (float)(numSteps) * PHYSICS_ENGINE_FIXED_SUBSTEP; const float INACTIVE_UPDATE_PERIOD = 0.5f; if (!_sentActive) { // we resend the inactive update every INACTIVE_UPDATE_PERIOD // until it is removed from the outgoing updates // (which happens when we don't own the simulation and it isn't touching our simulation) return (dt > INACTIVE_UPDATE_PERIOD); } bool isActive = _body->isActive(); if (!isActive) { // object has gone inactive but our last send was moving --> send non-moving update immediately return true; } _lastStep = simulationStep; if (glm::length2(_serverVelocity) > 0.0f) { _serverVelocity += _serverAcceleration * dt; _serverVelocity *= powf(1.0f - _body->getLinearDamping(), dt); _serverPosition += dt * _serverVelocity; } // Else we measure the error between current and extrapolated transform (according to expected behavior // of remote EntitySimulation) and return true if the error is significant. // NOTE: math is done in the simulation-frame, which is NOT necessarily the same as the world-frame // due to _worldOffset. // TODO: compensate for _worldOffset offset here // compute position error btTransform worldTrans = _body->getWorldTransform(); glm::vec3 position = bulletToGLM(worldTrans.getOrigin()); float dx2 = glm::distance2(position, _serverPosition); const float MAX_POSITION_ERROR_SQUARED = 0.001f; // 0.001 m^2 ~~> 0.03 m if (dx2 > MAX_POSITION_ERROR_SQUARED) { #ifdef WANT_DEBUG qCDebug(physics) << ".... (dx2 > MAX_POSITION_ERROR_SQUARED) ...."; qCDebug(physics) << "wasPosition:" << wasPosition; qCDebug(physics) << "bullet position:" << position; qCDebug(physics) << "_serverPosition:" << _serverPosition; qCDebug(physics) << "dx2:" << dx2; #endif return true; } if (glm::length2(_serverAngularVelocity) > 0.0f) { // compute rotation error float attenuation = powf(1.0f - _body->getAngularDamping(), dt); _serverAngularVelocity *= attenuation; // Bullet caps the effective rotation velocity inside its rotation integration step, therefore // we must integrate with the same algorithm and timestep in order achieve similar results. for (int i = 0; i < numSteps; ++i) { _serverRotation = glm::normalize(computeBulletRotationStep(_serverAngularVelocity, PHYSICS_ENGINE_FIXED_SUBSTEP) * _serverRotation); } } const float MIN_ROTATION_DOT = 0.99f; // 0.99 dot threshold coresponds to about 16 degrees of slop glm::quat actualRotation = bulletToGLM(worldTrans.getRotation()); #ifdef WANT_DEBUG if ((fabsf(glm::dot(actualRotation, _serverRotation)) < MIN_ROTATION_DOT)) { qCDebug(physics) << ".... ((fabsf(glm::dot(actualRotation, _serverRotation)) < MIN_ROTATION_DOT)) ...."; qCDebug(physics) << "wasAngularVelocity:" << wasAngularVelocity; qCDebug(physics) << "_serverAngularVelocity:" << _serverAngularVelocity; qCDebug(physics) << "length wasAngularVelocity:" << glm::length(wasAngularVelocity); qCDebug(physics) << "length _serverAngularVelocity:" << glm::length(_serverAngularVelocity); qCDebug(physics) << "wasRotation:" << wasRotation; qCDebug(physics) << "bullet actualRotation:" << actualRotation; qCDebug(physics) << "_serverRotation:" << _serverRotation; } #endif return (fabsf(glm::dot(actualRotation, _serverRotation)) < MIN_ROTATION_DOT); }