void TupNetSocket::readed(const QString &readed) { #ifdef K_DEBUG QString msg = "TupNetSocket::readed() - PACKAGE ARRIVING: "; #ifdef Q_OS_WIN32 qWarning() << msg; qWarning() << readed; #else tWarning() << msg; tWarning("net") << readed; #endif #endif QDomDocument doc; if (doc.setContent(readed)) { QString root = doc.documentElement().tagName(); m_handler->handlePackage(root, readed); } else { #ifdef K_DEBUG QString msg = "TupNetSocket::readed() - Error: Package isn't a DOM document"; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } }
bool TupXmlParserBase::error(const QXmlParseException & exception) { #ifdef K_DEBUG #ifdef Q_OS_WIN32 QString msg1 = exception.lineNumber() + QString("x") + exception.columnNumber() + QString(": ") + exception.message(); qDebug() << msg1; #else tWarning() << exception.lineNumber() << "x" << exception.columnNumber() << ": " << exception.message(); tWarning() << __PRETTY_FUNCTION__ << " Document: " << k->document; #endif #else Q_UNUSED(exception); #endif return true; }
TConfig::TConfig() : QObject(), k(new Private) { #ifdef K_DEBUG TINIT; #endif #ifdef Q_WS_X11 k->configDirectory.setPath(QDir::homePath() + "/." + QCoreApplication::applicationName()); #elif defined(Q_WS_WIN) k->configDirectory.setPath(QDir::homePath() + "/" + QCoreApplication::applicationName()); #elif defined(Q_WS_MAC) k->configDirectory.setPath(QDir::homePath() + "/." + QCoreApplication::applicationName()); #endif if (!k->configDirectory.exists()) { k->firstTime = true; #ifdef K_DEBUG tWarning() << "*** TConfig::TConfig() - Config file doesn't exist. Creating path: " << k->configDirectory.path(); #endif if (!k->configDirectory.mkdir(k->configDirectory.path())) { #ifdef K_DEBUG tError() << "TConfig::TConfig() - Fatal Error: Can't create path -> " << k->configDirectory.path(); #endif } } else { k->firstTime = false; } k->path = k->configDirectory.path() + "/" + QCoreApplication::applicationName().toLower() + ".cfg"; init(); }
void TupGraphicLibraryItem::setObject(TupLibraryObject *object) { if (!object) { #ifdef K_DEBUG tWarning("library") << "Setting null library object"; #endif return; } #ifdef K_DEBUG T_FUNCINFOX("library") << object->symbolName(); #endif k->symbolName = object->symbolName(); switch(object->type()) { case TupLibraryObject::Item: case TupLibraryObject::Text: case TupLibraryObject::Image: { setItem(qvariant_cast<QGraphicsItem *>(object->data())); } break; case TupLibraryObject::Svg: { setSvgContent(object->dataPath()); } break; default: break; } }
bool TupCommandExecutor::renameLayer(TupLayerResponse *response) { int scenePos = response->sceneIndex(); int position = response->layerIndex(); QString newName = response->arg().toString(); #ifdef K_DEBUG tWarning() << "Renamed layer: " << newName; #endif QString oldName; TupScene *scene = m_project->scene(scenePos); if (!scene) return false; TupLayer *layer = scene->layer(position); if (layer) { QString current = layer->layerName(); layer->setLayerName(newName); emit responsed(response); response->setArg(current); return true; } return false; }
bool TupCommandExecutor::removeLipSync(TupLayerResponse *response) { #ifdef K_DEBUG QString msg = "TupCommandExecutor::removeLipSync() - Adding lipsync..."; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif int scenePos = response->sceneIndex(); QString name = response->arg().toString(); TupScene *scene = m_project->scene(scenePos); if (!scene) return false; if (scene->removeLipSync(name)) { emit responsed(response); return true; } return false; }
bool TupCommandExecutor::addLipSync(TupLayerResponse *response) { #ifdef K_DEBUG QString msg = "TupCommandExecutor::addLipSync() - Adding lipsync..."; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif int scenePos = response->sceneIndex(); int position = response->layerIndex(); QString xml = response->arg().toString(); TupScene *scene = m_project->scene(scenePos); if (!scene) return false; TupLayer *layer = scene->layer(position); if (layer) { TupLipSync *lipsync = new TupLipSync(); lipsync->fromXml(xml); layer->addLipSync(lipsync); emit responsed(response); return true; } return false; }
bool TupCommandExecutor::updateLipSync(TupLayerResponse *response) { #ifdef K_DEBUG QString msg = "TupCommandExecutor::updateLipSync() - Updating lipsync..."; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif int scenePos = response->sceneIndex(); QString xml = response->arg().toString(); TupScene *scene = m_project->scene(scenePos); if (!scene) return false; TupLipSync *lipsync = new TupLipSync(); lipsync->fromXml(xml); if (scene->updateLipSync(lipsync)) { emit responsed(response); return true; } return false; }
bool TupXmlParserBase::parse(QFile *file) { if (!file->isOpen()) { if (! file->open(QIODevice::ReadOnly | QIODevice::Text)) { tWarning() << "Cannot open file " << file->fileName(); return false; } } return parse(QString::fromLocal8Bit(file->readAll())); }
bool TupProject::createSymbol(int type, const QString &name, const QByteArray &data, const QString &folder) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[TupProject::createSymbol()]"; #else T_FUNCINFOX("symbol"); #endif #endif if (!k->isOpen) { #ifdef K_DEBUG QString msg = "TupProject::createSymbol() - Fatal error: project is NOT open!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return false; } if (k->library->createSymbol(TupLibraryObject::Type(type), name, data, folder) == 0) { #ifdef K_DEBUG QString msg = "TupProject::createSymbol() - Fatal error: object can't be created. Data is NULL!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return false; } #ifdef K_DEBUG QString msg = "TupProject::createSymbol() - Object added successfully -> " + name; #ifdef Q_OS_WIN qWarning() << msg; #else tWarning() << msg; #endif #endif return true; }
TupProjectRequest TupRequestBuilder::fromResponse(TupProjectResponse *response) { TupProjectRequest request; switch (response->part()) { case TupProjectRequest::Item: { request = TupRequestBuilder::createItemRequest(static_cast<TupItemResponse*> (response)->sceneIndex(), static_cast<TupItemResponse*> (response)->layerIndex(), static_cast<TupItemResponse*> (response)->frameIndex(), static_cast<TupItemResponse*> (response)->itemIndex(), static_cast<TupItemResponse*> (response)->position(), TupProject::Mode(static_cast<TupItemResponse*> (response)->spaceMode()), TupLibraryObject::Type(static_cast<TupItemResponse*> (response)->itemType()), response->action(), response->arg().toString(), response->data()); } break; case TupProjectRequest::Frame: { request = TupRequestBuilder::createFrameRequest(static_cast<TupFrameResponse*> (response)->sceneIndex(), static_cast<TupFrameResponse*> (response)->layerIndex(), static_cast<TupFrameResponse*> (response)->frameIndex(), response->action(), response->arg().toString(), response->data()); } break; case TupProjectRequest::Layer: { request = TupRequestBuilder::createLayerRequest(static_cast<TupLayerResponse*> (response)->sceneIndex(), static_cast<TupLayerResponse*> (response)->layerIndex(), response->action(), response->arg().toString(), response->data()); } break; case TupProjectRequest::Scene: { request = TupRequestBuilder::createSceneRequest(static_cast<TupSceneResponse*> (response)->sceneIndex(), response->action(), response->arg().toString(), response->data()); } break; case TupProjectRequest::Library: { request = TupRequestBuilder::createLibraryRequest(response->action(), response->arg().toString(), TupLibraryObject::Type(static_cast<TupLibraryResponse*>(response)->symbolType()), TupProject::Mode(static_cast<TupLibraryResponse*>(response)->spaceMode()), response->data(), static_cast<TupLibraryResponse*>(response)->parent(), static_cast<TupLibraryResponse*>(response)->sceneIndex(), static_cast<TupLibraryResponse*>(response)->layerIndex(), static_cast<TupLibraryResponse*>(response)->frameIndex()); } break; default: { #ifdef K_DEBUG tWarning() << "wOw! Unknown response! O_o"; #endif } } return request; }
void TupScreen::playBack() { #ifdef K_DEBUG tWarning("camera") << "TupScreen::playBack() - Starting procedure..."; #endif if (k->timer->isActive()) stop(); k->currentFramePosition = k->photograms.count() - 1; if (!k->playBackTimer->isActive()) { if (!k->renderControl.at(k->currentSceneIndex)) render(); k->playBackTimer->start(1000 / k->fps); } }
void TupScreen::stop() { #ifdef K_DEBUG tWarning("camera") << "TupScreen::stop() - Stopping player!"; #endif if (k->timer->isActive()) k->timer->stop(); if (k->playBackTimer->isActive()) k->playBackTimer->stop(); foreach (TupSoundLayer *sound, k->sounds) sound->stop(); k->currentFramePosition = 0; repaint(); }
bool TupXmlParserBase::parse(QFile *file) { if (!file->isOpen()) { if (! file->open(QIODevice::ReadOnly | QIODevice::Text)) { #ifdef K_DEBUG QString msg = "TupXmlParserBase::parse() - Cannot open file " + file->fileName(); #ifdef Q_OS_WIN32 qDebug() << msg; #else tWarning() << msg; #endif #endif return false; } } return parse(QString::fromLocal8Bit(file->readAll())); }
bool TupCommandExecutor::lockScene(TupSceneResponse *response) { int position = response->sceneIndex(); bool lock = response->arg().toBool(); #ifdef K_DEBUG tWarning() << "Lock scene: " << lock; #endif TupScene *scene = m_project->scene(position); if (!scene) return false; scene->setLocked(lock); emit responsed(response); return true; }
TConfig::TConfig() : QObject(), k(new Private) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[TConfig()]"; #else TINIT; #endif #endif QString base = QDir::homePath() + "/"; k->configDirectory.setPath(base + "." + QCoreApplication::applicationName()); if (!k->configDirectory.exists()) { k->firstTime = true; #ifdef K_DEBUG QString msg = "TConfig::TConfig() - Config file doesn't exist. Creating path: " + k->configDirectory.path(); #ifdef Q_OS_WIN qWarning() << msg; #else tWarning() << msg; #endif #endif if (!k->configDirectory.mkdir(k->configDirectory.path())) { #ifdef K_DEBUG QString msg = "TConfig::TConfig() - Fatal Error: Can't create path -> " + k->configDirectory.path(); #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif } } else { k->firstTime = false; } k->path = k->configDirectory.path() + "/" + QCoreApplication::applicationName().toLower() + ".cfg"; init(); }
void TupScreen::play() { #ifdef K_DEBUG tWarning("camera") << "TupScreen::play() - Playing at " << k->fps << " FPS"; #endif if (k->playBackTimer->isActive()) stop(); k->currentFramePosition = 0; if (!k->timer->isActive()) { if (!k->renderControl.at(k->currentSceneIndex)) { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); render(); QApplication::restoreOverrideCursor(); } if (k->renderControl.at(k->currentSceneIndex)) k->timer->start(1000 / k->fps); } }
bool TupCommandExecutor::moveLayer(TupLayerResponse *response) { int scenePos = response->sceneIndex(); int position = response->layerIndex(); int newPosition = response->arg().toInt(); TupScene *scene = m_project->scene(scenePos); if (!scene) return false; if (! scene->moveLayer(position, newPosition)) { #ifdef K_DEBUG tWarning() << "Failed moving layer"; #endif return false; } else { emit responsed(response); return true; } return false; }
bool TupFileManager::save(const QString &fileName, TupProject *project) { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Saving file -> " + fileName; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif /* int indexPath = fileName.lastIndexOf(QDir::separator()); int indexFile = fileName.length() - indexPath; QString name = fileName.right(indexFile - 1); int indexDot = name.lastIndexOf("."); name = name.left(indexDot); */ QFileInfo info(fileName); QString name = info.baseName(); QString oldDirName = CACHE_DIR + project->projectName(); QDir projectDir(oldDirName); if (name.compare(project->projectName()) != 0) { project->setProjectName(name); projectDir.setPath(CACHE_DIR + name); project->library()->updatePaths(CACHE_DIR + name); if (!projectDir.exists()) { if (projectDir.rename(oldDirName, projectDir.path())) { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Directory renamed to -> " + projectDir.path(); #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } else { // SQA: Check if these lines are really needed if (! projectDir.mkdir(projectDir.path())) { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Can't create path -> " + projectDir.path(); #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif return false; } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Directory was created successfully -> " + projectDir.path(); #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } } } } else { if (!projectDir.exists()) { if (! projectDir.mkdir(projectDir.path())) { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Can't create path -> " + projectDir.path(); #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif return false; } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Directory was created successfully -> " + projectDir.path(); #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } } } { // Save project QFile projectFile(projectDir.path() + QDir::separator() + "project.tpp"); if (projectFile.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream ts(&projectFile); QDomDocument doc; project->setProjectName(name); doc.appendChild(project->toXml(doc)); ts << doc.toString(); projectFile.close(); } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Can't create file -> " + projectDir.path() + QDir::separator() + "project.tpp"; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } } // Save scenes { int index = 0; int totalScenes = project->scenes().size(); for (int i = 0; i < totalScenes; i++) { TupScene *scene = project->scenes().at(i); QDomDocument doc; doc.appendChild(scene->toXml(doc)); QString scenePath = projectDir.path() + QDir::separator() + "scene" + QString::number(index) + ".tps"; QFile sceneFile(scenePath); if (sceneFile.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream st(&sceneFile); st << doc.toString(); index += 1; sceneFile.close(); } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Can't create file -> " + scenePath; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } } } { // Save library QFile lbr(projectDir.path() + QDir::separator() + "library.tpl"); if (lbr.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream ts(&lbr); QDomDocument doc; doc.appendChild(project->library()->toXml(doc)); ts << doc.toString(); lbr.close(); } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Can't create file -> " + projectDir.path() + QDir::separator() + "library.tpl"; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } } TupPackageHandler packageHandler; bool ok = packageHandler.makePackage(projectDir.path(), fileName); if (ok) { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Project saved in -> " + fileName; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } else { #ifdef K_DEBUG QString msg = "TupFileManager::save() - Error: Project couldn't be saved in -> " + fileName; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif } return ok; }
TupLibraryObject *TupLibraryFolder::createSymbol(TupLibraryObject::Type type, const QString &name, const QByteArray &data, const QString &folder, bool loaded) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[TupLibraryFolder::createSymbol()]"; #else T_FUNCINFO; tWarning() << " - Creating symbol -> " << name; tWarning() << " - type -> " << type; tWarning() << " - folder -> " << folder; tWarning() << " - size -> " << data.size(); #endif #endif if (data.isNull()) { #ifdef K_DEBUG QString msg = "TupLibraryFolder::createSymbol() - [ Fatal Error ] - Data is null!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return 0; } if (data.isEmpty()) { #ifdef K_DEBUG QString msg = "TupLibraryFolder::createSymbol() - [ Fatal Error ] - Data is empty!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return 0; } TupLibraryObject *object = new TupLibraryObject(name, folder, type, this); // object->setSymbolName(name); // object->setParent(this); // object->setType(type); if (!object->loadRawData(data)) { #ifdef K_DEBUG QString msg = "TupLibraryFolder::createSymbol() - [ Fatal Error ] - Object have no data raw!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif delete object; return 0; } bool ret; if (folder.length() == 0) ret = addObject(object); else ret = addObject(folder, object); bool success = object->saveData(k->project->dataDir()); if (success) { if (loaded && ret) TupProjectLoader::createSymbol(type, name, id(), data, k->project); return object; } #ifdef K_DEBUG QString msg = "TupLibraryFolder::createSymbol() - [ Fatal Error ] - Object couldn't be saved!"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif return 0; }
void TupItemTweener::fromXml(const QString &xml) { #ifdef K_DEBUG QString msg = "TupItemTweener::fromXml() - Tween content: "; #ifdef Q_OS_WIN qWarning() << msg; qWarning() << xml; #else tWarning() << msg; tWarning() << xml; #endif #endif QDomDocument doc; if (doc.setContent(xml)) { QDomElement root = doc.documentElement(); k->name = root.attribute("name"); k->type = TupItemTweener::Type(root.attribute("type").toInt()); k->initFrame = root.attribute("initFrame").toInt(); k->initLayer = root.attribute("initLayer").toInt(); k->initScene = root.attribute("initScene").toInt(); k->frames = root.attribute("frames").toInt(); QString origin = root.attribute("origin"); // [x,y] QStringList list = origin.split(","); double x = list.first().toDouble(); double y = list.last().toDouble(); k->originPoint = QPointF(x, y); if (k->type == TupItemTweener::Composed) { QDomElement settings = root.firstChildElement("settings"); QDomNode node = settings.firstChild(); while (!node.isNull()) { QDomElement e = node.toElement(); if (!e.isNull()) { if (e.tagName() == "position") { // tError() << "TupItemTweener::fromXml() - Processing position settings"; k->tweenList.append(TupItemTweener::Position); k->compPositionInitFrame = e.attribute("init").toInt(); k->compPositionFrames = e.attribute("frames").toInt(); k->path = e.attribute("coords"); k->intervals = e.attribute("intervals"); } if (e.tagName() == "rotation") { // tError() << "TupItemTweener::fromXml() - Processing rotation settings"; k->tweenList.append(TupItemTweener::Rotation); k->compRotationInitFrame = e.attribute("init").toInt(); k->compRotationFrames = e.attribute("frames").toInt(); k->rotationType = TupItemTweener::RotationType(root.attribute("rotationType").toInt()); k->rotateSpeed = root.attribute("rotateSpeed").toInt(); k->rotateDirection = TupItemTweener::RotateDirection(root.attribute("rotateDirection").toInt()); if (k->rotationType == TupItemTweener::Partial) { k->rotateLoop = root.attribute("rotateLoop").toInt(); k->rotateStartDegree = root.attribute("rotateStartDegree").toInt(); k->rotateEndDegree = root.attribute("rotateEndDegree").toInt(); k->rotateReverseLoop = root.attribute("rotateReverseLoop").toInt(); } } if (e.tagName() == "scale") { // tError() << "TupItemTweener::fromXml() - Processing scale settings"; k->tweenList.append(TupItemTweener::Scale); k->compScaleInitFrame = e.attribute("init").toInt(); k->compScaleFrames = e.attribute("frames").toInt(); } if (e.tagName() == "shear") { // tError() << "TupItemTweener::fromXml() - Processing shear settings"; k->tweenList.append(TupItemTweener::Shear); k->compShearInitFrame = e.attribute("init").toInt(); k->compShearFrames = e.attribute("frames").toInt(); } if (e.tagName() == "opacity") { // tError() << "TupItemTweener::fromXml() - Processing opacity settings"; k->tweenList.append(TupItemTweener::Opacity); k->compOpacityInitFrame = e.attribute("init").toInt(); k->compOpacityFrames = e.attribute("frames").toInt(); } if (e.tagName() == "coloring") { // tError() << "TupItemTweener::fromXml() - Processing coloring settings"; k->tweenList.append(TupItemTweener::Coloring); k->colorFillType = FillType(e.attribute("fillType").toInt()); k->compColoringInitFrame = e.attribute("init").toInt(); k->compColoringFrames = e.attribute("frames").toInt(); } } node = node.nextSibling(); } } else { if (k->type == TupItemTweener::Position) { k->path = root.attribute("coords"); k->intervals = root.attribute("intervals"); } if (k->type == TupItemTweener::Rotation) { k->rotationType = TupItemTweener::RotationType(root.attribute("rotationType").toInt()); k->rotateSpeed = root.attribute("rotateSpeed").toInt(); k->rotateDirection = TupItemTweener::RotateDirection(root.attribute("rotateDirection").toInt()); if (k->rotationType == TupItemTweener::Partial) { k->rotateLoop = root.attribute("rotateLoop").toInt(); k->rotateStartDegree = root.attribute("rotateStartDegree").toInt(); k->rotateEndDegree = root.attribute("rotateEndDegree").toInt(); k->rotateReverseLoop = root.attribute("rotateReverseLoop").toInt(); } } if (k->type == TupItemTweener::Scale) { k->scaleAxes = TupItemTweener::TransformAxes(root.attribute("scaleAxes").toInt()); k->scaleFactor = root.attribute("scaleFactor").toDouble(); k->scaleIterations = root.attribute("scaleIterations").toInt(); k->scaleLoop = root.attribute("scaleLoop").toInt(); k->scaleReverseLoop = root.attribute("scaleReverseLoop").toInt(); } if (k->type == TupItemTweener::Shear) { k->shearAxes = TupItemTweener::TransformAxes(root.attribute("shearAxes").toInt()); k->shearFactor = root.attribute("shearFactor").toDouble(); k->shearIterations = root.attribute("shearIterations").toInt(); k->shearLoop = root.attribute("shearLoop").toInt(); k->shearReverseLoop = root.attribute("shearReverseLoop").toInt(); } if (k->type == TupItemTweener::Opacity) { k->initOpacityFactor = root.attribute("initOpacityFactor").toDouble(); k->endOpacityFactor = root.attribute("endOpacityFactor").toDouble(); k->opacityIterations = root.attribute("opacityIterations").toInt(); k->opacityLoop = root.attribute("opacityLoop").toInt(); k->opacityReverseLoop = root.attribute("opacityReverseLoop").toInt(); } if (k->type == TupItemTweener::Coloring) { k->colorFillType = FillType(root.attribute("fillType").toInt()); QString colorText = root.attribute("initialColor"); QStringList list = colorText.split(","); int red = list.at(0).toInt(); int green = list.at(1).toInt(); int blue = list.at(2).toInt(); k->initialColor = QColor(red, green, blue); colorText = root.attribute("endingColor"); list = colorText.split(","); red = list.at(0).toInt(); green = list.at(1).toInt(); blue = list.at(2).toInt(); k->endingColor = QColor(red, green, blue); k->colorIterations = root.attribute("colorIterations").toInt(); k->colorLoop = root.attribute("colorLoop").toInt(); k->colorReverseLoop = root.attribute("colorReverseLoop").toInt(); } } QDomNode node = root.firstChildElement("step"); while (!node.isNull()) { QDomElement e = node.toElement(); if (!e.isNull()) { if (e.tagName() == "step") { QString stepDoc; { QTextStream ts(&stepDoc); ts << node; } TupTweenerStep *step = new TupTweenerStep(0); step->fromXml(stepDoc); addStep(*step); delete step; } } node = node.nextSibling(); } } }
QDomElement TupItemTweener::toXml(QDomDocument &doc) const { #ifdef K_DEBUG QString msg1 = "TupItemTweener::toXml() - Saving tween: " + k->name; QString msg2 = "TupItemTweener::toXml() - Type: " + QString::number(k->type); #ifdef Q_OS_WIN qWarning() << msg1; qWarning() << msg2; #else tWarning() << msg1; tWarning() << msg2; #endif #endif QDomElement root = doc.createElement("tweening"); root.setAttribute("name", k->name); root.setAttribute("type", k->type); root.setAttribute("initFrame", QString::number(k->initFrame)); root.setAttribute("initLayer", QString::number(k->initLayer)); root.setAttribute("initScene", QString::number(k->initScene)); root.setAttribute("frames", QString::number(k->frames)); root.setAttribute("origin", QString::number(k->originPoint.x()) + "," + QString::number(k->originPoint.y())); if (k->type == TupItemTweener::Composed) { QDomElement settings = doc.createElement("settings"); for (int i=0; i < k->tweenList.size(); i++) { if (k->tweenList.at(i) == TupItemTweener::Position) { QDomElement position = doc.createElement("position"); position.setAttribute("init", QString::number(k->compPositionInitFrame)); position.setAttribute("frames", QString::number(k->compPositionFrames)); position.setAttribute("coords", k->path); position.setAttribute("intervals", k->intervals); settings.appendChild(position); } } root.appendChild(settings); } else { if (k->type == TupItemTweener::Position) { root.setAttribute("coords", k->path); root.setAttribute("intervals", k->intervals); } if (k->type == TupItemTweener::Rotation) { root.setAttribute("rotationType", k->rotationType); root.setAttribute("rotateSpeed", QString::number(k->rotateSpeed)); root.setAttribute("rotateDirection", k->rotateDirection); if (k->rotationType == TupItemTweener::Partial) { root.setAttribute("rotateLoop", QString::number(k->rotateLoop)); root.setAttribute("rotateStartDegree", QString::number(k->rotateStartDegree)); root.setAttribute("rotateEndDegree", QString::number(k->rotateEndDegree)); root.setAttribute("rotateReverseLoop", QString::number(k->rotateReverseLoop)); } } if (k->type == TupItemTweener::Scale) { root.setAttribute("scaleAxes", QString::number(k->scaleAxes)); root.setAttribute("scaleFactor", QString::number(k->scaleFactor)); root.setAttribute("scaleIterations", QString::number(k->scaleIterations)); root.setAttribute("scaleLoop", QString::number(k->scaleLoop)); root.setAttribute("scaleReverseLoop", QString::number(k->scaleReverseLoop)); } if (k->type == TupItemTweener::Shear) { root.setAttribute("shearAxes", QString::number(k->shearAxes)); root.setAttribute("shearFactor", QString::number(k->shearFactor)); root.setAttribute("shearIterations", QString::number(k->shearIterations)); root.setAttribute("shearLoop", QString::number(k->shearLoop)); root.setAttribute("shearReverseLoop", QString::number(k->shearReverseLoop)); } if (k->type == TupItemTweener::Opacity) { root.setAttribute("initOpacityFactor", QString::number(k->initOpacityFactor)); root.setAttribute("endOpacityFactor", QString::number(k->endOpacityFactor)); root.setAttribute("opacityIterations", QString::number(k->opacityIterations)); root.setAttribute("opacityLoop", QString::number(k->opacityLoop)); root.setAttribute("opacityReverseLoop", QString::number(k->opacityReverseLoop)); } if (k->type == TupItemTweener::Coloring) { root.setAttribute("fillType", k->colorFillType); QString colorText = QString::number(k->initialColor.red()) + "," + QString::number(k->initialColor.green()) + "," + QString::number(k->initialColor.blue()); root.setAttribute("initialColor", colorText); colorText = QString::number(k->endingColor.red()) + "," + QString::number(k->endingColor.green()) + "," + QString::number(k->endingColor.blue()); root.setAttribute("endingColor", colorText); root.setAttribute("colorIterations", QString::number(k->colorIterations)); root.setAttribute("colorLoop", QString::number(k->colorLoop)); root.setAttribute("colorReverseLoop", QString::number(k->colorReverseLoop)); } } foreach (TupTweenerStep *step, k->steps.values()) root.appendChild(step->toXml(doc)); return root; }
void NodesTool::release(const TupInputDeviceInformation *input, TupBrushManager *brushManager, TupGraphicsScene *scene) { #ifdef K_DEBUG #ifdef Q_OS_WIN qDebug() << "[NodesTool::release()]"; #else T_FUNCINFOX("tools"); #endif #endif Q_UNUSED(brushManager); QList<QGraphicsItem *> currentSelection = scene->selectedItems(); if (!currentSelection.isEmpty()) { QGraphicsItem *selectedItem = currentSelection.at(0); TupFrame *frame = currentFrame(); int itemIndex = frame->indexOf(selectedItem); if (qgraphicsitem_cast<TupSvgItem *>(selectedItem)) { TOsd::self()->display(tr("Error"), tr("SVG objects cannot be edited!"), TOsd::Error); return; } if (TupGraphicLibraryItem *libraryItem = qgraphicsitem_cast<TupGraphicLibraryItem *>(selectedItem)) { if (libraryItem->itemType() == TupLibraryObject::Image) { TOsd::self()->display(tr("Error"), tr("Images have no nodes!"), TOsd::Error); return; } } if (qgraphicsitem_cast<TupItemGroup *>(selectedItem)) { if (k->activeSelection) k->nodeGroup->clear(); QPointF coord = input->pos(); if (itemIndex >= 0) { TupProjectRequest event = TupRequestBuilder::createItemRequest( scene->currentSceneIndex(), k->currentLayer, k->currentFrame, itemIndex, coord, scene->spaceContext(), TupLibraryObject::Item, TupProjectRequest::Ungroup); emit requested(&event); } return; } if (!qgraphicsitem_cast<TControlNode*>(selectedItem)) { if (!qgraphicsitem_cast<TupPathItem *>(selectedItem)) { TOsd::self()->display(tr("Error"), tr("Only pencil/ink lines can be edited!"), TOsd::Error); return; } } if (itemIndex == -1) { if (qgraphicsitem_cast<TControlNode*>(selectedItem)) { QGraphicsItem *item = k->nodeGroup->parentItem(); int position = frame->indexOf(item); if (position >= 0) { // if (qgraphicsitem_cast<QGraphicsPathItem *>(item)) { QString path = qgraphicsitem_cast<TupPathItem *>(item)->pathToString(); TupProjectRequest event = TupRequestBuilder::createItemRequest(scene->currentSceneIndex(), k->currentLayer, k->currentFrame, position, QPointF(), scene->spaceContext(), TupLibraryObject::Item, TupProjectRequest::EditNodes, path); emit requested(&event); k->nodeGroup->clearChangedNodes(); // } } else { #ifdef K_DEBUG QString msg = "NodesTool::release() - Fatal Error: Invalid position [ " + QString::number(position) + " ]"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif } } else { #ifdef K_DEBUG QString msg = "NodesTool::release() - Invalid selected item index: " + QString::number(itemIndex); #ifdef Q_OS_WIN qDebug() << msg; #else tWarning() << msg; #endif #endif } return; } // Avoiding to select the same item twice if (k->activeSelection) { TupFrame *frame = currentFrame(); int oldIndex = frame->indexOf(k->nodeGroup->parentItem()); if (oldIndex != itemIndex) { k->nodeGroup->clear(); k->nodeGroup = new TNodeGroup(selectedItem, scene, TNodeGroup::LineSelection, k->baseZValue); k->nodeGroup->show(); k->nodeGroup->resizeNodes(k->realFactor); if (TupPathItem *path = qgraphicsitem_cast<TupPathItem *>(selectedItem)) { if (path->isNotEdited()) path->saveOriginalPath(); } } else { if (k->nodeGroup->hasChangedNodes()) { QGraphicsItem *item = k->nodeGroup->parentItem(); int position = frame->indexOf(item); if (position >= 0) { QString path = qgraphicsitem_cast<TupPathItem *>(item)->pathToString(); TupProjectRequest event = TupRequestBuilder::createItemRequest(scene->currentSceneIndex(), k->currentLayer, k->currentFrame, position, QPointF(), scene->spaceContext(), TupLibraryObject::Item, TupProjectRequest::EditNodes, path); emit requested(&event); k->nodeGroup->clearChangedNodes(); } else { #ifdef K_DEBUG QString msg = "NodesTool::release() - Fatal Error: Invalid position [ " + QString::number(position) + " ]"; #ifdef Q_OS_WIN qDebug() << msg; #else tError() << msg; #endif #endif } } else { #ifdef K_DEBUG QString msg = "NodesTool::release() - Node group has NO changes!"; #ifdef Q_OS_WIN qDebug() << msg; #else tWarning() << msg; #endif #endif } } } else { k->nodeGroup = new TNodeGroup(selectedItem, scene, TNodeGroup::LineSelection, k->baseZValue); k->nodeGroup->show(); k->activeSelection = true; k->nodeGroup->resizeNodes(k->realFactor); if (TupPathItem *path = qgraphicsitem_cast<TupPathItem *>(selectedItem)) { if (path->isNotEdited()) path->saveOriginalPath(); } } } else { if (k->activeSelection) { #ifdef K_DEBUG QString msg = "NodesTool::release() - Empty selection! Removing nodes..."; #ifdef Q_OS_WIN qDebug() << msg; #else tWarning() << msg; #endif #endif k->nodeGroup->clear(); k->nodeGroup = 0; k->activeSelection = false; } } }
bool TupXmlParserBase::fatalError(const QXmlParseException & exception) { tFatal() << exception.lineNumber() << "x" << exception.columnNumber() << ": " << exception.message(); tWarning() << __PRETTY_FUNCTION__ << " Document: " << k->document; return true; }
void TupConfigurationArea::shrink() { #ifdef K_DEBUG #ifdef Q_OS_WIN32 qDebug() << "[TupConfigurationArea::shrink()]"; #else T_FUNCINFO; #endif #endif QMainWindow *mainWindow = dynamic_cast<QMainWindow *>(parentWidget()); if (!mainWindow || !widget()) { #ifdef K_DEBUG QString msg = "TupConfigurationArea::shrink() - Fatal error!"; #ifdef Q_OS_WIN32 qDebug() << msg; #else tError() << msg; #endif #endif return; } bool hmt = mainWindow->hasMouseTracking(); int pm = style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent); mainWindow->setMouseTracking(true); int wOffset = 0; int hOffset= 0; Qt::DockWidgetArea position = mainWindow->dockWidgetArea(this); if (position == Qt::BottomDockWidgetArea) { wOffset = 20; hOffset = -(y() * 2 + pm - 1); // SQA: FIXME FIXME FIXME } else if (position == Qt::LeftDockWidgetArea) { wOffset = width()+(pm/2)+1; hOffset = height() / 2; } else if (position == Qt::RightDockWidgetArea) { wOffset = -(pm/2)+1; hOffset = height() / 2; } QMouseEvent press(QEvent::MouseButtonPress, mapToParent( QPoint(this->x(), this->y()))/2 + QPoint(wOffset, hOffset), Qt::LeftButton, 0, 0); if (! QApplication::sendEvent(mainWindow, &press)) qWarning("Fail pressing"); qApp->processEvents(); int df = 0; int x1 = 0; int x2 = 0; int y1 = 0; int y2 = 0; int xRelease = 0; int yRelease = 0; if (position == Qt::BottomDockWidgetArea) { df = widget()->height(); x1 = press.pos().x(); y1 = press.pos().y() + df; x2 = press.globalPos().x(); y2 = press.globalPos().y() + df; xRelease = this->x(); yRelease = 10; } else if (position == Qt::LeftDockWidgetArea) { df = widget()->width(); x1 = press.pos().x() - df; y1 = press.pos().y(); x2 = press.globalPos().x() - df; y2 = press.globalPos().y(); xRelease = 10; yRelease = this->y(); } else if (position == Qt::RightDockWidgetArea) { df = widget()->width(); x1 = press.pos().x() + df; y1 = press.pos().y(); x2 = press.globalPos().x() + df; y2 = press.globalPos().y(); xRelease = mainWindow->width(); yRelease = this->y(); } QMouseEvent move(QEvent::MouseMove, QPoint(x1, y1), QPoint(x2, y2), Qt::LeftButton, 0, 0); if (! QApplication::sendEvent(mainWindow, &move)) { #ifdef K_DEBUG QString msg = "TupConfigurationArea::shrink() - Error while moving!"; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } qApp->processEvents(); QMouseEvent release(QEvent::MouseButtonRelease, QPoint(xRelease, yRelease), Qt::LeftButton, 0, 0); if (! QApplication::sendEvent(mainWindow, &release)) { #ifdef K_DEBUG QString msg = "TupConfigurationArea::shrink() - Error while releasing!"; #ifdef Q_OS_WIN32 qWarning() << msg; #else tWarning() << msg; #endif #endif } qApp->processEvents(); mainWindow->setMouseTracking(hmt); }