Skip to content
Permalink
Browse files
Also allow removal of custom directory colors
  • Loading branch information
nyalldawson committed May 17, 2021
1 parent f1b436a commit 75cbed79c8748a343d5c3d454dbd1ef9f02cf5c4
@@ -239,6 +239,15 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe
changeDirectoryColor( directoryItem );
} );
menu->addAction( actionSetIconColor );
if ( directoryItem->iconColor().isValid() )
{
QAction *actionClearIconColor = new QAction( tr( "Clear Custom Color" ), menu );
connect( actionClearIconColor, &QAction::triggered, this, [ = ]
{
clearDirectoryColor( directoryItem );
} );
menu->addAction( actionClearIconColor );
}

QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), menu );
connect( fastScanAction, &QAction::triggered, this, [ = ]
@@ -327,6 +336,13 @@ void QgsAppDirectoryItemGuiProvider::changeDirectoryColor( QgsDirectoryItem *ite
item->setIconColor( color );
}

void QgsAppDirectoryItemGuiProvider::clearDirectoryColor( QgsDirectoryItem *item )
{
item->setCustomColor( item->dirPath(), QColor() );
// and update item's color immediately
item->setIconColor( QColor() );
}

void QgsAppDirectoryItemGuiProvider::hideDirectory( QgsDirectoryItem *item )
{
if ( ! item )
@@ -46,7 +46,8 @@ class QgsAppDirectoryItemGuiProvider : public QObject, public QgsDataItemGuiProv
void addFavorite( QgsDirectoryItem *item );
void removeFavorite( QgsFavoriteItem *favorite );
void renameFavorite( QgsFavoriteItem *favorite );
void changeDirectoryColor( QgsDirectoryItem *favorite );
void changeDirectoryColor( QgsDirectoryItem *item );
void clearDirectoryColor( QgsDirectoryItem *item );
void hideDirectory( QgsDirectoryItem *item );
void toggleFastScan( QgsDirectoryItem *item );
void showProperties( QgsDirectoryItem *item, QgsDataItemGuiContext context );
@@ -1184,7 +1184,9 @@ QIcon QgsDirectoryItem::icon()
QFileInfo fi( mDirPath );
if ( fi.isDir() && fi.isSymLink() )
{
return QgsApplication::getThemeIcon( QStringLiteral( "mIconFolderLink.svg" ), mIconColor, mIconColor.darker() );
return mIconColor.isValid()
? QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderLinkParams.svg" ), mIconColor, mIconColor.darker() )
: QgsApplication::getThemeIcon( QStringLiteral( "/mIconFolderLink.svg" ) );
}

// loaded? show the open dir icon

0 comments on commit 75cbed7

Please sign in to comment.