Skip to content

Commit

Permalink
Merge branch 'devel'
Browse files Browse the repository at this point in the history
# Conflicts:
#	.idea/workspace.xml
  • Loading branch information
SanPen committed Dec 16, 2024
2 parents 0c85eda + 559eadd commit f6dd7da
Show file tree
Hide file tree
Showing 15 changed files with 573 additions and 407 deletions.
6 changes: 3 additions & 3 deletions src/GridCal/Gui/Main/ConsoleLog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'ConsoleLog.ui'
##
## Created by: Qt User Interface Compiler version 6.7.2
## Created by: Qt User Interface Compiler version 6.6.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand All @@ -28,7 +28,7 @@ def setupUi(self, mainWindow):
mainWindow.resize(516, 327)
mainWindow.setBaseSize(QSize(0, 0))
icon = QIcon()
icon.addFile(u":/Program icon/GridCal_icon.svg", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
icon.addFile(u":/Program icon/GridCal_icon.svg", QSize(), QIcon.Normal, QIcon.Off)
mainWindow.setWindowIcon(icon)
mainWindow.setIconSize(QSize(24, 24))
mainWindow.setDocumentMode(False)
Expand All @@ -37,7 +37,7 @@ def setupUi(self, mainWindow):
self.actionSave = QAction(mainWindow)
self.actionSave.setObjectName(u"actionSave")
icon1 = QIcon()
icon1.addFile(u":/Icons/icons/savec.svg", QSize(), QIcon.Mode.Normal, QIcon.State.Off)
icon1.addFile(u":/Icons/icons/savec.svg", QSize(), QIcon.Normal, QIcon.Off)
self.actionSave.setIcon(icon1)
self.centralwidget = QWidget(mainWindow)
self.centralwidget.setObjectName(u"centralwidget")
Expand Down
256 changes: 128 additions & 128 deletions src/GridCal/Gui/Main/MainWindow.py

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions src/GridCal/Gui/Main/SubClasses/Settings/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,11 @@ def add_plugins(self):
during the iteration and not after the loop
- func(self) is then what I wanted to lambda in the first place
"""
# func = plugin_info.main_fcn.function_ptr
# lmbd = lambda e, func=func: func(self) # This is not an error, it is correct

action = add_menu_entry(
add_menu_entry(
menu=self.ui.menuplugins,
text=plugin_info.name,
icon_path=":/Icons/icons/plugin.svg",
icon_pixmap=plugin_info.icon,
# function_ptr=plugin_info.main_fcn.get_pointer_lambda(gui_instance=self)
function_ptr=lambda: self.launch_plugin(plugin_info.main_fcn)
)

Expand All @@ -473,14 +469,15 @@ def add_plugins(self):

def launch_plugin(self, fcn: PluginFunction):
"""
:param fcn:
:return:
Action wrapper to launch the plugin
:param fcn: some PluginFunction
"""

# call the main fuinction of the plugin
ret = fcn.get_pointer_lambda(gui_instance=self)()

if fcn.call_gui and ret is not None:
self.plugin_windows_list.append(ret)
ret.show()
print("Plugin show...")
if hasattr(ret, "show"):
self.plugin_windows_list.append(ret) # This avoids the window to be garbage collected and be displayed
ret.show()

38 changes: 36 additions & 2 deletions src/GridCal/Gui/Main/SubClasses/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import GridCal.Gui.gui_functions as gf
import GridCal.Session.export_results_driver as exprtdrv
import GridCal.Session.file_handler as filedrv

from GridCal.plugins import install_plugin, get_plugin_info
from GridCal.Gui.CoordinatesInput.coordinates_dialogue import CoordinatesInputGUI
from GridCal.Gui.general_dialogues import LogsDialogue, CustomQuestionDialogue
from GridCal.Gui.Diagrams.SchematicWidget.schematic_widget import SchematicWidget
Expand Down Expand Up @@ -53,7 +53,8 @@ def __init__(self, parent=None):
self.accepted_extensions = ['.gridcal', '.dgridcal', '.xlsx', '.xls', '.sqlite', '.gch5',
'.dgs', '.m', '.raw', '.RAW', '.json',
'.ejson2', '.ejson3',
'.xml', '.rawx', '.zip', '.dpx', '.epc', '.EPC']
'.xml', '.rawx', '.zip', '.dpx', '.epc', '.EPC',
'.gcplugin']

self.cgmes_version_dict = {x.value: x for x in [CGMESVersions.v2_4_15,
CGMESVersions.v3_0_0]}
Expand Down Expand Up @@ -137,6 +138,9 @@ def dropEvent(self, event):

if file_name.endswith('.dgridcal'):
any_grid_delta = True
elif file_name.endswith('.gcplugin'):
self.install_plugin_now(file_name)
return
else:
any_normal_grid = True

Expand Down Expand Up @@ -425,6 +429,36 @@ def post_open_file(self) -> None:
self.get_circuit_snapshot_datetime()
self.change_theme_mode()

def install_plugin_now(self, fname: str):
"""
Install plugin
:param fname: name of the plugin
"""
if fname.endswith('.gcplugin'):
info = get_plugin_info(fname)

if info is not None:
found = False
for key, plugin in self.plugins_info.plugins.items():
if plugin.name == info.name:
found = True

if found:
ok = yes_no_question( f"There is a plugin already: "
f"{plugin.name} {plugin.version} "
f"The new plugin is {info.version}. "
f"Install?", "Plugin install")
if not ok:
return

install_plugin(fname)
self.add_plugins()
info_msg(f"{info.name} {info.version} installed!", "Plugin install")
else:
error_msg("There is no manifest :(", "Plugin install")
else:
error_msg("Does not seem to be a plugin :/", "Plugin install")

def select_csv_file(self, caption='Open CSV file'):
"""
Select a CSV file
Expand Down
Loading

0 comments on commit f6dd7da

Please sign in to comment.