Skip to content
Permalink
Browse files
Moved settingsRespectScreenDPI to new settings registry gui
  • Loading branch information
domi4484 committed Jul 12, 2021
1 parent ded3d0d commit 18bd5833bb58e047eef2720d4dbc9c776c2a4bde
@@ -46,6 +46,11 @@ The ``searchChildRegistries`` parameter specifies if child registries should be
void addSubRegistry( const QgsSettingsRegistry *settingsRegistry );
%Docstring
Append a child ``settingsRegistry`` to the register.
%End

void removeSubRegistry( const QgsSettingsRegistry *settingsRegistry );
%Docstring
Remove a child ``settingsRegistry`` from the register.
%End

QList<const QgsSettingsRegistry *> subRegistries() const;
@@ -38,6 +38,13 @@ Returns a pointer to the singleton instance.
%End


static QgsSettingsRegistryGui *settingsRegistryGui() /KeepReference/;
%Docstring
Returns the gui's settings registry, used for managing gui settings.

.. versionadded:: 3.22
%End

static QgsEditorWidgetRegistry *editorWidgetRegistry() /KeepReference/;
%Docstring
Returns the global editor widget registry, used for managing all known edit widget factories.
@@ -55,6 +55,7 @@
#include "qgsclipboard.h"
#include "qgssettings.h"
#include "qgssettingsregistrycore.h"
#include "qgssettingsregistrygui.h"
#include "qgsoptionswidgetfactory.h"
#include "qgslocatorwidget.h"
#include "qgslocatoroptionswidget.h"
@@ -740,7 +741,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
mMapTipsDelaySpinBox->setValue( mSettings->value( QStringLiteral( "qgis/mapTipsDelay" ), 850 ).toInt() );
mMapTipsDelaySpinBox->setClearValue( 850 );

mRespectScreenDpiCheckBox->setChecked( QgsSettingsRegistryCore::settingsRespectScreenDPI.value() );
mRespectScreenDpiCheckBox->setChecked( QgsSettingsRegistryGui::settingsRespectScreenDPI.value() );

//
// Raster properties
@@ -1608,7 +1609,7 @@ void QgsOptions::saveOptions()

mSettings->setValue( QStringLiteral( "/qgis/defaultLegendGraphicResolution" ), mLegendGraphicResolutionSpinBox->value() );
mSettings->setValue( QStringLiteral( "/qgis/mapTipsDelay" ), mMapTipsDelaySpinBox->value() );
QgsSettingsRegistryCore::settingsRespectScreenDPI.setValue( mRespectScreenDpiCheckBox->isChecked() );
QgsSettingsRegistryGui::settingsRespectScreenDPI.setValue( mRespectScreenDpiCheckBox->isChecked() );

mSettings->setEnumValue( QStringLiteral( "/qgis/copyFeatureFormat" ), ( QgsClipboard::CopyFormat )mComboCopyFeatureFormat->currentData().toInt() );
QgisApp::instance()->setMapTipsDelay( mMapTipsDelaySpinBox->value() );
@@ -98,6 +98,23 @@ void QgsSettingsRegistry::addSubRegistry( const QgsSettingsRegistry *settingsReg
mSettingsRegistryChildList.append( settingsRegistry );
}

void QgsSettingsRegistry::removeSubRegistry( const QgsSettingsRegistry *settingsRegistry )
{
if ( !settingsRegistry )
{
QgsDebugMsg( QStringLiteral( "Trying to unregister a nullptr child settings registry." ) );
return;
}

if ( mSettingsRegistryChildList.contains( settingsRegistry ) )
{
QgsDebugMsg( QStringLiteral( "Child register is not registered." ) );
return;
}

mSettingsRegistryChildList.removeAll( settingsRegistry );
}

QList<const QgsSettingsRegistry *> QgsSettingsRegistry::subRegistries() const
{
return mSettingsRegistryChildList;
@@ -62,6 +62,11 @@ class CORE_EXPORT QgsSettingsRegistry
*/
void addSubRegistry( const QgsSettingsRegistry *settingsRegistry );

/**
* Remove a child \a settingsRegistry from the register.
*/
void removeSubRegistry( const QgsSettingsRegistry *settingsRegistry );

/**
* Returns the list of registered child QgsSettingsRegistry.
*/
@@ -95,7 +95,6 @@ QgsSettingsRegistryCore::QgsSettingsRegistryCore()
addSettingsEntry( &settingsDigitizingOffsetCapStyle );
addSettingsEntry( &settingsDigitizingOffsetShowAdvanced );
addSettingsEntry( &settingsDigitizingTracingMaxFeatureCount );
addSettingsEntry( &settingsRespectScreenDPI );
}

QgsSettingsRegistryCore::~QgsSettingsRegistryCore()
@@ -170,9 +170,6 @@ class CORE_EXPORT QgsSettingsRegistryCore : public QgsSettingsRegistry

//! Settings entry digitizing tracing max feature count
static const inline QgsSettingsEntryInteger settingsDigitizingTracingMaxFeatureCount = QgsSettingsEntryInteger( QStringLiteral( "/qgis/digitizing/tracing_max_feature_count" ), QgsSettings::NoSection, 10000 );

//! Settings entry respect screen dpi
static const inline QgsSettingsEntryBool settingsRespectScreenDPI = QgsSettingsEntryBool( QStringLiteral( "qgis/respect_screen_dpi" ), QgsSettings::Gui, false );
#endif

};
@@ -368,6 +368,8 @@ set(QGIS_GUI_SRCS
providers/ogr/qgsogritemguiprovider.cpp
providers/ogr/qgsgeopackageprojectstorageguiprovider.cpp

settings/qgssettingsregistrygui.cpp

tableeditor/qgstableeditordialog.cpp
tableeditor/qgstableeditorformattingwidget.cpp
tableeditor/qgstableeditorwidget.cpp
@@ -1239,6 +1241,8 @@ set(QGIS_GUI_HDRS
symbology/qgssymbolwidgetcontext.h
symbology/qgsvectorfieldsymbollayerwidget.h

settings/qgssettingsregistrygui.h

tableeditor/qgstableeditordialog.h
tableeditor/qgstableeditorformattingwidget.h
tableeditor/qgstableeditorwidget.h
@@ -1420,9 +1424,10 @@ target_include_directories(qgis_gui PUBLIC
${CMAKE_SOURCE_DIR}/src/gui/providers/ogr
${CMAKE_SOURCE_DIR}/src/gui/pointcloud
${CMAKE_SOURCE_DIR}/src/gui/raster
${CMAKE_SOURCE_DIR}/src/gui/settings
${CMAKE_SOURCE_DIR}/src/gui/tableeditor
${CMAKE_SOURCE_DIR}/src/gui/vector
${CMAKE_SOURCE_DIR}/src/gui/vectortile
${CMAKE_SOURCE_DIR}/src/gui/tableeditor

${CMAKE_BINARY_DIR}/src/gui
${CMAKE_BINARY_DIR}/src/ui
@@ -61,6 +61,7 @@
#include "qgssubsetstringeditorproviderregistry.h"
#include "qgsprovidersourcewidgetproviderregistry.h"
#include "qgsrelationwidgetregistry.h"
#include "qgssettingsregistrygui.h"

QgsGui *QgsGui::instance()
{
@@ -73,6 +74,11 @@ QgsNative *QgsGui::nativePlatformInterface()
return instance()->mNative;
}

QgsSettingsRegistryGui *QgsGui::settingsRegistryGui()
{
return instance()->mSettingsRegistryGui;
}

QgsEditorWidgetRegistry *QgsGui::editorWidgetRegistry()
{
return instance()->mEditorWidgetRegistry;
@@ -204,6 +210,7 @@ QgsGui::~QgsGui()
delete mSubsetStringEditorProviderRegistry;
delete mProviderSourceWidgetProviderRegistry;
delete mRelationEditorRegistry;
delete mSettingsRegistryGui;
}

QColor QgsGui::sampleColor( QPoint point )
@@ -249,6 +256,8 @@ QgsGui::QgsGui()
mNative = new QgsNative();
#endif

mSettingsRegistryGui = new QgsSettingsRegistryGui();

mCodeEditorColorSchemeRegistry = new QgsCodeEditorColorSchemeRegistry();

// provider gui registry initialize QgsProviderRegistry too
@@ -23,6 +23,7 @@
#include <QWidget>
#include <memory>

class QgsSettingsRegistryGui;
class QgsEditorWidgetRegistry;
class QgsShortcutsManager;
class QgsLayerTreeEmbeddedWidgetRegistry;
@@ -84,6 +85,12 @@ class GUI_EXPORT QgsGui : public QObject
*/
SIP_SKIP static QgsNative *nativePlatformInterface();

/**
* Returns the gui's settings registry, used for managing gui settings.
* \since QGIS 3.22
*/
static QgsSettingsRegistryGui *settingsRegistryGui() SIP_KEEPREFERENCE;

/**
* Returns the global editor widget registry, used for managing all known edit widget factories.
*/
@@ -261,6 +268,7 @@ class GUI_EXPORT QgsGui : public QObject

QgsGui();

QgsSettingsRegistryGui *mSettingsRegistryGui = nullptr;
QgsProviderGuiRegistry *mProviderGuiRegistry = nullptr;
QgsWidgetStateHelper *mWidgetStateHelper = nullptr;
QgsNative *mNative = nullptr;
@@ -91,7 +91,7 @@ email : sherman at mrcc.com
#include "qgscoordinatereferencesystemregistry.h"
#include "qgslabelingresults.h"
#include "qgsmaplayerutils.h"
#include "qgssettingsregistrycore.h"
#include "qgssettingsregistrygui.h"

/**
* \ingroup gui
@@ -985,7 +985,7 @@ void QgsMapCanvas::updateDevicePixelFromScreen()
{
mSettings.setDevicePixelRatio( devicePixelRatio() );
// TODO: QGIS 4 -> always respect screen dpi
if ( QgsSettingsRegistryCore::settingsRespectScreenDPI.value() )
if ( QgsSettingsRegistryGui::settingsRespectScreenDPI.value() )
{
mSettings.setOutputDpi( screen()->physicalDotsPerInch() );
}
@@ -0,0 +1,33 @@
/***************************************************************************
qgssettingsregistrygui.cpp
--------------------------------------
Date : July 2021
Copyright : (C) 2021 by Damiano Lombardi
Email : damiano at opengis dot ch
***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#include "qgssettingsregistrygui.h"

#include "qgsapplication.h"
#include "qgssettingsregistrycore.h"

QgsSettingsRegistryGui::QgsSettingsRegistryGui()
: QgsSettingsRegistry()
{
addSettingsEntry( &settingsRespectScreenDPI );

QgsApplication::settingsRegistryCore()->addSubRegistry( this );
}

QgsSettingsRegistryGui::~QgsSettingsRegistryGui()
{
QgsApplication::settingsRegistryCore()->removeSubRegistry( this );
}

@@ -0,0 +1,54 @@
/***************************************************************************
qgssettingsregistrygui.h
--------------------------------------
Date : July 2021
Copyright : (C) 2021 by Damiano Lombardi
Email : damiano at opengis dot ch
***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/


#ifndef QGSSETTINGSREGISTRYGUI_H
#define QGSSETTINGSREGISTRYGUI_H

#include "qgis_core.h"
#include "qgis_sip.h"
#include "qgssettingsregistry.h"
#include "qgssettingsentry.h"

/**
* \ingroup gui
* \class QgsSettingsRegistryGui
* QgsSettingsRegistryGui is used for settings introspection and collects all
* QgsSettingsEntry instances of gui.
*
* \since QGIS 3.22
*/
class CORE_EXPORT QgsSettingsRegistryGui : public QgsSettingsRegistry
{
public:

/**
* Constructor for QgsSettingsRegistryGui.
*/
QgsSettingsRegistryGui();

/**
* Destructor for QgsSettingsRegistryGui.
*/
virtual ~QgsSettingsRegistryGui();

#ifndef SIP_RUN
//! Settings entry respect screen dpi
static const inline QgsSettingsEntryBool settingsRespectScreenDPI = QgsSettingsEntryBool( QStringLiteral( "qgis/respect_screen_dpi" ), QgsSettings::Gui, false );
#endif

};

#endif // QGSSETTINGSREGISTRYGUI_H

0 comments on commit 18bd583

Please sign in to comment.