-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iconloader scaling enhancemets #275
base: master
Are you sure you want to change the base?
Conversation
Use map to not traverse and evaluate the existing entries each time when info/icon is needed.
@tsujan Can you, please, have a look into this commits? |
I assure you that the problem isn't in Anyway, this patch causes a crash with a scale factor:
|
BTW, what you see (with your eyes) partly depends on the widget style too (→ second paragraph of lxqt/libfm-qt#788 (comment)); don't trust your eyes too much ;) |
Did you rebuild the |
Oh, you're right; I forgot that. But, still, I think it's important to stick with how Qt does it, in order to guarantee that our code is as standard as possible. |
If we don't fix spotted bugs/problems, then there is no point for us to have our own implementation. |
Yes, but I'm not sure to which bug you refer. lxqt/libfm-qt#792 isn't a bug in |
There are 3 commits here:
Don't you think, it is worth addressing? EDIT: forget the "iconloader: Handle non-integer scaling more precise" commit, I was reading the logic wrong and I've substituted it with more suitable one |
I'll need some time to read them. Just one thing caught my eyes by a glance: const qreal scale = qApp->devicePixelRatio();// Don't know which window to target As far as I remember, we didn't have that elsewhere and I didn't find it in Qt's icon loader either. The problem is that a window of an app can be inside another screen with scaling. Therefore, My general point is that such details could easily get out of hand after a while if we don't stick with Qt's way of doing things as far as possible. Moreover, if our code gets too much different from that of Qt, we'll have trouble in importing Qt's fixes (like #225). |
I believe all these commits can be ported to Qt straight away. But this probably won't be backported to Qt v5.15 (I don't know if Qt would accept this binary incompatible change). |
It is used in Qt for similar purposes also:
|
It's the last resort and only where really needed. The pixel ratio of window, pixmap or paint device has priority over it. Just one possible scenario among who knows how many? I have an app with a |
..and avoid unneded size multiplication/division.
These APIs don't provide the scaling information, we will guess it by using the application's one (QIcon does it similarly in such cases).
...and we can say the same for the former "HDPI windows" -> without the change the windows on all HDPI screens may get wrong pixmaps (because we assume the scale == 1). |
2e9bff0
to
5821616
Compare
No. It's correctly handled by In old times, we relied on qApp's pixel ratio. Now things are different: qApp's pixel ratio shouldn't take priority and, especially, it shouldn't be considered prematurely. One of our (or my) users warned me about this (don't remember where). My first reaction was like yours but then I saw its logic; made changes here (following Qt) as well as in Kvantum.
Following Qt is the safest way. |
Then this exact answer is for you initial issue. We're not using/guessing the scale in PixmapEntry/ScalableEntry... but in the XdgIconLoaderEngine. Here I don't consider the usage pre-mature. |
Qt6 has gone further and has removed the scaling from |
It dropped the whole |
I've kept scaling of |
There are still the QPixmap QIcon::pixmap(const QSize &size, qreal devicePixelRatio, Mode mode, State state) const
{
if (!d)
return QPixmap();
// Use the global devicePixelRatio if the caller does not know the target dpr
if (devicePixelRatio == -1)
devicePixelRatio = qApp->devicePixelRatio();
// Handle the simple normal-dpi case
if (!(devicePixelRatio > 1.0)) {
QPixmap pixmap = d->engine->pixmap(size, mode, state);
pixmap.setDevicePixelRatio(1.0);
return pixmap;
}
// Try get a pixmap that is big enough to be displayed at device pixel resolution.
QPixmap pixmap = d->engine->scaledPixmap(size * devicePixelRatio, mode, state, devicePixelRatio);
pixmap.setDevicePixelRatio(d->pixmapDevicePixelRatio(devicePixelRatio, size, pixmap.size()));
return pixmap;
} But reading the code of Qt (5.15 & 6.dev) and how the But the |
In Qt5, because of the way In Qt6, |
While debugging the lxqt/libfm-qt#788 I dived "deeply" into some aspects of the iconloader logic and here are probable enhancements.