Giter Club home page Giter Club logo

Comments (2)

jerome-cui avatar jerome-cui commented on June 16, 2024

It is caused by the fixed dpr in ImageViewerV2, which the value is from the primary monitor. I fixed this issue with the following code updates:

diff --git a/qimgv/gui/viewers/imageviewerv2.cpp b/qimgv/gui/viewers/imageviewerv2.cpp
index 2bf906cd..571c5cfb 100644
--- a/qimgv/gui/viewers/imageviewerv2.cpp
+++ b/qimgv/gui/viewers/imageviewerv2.cpp
@@ -31,7 +31,7 @@ ImageViewerV2::ImageViewerV2(QWidget *parent) : QGraphicsView(parent),
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     setAcceptDrops(false);

-    dpr = this->devicePixelRatioF();
+    // dpr = this->devicePixelRatioF();
     hs = horizontalScrollBar();
     vs = verticalScrollBar();

@@ -235,7 +235,7 @@ bool ImageViewerV2::showAnimationFrame(int frame) {

 void ImageViewerV2::updatePixmap(std::unique_ptr<QPixmap> newPixmap) {
     pixmap = std::move(newPixmap);
-    pixmap->setDevicePixelRatio(dpr);
+    pixmap->setDevicePixelRatio(this->devicePixelRatioF());
     pixmapItem.setPixmap(*pixmap);
     pixmapItem.show();
     pixmapItem.update();
@@ -276,7 +276,7 @@ void ImageViewerV2::showImage(std::unique_ptr<QPixmap> _pixmap) {
     if(_pixmap) {
         pixmapItemScaled.hide();
         pixmap = std::move(_pixmap);
-        pixmap->setDevicePixelRatio(dpr);
+        pixmap->setDevicePixelRatio(this->devicePixelRatioF());
         pixmapItem.setPixmap(*pixmap);
         Qt::TransformationMode mode = Qt::SmoothTransformation;
         if(mScalingFilter == QI_FILTER_NEAREST)
@@ -323,11 +323,11 @@ void ImageViewerV2::closeImage() {
 }

 void ImageViewerV2::setScaledPixmap(std::unique_ptr<QPixmap> newFrame) {
-    if(!movie && newFrame->size() != scaledSizeR() * dpr)
+    if(!movie && newFrame->size() != scaledSizeR() * this->devicePixelRatioF())
         return;

     pixmapScaled = std::move(newFrame);
-    pixmapScaled->setDevicePixelRatio(dpr);
+    pixmapScaled->setDevicePixelRatio(this->devicePixelRatioF());
     pixmapItemScaled.setPixmap(*pixmapScaled);
     pixmapItem.hide();
     pixmapItemScaled.show();
@@ -433,7 +433,7 @@ void ImageViewerV2::requestScaling() {
     // request "real" scaling when graphicsscene scaling is insufficient
     // (it uses a single pass bilinear which is sharp but produces artifacts on low zoom levels)
     if(currentScale() < FAST_SCALE_THRESHOLD)
-        emit scalingRequested(scaledSizeR() * dpr, mScalingFilter);
+        emit scalingRequested(scaledSizeR() * this->devicePixelRatioF(), mScalingFilter);
 }

 bool ImageViewerV2::imageFits() const {
@@ -517,7 +517,7 @@ void ImageViewerV2::mouseMoveEvent(QMouseEvent *event) {
     } else if(event->buttons() & Qt::RightButton) {
         // ------------------- ZOOM ----------------------
         // filter out possible mouse jitter by ignoring low delta drags
-        if(mouseInteraction == MouseInteractionState::MOUSE_ZOOM || abs(mousePressPos.y() - event->pos().y()) > zoomThreshold / dpr) {
+        if(mouseInteraction == MouseInteractionState::MOUSE_ZOOM || abs(mousePressPos.y() - event->pos().y()) > zoomThreshold / this->devicePixelRatioF()) {
             if(cursor().shape() != Qt::SizeVerCursor) {
                 setCursor(Qt::SizeVerCursor);
             }
@@ -677,7 +677,7 @@ void ImageViewerV2::mouseMoveZoom(QMouseEvent *event) {
     float stepMultiplier = 0.003f; // this one feels ok
     int currentPos = event->pos().y();
     int moveDistance = mouseMoveStartPos.y() - currentPos;
-    float newScale = currentScale() * (1.0f + stepMultiplier * moveDistance * dpr);
+    float newScale = currentScale() * (1.0f + stepMultiplier * moveDistance * this->devicePixelRatioF());
     mouseMoveStartPos = event->pos();
     imageFitMode = FIT_FREE;

from qimgv.

drocheam avatar drocheam commented on June 16, 2024

If I remember correctly, different scales between monitors aren't supported by X11, so this only affects Wayland.

Until this is fixed qimgv can also be run with enforced usage of X11:

env QT_QPA_PLATFORM=xcb qimgv

Also see https://wiki.archlinux.org/title/Wayland#Qt.

Or just add the environment variable QT_QPA_PLATFORM=xcb to the .desktop entry.

from qimgv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.