open files by drag&drop
This commit is contained in:
13
main.py
13
main.py
@@ -8,11 +8,13 @@ from PyQt6.QtCore import *
|
||||
from PyQt6.QtGui import *
|
||||
import sys
|
||||
|
||||
import urlutils
|
||||
from aboutdialog import AboutDialog
|
||||
from ravenui import RavenUI
|
||||
from settings import Settings
|
||||
from settingsstore import SettingsStore
|
||||
from tabs import Tabs
|
||||
from urlutils import url_is_file
|
||||
|
||||
MAX_LINE_LENGTH = 4096
|
||||
|
||||
@@ -28,6 +30,7 @@ class MainWindow(QMainWindow):
|
||||
self.setWindowTitle(self.tr("RavenLog"))
|
||||
self.setGeometry(0, 0, 640, 480)
|
||||
self.setDockNestingEnabled(True)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
self.tabs = Tabs(self.settings)
|
||||
self.tabs.create_tab("/home/andi/ws/performanceDb/data/production/logs_2018-09-06_2018-09-06.csv")
|
||||
@@ -121,6 +124,16 @@ class MainWindow(QMainWindow):
|
||||
self.settings.set_session('general', 'recent_files', recent_files)
|
||||
self._update_recent_files_menu()
|
||||
|
||||
def dragEnterEvent(self, e: QDragEnterEvent):
|
||||
if e.mimeData().hasFormat('text/plain') and url_is_file(e.mimeData().text()):
|
||||
e.accept()
|
||||
else:
|
||||
e.ignore()
|
||||
|
||||
def dropEvent(self, e):
|
||||
file = urlutils.url_to_path(e.mimeData().text())
|
||||
self._open_file(file)
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.destruct()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user