Skip to content

Commit

Permalink
add PLUGIN_NAME into conf.py
Browse files Browse the repository at this point in the history
  • Loading branch information
minorua committed Feb 21, 2022
1 parent 81bfdce commit 3f5ae08
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 26 deletions.
1 change: 1 addition & 0 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# begin: 2015-03-02

# general
PLUGIN_NAME = "Qgis2threejs"
PLUGIN_VERSION = "2.6"
PLUGIN_VERSION_INT = int(float(PLUGIN_VERSION) * 100)

Expand Down
7 changes: 4 additions & 3 deletions exportdialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox
from qgis.core import QgsApplication, QgsProject

from .conf import PLUGIN_NAME
from .export import ThreeJSExporter
from .tools import getTemplateConfig, openUrl, templateDir, temporaryOutputDir
from .ui.exporttowebdialog import Ui_ExportToWebDialog
Expand Down Expand Up @@ -120,7 +121,7 @@ def accept(self):

filepath = os.path.join(out_dir, filename)
if not is_temporary and os.path.exists(filepath):
if QMessageBox.question(self, "Qgis2threejs", "The HTML file already exists. Do you want to overwrite it?", QMessageBox.Ok | QMessageBox.Cancel) != QMessageBox.Ok:
if QMessageBox.question(self, PLUGIN_NAME, "The HTML file already exists. Do you want to overwrite it?", QMessageBox.Ok | QMessageBox.Cancel) != QMessageBox.Ok:
return

self.settings.setOutputFilename("" if is_temporary else filepath)
Expand All @@ -147,7 +148,7 @@ def accept(self):
try:
self.settings.setOption("AR.MND", float(self.ui.lineEdit_MND.text()))
except Exception as e:
QMessageBox.warning(self, "Qgis2threejs", "Invalid setting value for M.N. direction. Must be a numeric value.")
QMessageBox.warning(self, PLUGIN_NAME, "Invalid setting value for M.N. direction. Must be a numeric value.")
return

# animation settings
Expand All @@ -169,7 +170,7 @@ def accept(self):

err_msg = settings.checkValidity()
if err_msg:
QMessageBox.warning(self, "Qgis2threejs", err_msg or "Invalid settings")
QMessageBox.warning(self, PLUGIN_NAME, err_msg or "Invalid settings")
return

for w in [self.ui.tabSettings, self.ui.pushButton_Export, self.ui.pushButton_Close]:
Expand Down
12 changes: 6 additions & 6 deletions keyframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
QMessageBox, QTreeWidget, QTreeWidgetItem, QWidget)
from qgis.core import QgsApplication, QgsFieldProxyModel

from .conf import DEBUG_MODE, DEF_SETS, EASING
from .conf import DEBUG_MODE, DEF_SETS, EASING, PLUGIN_NAME
from .q3dconst import DEMMtlType, LayerType, ATConst
from .q3dcore import Layer
from .tools import createUid, js_bool, logMessage, parseInt
Expand Down Expand Up @@ -106,7 +106,7 @@ def updateKeyframeView(self):
view = self.webPage.cameraState(flat=True)

msg = "Are you sure you want to update the camera position and focal point of this keyframe?"
if QMessageBox.question(self, "Qgis2threejs", msg) == QMessageBox.Yes:
if QMessageBox.question(self, PLUGIN_NAME, msg) == QMessageBox.Yes:
item = self.tree.currentItem()
item.setData(0, ATConst.DATA_CAMERA, view)

Expand Down Expand Up @@ -331,7 +331,7 @@ def addNewItem(self):
self.addMaterialItem()

elif gt == ATConst.ITEM_GRP_GROWING_LINE:
QMessageBox.warning(self, "Qgis2threejs", "This group can't have more than one item.")
QMessageBox.warning(self, PLUGIN_NAME, "This group can't have more than one item.")

def removeSelectedItems(self):
items = self.selectedItems() or [self.currentItem()]
Expand All @@ -342,7 +342,7 @@ def removeSelectedItems(self):
else:
msg = "Are you sure you want to remove {} items?".format(len(items))

if QMessageBox.question(self, "Qgis2threejs", msg) != QMessageBox.Yes:
if QMessageBox.question(self, PLUGIN_NAME, msg) != QMessageBox.Yes:
return

for item in items:
Expand Down Expand Up @@ -767,7 +767,7 @@ def showDialog(self, item=None):
isKF = (t != ATConst.ITEM_GROWING_LINE)

if isKF and item.parent().childCount() < 2:
QMessageBox.warning(self, "Qgis2threejs", "Two or more keyframes are necessary for animation to work. Please add a keyframe.")
QMessageBox.warning(self, PLUGIN_NAME, "Two or more keyframes are necessary for animation to work. Please add a keyframe.")
return

elif t & ATConst.ITEM_GRP:
Expand Down Expand Up @@ -795,7 +795,7 @@ def showDialog(self, item=None):
return

if self.dialog:
QMessageBox.warning(self, "Qgis2threejs", "Cannot open more than one keyframe dialog at same time.")
QMessageBox.warning(self, PLUGIN_NAME, "Cannot open more than one keyframe dialog at same time.")
return

self.panel.setEnabled(False)
Expand Down
5 changes: 3 additions & 2 deletions procprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from processing.core.ProcessingConfig import ProcessingConfig, Setting

from .conf import PLUGIN_NAME
from .tools import pluginDir

QTO3_ACTIVE = "QGIS2THREEJS_ACTIVE"
Expand All @@ -20,10 +21,10 @@ def __init__(self):
self.algs = []

def id(self):
return "Qgis2threejs"
return PLUGIN_NAME

def name(self):
return "Qgis2threejs"
return PLUGIN_NAME

def icon(self):
return QIcon(pluginDir("Qgis2threejs.png"))
Expand Down
4 changes: 2 additions & 2 deletions proppages.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from .ui.pcproperties import Ui_PCPropertiesWidget

from . import q3dconst
from .conf import DEF_SETS
from .conf import DEF_SETS, PLUGIN_NAME
from .datamanager import MaterialManager
from .mapextent import MapExtent
from .pluginmanager import pluginManager
Expand Down Expand Up @@ -675,7 +675,7 @@ def removeMaterial(self):
if row >= 0:
item = self.listWidget_Materials.item(row)
msg = "Are you sure you want to remove material '{}'?".format(item.text())
if QMessageBox.question(self, "Qgis2threejs", msg) == QMessageBox.Yes:
if QMessageBox.question(self, PLUGIN_NAME, msg) == QMessageBox.Yes:
self.listWidget_Materials.takeItem(row)

def renameMtlItem(self):
Expand Down
3 changes: 2 additions & 1 deletion q3dtreeview.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from PyQt5.QtWidgets import QAction, QMenu, QMessageBox, QTreeView
from qgis.core import QgsApplication

from .conf import PLUGIN_NAME
from .q3dconst import LayerType, DEMMtlType
from .tools import hex_color

Expand Down Expand Up @@ -293,7 +294,7 @@ def removeAdditionalLayer(self, _=None):
if layer is None:
return

if QMessageBox.question(self, "Qgis2threejs", "Are you sure you want to remove the layer '{0}' from layer tree?".format(layer.name)) != QMessageBox.Yes:
if QMessageBox.question(self, PLUGIN_NAME, "Are you sure you want to remove the layer '{0}' from layer tree?".format(layer.name)) != QMessageBox.Yes:
return

self.iface.layerRemoved.emit(layer.layerId)
Expand Down
4 changes: 2 additions & 2 deletions q3dview.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
from PyQt5.QtGui import QImage, QPainter
from PyQt5.QtWidgets import QDialog, QFileDialog, QMessageBox, QVBoxLayout

from .conf import DEBUG_MODE
from .conf import DEBUG_MODE, PLUGIN_NAME
try:
from PyQt5.QtWebKit import QWebSettings, QWebSecurityOrigin
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
if DEBUG_MODE:
from PyQt5.QtWebKitWidgets import QWebInspector
except ModuleNotFoundError:
if os.name == "posix":
QMessageBox.warning(None, "Qgis2threejs", 'Missing dependencies related to PyQt5 and QtWebKit. Please install "python3-pyqt5.qtwebkit" package (Debian/Ubuntu) before using this plugin.')
QMessageBox.warning(None, PLUGIN_NAME, 'Missing dependencies related to PyQt5 and QtWebKit. Please install "python3-pyqt5.qtwebkit" package (Debian/Ubuntu) before using this plugin.')
raise

from .q3dconst import Script
Expand Down
4 changes: 2 additions & 2 deletions q3dwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
QDialog, QDialogButtonBox, QFileDialog, QMainWindow, QMenu, QMessageBox, QProgressBar)
from qgis.core import Qgis, QgsProject, QgsApplication

from .conf import DEBUG_MODE, RUN_CNTLR_IN_BKGND, PLUGIN_VERSION
from .conf import DEBUG_MODE, RUN_CNTLR_IN_BKGND, PLUGIN_NAME, PLUGIN_VERSION
from .exportsettings import ExportSettings
from .pluginmanager import pluginManager
from .proppages import ScenePropertyPage, DEMPropertyPage, VectorPropertyPage, PointCloudPropertyPage
Expand Down Expand Up @@ -394,7 +394,7 @@ def saveSettings(self):
self.lastDir = os.path.dirname(filename)

def clearSettings(self):
if QMessageBox.question(self, "Qgis2threejs", "Are you sure you want to clear export settings?") != QMessageBox.Yes:
if QMessageBox.question(self, PLUGIN_NAME, "Are you sure you want to clear export settings?") != QMessageBox.Yes:
return

self.ui.treeView.uncheckAll() # hide all 3D objects from the scene
Expand Down
11 changes: 5 additions & 6 deletions qgis2threejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from qgis.core import QgsApplication, QgsProject

from .conf import PLUGIN_NAME
from .exportsettings import ExportSettings
from .procprovider import Qgis2threejsProvider
from .tools import logMessage, pluginDir, removeTemporaryOutputDir
Expand Down Expand Up @@ -38,20 +39,18 @@ def initGui(self):
self.actionNP.triggered.connect(self.openExporterWithPreviewDisabled)

# add toolbar button and web menu items
name = "Qgis2threejs"
self.iface.addWebToolBarIcon(self.action)
self.iface.addPluginToWebMenu(name, self.action)
self.iface.addPluginToWebMenu(name, self.actionNP)
self.iface.addPluginToWebMenu(PLUGIN_NAME, self.action)
self.iface.addPluginToWebMenu(PLUGIN_NAME, self.actionNP)

# register processing provider
QgsApplication.processingRegistry().addProvider(self.pprovider)

def unload(self):
# remove the web menu items and icon
name = "Qgis2threejs"
self.iface.removeWebToolBarIcon(self.action)
self.iface.removePluginWebMenu(name, self.action)
self.iface.removePluginWebMenu(name, self.actionNP)
self.iface.removePluginWebMenu(PLUGIN_NAME, self.action)
self.iface.removePluginWebMenu(PLUGIN_NAME, self.actionNP)

# remove provider from processing registry
QgsApplication.processingRegistry().removeProvider(self.pprovider)
Expand Down
4 changes: 2 additions & 2 deletions tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from PyQt5.QtGui import QDesktopServices
from qgis.core import NULL, Qgis, QgsMapLayer, QgsMessageLog, QgsProject

from .conf import DEBUG_MODE
from .conf import DEBUG_MODE, PLUGIN_NAME


def getLayersInProject():
Expand Down Expand Up @@ -133,7 +133,7 @@ def createUid():

def logMessage(message, warning=True, error=False):
level = Qgis.Critical if error else (Qgis.Warning if warning else Qgis.Info)
QgsMessageLog.logMessage(str(message), "Qgis2threejs", level, warning or error)
QgsMessageLog.logMessage(str(message), PLUGIN_NAME, level, warning or error)


def shortTextFromSelectedLayerIds(layerIds):
Expand Down

0 comments on commit 3f5ae08

Please sign in to comment.