Remove another compiled icon use

This commit is contained in:
Nyall Dawson 2024-02-20 14:57:26 +10:00
parent c4342425eb
commit b45f68274c
3 changed files with 22 additions and 9 deletions

View File

@ -77,7 +77,7 @@ class DatabaseInfo:
def toHtml(self):
if self.db is None:
return HtmlSection(QApplication.translate("DBManagerPlugin", 'Not connected')).toHtml()
return HtmlSection(QApplication.translate("DBManagerPlugin", '<warning> Not connected')).toHtml()
ret = []

View File

@ -72,11 +72,9 @@ class GuiUtils:
return path
@staticmethod
def get_icon_as_pixmap(icon: str) -> Optional[QPixmap]:
def get_pixmap_path(icon: str) -> Optional[str]:
"""
Returns a plugin icon's PNG file path
:param icon: icon name (png file name)
:return: icon png path
Returns the path to a pixmap icon
"""
for suffix in ('.png', '.gif', '.xpm'):
path = os.path.join(
@ -84,8 +82,21 @@ class GuiUtils:
'icons',
icon + suffix)
if os.path.exists(path):
im = QImage(path)
return QPixmap.fromImage(im)
return path
return None
@staticmethod
def get_icon_as_pixmap(icon: str) -> Optional[QPixmap]:
"""
Returns a plugin icon's PNG file path
:param icon: icon name (png file name)
:return: icon png path
"""
path = GuiUtils.get_pixmap_path(icon)
if path is not None:
im = QImage(path)
return QPixmap.fromImage(im)
return None

View File

@ -24,6 +24,7 @@ from qgis.utils import OverrideCursor
from .db_plugins.plugin import BaseError, DbError, DBPlugin, Schema, Table
from .dlg_db_error import DlgDbError
from .gui_utils import GuiUtils
class InfoViewer(QTextBrowser):
@ -135,8 +136,9 @@ class InfoViewer(QTextBrowser):
return True
def setHtml(self, html):
# convert special tags :)
html = str(html).replace('<warning>', '<img src=":/db_manager/warning">&nbsp;&nbsp; ')
# convert special tags
warning_icon_path = GuiUtils.get_pixmap_path('warning-20px')
html = str(html).replace('<warning>', f'<img src="{warning_icon_path}">&nbsp;&nbsp; ')
# add default style
html = """