コード例 #1
0
ファイル: PictureContent.cpp プロジェクト: madjar/fotowall
bool PictureContent::fromXml(QDomElement & pe)
{
    AbstractContent::fromXml(pe);

    // load picture properties
    QString path = pe.firstChildElement("path").text();

    // build the afterload effects list
    m_afterLoadEffects.clear();
    QDomElement effectsE = pe.firstChildElement("effects");
    for (QDomElement effectE = effectsE.firstChildElement("effect"); effectE.isElement(); effectE = effectE.nextSiblingElement("effect")) {
        PictureEffect fx;
        fx.effect = (PictureEffect::Effect)effectE.attribute("type").toInt();
        fx.param = effectE.attribute("param").toDouble();
        if (fx.effect == PictureEffect::Opacity)
            setOpacity(fx.param);
        else if (fx.effect == PictureEffect::Crop) {
            QString rect = effectE.attribute("cropingRect");
            QStringList coordinates = rect.split(" ");
            if(coordinates.size() >= 3) {
                QRect cropingRect (coordinates.at(0).toInt(), coordinates.at(1).toInt(), coordinates.at(2).toInt(), coordinates.at(3).toInt());
                fx.cropingRect = cropingRect;
            }
        }
        m_afterLoadEffects.append(fx);
    }

    // load Network image
    if (path.startsWith("http", Qt::CaseInsensitive) || path.startsWith("ftp", Qt::CaseInsensitive))
        return loadFromNetwork(path, 0);

    // load Local image
    return loadPhoto(path);
}
コード例 #2
0
void GroupProfileGUI::refreshProfile()
{
    //retrieve information
    groupName = group->getProfile()->getFullName();
    groupDescription = group->getProfile()->getDescription();
    photoPath = group->getProfile()->getPicturePath();


    this->setWindowTitle(groupName + "'s Profile");
    ui->groupNameLabel->setText(groupName);
    ui->descriptionBrowser->setText(groupDescription);
    loadPhoto();
    refreshMembers();
}
コード例 #3
0
ファイル: tphoto.cpp プロジェクト: IlyaSukhanov/kipi-plugins
void TPhoto::loadCache()
{
    // load the thumbnail and size only once.
    delete m_thumbnail;

    QImage photo = loadPhoto();
    QImage image = photo.scaled(m_thumbnailSize, m_thumbnailSize, Qt::KeepAspectRatio);
    m_thumbnail  = new QPixmap(image.width(), image.height());
    QPainter painter(m_thumbnail);
    painter.drawImage(0, 0, image );
    painter.end();

    delete m_size;
    m_size = new QSize(photo.width(), photo.height());
}
コード例 #4
0
ファイル: VcardForm.cpp プロジェクト: m8r-ds1twq/bombusng-qd
void VcardForm::onHotSpot( LPCSTR url, LPCSTR param ) {
    std::string nurl=std::string(url);
    if (nurl=="load") {
        wchar_t filename[MAX_PATH];
        *filename=0;
        OPENFILENAME ofn;
        memset(&ofn, 0, sizeof(OPENFILENAME));
        ofn.lStructSize=sizeof(OPENFILENAME);
        ofn.hwndOwner=getHWnd();
        ofn.hInstance=g_hInst;
        ofn.lpstrFilter=FILEIMGMASK;
        ofn.nFilterIndex=0;
        ofn.lpstrFile=filename;
        ofn.nMaxFile=MAX_PATH;
        ofn.lpstrTitle=L"Select image file";
        ofn.Flags=OFN_FILEMUSTEXIST | OFN_EXPLORER;
        BOOL result=GetOpenFileNameEx(&ofn);
        if (!result) return;

        loadPhoto(filename);

        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="save") {
        savePhoto(NULL);
        return;
    }
    if (nurl=="clear") {
        //todo: clear photo
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) return;
        vcardTemp->removeChild("PHOTO");
        vcardArrivedNotify(vcard);
        return;
    }
    if (nurl=="reload") {
        //todo: re-request vcard
        return;
    }
    if (nurl=="publish") {
        //todo: publish vcard

        
        JabberDataBlockRef vcardTemp=vcard->findChildNamespace("vCard","vcard-temp");
        if (!vcardTemp) {
            vcardTemp=JabberDataBlockRef(new JabberDataBlock("vCard"));
            vcardTemp->setAttribute("xmlns","vcard-temp");
        }

        JabberDataBlock viq("iq");
        viq.setAttribute("to",vcard->getAttribute("from"));
        viq.setAttribute("type","set");
        viq.setAttribute("id","my-vcard-publish");
        viq.addChild(vcardTemp);

        StringMapRef m=HtmlView::splitHREFtext(param);
        for (StringMap::iterator i=m->begin(); i!=m->end(); i++) {
            std::string key=i->first;
            std::string value=i->second;
            std::string key2;
            int k2=key.find('#');
            if (k2>0) {
                key2=key.substr(k2+1, key.length()-k2-1);
                key=key.substr(0, k2);
            }

            JabberDataBlockRef child=vcardTemp->getChildByName(key.c_str());
            if (!child) child=vcardTemp->addChild(key.c_str(), NULL);
            if (k2>0) {
                JabberDataBlockRef child2=child->getChildByName(key2.c_str());
                if (!child2) child2=child->addChild(key2.c_str(), NULL);
                child=child2;
            }
            child->setText(value);
        }

        /*if (img) if (img->getHBmp()) {
            std::wstring imgFile=appRootPath+L"$tmpimg.jpg";
            loadPhoto(imgFile.c_str());
        }*/

        //StringRef result=viq->toXML();

        //todo: verify result
        rc.lock()->jabberStream->sendStanza(viq);
        
        vcardArrivedNotify(vcard);
        return;
    }

}
コード例 #5
0
void mediaLoad(Display *d)
{
/* the enum for the entity type values is in base.h
 * wall tiles and some types of door have no image,
 * but are displayed in terminal for debugging. */

  loadPhoto(d, (char*)"images/board.png" , BG_LOBBY);  /* use numbers for backgrounds.  these are unused ascii chars */
  loadPhoto(d, (char*)"images/room2.png" , BG_BIN);
  loadPhoto(d, (char*)"images/room1.png" , BG_ENC);
  loadPhoto(d, (char*)"images/gameOver.png", GOVER_SCREEN);
  loadPhoto(d, (char*)"images/Intro.png", INTRO_SCREEN);

  loadPhoto(d, (char*)"images/offlight.png", OFFLIGHT);
  loadPhoto(d, (char*)"images/onlight.png", ONLIGHT);
  loadPhoto(d, (char*)"images/offswitch.bmp", OFFSWITCH);
  loadPhoto(d, (char*)"images/onswitch.bmp", ONSWITCH);

  loadPhoto(d, (char*)"images/dooropen.bmp", DOOROPEN);
  loadPhoto(d, (char*)"images/doorclosed.bmp", DOORCLOSED);

  loadPhoto(d, (char*)"images/blue_un.png", HINTBUTTON);
  loadPhoto(d, (char*)"images/red_un.png", RESETBUTTON);
  loadPhoto(d, (char*)"images/blue_pr.png", HBUTTON_PR);
  loadPhoto(d, (char*)"images/red_pr.png", RBUTTON_PR);

  loadPhoto(d, (char*)"images/Red_Elf_Front.bmp", P_DOWN1);
  loadPhoto(d, (char*)"images/Red_Elf_Front2.bmp", P_DOWN2);
  loadPhoto(d, (char*)"images/Red_Elf_Front3.bmp", P_DOWN3);

  loadPhoto(d, (char*)"images/Red_Elf_Back.bmp", P_UP1);
  loadPhoto(d, (char*)"images/Red_Elf_Back2.bmp", P_UP2);
  loadPhoto(d, (char*)"images/Red_Elf_Back3.bmp", P_UP3);

  loadPhoto(d, (char*)"images/Red_Elf_Left.bmp", P_L1);
  loadPhoto(d, (char*)"images/Red_Elf_Left2.bmp", P_L2);
  loadPhoto(d, (char*)"images/Red_Elf_Left3.bmp", P_L3);

  loadPhoto(d, (char*)"images/Red_Elf_Right.bmp", P_R1);
  loadPhoto(d, (char*)"images/Red_Elf_Right2.bmp", P_R2);
  loadPhoto(d, (char*)"images/Red_Elf_Right3.bmp", P_R3);

  loadPhoto(d, (char*)"images/DArrow.bmp", DARROW);
  loadPhoto(d, (char*)"images/UArrow.bmp", UARROW);

  loadPhoto(d, (char*)"images/chars/a.bmp", 'a');
  loadPhoto(d, (char*)"images/chars/b.bmp", 'b');
  loadPhoto(d, (char*)"images/chars/c.bmp", 'c');
  loadPhoto(d, (char*)"images/chars/d.bmp", 'd');
  loadPhoto(d, (char*)"images/chars/e.bmp", 'e');
  loadPhoto(d, (char*)"images/chars/f.bmp", 'f');
  loadPhoto(d, (char*)"images/chars/g.bmp", 'g');
  loadPhoto(d, (char*)"images/chars/h.bmp", 'h');
  loadPhoto(d, (char*)"images/chars/i.bmp", 'i');
  loadPhoto(d, (char*)"images/chars/j.bmp", 'j');
  loadPhoto(d, (char*)"images/chars/k.bmp", 'k');
  loadPhoto(d, (char*)"images/chars/l.bmp", 'l');
  loadPhoto(d, (char*)"images/chars/m.bmp", 'm');
  loadPhoto(d, (char*)"images/chars/n.bmp", 'n');
  loadPhoto(d, (char*)"images/chars/o.bmp", 'o');
  loadPhoto(d, (char*)"images/chars/p.bmp", 'p');
  loadPhoto(d, (char*)"images/chars/q.bmp", 'q');
  loadPhoto(d, (char*)"images/chars/r.bmp", 'r');
  loadPhoto(d, (char*)"images/chars/s.bmp", 's');
  loadPhoto(d, (char*)"images/chars/t.bmp", 't');
  loadPhoto(d, (char*)"images/chars/v.bmp", 'v');
  loadPhoto(d, (char*)"images/chars/u.bmp", 'u');
  loadPhoto(d, (char*)"images/chars/w.bmp", 'w');
  loadPhoto(d, (char*)"images/chars/x.bmp", 'x');
  loadPhoto(d, (char*)"images/chars/y.bmp", 'y');
  loadPhoto(d, (char*)"images/chars/z.bmp", 'z');
}
コード例 #6
0
ファイル: PictureContent.cpp プロジェクト: sanyaade/fotowall
bool PictureContent::fromXml(QDomElement & contentElement, const QDir & baseDir)
{
    AbstractContent::fromXml(contentElement, baseDir);

    // build the afterload effects list
    m_afterLoadEffects.clear();
    QDomElement effectsE = contentElement.firstChildElement("effects");
    for (QDomElement effectE = effectsE.firstChildElement("effect"); effectE.isElement(); effectE = effectE.nextSiblingElement("effect")) {
        PictureEffect fx;
        fx.effect = (PictureEffect::Effect)effectE.attribute("type").toInt();
        fx.param = effectE.attribute("param").toDouble();
        if (fx.effect == PictureEffect::Crop) {
            QString rect = effectE.attribute("croppingRect");
            QStringList coordinates = rect.split(" ");
            if(coordinates.size() >= 3) {
                QRect croppingRect (coordinates.at(0).toInt(), coordinates.at(1).toInt(), coordinates.at(2).toInt(), coordinates.at(3).toInt());
                fx.rect = croppingRect;
            }
        }
        else if (fx.effect == PictureEffect::Opacity)
            setContentOpacity(fx.param);
        m_afterLoadEffects.append(fx);
    }

    // load picture properties
    QString path;

    // try relative file path
    const QString relPath = contentElement.firstChildElement("relativeFilePath").text();
    if (!relPath.isEmpty() && baseDir.exists(relPath))
        path = QDir::cleanPath(baseDir.filePath(relPath));

    // or use absolute path/url
    if (path.isEmpty())
        path = contentElement.firstChildElement("fileUrl").text();

    // RETROCOMP <= 0.8
    if (path.isEmpty())
        path = contentElement.firstChildElement("path").text();

    // load Network image
    if (path.startsWith("http", Qt::CaseInsensitive) || path.startsWith("ftp", Qt::CaseInsensitive))
        return loadFromNetwork(path, 0);

    // look for the file if can't find it anymore
    if (!QFile::exists(path)) {
        QString searchFileName = QFileInfo(path).fileName();
        if (!searchFileName.isEmpty()) {

            // find all replacements from the current basepath
            qWarning("PictureContent::fromXml: file '%s' not found, scanning for replacements", qPrintable(path));
            QDirIterator dIt(baseDir, QDirIterator::Subdirectories);
            QStringList replacements;
            while (dIt.hasNext()) {
                dIt.next();
                if (dIt.fileName() == searchFileName) {
                    QString replacement = dIt.fileInfo().absoluteFilePath();
                    replacements.append(replacement);
                    qWarning("PictureContent::fromXml:    found '%s'", qPrintable(replacement));
                }
            }

            // use the first replacement (### 1.0 display a selection dialog)
            if (!replacements.isEmpty()) {
                path = replacements.first();
                qWarning("PictureContent::fromXml:    using '%s'", qPrintable(path));
            } else
                qWarning("PictureContent::fromXml:    no replacements found");
        }
    }

    // load Local image
    return loadPhoto(path, false, false);
}