FileIconProvider: Load icons and create overlay lazily

If the icon is registered via file path, not the icon directly, we can
delay loading the icon and creating the overlay to until it is actually
needed.

Change-Id: Icfdc30ac0b717ff566a1064e4791e4bb23814958
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Eike Ziller
2019-11-15 14:12:26 +01:00
parent dd93820fdd
commit 349de159c9
2 changed files with 55 additions and 34 deletions

View File

@@ -296,14 +296,14 @@ void CppEditorPlugin::extensionsInitialized()
if (!HostOsInfo::isMacHost() && !HostOsInfo::isWindowsHost()) {
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppSource, QLatin1String(":/cppeditor/images/qt_cpp.png"))),
CppTools::Constants::CPP_SOURCE_MIMETYPE);
creatorTheme()->imageFile(Theme::IconOverlayCppSource, ":/cppeditor/images/qt_cpp.png"),
CppTools::Constants::CPP_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCSource, QLatin1String(":/cppeditor/images/qt_c.png"))),
CppTools::Constants::C_SOURCE_MIMETYPE);
creatorTheme()->imageFile(Theme::IconOverlayCSource, ":/cppeditor/images/qt_c.png"),
CppTools::Constants::C_SOURCE_MIMETYPE);
FileIconProvider::registerIconOverlayForMimeType(
QIcon(creatorTheme()->imageFile(Theme::IconOverlayCppHeader, QLatin1String(":/cppeditor/images/qt_h.png"))),
CppTools::Constants::CPP_HEADER_MIMETYPE);
creatorTheme()->imageFile(Theme::IconOverlayCppHeader, ":/cppeditor/images/qt_h.png"),
CppTools::Constants::CPP_HEADER_MIMETYPE);
}
}