Skip to content

Commit

Permalink
Added DependencyErrorDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
faggionluca committed Sep 26, 2020
1 parent 8d492ac commit edcc1e0
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions megascan_link_python/dialogs.py
Expand Up @@ -5,16 +5,18 @@
"""

import importlib
import webbrowser

import PySide2
from PySide2 import QtWidgets, QtGui, QtCore
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtCore import Qt

from .ui import settings_dialog, icon, painterslider
from . import config, log, sockets
from .ui import error_dialog, icon, painterslider, settings_dialog

importlib.reload(settings_dialog)
importlib.reload(painterslider)
importlib.reload(error_dialog)

class SettingsDialog(QtWidgets.QDialog, settings_dialog.Ui_Dialog):
"""Dialog displayed to the user for editing the plugin settings
Expand Down Expand Up @@ -104,3 +106,44 @@ def _saveSettings(self):
self._socketRef.restart()
self.close()


class DependencyErrorDialog(QtWidgets.QDialog, error_dialog.Ui_Dialog):
"""
Generic Error dialog for displaying error messages
"""
def __init__(self, parent, helpLink = None):
super().__init__(parent=parent)
self.helpLink = helpLink
self.setupUi(self)
self.descriptionLabel.setOpenExternalLinks(True)
for btn in self.buttonBox.buttons():
if (btn.text() == "Help"):
btn.setFocus()
btn.clicked.connect(self.openHelp)
else:
btn.clicked.connect(self.close)

def close(self):
"""
Close the dialog and updates the ini file if necessary
"""
dontShowAgainState = True if self.dontShowAgain.checkState() != Qt.CheckState.Checked else False
config.ConfigSettings.updateConfigSetting("General", "showDependencyError", dontShowAgainState, False)
config.ConfigSettings.flush()
super().close()

def show(self):
"""
Shows the error dialog only if the users has not checked before the "don't show again" checkbox
"""
if (config.ConfigSettings.checkIfOptionIsSet("General", "showDependencyError", 'True')):
super().show()

def openHelp(self):
"""
Summon a browser with the documentation page opened
"""
if (self.helpLink):
webbrowser.open(self.helpLink)
else:
self.close()

0 comments on commit edcc1e0

Please sign in to comment.