mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-12 00:06:43 -04:00
[hidpi] Auto-scale cursors based on DPIs
This should work well on different DPI screens. Still needs some testing on the various platforms.
This commit is contained in:
parent
7ae8e16427
commit
346ab6099c
@ -27,25 +27,27 @@
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1071"
|
||||
inkscape:window-height="548"
|
||||
inkscape:window-width="2880"
|
||||
inkscape:window-height="1678"
|
||||
id="namedview11"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.36"
|
||||
inkscape:cx="49.576271"
|
||||
inkscape:cy="50"
|
||||
inkscape:window-x="1188"
|
||||
inkscape:window-y="1073"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:cx="49.152542"
|
||||
inkscape:cy="83.898305"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="Layer_1" /><g
|
||||
id="g3"><g
|
||||
id="g3"
|
||||
transform="matrix(1.1318275,0,0,1.1177011,-6.1676779,-5.6731926)"><g
|
||||
id="g5"><path
|
||||
d="m91.645 8.355c-4.474-4.474-11.727-4.474-16.2 0l-13.5 13.501-3.727-3.727c-1.959-1.959-5.134-1.959-7.093 0s-1.959 5.134 0 7.093l3.727 3.727-41.51 41.508c-2.039 2.039-3.149 4.656-3.329 7.324-0.073 1.087-0.347 3.105-0.675 5.292-0.053 0.359-0.212 0.706-0.487 0.983l-3.105 3.106c-0.994 0.994-0.994 2.606 0 3.6l3.493 3.493c0.994 0.994 2.606 0.994 3.6 0l3.106-3.105c0.277-0.275 0.622-0.433 0.981-0.486 2.187-0.329 4.205-0.602 5.293-0.675 2.668-0.18 5.285-1.29 7.325-3.33l41.508-41.508 3.727 3.727c1.959 1.959 5.134 1.959 7.093 0s1.959-5.134 0-7.093l-12.365-12.366 9.697 7.577 12.44-12.441c4.475-4.473 4.474-11.726 0.001-16.2zm-26.594 34.394l-20.53 20.53c-0.994 0.994-2.606 0.994-3.6 0l-3.27-3.27c-0.994-0.993-2.605-0.993-3.599 0.001l-0.616 0.616-0.002-0.002-14.728 14.727c-0.337 0.337-0.819 0.401-1.076 0.143s-0.194-0.74 0.143-1.076l23.841-23.841 0.004 0.004 15.633-15.633c0.994-0.994 2.606-0.994 3.6 0l4.2 4.201c0.994 0.994 0.994 2.606 0 3.6z"
|
||||
id="path7" /></g></g><metadata
|
||||
d="m 91.645,8.355 c -4.474,-4.474 -11.727,-4.474 -16.2,0 l -13.5,13.501 -3.727,-3.727 c -1.959,-1.959 -5.134,-1.959 -7.093,0 -1.959,1.959 -1.959,5.134 0,7.093 l 3.727,3.727 -41.51,41.508 c -2.039,2.039 -3.149,4.656 -3.329,7.324 -0.073,1.087 -0.347,3.105 -0.675,5.292 -0.053,0.359 -0.212,0.706 -0.487,0.983 l -3.105,3.106 c -0.994,0.994 -0.994,2.606 0,3.6 l 3.493,3.493 c 0.994,0.994 2.606,0.994 3.6,0 l 3.106,-3.105 c 0.277,-0.275 0.622,-0.433 0.981,-0.486 2.187,-0.329 4.205,-0.602 5.293,-0.675 2.668,-0.18 5.285,-1.29 7.325,-3.33 l 41.508,-41.508 3.727,3.727 c 1.959,1.959 5.134,1.959 7.093,0 1.959,-1.959 1.959,-5.134 0,-7.093 l -12.365,-12.366 9.697,7.577 12.44,-12.441 c 4.475,-4.473 4.474,-11.726 10e-4,-16.2 z m -26.594,34.394 -20.53,20.53 c -0.994,0.994 -2.606,0.994 -3.6,0 l -3.27,-3.27 c -0.994,-0.993 -2.605,-0.993 -3.599,10e-4 l -0.616,0.616 -0.002,-0.002 -14.728,14.727 c -0.337,0.337 -0.819,0.401 -1.076,0.143 -0.257,-0.258 -0.194,-0.74 0.143,-1.076 l 23.841,-23.841 0.004,0.004 15.633,-15.633 c 0.994,-0.994 2.606,-0.994 3.6,0 l 4.2,4.201 c 0.994,0.994 0.994,2.606 0,3.6 z"
|
||||
id="path7"
|
||||
inkscape:connector-curvature="0" /></g></g><metadata
|
||||
id="metadata9"><rdf:RDF><cc:Work><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><cc:license
|
||||
rdf:resource="http://creativecommons.org/licenses/publicdomain/" /><dc:publisher><cc:Agent
|
||||
rdf:about="http://openclipart.org/"><dc:title>Openclipart</dc:title></cc:Agent></dc:publisher><dc:title></dc:title></cc:Work><cc:License
|
||||
rdf:about="http://openclipart.org/"><dc:title>Openclipart</dc:title></cc:Agent></dc:publisher><dc:title /></cc:Work><cc:License
|
||||
rdf:about="http://creativecommons.org/licenses/publicdomain/"><cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Reproduction" /><cc:permits
|
||||
rdf:resource="http://creativecommons.org/ns#Distribution" /><cc:permits
|
||||
|
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.3 KiB |
@ -360,6 +360,8 @@ Returns the path to the default theme directory.
|
||||
%Docstring
|
||||
Helper to get a theme cursor. It will fall back to the
|
||||
default theme if the active theme does not have the required icon.
|
||||
Cursors are automatically scaled to look like a 16px cursor on 96dpi
|
||||
screens.
|
||||
:rtype: QCursor
|
||||
%End
|
||||
|
||||
|
@ -487,10 +487,7 @@ QCursor QgsApplication::getThemeCursor( const Cursor &cursor )
|
||||
if ( app && app->mCursorCache.contains( cursor ) )
|
||||
return app->mCursorCache.value( cursor );
|
||||
|
||||
// Cursor are supposed to be 32x32 as it seems to be the
|
||||
// most cross-platform size
|
||||
// If we want to make this size user-configurable or make
|
||||
// a better guess: we might use fontMetrics
|
||||
// All calculations are done on 32x32 icons
|
||||
// Defaults to center, individual cursors may override
|
||||
int activeX = 16;
|
||||
int activeY = 16;
|
||||
@ -520,7 +517,7 @@ QCursor QgsApplication::getThemeCursor( const Cursor &cursor )
|
||||
break;
|
||||
case Sampler:
|
||||
activeX = 0;
|
||||
activeY = 0;
|
||||
activeY = 32;
|
||||
name = QStringLiteral( "mSampler.svg" );
|
||||
break;
|
||||
// No default
|
||||
@ -533,7 +530,9 @@ QCursor QgsApplication::getThemeCursor( const Cursor &cursor )
|
||||
// Check if an icon exists for this cursor (the O.S. default cursor will be used if it does not)
|
||||
if ( ! icon.isNull( ) )
|
||||
{
|
||||
_cursor = QCursor( icon.pixmap( 32, 32 ), activeX, activeY );
|
||||
// Apply scaling
|
||||
float scale( ( float ) app->fontMetrics().height() / 32 );
|
||||
_cursor = QCursor( icon.pixmap( std::ceil( scale * 32 ), std::ceil( scale * 32 ) ), std::ceil( scale * activeX ), std::ceil( scale * activeY ) );
|
||||
}
|
||||
if ( app )
|
||||
app->mCursorCache.insert( cursor, _cursor );
|
||||
|
@ -329,6 +329,8 @@ class CORE_EXPORT QgsApplication : public QApplication
|
||||
/**
|
||||
* Helper to get a theme cursor. It will fall back to the
|
||||
* default theme if the active theme does not have the required icon.
|
||||
* Cursors are automatically scaled to look like a 16px cursor on 96dpi
|
||||
* screens.
|
||||
*/
|
||||
static QCursor getThemeCursor( const Cursor &cursor );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user