mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-17 19:32:30 +12:00
Add drag and drop functionality for outline items to editors
This commit is contained in:
parent
48af930b11
commit
22609fa1fd
|
@ -4,6 +4,7 @@ import locale
|
|||
|
||||
from PyQt5.QtCore import QModelIndex, QRect, QPoint, Qt, QObject, QSize
|
||||
from PyQt5.QtGui import QIcon, QPalette
|
||||
from PyQt5.QtGui import QDropEvent, QDragEnterEvent
|
||||
from PyQt5.QtWidgets import QWidget, QPushButton, qApp
|
||||
|
||||
from manuskript.functions import mainWindow, appPath
|
||||
|
@ -80,6 +81,19 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
self.tab.currentChanged.connect(self.mainEditor.tabChanged)
|
||||
qApp.focusChanged.connect(self.focusChanged)
|
||||
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
def dragEnterEvent(self, event: QDragEnterEvent) -> None:
|
||||
if event.mimeData().hasFormat('application/xml'):
|
||||
event.accept()
|
||||
else:
|
||||
event.ignore()
|
||||
|
||||
def dropEvent(self, event: QDropEvent) -> None:
|
||||
itemID = mainWindow().mdlOutline.decodeMimeData(event.mimeData())[0].ID()
|
||||
itemIndex = mainWindow().mdlOutline.getIndexByID(itemID)
|
||||
self.mainEditor.setCurrentModelIndex(itemIndex, tabWidget = self.tab)
|
||||
|
||||
def updateStyleSheet(self):
|
||||
self.setStyleSheet(style.mainEditorTabSS())
|
||||
if self.secondTab:
|
||||
|
|
Loading…
Reference in a new issue