mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-14 18:02:23 +12:00
tabSplitter allows target.
This commit is contained in:
parent
a77e6fc79f
commit
e90e9f9cc4
7
icons/NumixMsk/256x256/actions/set-target.svg
Normal file
7
icons/NumixMsk/256x256/actions/set-target.svg
Normal file
|
@ -0,0 +1,7 @@
|
|||
<svg width="256" xmlns="http://www.w3.org/2000/svg" height="256" viewBox="0 0 256 256" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<path style="fill:#268bd2" d="M 50.464844 15.996094 L 205.535156 15.996094 C 224.570312 15.996094 240 31.425781 240 50.460938 L 240 205.53125 C 240 224.566406 224.570312 239.996094 205.535156 239.996094 L 50.464844 239.996094 C 31.429688 239.996094 16 224.566406 16 205.53125 L 16 50.460938 C 16 31.425781 31.429688 15.996094 50.464844 15.996094 Z "/>
|
||||
<g style="fill-opacity:.902;fill:#fff">
|
||||
<path d="M 48 48 L 48 112 L 64 112 L 64 64 L 112 64 L 112 48 Z M 144 48 L 144 64 L 192 64 L 192 112 L 208 112 L 208 48 Z M 48 144 L 48 208 L 112 208 L 112 192 L 64 192 L 64 144 Z M 192 144 L 192 192 L 144 192 L 144 208 L 208 208 L 208 144 Z "/>
|
||||
<path d="M 80 80 L 80 176 L 176 176 L 176 80 Z M 96 96 L 160 96 L 160 160 L 96 160 Z "/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 869 B |
|
@ -325,6 +325,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
|
||||
self.mainEditor.setFolderView(settings.folderView)
|
||||
self.mainEditor.updateFolderViewButtons(settings.folderView)
|
||||
self.mainEditor.tabSplitter.updateStyleSheet()
|
||||
self.tabMain.setCurrentIndex(settings.lastTab)
|
||||
# We force to emit even if it opens on the current tab
|
||||
self.tabMain.currentChanged.emit(settings.lastTab)
|
||||
|
@ -659,17 +660,12 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
# self.redacEditor.setModel(self.mdlOutline)
|
||||
self.storylineView.setModels(self.mdlOutline, self.mdlCharacter, self.mdlPlots)
|
||||
|
||||
self.treeOutlineOutline.selectionModel().selectionChanged.connect(lambda:
|
||||
self.outlineItemEditor.selectionChanged(
|
||||
self.treeOutlineOutline), AUC)
|
||||
self.treeOutlineOutline.clicked.connect(lambda:
|
||||
self.outlineItemEditor.selectionChanged(self.treeOutlineOutline), AUC)
|
||||
self.treeOutlineOutline.selectionModel().selectionChanged.connect(self.outlineItemEditor.selectionChanged, AUC)
|
||||
self.treeOutlineOutline.clicked.connect(self.outlineItemEditor.selectionChanged, AUC)
|
||||
|
||||
# Sync selection
|
||||
self.treeRedacOutline.selectionModel().selectionChanged.connect(
|
||||
lambda: self.redacMetadata.selectionChanged(self.treeRedacOutline), AUC)
|
||||
self.treeRedacOutline.clicked.connect(
|
||||
lambda: self.redacMetadata.selectionChanged(self.treeRedacOutline), AUC)
|
||||
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.redacMetadata.selectionChanged, AUC)
|
||||
self.treeRedacOutline.clicked.connect(self.redacMetadata.selectionChanged, AUC)
|
||||
|
||||
self.treeRedacOutline.selectionModel().selectionChanged.connect(self.mainEditor.selectionChanged, AUC)
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ from manuskript import settings
|
|||
from manuskript.enums import Outline
|
||||
from manuskript.functions import allPaths, iconColor, writablePath, appPath, findWidgetsOfClass
|
||||
from manuskript.functions import mainWindow
|
||||
from manuskript.ui.editors.tabSplitter import tabSplitter
|
||||
from manuskript.ui.editors.themes import createThemePreview
|
||||
from manuskript.ui.editors.themes import getThemeName
|
||||
from manuskript.ui.editors.themes import loadThemeDatas
|
||||
|
@ -398,6 +399,10 @@ class settingsWindow(QWidget, Ui_Settings):
|
|||
for w in mainWindow().findChildren(textEditView, QRegExp(".*")):
|
||||
w.loadFontSettings()
|
||||
|
||||
# Update background color in all tabSplitter (tabs)
|
||||
for w in mainWindow().findChildren(tabSplitter, QRegExp(".*")):
|
||||
w.updateStyleSheet()
|
||||
|
||||
def choseEditorFontColor(self):
|
||||
color = settings.textEditor["fontColor"]
|
||||
self.colorDialog = QColorDialog(QColor(color), self)
|
||||
|
|
|
@ -166,10 +166,12 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
self.stack.setCurrentIndex(2)
|
||||
self.corkView.setModel(self.mw.mdlOutline)
|
||||
self.corkView.setRootIndex(self.currentIndex)
|
||||
self.corkView.selectionModel().selectionChanged.connect(
|
||||
lambda: mainWindow().redacMetadata.selectionChanged(self.corkView), AUC)
|
||||
self.corkView.clicked.connect(
|
||||
lambda: mainWindow().redacMetadata.selectionChanged(self.corkView), AUC)
|
||||
try:
|
||||
self.corkView.selectionModel().selectionChanged.connect(mainWindow().redacMetadata.selectionChanged, AUC)
|
||||
self.corkView.clicked.connect(mainWindow().redacMetadata.selectionChanged, AUC)
|
||||
self.corkView.clicked.connect(mainWindow().mainEditor.updateTargets, AUC)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
elif item and item.isFolder() and self.folderView == "outline":
|
||||
self.stack.setCurrentIndex(3)
|
||||
|
@ -178,10 +180,13 @@ class editorWidget(QWidget, Ui_editorWidget_ui):
|
|||
self.outlineView.setModelStatus(mainWindow().mdlStatus)
|
||||
self.outlineView.setModel(self.mw.mdlOutline)
|
||||
self.outlineView.setRootIndex(self.currentIndex)
|
||||
self.outlineView.selectionModel().selectionChanged.connect(
|
||||
lambda: mainWindow().redacMetadata.selectionChanged(self.outlineView), AUC)
|
||||
self.outlineView.clicked.connect(
|
||||
lambda: mainWindow().redacMetadata.selectionChanged(self.outlineView), AUC)
|
||||
|
||||
try:
|
||||
self.outlineView.selectionModel().selectionChanged.connect(mainWindow().redacMetadata.selectionChanged, AUC)
|
||||
self.outlineView.clicked.connect(mainWindow().redacMetadata.selectionChanged, AUC)
|
||||
self.outlineView.clicked.connect(mainWindow().mainEditor.updateTargets, AUC)
|
||||
except TypeError:
|
||||
pass
|
||||
|
||||
else:
|
||||
self.txtRedacText.setCurrentModelIndex(self.currentIndex)
|
||||
|
|
|
@ -45,9 +45,15 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
|
||||
# self.tab.setDocumentMode(False)
|
||||
|
||||
self.btnRedacFolderCork.setIcon(QIcon.fromTheme("view-cards"))
|
||||
self.btnRedacFolderOutline.setIcon(QIcon.fromTheme("view-outline"))
|
||||
self.btnRedacFolderText.setIcon(QIcon.fromTheme("view-text"))
|
||||
# Bug in Qt < 5.5: doesn't always load icons from custom theme.
|
||||
# Cf. https://github.com/qtproject/qtbase/commit/a8621a3f85e64f1252a80ae81a6e22554f7b3f44
|
||||
# Since those are important, we provide fallback.
|
||||
self.btnRedacFolderCork.setIcon(QIcon.fromTheme("view-cards",
|
||||
QIcon("../icons/NumixMsk/256x256/actions/view-cards.svg")))
|
||||
self.btnRedacFolderOutline.setIcon(QIcon.fromTheme("view-outline",
|
||||
QIcon("../icons/NumixMsk/256x256/actions/view-outline.svg")))
|
||||
self.btnRedacFolderText.setIcon(QIcon.fromTheme("view-text",
|
||||
QIcon("../icons/NumixMsk/256x256/actions/view-text.svg")))
|
||||
|
||||
for btn in [self.btnRedacFolderCork, self.btnRedacFolderText, self.btnRedacFolderOutline]:
|
||||
btn.setToolTip(btn.text())
|
||||
|
@ -66,8 +72,10 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
else:
|
||||
ts = ts.secondTab
|
||||
|
||||
def currentEditor(self):
|
||||
return self.currentTabWidget().currentWidget()
|
||||
def currentEditor(self, tabWidget=None):
|
||||
if tabWidget is None:
|
||||
tabWidget = self.currentTabWidget()
|
||||
return tabWidget.currentWidget()
|
||||
# return self.tab.currentWidget()
|
||||
|
||||
def tabChanged(self, index=QModelIndex()):
|
||||
|
@ -78,13 +86,16 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
else:
|
||||
index = QModelIndex()
|
||||
|
||||
self._updating = True
|
||||
self.mw.treeRedacOutline.setCurrentIndex(index)
|
||||
self._updating = False
|
||||
self.updateMainTreeView(index)
|
||||
|
||||
self.updateStats()
|
||||
self.updateThingsVisible(index)
|
||||
|
||||
def updateMainTreeView(self, index):
|
||||
self._updating = True
|
||||
self.mw.treeRedacOutline.setCurrentIndex(index)
|
||||
self._updating = False
|
||||
|
||||
def closeAllTabs(self):
|
||||
for ts in self.allTabSplitters():
|
||||
while(ts.tab.count()):
|
||||
|
@ -130,24 +141,23 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
idx = self.mw.treeRedacOutline.currentIndex()
|
||||
|
||||
self.setCurrentModelIndex(idx)
|
||||
|
||||
self.updateThingsVisible(idx)
|
||||
|
||||
def openIndexes(self, indexes, newTab=False):
|
||||
for i in indexes:
|
||||
self.setCurrentModelIndex(i, newTab)
|
||||
|
||||
def setCurrentModelIndex(self, index, newTab=False):
|
||||
def setCurrentModelIndex(self, index, newTab=False, tabWidget=None):
|
||||
|
||||
if not index.isValid():
|
||||
title = self.tr("Root")
|
||||
else:
|
||||
title = index.internalPointer().title()
|
||||
title = self.getIndexTitle(index)
|
||||
|
||||
if tabWidget is None:
|
||||
tabWidget = self.currentTabWidget()
|
||||
|
||||
# Checking if tab is already openned
|
||||
for w in self.allTabs():
|
||||
for w in self.allTabs(tabWidget):
|
||||
if w.currentIndex == index:
|
||||
self.currentTabWidget().setCurrentWidget(w)
|
||||
tabWidget.setCurrentWidget(w)
|
||||
return
|
||||
|
||||
if qApp.keyboardModifiers() & Qt.ControlModifier:
|
||||
|
@ -156,11 +166,29 @@ class mainEditor(QWidget, Ui_mainEditor):
|
|||
if newTab or not self.currentTabWidget().count():
|
||||
editor = editorWidget(self)
|
||||
editor.setCurrentModelIndex(index)
|
||||
self.currentTabWidget().addTab(editor, title)
|
||||
self.currentTabWidget().setCurrentIndex(self.currentTabWidget().count() - 1)
|
||||
tabWidget.addTab(editor, title)
|
||||
tabWidget.setCurrentIndex(self.currentTabWidget().count() - 1)
|
||||
else:
|
||||
self.currentEditor().setCurrentModelIndex(index)
|
||||
self.currentTabWidget().setTabText(self.currentTabWidget().currentIndex(), title)
|
||||
self.currentEditor(tabWidget).setCurrentModelIndex(index)
|
||||
tabWidget.setTabText(tabWidget.currentIndex(), title)
|
||||
|
||||
def updateTargets(self):
|
||||
"""Updates all tabSplitter that are targets. This is called from editorWidget."""
|
||||
index = self.sender().currentIndex()
|
||||
|
||||
for ts in self.allTabSplitters():
|
||||
if ts.isTarget:
|
||||
self.updateMainTreeView(index)
|
||||
self.setCurrentModelIndex(index, tabWidget=ts.tab)
|
||||
self.updateThingsVisible(index)
|
||||
|
||||
def getIndexTitle(self, index):
|
||||
if not index.isValid():
|
||||
title = self.tr("Root")
|
||||
else:
|
||||
title = index.internalPointer().title()
|
||||
|
||||
return title
|
||||
|
||||
###############################################################################
|
||||
# UI
|
||||
|
|
|
@ -15,16 +15,13 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
def __init__(self, parent=None, mainEditor=None):
|
||||
QWidget.__init__(self, parent)
|
||||
self.setupUi(self)
|
||||
self.setStyleSheet(style.mainEditorTabSS())
|
||||
|
||||
try:
|
||||
self.tab.setTabBarAutoHide(True)
|
||||
except AttributeError:
|
||||
print("Info: install Qt 5.4 or higher to use tabbar auto-hide in editor.")
|
||||
|
||||
#Remove empty widget
|
||||
# self.splitter.widget(1).setParent(None)
|
||||
# try:
|
||||
# self.tab.setTabBarAutoHide(True)
|
||||
# except AttributeError:
|
||||
# print("Info: install Qt 5.4 or higher to use tabbar auto-hide in editor.")
|
||||
|
||||
# Button to split
|
||||
self.btnSplit = QPushButton(self)
|
||||
self.btnSplit.setGeometry(QRect(0, 0, 24, 24))
|
||||
self.btnSplit.setMinimumSize(QSize(24, 24))
|
||||
|
@ -33,20 +30,38 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
self.btnSplit.setFlat(True)
|
||||
self.btnSplit.setObjectName("btnSplit")
|
||||
self.btnSplit.installEventFilter(self)
|
||||
self.btnSplit.clicked.connect(self.split)
|
||||
|
||||
# Button to set target
|
||||
self.isTarget = False
|
||||
self.btnTarget = QPushButton(QIcon.fromTheme("set-target"), "", self)
|
||||
self.btnTarget.setGeometry(QRect(25, 0, 24, 24))
|
||||
self.btnTarget.setMinimumSize(QSize(24, 24))
|
||||
self.btnTarget.setMaximumSize(QSize(24, 24))
|
||||
# self.btnTarget.setCheckable(True)
|
||||
self.btnTarget.setFlat(True)
|
||||
self.btnTarget.setObjectName("btnTarget")
|
||||
self.btnTarget.clicked.connect(self.setTarget)
|
||||
self.updateTargetIcon(self.isTarget)
|
||||
|
||||
self.mainEditor = mainEditor or parent
|
||||
|
||||
self.btnSplit.clicked.connect(self.split)
|
||||
self.secondTab = None
|
||||
self.splitState = 0
|
||||
self.focusTab = 1
|
||||
self.closeSplit()
|
||||
|
||||
self.updateStyleSheet()
|
||||
|
||||
self.tab.tabCloseRequested.connect(self.closeTab)
|
||||
self.tab.currentChanged.connect(self.mainEditor.tabChanged)
|
||||
|
||||
qApp.focusChanged.connect(self.focusChanged)
|
||||
|
||||
def updateStyleSheet(self):
|
||||
self.setStyleSheet(style.mainEditorTabSS())
|
||||
if self.secondTab:
|
||||
self.secondTab.updateStyleSheet()
|
||||
|
||||
###############################################################################
|
||||
# TABS
|
||||
###############################################################################
|
||||
|
@ -90,6 +105,20 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
print("Failed to load indexes from settings...")
|
||||
print("Indexes:", openIndexes)
|
||||
|
||||
###############################################################################
|
||||
# TARGET
|
||||
###############################################################################
|
||||
|
||||
def setTarget(self):
|
||||
self.isTarget = not self.isTarget
|
||||
self.updateTargetIcon(self.isTarget)
|
||||
|
||||
def updateTargetIcon(self, val):
|
||||
icon = QIcon.fromTheme("set-target", QIcon("../icons/NumixMsk/256x256/actions/set-target.svg"))
|
||||
if not val:
|
||||
icon = QIcon(icon.pixmap(128, 128, icon.Disabled))
|
||||
self.btnTarget.setIcon(icon)
|
||||
|
||||
###############################################################################
|
||||
# SPLITTER
|
||||
###############################################################################
|
||||
|
@ -150,6 +179,9 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
self.btnSplit.setIcon(QIcon.fromTheme("split-close"))
|
||||
self.btnSplit.setToolTip(self.tr("Split vertically"))
|
||||
|
||||
if len(l):
|
||||
self.mainEditor.tabChanged()
|
||||
|
||||
# def resizeEvent(self, event):
|
||||
# r = self.geometry()
|
||||
# r.moveLeft(0)
|
||||
|
@ -178,7 +210,7 @@ class tabSplitter(QWidget, Ui_tabSplitter):
|
|||
def eventFilter(self, object, event):
|
||||
if object == self.btnSplit and event.type() == event.HoverEnter:
|
||||
self.setAutoFillBackground(True)
|
||||
self.setBackgroundRole(QPalette.Midlight)
|
||||
self.setBackgroundRole(QPalette.Highlight)
|
||||
elif object == self.btnSplit and event.type() == event.HoverLeave:
|
||||
self.setAutoFillBackground(False)
|
||||
self.setBackgroundRole(QPalette.Window)
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
|
||||
|
||||
# default window color (linux):
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtGui import QColor, QPalette
|
||||
from PyQt5.QtWidgets import qApp
|
||||
|
||||
window = "#d6d2d0" #"#eee"
|
||||
from manuskript import settings
|
||||
|
||||
window = "#d6d2d0" #"#eee" / #eff0f1
|
||||
|
||||
bgHover = "#ccc"
|
||||
bgChecked = "#bbb"
|
||||
|
@ -51,6 +54,24 @@ def appPalette():
|
|||
# p.setColor(p.Base, QColor("#FFF"))
|
||||
return p
|
||||
|
||||
# dark_palette = QPalette()
|
||||
# dark_palette.setColor(QPalette.Window, QColor(53, 53, 53))
|
||||
# dark_palette.setColor(QPalette.WindowText, Qt.white)
|
||||
# dark_palette.setColor(QPalette.Base, QColor(25, 25, 25))
|
||||
# dark_palette.setColor(QPalette.AlternateBase, QColor(53, 53, 53))
|
||||
# dark_palette.setColor(QPalette.ToolTipBase, Qt.white)
|
||||
# dark_palette.setColor(QPalette.ToolTipText, Qt.white)
|
||||
# dark_palette.setColor(QPalette.Text, Qt.white)
|
||||
# dark_palette.setColor(QPalette.Button, QColor(53, 53, 53))
|
||||
# dark_palette.setColor(QPalette.ButtonText, Qt.white)
|
||||
# dark_palette.setColor(QPalette.BrightText, Qt.red)
|
||||
# dark_palette.setColor(QPalette.Link, QColor(42, 130, 218))
|
||||
# dark_palette.setColor(QPalette.Highlight, QColor(42, 130, 218))
|
||||
# dark_palette.setColor(QPalette.HighlightedText, Qt.black)
|
||||
# qApp.setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }")
|
||||
#
|
||||
# return dark_palette
|
||||
|
||||
|
||||
def collapsibleGroupBoxButton():
|
||||
s1 = """
|
||||
|
@ -85,58 +106,61 @@ def collapsibleGroupBoxButton():
|
|||
|
||||
def mainEditorTabSS():
|
||||
return """
|
||||
QTabWidget::pane{
|
||||
QTabWidget::pane{{
|
||||
margin-top: -1px;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
QTabWidget::tab-bar{
|
||||
left:25px;
|
||||
}
|
||||
QTabBar{
|
||||
}}
|
||||
QTabWidget::tab-bar{{
|
||||
left:50px;
|
||||
}}
|
||||
QTabBar{{
|
||||
background: transparent;
|
||||
border-radius: 0;
|
||||
border: 0px;
|
||||
}
|
||||
QTabBar::tab{
|
||||
}}
|
||||
QTabBar::tab{{
|
||||
margin: 2px 0 0 0;
|
||||
padding: 2px 9px;
|
||||
border: 1px solid #999;
|
||||
border-bottom: 0px;
|
||||
margin-top: 3px;
|
||||
}
|
||||
QTabBar::tab:selected{
|
||||
}}
|
||||
QTabBar::tab:selected{{
|
||||
border: 1px solid #999;
|
||||
background: white;
|
||||
background: {bgColor};
|
||||
border-bottom: 0px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
QTabBar::tab:!selected:hover{
|
||||
color: {foreground};
|
||||
}}
|
||||
QTabBar::tab:!selected:hover{{
|
||||
background:#ddd;
|
||||
}
|
||||
}}
|
||||
|
||||
QScrollBar:vertical {
|
||||
border: none;
|
||||
background: transparent;
|
||||
width: 10px;
|
||||
}
|
||||
QScrollBar::handle {
|
||||
background: rgba(180, 180, 180, 40%);
|
||||
}
|
||||
QScrollBar::add-line:vertical {
|
||||
width:0;
|
||||
height: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
QScrollBar::sub-line:vertical {
|
||||
width:0;
|
||||
height: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}
|
||||
|
||||
"""
|
||||
QScrollBar:vertical {{
|
||||
border: none;
|
||||
background: transparent;
|
||||
width: 10px;
|
||||
}}
|
||||
QScrollBar::handle {{
|
||||
background: rgba(180, 180, 180, 40%);
|
||||
}}
|
||||
QScrollBar::add-line:vertical {{
|
||||
width:0;
|
||||
height: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}}
|
||||
|
||||
QScrollBar::sub-line:vertical {{
|
||||
width:0;
|
||||
height: 0;
|
||||
border: none;
|
||||
background: none;
|
||||
}}
|
||||
""".format(
|
||||
bgColor=settings.textEditor["background"],
|
||||
foreground=settings.textEditor["fontColor"]
|
||||
)
|
||||
|
||||
def toolBarSS():
|
||||
return """
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# --!-- coding: utf8 --!--
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from PyQt5.QtWidgets import QWidget, QAbstractItemView
|
||||
|
||||
from manuskript.enums import Outline
|
||||
from manuskript.ui.views.basicItemView_ui import Ui_basicItemView
|
||||
|
@ -24,7 +24,7 @@ class basicItemView(QWidget, Ui_basicItemView):
|
|||
"""Returns a list of indexes from list of QItemSelectionRange"""
|
||||
indexes = []
|
||||
|
||||
for i in sourceView.selectionModel().selection().indexes():
|
||||
for i in sourceView.selection().indexes():
|
||||
if i.column() != 0:
|
||||
continue
|
||||
|
||||
|
@ -33,9 +33,13 @@ class basicItemView(QWidget, Ui_basicItemView):
|
|||
|
||||
return indexes
|
||||
|
||||
def selectionChanged(self, sourceView):
|
||||
def selectionChanged(self):
|
||||
if isinstance(self.sender(), QAbstractItemView):
|
||||
selectionModel = self.sender().selectionModel()
|
||||
else:
|
||||
selectionModel = self.sender()
|
||||
|
||||
indexes = self.getIndexes(sourceView)
|
||||
indexes = self.getIndexes(selectionModel)
|
||||
|
||||
if len(indexes) == 0:
|
||||
self.setEnabled(False)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
# --!-- coding: utf8 --!--
|
||||
from PyQt5.QtWidgets import QWidget
|
||||
from PyQt5.QtWidgets import QWidget, QAbstractItemView
|
||||
|
||||
from manuskript.enums import Outline
|
||||
from manuskript.ui.views.metadataView_ui import Ui_metadataView
|
||||
|
@ -27,7 +27,7 @@ class metadataView(QWidget, Ui_metadataView):
|
|||
"""Returns a list of indexes from list of QItemSelectionRange"""
|
||||
indexes = []
|
||||
|
||||
for i in sourceView.selectionModel().selection().indexes():
|
||||
for i in sourceView.selection().indexes():
|
||||
if i.column() != 0:
|
||||
continue
|
||||
|
||||
|
@ -36,8 +36,14 @@ class metadataView(QWidget, Ui_metadataView):
|
|||
|
||||
return indexes
|
||||
|
||||
def selectionChanged(self, sourceView):
|
||||
indexes = self.getIndexes(sourceView)
|
||||
def selectionChanged(self):
|
||||
|
||||
if isinstance(self.sender(), QAbstractItemView):
|
||||
selectionModel = self.sender().selectionModel()
|
||||
else:
|
||||
selectionModel = self.sender()
|
||||
|
||||
indexes = self.getIndexes(selectionModel)
|
||||
|
||||
if self._lastIndexes == indexes:
|
||||
return
|
||||
|
@ -62,7 +68,7 @@ class metadataView(QWidget, Ui_metadataView):
|
|||
self.txtNotes.setCurrentModelIndexes(indexes)
|
||||
self.revisions.setEnabled(False)
|
||||
|
||||
self.properties.selectionChanged(sourceView)
|
||||
self.properties.selectionChanged(self.sender())
|
||||
self._lastIndexes = indexes
|
||||
|
||||
def setDict(self, d):
|
||||
|
|
|
@ -24,7 +24,7 @@ class propertiesView(QWidget, Ui_propertiesView):
|
|||
"""Returns a list of indexes from list of QItemSelectionRange"""
|
||||
indexes = []
|
||||
|
||||
for i in sourceView.selectionModel().selection().indexes():
|
||||
for i in sourceView.selection().indexes():
|
||||
if i.column() != 0:
|
||||
continue
|
||||
|
||||
|
|
Loading…
Reference in a new issue