void TelegramImageElement::initImage()
{
    if(p->image)
        return;

    QQmlEngine *engine = qmlEngine(this);
    QQmlContext *context = qmlContext(this);
    if(!engine || !context)
        return;

    QQmlComponent component(engine);

    QString qmlImageCreationCode = p->qmlImageCreationCode;
    if(qmlImageCreationCode.isEmpty())
        qmlImageCreationCode = QString("import QtQuick %1\n"
                                       "Image { anchors.fill: parent; }").arg(p->qtQuickVersion);

    component.setData(qmlImageCreationCode.toUtf8(), QUrl());
    QQuickItem *item = qobject_cast<QQuickItem *>(component.create(context));
    if(!item)
        return;

    item->setParent(this);
    item->setParentItem(this);

    QHashIterator<QString, QVariant> i(p->properties);
    while(i.hasNext())
    {
        i.next();
        item->setProperty(i.key().toUtf8(), i.value());
    }

    connect(item, SIGNAL(asynchronousChanged()), this, SIGNAL(asynchronousChanged()));

    #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
        connect(item, SIGNAL(autoTransformChanged()), this, SIGNAL(autoTransformChanged()));
    #endif

    connect(item, SIGNAL(cacheChanged()), this, SIGNAL(cacheChanged()));
    connect(item, SIGNAL(fillModeChanged()), this, SIGNAL(fillModeChanged()));
    connect(item, SIGNAL(mirrorChanged()), this, SIGNAL(mirrorChanged()));
    connect(item, SIGNAL(sourceSizeChanged()), this, SIGNAL(sourceSizeChanged()));

    p->image = item;
}
void ImageBase::setMirror(bool mirror) {
    if (mirror != this->mirror()) {
        Q_D(ImageBase);
        d->mirror = mirror;
        emit mirrorChanged();

        if (d->complete) {
            this->update();
        }
    }
}
void QQuickImageBase::setMirror(bool mirror)
{
    Q_D(QQuickImageBase);
    if (mirror == d->mirror)
        return;

    d->mirror = mirror;

    if (isComponentComplete())
        update();

    emit mirrorChanged();
}
PluginDialog::PluginDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PluginDialog)
{
    ui->setupUi(this);
    pluginManager = new PluginManager();
    busyOverlay = new BusyOverlay();
    QHBoxLayout *layout = new QHBoxLayout(ui->tree_plugins);
    layout->setAlignment(Qt::AlignCenter);
    layout->addWidget(busyOverlay);
    //connect(pluginManager, SIGNAL(pluginInstalled(QString)), this, SLOT(pluginInstalled(QString)));
    connect(this, SIGNAL(mirrorChanged(QString)), this, SLOT(setMirror(QString)));
    connect(&netManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(replyFinished(QNetworkReply*)));
    setMirror("https://raw.github.com/olav-st/screencloud-plugin-list/master/plugin-list.xml");
}
void BioXASMirrorBendView::setMirror(BioXASMirror *newMirror)
{
	if (mirror_ != newMirror) {

		if (mirror_) {
			bendEditor_->setControl(0);
			upstreamEditor_->setControl(0);
			downstreamEditor_->setControl(0);
		}

		mirror_ = newMirror;

		if (mirror_) {
			bendEditor_->setControl(mirror_->bendControl());
			upstreamEditor_->setControl(mirror_->benderUpstreamMotorControl());
			downstreamEditor_->setControl(mirror_->benderDownstreamMotorControl());
		}

		emit mirrorChanged(mirror_);
	}
}
void BioXASM1MirrorView::setMirror(BioXASM1Mirror *newMirror)
{
	if (mirror_ != newMirror) {

		if (mirror_) {
			mirrorEditor_->setMirror(0);
			upperSlitEditor_->setControl(0);
			bendView_->setMirror(0);
		}

		mirror_ = newMirror;

		if (mirror_) {
			mirrorEditor_->setMirror(mirror_);
			upperSlitEditor_->setControl(mirror_->upperSlitBladeMotorControl());
			bendView_->setMirror(mirror_);
		}

		emit mirrorChanged(mirror_);
	}
}
void BioXASMirrorView::setMirror(BioXASMirror *newMirror)
{
	if (mirror_ != newMirror) {

		if (mirror_)
			disconnect( mirror_, 0, this, 0 );

		mirror_ = newMirror;

		if (mirror_) {
			connect( mirror_, SIGNAL(pitchChanged(BioXASMirrorPitchControl*)), this, SLOT(updatePitchEditor()) );
			connect( mirror_, SIGNAL(rollChanged(BioXASMirrorRollControl*)), this, SLOT(updateRollEditor()) );
			connect( mirror_, SIGNAL(yawChanged(BioXASMirrorYawControl*)), this, SLOT(updateYawEditor()) );
			connect( mirror_, SIGNAL(heightChanged(BioXASMirrorHeightControl*)), this, SLOT(updateHeightEditor()) );
			connect( mirror_, SIGNAL(lateralChanged(BioXASMirrorLateralControl*)), this, SLOT(updateLateralEditor()) );
		}

		refresh();

		emit mirrorChanged(mirror_);
	}
}