Skip to content

Commit

Permalink
staytop
Browse files Browse the repository at this point in the history
  • Loading branch information
ZITOUNI Clement committed Apr 20, 2023
1 parent ebd141e commit ede7392
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
Binary file added __pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/resources.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/simple_ban.cpython-39.pyc
Binary file not shown.
Binary file added __pycache__/simple_ban_dialog.cpython-39.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ category=Plugins
icon=icon.png
experimental=False
deprecated=False
keep_dialog_on_top=True
4 changes: 2 additions & 2 deletions simple_ban.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os.path
import json


class AdressesFr:

def __init__(self, iface):
Expand Down Expand Up @@ -77,9 +78,8 @@ def closeEvent(self, event):
self.deleteMarker()

def run(self):
self.dlg = SimbleBanDialog()
self.dlg = SimbleBanDialog(self.iface)
self.dlg.rejected.connect(self.deleteMarker)
# self.dlg.setWindowFlags(Qt.WindowStaysOnTopHint)
self.manager = QNetworkAccessManager()
self.completer = QCompleter(['', '', '', '', ''])
self.completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
Expand Down
24 changes: 22 additions & 2 deletions simple_ban_dialog.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
import os
from qgis.PyQt import uic
from qgis.PyQt import QtWidgets
from qgis.PyQt.QtCore import QObject, QEvent, Qt
from qgis.gui import QgisInterface

FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'simple_ban_dialog_base.ui'))

class StayOnTopEventFilter(QObject):
def __init__(self, dialog, qgis_main_window):
super(StayOnTopEventFilter, self).__init__()
self.dialog = dialog
self.qgis_main_window = qgis_main_window

def eventFilter(self, watched, event):
if watched == self.qgis_main_window and event.type() == QEvent.WindowActivate:
if self.dialog.isVisible() and not self.dialog.isActiveWindow():
self.dialog.raise_()
return super(StayOnTopEventFilter, self).eventFilter(watched, event)

class SimbleBanDialog(QtWidgets.QDialog, FORM_CLASS):
def __init__(self, parent=None):
def __init__(self, iface: QgisInterface, parent=None):
super(SimbleBanDialog, self).__init__(parent)
self.setupUi(self)
self.setupUi(self)
self.iface = iface
self.event_filter = StayOnTopEventFilter(self, iface.mainWindow())
self.iface.mainWindow().installEventFilter(self.event_filter)

0 comments on commit ede7392

Please sign in to comment.