simplify icon
This commit is contained in:
parent
ca258bc445
commit
04af3c1884
1
plot_layout/.gitignore
vendored
Normal file
1
plot_layout/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
__pycache__/
|
Binary file not shown.
@ -9,6 +9,7 @@ from qgis.PyQt.QtWidgets import (
|
|||||||
QPushButton,
|
QPushButton,
|
||||||
QVBoxLayout
|
QVBoxLayout
|
||||||
)
|
)
|
||||||
|
from qgis.PyQt.QtGui import QIcon
|
||||||
from qgis.gui import (
|
from qgis.gui import (
|
||||||
QgsLayoutItemAbstractGuiMetadata,
|
QgsLayoutItemAbstractGuiMetadata,
|
||||||
QgsLayoutItemBaseWidget,
|
QgsLayoutItemBaseWidget,
|
||||||
@ -17,9 +18,7 @@ from qgis.gui import (
|
|||||||
|
|
||||||
from qgis.core import ( QgsLayoutItemRegistry )
|
from qgis.core import ( QgsLayoutItemRegistry )
|
||||||
|
|
||||||
from plot_settings_widget import DataPlotlyPanelWidget
|
# from plot_settings_widget import DataPlotlyPanelWidget
|
||||||
|
|
||||||
from gui_utils import GuiUtils
|
|
||||||
|
|
||||||
ITEM_TYPE = QgsLayoutItemRegistry.PluginItem + 1338
|
ITEM_TYPE = QgsLayoutItemRegistry.PluginItem + 1338
|
||||||
|
|
||||||
@ -268,10 +267,11 @@ class PlotLayoutItemGuiMetadata(QgsLayoutItemAbstractGuiMetadata):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(ITEM_TYPE, 'test')
|
super().__init__(ITEM_TYPE, 'layoutItemGui')
|
||||||
|
|
||||||
def creationIcon(self): # pylint: disable=missing-docstring, no-self-use
|
def creationIcon(self): # pylint: disable=missing-docstring, no-self-use
|
||||||
return GuiUtils.get_icon('circle.svg')
|
icon_path = ':/plugins/plot_layout/icon.png'
|
||||||
|
return QIcon(icon_path)
|
||||||
|
|
||||||
def createItemWidget(self, item): # pylint: disable=missing-docstring, no-self-use
|
def createItemWidget(self, item): # pylint: disable=missing-docstring, no-self-use
|
||||||
return PlotLayoutItemWidget(None, item)
|
return PlotLayoutItemWidget(None, item)
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
"""GUI Utilities
|
|
||||||
|
|
||||||
.. note:: This program is free software; you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
|
||||||
|
|
||||||
|
|
||||||
class GuiUtils:
|
|
||||||
"""
|
|
||||||
Utilities for GUI plugin components
|
|
||||||
"""
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_icon(icon: str) -> QIcon:
|
|
||||||
"""
|
|
||||||
Returns a plugin icon
|
|
||||||
:param icon: icon name (svg file name)
|
|
||||||
:return: QIcon
|
|
||||||
"""
|
|
||||||
path = GuiUtils.get_icon_svg(icon)
|
|
||||||
if not path:
|
|
||||||
return QIcon()
|
|
||||||
|
|
||||||
return QIcon(path)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_icon_svg(icon: str) -> str:
|
|
||||||
"""
|
|
||||||
Returns a plugin icon's SVG file path
|
|
||||||
:param icon: icon name (svg file name)
|
|
||||||
:return: icon svg path
|
|
||||||
"""
|
|
||||||
path = os.path.join(
|
|
||||||
os.path.dirname(__file__),
|
|
||||||
'..',
|
|
||||||
'icons',
|
|
||||||
icon)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
return path
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_ui_file_path(file: str) -> str:
|
|
||||||
"""
|
|
||||||
Returns a UI file's path
|
|
||||||
:param file: file name (uifile name)
|
|
||||||
:return: ui file path
|
|
||||||
"""
|
|
||||||
path = os.path.join(
|
|
||||||
os.path.dirname(__file__),
|
|
||||||
'..',
|
|
||||||
'ui',
|
|
||||||
file)
|
|
||||||
if not os.path.exists(path):
|
|
||||||
return ''
|
|
||||||
|
|
||||||
return path
|
|
Binary file not shown.
@ -15,31 +15,27 @@ class PlotLayoutItem(QgsLayoutItem):
|
|||||||
|
|
||||||
def __init__(self, layout):
|
def __init__(self, layout):
|
||||||
super().__init__(layout)
|
super().__init__(layout)
|
||||||
# self.setCacheMode(QGraphicsItem.NoCache)
|
|
||||||
# self.plot_settings = []
|
|
||||||
# self.plot_settings.append(PlotSettings())
|
|
||||||
# self.linked_map_uuid = ''
|
|
||||||
# self.linked_map = None
|
|
||||||
|
|
||||||
# self.filter_by_map = False
|
def draw(self, context):
|
||||||
# self.filter_by_atlas = False
|
pass
|
||||||
|
# if not self.html_loaded:
|
||||||
|
# self.load_content()
|
||||||
|
|
||||||
# self.web_page = LoggingWebPage(self)
|
# if not self.layout().renderContext().isPreviewRender():
|
||||||
# self.web_page.setNetworkAccessManager(QgsNetworkAccessManager.instance())
|
# # this is NOT safe to do when rendering in the gui (i.e. a preview render), but for exports we have
|
||||||
|
# # to loop around until the HTML has fully loaded
|
||||||
|
# while not self.html_loaded:
|
||||||
|
# QCoreApplication.processEvents()
|
||||||
|
|
||||||
# # This makes the background transparent. (copied from QgsLayoutItemLabel)
|
# # almost a direct copy from QgsLayoutItemLabel!
|
||||||
# palette = self.web_page.palette()
|
# painter = context.renderContext().painter()
|
||||||
# palette.setBrush(QPalette.Base, Qt.transparent)
|
# painter.save()
|
||||||
# self.web_page.setPalette(palette)
|
|
||||||
# self.web_page.mainFrame().setZoomFactor(10.0)
|
|
||||||
# self.web_page.mainFrame().setScrollBarPolicy(Qt.Horizontal, Qt.ScrollBarAlwaysOff)
|
|
||||||
# self.web_page.mainFrame().setScrollBarPolicy(Qt.Vertical, Qt.ScrollBarAlwaysOff)
|
|
||||||
|
|
||||||
# self.web_page.loadFinished.connect(self.loading_html_finished)
|
# # painter is scaled to dots, so scale back to layout units
|
||||||
# self.html_loaded = False
|
# painter.scale(context.renderContext().scaleFactor() / self.html_units_to_layout_units,
|
||||||
# self.html_units_to_layout_units = self.calculate_html_units_to_layout_units()
|
# context.renderContext().scaleFactor() / self.html_units_to_layout_units)
|
||||||
|
# self.web_page.mainFrame().render(painter)
|
||||||
# self.sizePositionChanged.connect(self.refresh)
|
# painter.restore()
|
||||||
|
|
||||||
def type(self):
|
def type(self):
|
||||||
return ITEM_TYPE
|
return ITEM_TYPE
|
||||||
@ -47,7 +43,7 @@ class PlotLayoutItem(QgsLayoutItem):
|
|||||||
class PlotLayoutItemMetadata(QgsLayoutItemAbstractMetadata):
|
class PlotLayoutItemMetadata(QgsLayoutItemAbstractMetadata):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(ITEM_TYPE, 'test')
|
super().__init__(ITEM_TYPE, 'layoutItem')
|
||||||
|
|
||||||
def createItem(self, layout):
|
def createItem(self, layout):
|
||||||
return PlotLayoutItem(layout)
|
return PlotLayoutItem(layout)
|
Loading…
Reference in New Issue
Block a user