mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Fix incorrect icon sizes in Python console
Console was not respecting application icon size setting
This commit is contained in:
parent
139fe68a4a
commit
cad54f2cea
@ -351,7 +351,7 @@ class PythonConsoleWidget(QWidget):
|
||||
self.toolBar.setFocusPolicy(Qt.NoFocus)
|
||||
self.toolBar.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
self.toolBar.setLayoutDirection(Qt.LeftToRight)
|
||||
self.toolBar.setIconSize(QSize(16, 16))
|
||||
self.toolBar.setIconSize(iface.iconSize(dockedToolbar=True))
|
||||
self.toolBar.setMovable(False)
|
||||
self.toolBar.setFloatable(False)
|
||||
self.toolBar.addAction(self.clearButton)
|
||||
@ -367,7 +367,7 @@ class PythonConsoleWidget(QWidget):
|
||||
self.toolBarEditor.setFocusPolicy(Qt.NoFocus)
|
||||
self.toolBarEditor.setContextMenuPolicy(Qt.DefaultContextMenu)
|
||||
self.toolBarEditor.setLayoutDirection(Qt.LeftToRight)
|
||||
self.toolBarEditor.setIconSize(QSize(16, 16))
|
||||
self.toolBarEditor.setIconSize(iface.iconSize(dockedToolbar=True))
|
||||
self.toolBarEditor.setMovable(False)
|
||||
self.toolBarEditor.setFloatable(False)
|
||||
self.toolBarEditor.addAction(self.openFileButton)
|
||||
|
@ -99,6 +99,13 @@ Constructor
|
||||
.. seealso:: createNewMapCanvas()
|
||||
%End
|
||||
|
||||
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
||||
%Docstring
|
||||
Returns the toolbar icon size. If ``dockedToolbar`` is true, the icon size
|
||||
for toolbars contained within docks is returned.
|
||||
:rtype: QSize
|
||||
%End
|
||||
|
||||
public slots: // TODO: do these functions really need to be slots?
|
||||
|
||||
|
||||
|
@ -68,8 +68,7 @@ class ScriptEditorDialog(BASE, WIDGET):
|
||||
self.restoreState(settings.value("/Processing/stateScriptEditor", QByteArray()))
|
||||
self.restoreGeometry(settings.value("/Processing/geometryScriptEditor", QByteArray()))
|
||||
|
||||
iconSize = int(settings.value("IconSize", 24))
|
||||
self.toolBar.setIconSize(QSize(iconSize, iconSize))
|
||||
self.toolBar.setIconSize(iface.iconSize())
|
||||
|
||||
self.actionOpenScript.setIcon(
|
||||
QgsApplication.getThemeIcon('/mActionFileOpen.svg'))
|
||||
|
@ -52,6 +52,8 @@ from processing.modeler.ModelerParameterDefinitionDialog import ModelerParameter
|
||||
from processing.modeler.ModelerParametersDialog import ModelerParametersDialog
|
||||
from processing.modeler.ModelerUtils import ModelerUtils
|
||||
from processing.modeler.ModelerScene import ModelerScene
|
||||
from qgis.utils import iface
|
||||
|
||||
from processing.modeler.WrongModelException import WrongModelException
|
||||
from qgis.PyQt.QtXml import QDomDocument
|
||||
|
||||
|
@ -1786,6 +1786,24 @@ int QgisApp::chooseReasonableDefaultIconSize() const
|
||||
|
||||
}
|
||||
|
||||
int QgisApp::dockedToolbarIconSize( int standardToolbarIconSize ) const
|
||||
{
|
||||
int dockSize;
|
||||
if ( standardToolbarIconSize > 32 )
|
||||
{
|
||||
dockSize = standardToolbarIconSize - 16;
|
||||
}
|
||||
else if ( standardToolbarIconSize == 32 )
|
||||
{
|
||||
dockSize = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
dockSize = 16;
|
||||
}
|
||||
return dockSize;
|
||||
}
|
||||
|
||||
void QgisApp::readSettings()
|
||||
{
|
||||
QgsSettings settings;
|
||||
@ -2831,19 +2849,7 @@ void QgisApp::createStatusBar()
|
||||
|
||||
void QgisApp::setIconSizes( int size )
|
||||
{
|
||||
int dockSize;
|
||||
if ( size > 32 )
|
||||
{
|
||||
dockSize = size - 16;
|
||||
}
|
||||
else if ( size == 32 )
|
||||
{
|
||||
dockSize = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
dockSize = 16;
|
||||
}
|
||||
int dockSize = dockedToolbarIconSize( size );
|
||||
|
||||
//Set the icon size of for all the toolbars created in the future.
|
||||
setIconSize( QSize( size, size ) );
|
||||
@ -9736,6 +9742,19 @@ QgsMapLayer *QgisApp::activeLayer()
|
||||
return mLayerTreeView ? mLayerTreeView->currentLayer() : nullptr;
|
||||
}
|
||||
|
||||
QSize QgisApp::iconSize( bool dockedToolbar ) const
|
||||
{
|
||||
QgsSettings s;
|
||||
int size = s.value( QStringLiteral( "/IconSize" ), 32 ).toInt();
|
||||
|
||||
if ( dockedToolbar )
|
||||
{
|
||||
size = dockedToolbarIconSize( size );
|
||||
}
|
||||
|
||||
return QSize( size, size );
|
||||
}
|
||||
|
||||
bool QgisApp::setActiveLayer( QgsMapLayer *layer )
|
||||
{
|
||||
if ( !layer )
|
||||
|
@ -621,6 +621,12 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
//! Returns the active map layer.
|
||||
QgsMapLayer *activeLayer();
|
||||
|
||||
/**
|
||||
* Returns the toolbar icon size. If \a dockedToolbar is true, the icon size
|
||||
* for toolbars contained within docks is returned.
|
||||
*/
|
||||
QSize iconSize( bool dockedToolbar = false ) const;
|
||||
|
||||
public slots:
|
||||
//! Process the list of URIs that have been dropped in QGIS
|
||||
void handleDropUriList( const QgsMimeDataUtils::UriList &lst );
|
||||
@ -1715,6 +1721,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
|
||||
//! Attempts to choose a reasonable default icon size based on the window's screen DPI
|
||||
int chooseReasonableDefaultIconSize() const;
|
||||
|
||||
/**
|
||||
* Returns the size of docked toolbars for a given standard (non-docked) toolbar icon size.
|
||||
*/
|
||||
int dockedToolbarIconSize( int standardToolbarIconSize ) const;
|
||||
|
||||
QgisAppStyleSheet *mStyleSheetBuilder = nullptr;
|
||||
|
||||
// actions for menus and toolbars -----------------
|
||||
|
@ -352,6 +352,11 @@ void QgisAppInterface::closeMapCanvas( const QString &name )
|
||||
qgis->closeMapCanvas( name );
|
||||
}
|
||||
|
||||
QSize QgisAppInterface::iconSize( bool dockedToolbar ) const
|
||||
{
|
||||
return qgis->iconSize( dockedToolbar );
|
||||
}
|
||||
|
||||
QgsLayerTreeMapCanvasBridge *QgisAppInterface::layerTreeCanvasBridge()
|
||||
{
|
||||
return qgis->layerTreeCanvasBridge();
|
||||
|
@ -183,6 +183,8 @@ class APP_EXPORT QgisAppInterface : public QgisInterface
|
||||
QgsMapCanvas *createNewMapCanvas( const QString &name ) override;
|
||||
virtual void closeMapCanvas( const QString &name ) override;
|
||||
|
||||
virtual QSize iconSize( bool dockedToolbar = false ) const override;
|
||||
|
||||
/**
|
||||
* Returns a pointer to the layer tree canvas bridge
|
||||
*
|
||||
|
@ -128,6 +128,12 @@ class GUI_EXPORT QgisInterface : public QObject
|
||||
*/
|
||||
virtual void closeMapCanvas( const QString &name ) = 0;
|
||||
|
||||
/**
|
||||
* Returns the toolbar icon size. If \a dockedToolbar is true, the icon size
|
||||
* for toolbars contained within docks is returned.
|
||||
*/
|
||||
virtual QSize iconSize( bool dockedToolbar = false ) const = 0;
|
||||
|
||||
public slots: // TODO: do these functions really need to be slots?
|
||||
|
||||
/* Exposed functions */
|
||||
|
Loading…
x
Reference in New Issue
Block a user