diff --git a/ORStools/gui/ORStoolsDialog.py b/ORStools/gui/ORStoolsDialog.py
index 6fb78d4..5103a5f 100644
--- a/ORStools/gui/ORStoolsDialog.py
+++ b/ORStools/gui/ORStoolsDialog.py
@@ -67,7 +67,6 @@
)
from ORStools import (
- RESOURCE_PREFIX,
PLUGIN_NAME,
DEFAULT_COLOR,
__version__,
@@ -166,9 +165,13 @@ def initGui(self) -> None:
self.iface.mainWindow(),
),
# About dialog
- QAction(gui.GuiUtils.get_icon("icon_about.png"), self.tr("About"), self.iface.mainWindow()),
+ QAction(
+ gui.GuiUtils.get_icon("icon_about.png"), self.tr("About"), self.iface.mainWindow()
+ ),
# Help page
- QAction(gui.GuiUtils.get_icon("icon_help.png"), self.tr("Help"), self.iface.mainWindow()),
+ QAction(
+ gui.GuiUtils.get_icon("icon_help.png"), self.tr("Help"), self.iface.mainWindow()
+ ),
]
# Create menu
@@ -439,7 +442,9 @@ def run_gui_control(self) -> None:
def tr(self, string: str) -> str:
return QCoreApplication.translate(str(self.__class__.__name__), string)
-MAIN_WIDGET, _ = uic.loadUiType(gui.GuiUtils.get_ui_file_path('ORStoolsDialogUI.ui'))
+
+MAIN_WIDGET, _ = uic.loadUiType(gui.GuiUtils.get_ui_file_path("ORStoolsDialogUI.ui"))
+
class ORStoolsDialog(QDialog, MAIN_WIDGET):
"""Define the custom behaviour of Dialog"""
diff --git a/ORStools/gui/ORStoolsDialogConfig.py b/ORStools/gui/ORStoolsDialogConfig.py
index bd100ee..c253a7e 100644
--- a/ORStools/gui/ORStoolsDialogConfig.py
+++ b/ORStools/gui/ORStoolsDialogConfig.py
@@ -36,7 +36,8 @@
from ORStools.utils import configmanager, gui
-CONFIG_WIDGET, _ = uic.loadUiType(gui.GuiUtils.get_ui_file_path('ORStoolsDialogConfigUI.ui'))
+CONFIG_WIDGET, _ = uic.loadUiType(gui.GuiUtils.get_ui_file_path("ORStoolsDialogConfigUI.ui"))
+
class ORStoolsDialogConfigMain(QDialog, CONFIG_WIDGET):
"""Builds provider config dialog."""
diff --git a/ORStools/proc/provider.py b/ORStools/proc/provider.py
index 03efb8c..c8e7a8e 100644
--- a/ORStools/proc/provider.py
+++ b/ORStools/proc/provider.py
@@ -29,9 +29,8 @@
from qgis.core import QgsProcessingProvider
-from qgis.PyQt.QtGui import QIcon
-from ORStools import RESOURCE_PREFIX, PLUGIN_NAME, __version__
+from ORStools import PLUGIN_NAME, __version__
from .directions_lines_proc import ORSDirectionsLinesAlgo
from .directions_points_layer_proc import ORSDirectionsPointsLayerAlgo
from .directions_points_layers_proc import ORSDirectionsPointsLayersAlgo
@@ -42,7 +41,6 @@
from ORStools.utils.gui import GuiUtils
-
class ORStoolsProvider(QgsProcessingProvider):
def __init__(self):
QgsProcessingProvider.__init__(self)
diff --git a/ORStools/utils/gui.py b/ORStools/utils/gui.py
index 6375e92..911b7dd 100644
--- a/ORStools/utils/gui.py
+++ b/ORStools/utils/gui.py
@@ -7,19 +7,16 @@
(at your option) any later version.
"""
-__author__ = '(C) 2018 by Nyall Dawson'
-__date__ = '20/04/2018'
-__copyright__ = 'Copyright 2018, North Road'
+__author__ = "(C) 2018 by Nyall Dawson"
+__date__ = "20/04/2018"
+__copyright__ = "Copyright 2018, North Road"
# This will get replaced with a git SHA1 when you do a git archive
-__revision__ = '$Format:%H$'
+__revision__ = "$Format:%H$"
import math
import os
import re
-from typing import (
- Optional,
- Union
-)
+from typing import Optional, Union
from qgis.PyQt.QtCore import Qt
from qgis.PyQt.QtGui import (
@@ -30,18 +27,13 @@
QPixmap,
QFontDatabase,
QColor,
- QPainter
+ QPainter,
)
from qgis.PyQt.QtSvg import QSvgRenderer
-from qgis.PyQt.QtWidgets import (
- QMenu
-)
-from qgis.core import (
- Qgis
-)
+from qgis.PyQt.QtWidgets import QMenu
+from qgis.core import Qgis
from qgis.utils import iface
-from ORStools import RESOURCE_PREFIX
from ORStools.utils import logger
FONT_FAMILIES = ""
@@ -80,9 +72,9 @@ class GuiUtils:
APPLICATION_FONT_MAP = {}
@staticmethod
- def set_link_color(html: str,
- wrap_color=True,
- color: Optional[Union[QColor, str]] = None) -> str:
+ def set_link_color(
+ html: str, wrap_color=True, color: Optional[Union[QColor, str]] = None
+ ) -> str:
"""
Adds style tags to links in a HTML string for the standard link color
"""
@@ -92,13 +84,10 @@ def set_link_color(html: str,
else:
color_string = color.name()
else:
- color_string = 'rgba(0,0,0,.3)'
- res = re.sub(r'(',
- r'\1 style="color: {};">'.format(color_string),
- html)
+ color_string = "rgba(0,0,0,.3)"
+ res = re.sub(r"(", r'\1 style="color: {};">'.format(color_string), html)
if wrap_color:
- res = '{}'.format(color_string,
- res)
+ res = '{}'.format(color_string, res)
return res
@staticmethod
@@ -121,14 +110,10 @@ def get_icon_svg(icon: str) -> str:
:param icon: icon name (svg file name)
:return: icon svg path
"""
- path = os.path.join(
- os.path.dirname(__file__),
- '..',
- 'gui/img',
- icon)
+ path = os.path.join(os.path.dirname(__file__), "..", "gui/img", icon)
logger.log(path)
if not os.path.exists(path):
- return ''
+ return ""
return path
@@ -139,11 +124,7 @@ def get_icon_pixmap(icon: str) -> QPixmap:
:param icon: icon name (png file name)
:return: icon png path
"""
- path = os.path.join(
- os.path.dirname(__file__),
- '..',
- 'icons',
- icon)
+ path = os.path.join(os.path.dirname(__file__), "..", "icons", icon)
if not os.path.exists(path):
return QPixmap()
@@ -151,9 +132,13 @@ def get_icon_pixmap(icon: str) -> QPixmap:
return QPixmap.fromImage(im)
@staticmethod
- def get_svg_as_image(icon: str, width: int, height: int,
- background_color: Optional[QColor] = None,
- device_pixel_ratio: float = 1) -> QImage:
+ def get_svg_as_image(
+ icon: str,
+ width: int,
+ height: int,
+ background_color: Optional[QColor] = None,
+ device_pixel_ratio: float = 1,
+ ) -> QImage:
"""
Returns an SVG returned as an image
"""
@@ -162,9 +147,9 @@ def get_svg_as_image(icon: str, width: int, height: int,
return QImage()
renderer = QSvgRenderer(path)
- image = QImage(int(width * device_pixel_ratio),
- int(height * device_pixel_ratio),
- QImage.Format_ARGB32)
+ image = QImage(
+ int(width * device_pixel_ratio), int(height * device_pixel_ratio), QImage.Format_ARGB32
+ )
image.setDevicePixelRatio(device_pixel_ratio)
if not background_color:
image.fill(Qt.transparent)
@@ -172,8 +157,7 @@ def get_svg_as_image(icon: str, width: int, height: int,
image.fill(background_color)
painter = QPainter(image)
- painter.scale(1 / device_pixel_ratio,
- 1 / device_pixel_ratio)
+ painter.scale(1 / device_pixel_ratio, 1 / device_pixel_ratio)
renderer.render(painter)
painter.end()
@@ -186,11 +170,7 @@ def get_ui_file_path(file: str) -> str:
:param file: file name (uifile name)
:return: ui file path
"""
- path = os.path.join(
- os.path.dirname(__file__),
- '..',
- 'gui',
- file)
+ path = os.path.join(os.path.dirname(__file__), "..", "gui", file)
if not os.path.exists(path):
return path
@@ -203,8 +183,9 @@ def scale_icon_size(standard_size: int) -> int:
"""
fm = QFontMetrics((QFont()))
scale = 1.1 * standard_size / 24.0
- return int(math.floor(max(Qgis.UI_SCALE_FACTOR * fm.height() * scale,
- float(standard_size))))
+ return int(
+ math.floor(max(Qgis.UI_SCALE_FACTOR * fm.height() * scale, float(standard_size)))
+ )
@staticmethod
def get_default_font() -> QFont:
@@ -212,8 +193,8 @@ def get_default_font() -> QFont:
Returns the best font match for the Koordinates default font
families which is available on the system
"""
- for family in FONT_FAMILIES.split(','):
- family_cleaned = re.match(r'^\s*\'?(.*?)\'?\s*$', family).group(1)
+ for family in FONT_FAMILIES.split(","):
+ family_cleaned = re.match(r"^\s*\'?(.*?)\'?\s*$", family).group(1)
font = QFont(family_cleaned)
if font.exactMatch():
return font
@@ -227,13 +208,9 @@ def get_font_path(font: str) -> str:
:param font: font name
:return: font file path
"""
- path = os.path.join(
- os.path.dirname(__file__),
- '..',
- 'fonts',
- font)
+ path = os.path.join(os.path.dirname(__file__), "..", "fonts", font)
if not os.path.exists(path):
- return ''
+ return ""
return path
@@ -267,9 +244,8 @@ def get_project_import_export_menu() -> Optional[QMenu]:
pass
project_menu = iface.projectMenu()
- matches = [m for m in project_menu.children()
- if m.objectName() == 'menuImport_Export']
+ matches = [m for m in project_menu.children() if m.objectName() == "menuImport_Export"]
if matches:
return matches[0]
- return None
\ No newline at end of file
+ return None