Skip to content
Snippets Groups Projects
Select Git revision
  • c09766a08866278fcd960e7e8ae64d60b6f9751f
  • master default protected
  • release/202005
  • release/202001
  • release/201912
  • release/201911
  • release/releaseWindowsTestOne
  • release/releaseTest
  • release/releaseWindowsTest
  • release/windowsReleaseTest
  • release/201910
  • release/qt/201910
  • release/windows-test/201910
  • release/201908
  • release/201906
  • release/201905
  • release/201904
  • release/201903
  • release/201902
  • release/201901
  • release/201812
  • 1.0.0
  • 0.3.0
  • 0.2.1
  • 0.2.0
  • 0.1.0
26 results

configurationmanager.cpp

Blame
    • Stepan Salenikovich's avatar
      c09766a0
      dbus: add dbus error handler interface · c09766a0
      Stepan Salenikovich authored
      The default implementation of this interface throws an exception,
      as before, but the clients now have the option to implement an
      alternative way to handle dbus errors.
      
      Issue: #79654
      Change-Id: I9e929e97b84e78432151d285199ccf09d90e4c01
      c09766a0
      History
      dbus: add dbus error handler interface
      Stepan Salenikovich authored
      The default implementation of this interface throws an exception,
      as before, but the clients now have the option to implement an
      alternative way to handle dbus errors.
      
      Issue: #79654
      Change-Id: I9e929e97b84e78432151d285199ccf09d90e4c01
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    distantrenderer.cpp 3.17 KiB
    /*
     * Copyright (C) 2019-2020 by Savoir-faire Linux
     * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
     * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License as published by
     * the Free Software Foundation; either version 3 of the License, or
     * (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     */
    
    #include "distantrenderer.h"
    
    #include "lrcinstance.h"
    
    DistantRenderer::DistantRenderer(QQuickItem* parent)
        : QQuickPaintedItem(parent)
    {
        setAntialiasing(true);
        setFillColor(Qt::black);
        setRenderTarget(QQuickPaintedItem::FramebufferObject);
        setPerformanceHint(QQuickPaintedItem::FastFBOResizing);
    
        connect(LRCInstance::renderer(), &RenderManager::distantFrameUpdated, [this](const QString& id) {
            if (distantRenderId_ == id)
                update(QRect(0, 0, width(), height()));
        });
    }
    
    DistantRenderer::~DistantRenderer() {}
    
    void
    DistantRenderer::setRendererId(const QString& id)
    {
        distantRenderId_ = id;
    }
    
    int
    DistantRenderer::getXOffset() const
    {
        return xOffset_;
    }
    
    int
    DistantRenderer::getYOffset() const
    {
        return yOffset_;
    }
    
    double
    DistantRenderer::getScaledWidth() const
    {
        return scaledWidth_;
    }
    
    double
    DistantRenderer::getScaledHeight() const
    {
        return scaledHeight_;
    }
    
    void
    DistantRenderer::paint(QPainter* painter)
    {
        LRCInstance::renderer()->drawFrame(distantRenderId_, [this, painter](QImage* distantImage) {
            if (distantImage) {
                auto scaledDistant = distantImage->scaled(size().toSize(), Qt::KeepAspectRatio);
                auto tempScaledWidth = static_cast<int>(scaledWidth_ * 1000);
                auto tempScaledHeight = static_cast<int>(scaledHeight_ * 1000);
                auto tempXOffset = xOffset_;
                auto tempYOffset = yOffset_;
                scaledWidth_ = static_cast<double>(scaledDistant.width())
                               / static_cast<double>(distantImage->width());
                scaledHeight_ = static_cast<double>(scaledDistant.height())
                                / static_cast<double>(distantImage->height());
                xOffset_ = (width() - scaledDistant.width()) / 2;
                yOffset_ = (height() - scaledDistant.height()) / 2;
                if (tempXOffset != xOffset_ or tempYOffset != yOffset_
                    or static_cast<int>(scaledWidth_ * 1000) != tempScaledWidth
                    or static_cast<int>(scaledHeight_ * 1000) != tempScaledHeight) {
                    emit offsetChanged();
                }
                painter->drawImage(QRect(xOffset_,
                                         yOffset_,
                                         scaledDistant.width(),
                                         scaledDistant.height()),
                                   scaledDistant);
            }
        });
    }