Пример #1
0
void CBDS::loadViewers()
{
    QFile f(QApplication::applicationDirPath() + "/Viewers.json");
    if (f.exists())
    {
        if (f.open(QIODevice::ReadOnly | QIODevice::Text))
        {
            QJsonParseError pe;
            QVariantList json = QJsonDocument::fromJson(f.readAll(), &pe).toVariant().toList();
            f.close();
            if (pe.error == QJsonParseError::NoError)
                parseViewerData(json);
            else
                emit error("Failed to parse Viewers.json: " + pe.errorString());
        }
        else
            emit error("Can't open file: " + f.fileName());
    }

    if (!m_viewers.rowCount(QModelIndex()))
    {
        Viewer* l = addViewer("llua", 0, 0, 0, 1, 'c');
        l->setRoomOwner(true);
        setRoomOwner("llua");
    }
}
Пример #2
0
void ViewerController::onAppEvent(const ds::Event& in_e){
	if(in_e.mWhat == RequestMediaOpenEvent::WHAT()){
		const RequestMediaOpenEvent& e((const RequestMediaOpenEvent&)in_e);
		addViewer(e.mMedia, e.mLocation, e.mStartWidth);
	} else if(in_e.mWhat == RequestCloseAllEvent::WHAT()){
		const float deltaAnim = mGlobals.getAnimDur() / (float)mViewers.size();
		float delayey = 0.0f;
		for(auto it = mViewers.begin(); it < mViewers.end(); ++it){
			animateViewerOff((*it), delayey);
			delayey += deltaAnim;
		}
	} else if(in_e.mWhat == RequestLayoutEvent::WHAT()){
		layoutViewers();
	}
}