Firstly I must admit I have never really delved into Actions before now, so based on discussions in comments below and my own experimentations, I have heavily revised my original answer.
My test layer contains overlapping polygons. A sample of the attribute table looks like this:

For what it's worth, I can get the files to load as a Python action using the following code snippet in the action editor:
from qgis.utils import iface
layer_id = '[%@layer_id%]'
fid = [%$id%]
layer_obj = QgsProject().instance().mapLayer(layer_id)
feat = layer_obj.getFeature(fid)
path = feat['Path']
iface.addVectorLayer(path, '', 'ogr')
The Action settings looks like this:

Result:

However, I have not yet found any way to show the filenames instead of feature ids in the pop up list which shows when you click on overlapping features.
Given that, I would suggest implementing a custom map tool which subclasses QgsMapToolIdentifyFeature
.
Try copying the script below into an editor in the Python console.
*Note- you just have to change the following line. Replace 'Layer_Name'
with the name of your overlapping polygon layer. The script will set this layer as active and ensure that the custom identify tool only identifies features in this layer. This will avoid any errors which would occur if features were identified from other layers which didn't contain a field called 'FileName'.
self.lyr = QgsProject().instance().mapLayersByName('Layer_Name')[0]
Once you have done that, simply run the script.
To deactivate the tool, just select a different map tool from the toolbar.
You can save this script locally as a .py
file so you can load and run it from the console anytime you like. You could also make it a plugin easily enough.
class LoadLayerTool(QgsMapToolIdentifyFeature):
def __init__(self, canvas):
self.canvas = canvas
self.lyr = QgsProject().instance().mapLayersByName('Layer_Name')[0] # change to name of your polygon layer
iface.setActiveLayer(self.lyr)
self.vlayer = iface.activeLayer()
self.ids = None
QgsMapToolIdentifyFeature.__init__(self, self.canvas)
self.setLayer(self.vlayer)
def canvasPressEvent(self, event):
results = self.identify(event.x(), event.y())
self.ids = [f.mFeature.id() for f in results]
if self.ids:
self.W = Dlg(self.vlayer, self.ids)
self.W.show()
self.W.setGeometry(event.x(), event.y(), 300, 100)
class Dlg(QDialog):
def __init__(self, layer, ids):
self.layer = layer
self.ids = ids
QDialog.__init__(self)
self.layout = QVBoxLayout(self)
self.cb1 = QComboBox(self)
self.btn1 = QPushButton('Load File as vector layer', self)
self.layout.addWidget(self.cb1)
self.layout.addWidget(self.btn1)
self.layer = iface.activeLayer()
self.file_names = []
for f in self.layer.getFeatures(self.ids):
self.file_names.append(str(f['FileName']))
self.cb1.addItems(self.file_names)
self.btn1.clicked.connect(self.load_layer)
def load_layer(self):
fpath = []
for f in self.layer.getFeatures():
if f['FileName'] == self.cb1.currentText():
fpath.append(f['Path'])
iface.addVectorLayer(fpath[0], '', 'ogr')
iface.setActiveLayer(self.layer)
self.close()
c = iface.mapCanvas()
t = LoadLayerTool(c)
c.setMapTool(t)
Result:
