Skip to content

Commit

Permalink
Merge pull request #5737 from elpaso/hidpi-cursors
Browse files Browse the repository at this point in the history
[bugfix][hidpi] Scalable SVG theme cursors
  • Loading branch information
elpaso committed Dec 1, 2017
2 parents f6e63d7 + 656de62 commit 62ff88a
Show file tree
Hide file tree
Showing 37 changed files with 217 additions and 330 deletions.
7 changes: 7 additions & 0 deletions images/images.qrc
Expand Up @@ -606,6 +606,13 @@
<file>themes/default/mActionResizeSquare.svg</file>
<file>themes/default/mSourceFields.svg</file>
<file>flags/zh_Hant.svg</file>
<file>themes/default/cursors/mCapturePoint.svg</file>
<file>themes/default/cursors/mCrossHair.svg</file>
<file>themes/default/cursors/mSampler.svg</file>
<file>themes/default/cursors/mSelect.svg</file>
<file>themes/default/cursors/mZoomIn.svg</file>
<file>themes/default/cursors/mZoomOut.svg</file>
<file>themes/default/cursors/mIdentify.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
1 change: 1 addition & 0 deletions images/themes/default/cursors/mCapturePoint.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mCrossHair.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mIdentify.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mSampler.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mSelect.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mZoomIn.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions images/themes/default/cursors/mZoomOut.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions python/core/qgsapplication.sip
Expand Up @@ -345,6 +345,26 @@ Returns the path to the default theme directory.
:rtype: QIcon
%End

enum Cursor
{
ZoomIn,
ZoomOut,
Identify,
CrossHair,
CapturePoint,
Select,
Sampler,
};

static QCursor getThemeCursor( const Cursor &cursor );
%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

static QPixmap getThemePixmap( const QString &name );
%Docstring
Helper to get a theme icon as a pixmap. It will fall back to the
Expand Down
1 change: 0 additions & 1 deletion src/app/composer/qgscomposer.cpp
Expand Up @@ -57,7 +57,6 @@
#include "qgsproject.h"
#include "qgsmapcanvas.h"
#include "qgsmessageviewer.h"
#include "qgscursors.h"
#include "qgsmaplayeractionregistry.h"
#include "qgsgeometry.h"
#include "qgspaperitem.h"
Expand Down
1 change: 0 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -161,7 +161,6 @@ Q_GUI_EXPORT extern int qt_defaultDpiX();
#include "qgscoordinatetransform.h"
#include "qgscoordinateutils.h"
#include "qgscredentialdialog.h"
#include "qgscursors.h"
#include "qgscustomdrophandler.h"
#include "qgscustomization.h"
#include "qgscustomlayerorderwidget.h"
Expand Down
8 changes: 1 addition & 7 deletions src/app/qgsmaptoolidentifyaction.cpp
Expand Up @@ -16,7 +16,6 @@
#include "qgsapplication.h"
#include "qgisapp.h"
#include "qgsattributetabledialog.h"
#include "qgscursors.h"
#include "qgsdistancearea.h"
#include "qgsfeature.h"
#include "qgsfeaturestore.h"
Expand Down Expand Up @@ -50,14 +49,9 @@ QgsMapToolIdentifyAction::QgsMapToolIdentifyAction( QgsMapCanvas *canvas )
: QgsMapToolIdentify( canvas )
{
mToolName = tr( "Identify" );
// set cursor
QPixmap myIdentifyQPixmap = QPixmap( ( const char ** ) identify_cursor );
mCursor = QCursor( myIdentifyQPixmap, 1, 1 );

setCursor( QgsApplication::getThemeCursor( QgsApplication::Cursor::Identify ) );
connect( this, &QgsMapToolIdentify::changedRasterResults, this, &QgsMapToolIdentifyAction::handleChangedRasterResults );

mIdentifyMenu->setAllowMultipleReturn( true );

QgsMapLayerAction *attrTableAction = new QgsMapLayerAction( tr( "Show attribute table" ), mIdentifyMenu, QgsMapLayer::VectorLayer, QgsMapLayerAction::MultipleFeatures );
connect( attrTableAction, &QgsMapLayerAction::triggeredForFeatures, this, &QgsMapToolIdentifyAction::showAttributeTable );
identifyMenu()->addCustomAction( attrTableAction );
Expand Down
4 changes: 1 addition & 3 deletions src/app/qgsmaptoolselectrectangle.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgsmapcanvas.h"
#include "qgsmaptopixel.h"
#include "qgsvectorlayer.h"
#include "qgscursors.h"
#include "qgsgeometry.h"
#include "qgspointxy.h"
#include "qgis.h"
Expand All @@ -34,8 +33,7 @@ QgsMapToolSelectFeatures::QgsMapToolSelectFeatures( QgsMapCanvas *canvas )
, mDragging( false )
{
mToolName = tr( "Select features" );
QPixmap mySelectQPixmap = QPixmap( ( const char ** ) select_cursor );
mCursor = QCursor( mySelectQPixmap, 1, 1 );
setCursor( QgsApplication::getThemeCursor( QgsApplication::Cursor::Select ) );
mRubberBand = nullptr;
mFillColor = QColor( 254, 178, 76, 63 );
mStrokeColor = QColor( 254, 58, 29, 100 );
Expand Down
4 changes: 1 addition & 3 deletions src/app/qgsmeasuretool.cpp
Expand Up @@ -24,7 +24,6 @@
#include "qgsexception.h"
#include "qgsmeasuredialog.h"
#include "qgsmeasuretool.h"
#include "qgscursors.h"
#include "qgsmessagelog.h"
#include "qgssettings.h"

Expand All @@ -40,8 +39,7 @@ QgsMeasureTool::QgsMeasureTool( QgsMapCanvas *canvas, bool measureArea )
mRubberBand = new QgsRubberBand( canvas, mMeasureArea ? QgsWkbTypes::PolygonGeometry : QgsWkbTypes::LineGeometry );
mRubberBandPoints = new QgsRubberBand( canvas, QgsWkbTypes::PointGeometry );

QPixmap myCrossHairQPixmap = QPixmap( ( const char ** ) cross_hair_cursor );
mCursor = QCursor( myCrossHairQPixmap, 8, 8 );
setCursor( QgsApplication::getThemeCursor( QgsApplication::Cursor::CrossHair ) );

mDone = true;
// Append point we will move
Expand Down

0 comments on commit 62ff88a

Please sign in to comment.