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): def toHtml(self):
if self.db is None: if self.db is None:
return HtmlSection(QApplication.translate("DBManagerPlugin", 'Not connected')).toHtml() return HtmlSection(QApplication.translate("DBManagerPlugin", '<warning> Not connected')).toHtml()
ret = [] ret = []

View File

@ -72,11 +72,9 @@ class GuiUtils:
return path return path
@staticmethod @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 Returns the path to a pixmap icon
:param icon: icon name (png file name)
:return: icon png path
""" """
for suffix in ('.png', '.gif', '.xpm'): for suffix in ('.png', '.gif', '.xpm'):
path = os.path.join( path = os.path.join(
@ -84,6 +82,19 @@ class GuiUtils:
'icons', 'icons',
icon + suffix) icon + suffix)
if os.path.exists(path): if os.path.exists(path):
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) im = QImage(path)
return QPixmap.fromImage(im) return QPixmap.fromImage(im)

View File

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