Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Allow fill/stroke color to be specified for QgsDataItem::iconDir/open…
…DirIcon
  • Loading branch information
nyalldawson committed May 17, 2021
1 parent cd6aa7f commit 2aa7040
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
10 changes: 8 additions & 2 deletions python/core/auto_generated/qgsdataitem.sip.in
Expand Up @@ -687,10 +687,13 @@ The optional ``providerKey`` string can be used to specify the key for the :py:c

void addChild( QgsDataItem *item /Transfer/ );

static QIcon iconDir();
static QIcon iconDir( const QColor &fillColor = QColor(), const QColor &strokeColor = QColor() );
%Docstring
Returns the standard browser directory icon.

Since QGIS 3.20 the optional ``fillColor`` and ``strokeColor`` arguments can be used to specify
a fill and stroke color for the icon.

.. seealso:: :py:func:`iconDataCollection`
%End

Expand All @@ -706,10 +709,13 @@ Returns the standard browser data collection icon.

protected:

static QIcon openDirIcon();
static QIcon openDirIcon( const QColor &fillColor = QColor(), const QColor &strokeColor = QColor() );
%Docstring
Shared open directory icon.

Since QGIS 3.20 the optional ``fillColor`` and ``strokeColor`` arguments can be used to specify
a fill and stroke color for the icon.

.. versionadded:: 3.4
%End

Expand Down
12 changes: 8 additions & 4 deletions src/core/qgsdataitem.cpp
Expand Up @@ -123,9 +123,11 @@ QIcon QgsDataCollectionItem::iconDataCollection()
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconDbSchema.svg" ) );
}

QIcon QgsDataCollectionItem::openDirIcon()
QIcon QgsDataCollectionItem::openDirIcon( const QColor &fillColor, const QColor &strokeColor )
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderOpen.svg" ) );
return fillColor.isValid() || strokeColor.isValid()
? QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderOpenParams.svg" ), fillColor, strokeColor )
: QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderOpen.svg" ) );
}

QIcon QgsDataCollectionItem::homeDirIcon()
Expand Down Expand Up @@ -171,9 +173,11 @@ QgsAbstractDatabaseProviderConnection *QgsDataCollectionItem::databaseConnection
return nullptr;
}

QIcon QgsDataCollectionItem::iconDir()
QIcon QgsDataCollectionItem::iconDir( const QColor &fillColor, const QColor &strokeColor )
{
return QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolder.svg" ) );
return fillColor.isValid() || strokeColor.isValid()
? QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderParams.svg" ), fillColor, strokeColor )
: QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolder.svg" ) );
}


Expand Down
12 changes: 10 additions & 2 deletions src/core/qgsdataitem.h
Expand Up @@ -703,9 +703,13 @@ class CORE_EXPORT QgsDataCollectionItem : public QgsDataItem

/**
* Returns the standard browser directory icon.
*
* Since QGIS 3.20 the optional \a fillColor and \a strokeColor arguments can be used to specify
* a fill and stroke color for the icon.
*
* \see iconDataCollection()
*/
static QIcon iconDir();
static QIcon iconDir( const QColor &fillColor = QColor(), const QColor &strokeColor = QColor() );

/**
* Returns the standard browser data collection icon.
Expand All @@ -719,9 +723,13 @@ class CORE_EXPORT QgsDataCollectionItem : public QgsDataItem

/**
* Shared open directory icon.
*
* Since QGIS 3.20 the optional \a fillColor and \a strokeColor arguments can be used to specify
* a fill and stroke color for the icon.
*
* \since QGIS 3.4
*/
static QIcon openDirIcon();
static QIcon openDirIcon( const QColor &fillColor = QColor(), const QColor &strokeColor = QColor() );

/**
* Shared home directory icon.
Expand Down

0 comments on commit 2aa7040

Please sign in to comment.