@@ -13,11 +13,9 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtGui import QFont
|
||||
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel
|
||||
|
||||
from nw.enum import nwItemType, nwItemClass, nwItemLayout
|
||||
from nw.constants import nwLabels
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+1
-1
@@ -16,9 +16,9 @@ import enchant
|
||||
|
||||
from time import time
|
||||
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtWidgets import QTextEdit, QAction, QMenu, QShortcut
|
||||
from PyQt5.QtGui import QTextCursor, QTextOption, QIcon, QKeySequence
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
|
||||
from nw.gui.dochighlight import GuiDocHighlighter
|
||||
from nw.gui.wordcounter import WordCounter
|
||||
|
||||
+1
-2
@@ -13,10 +13,9 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtCore import Qt, QSize
|
||||
from PyQt5.QtGui import QIcon, QFont, QColor
|
||||
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QInputDialog, QLineEdit, QApplication
|
||||
from PyQt5.QtWidgets import QTreeWidget, QTreeWidgetItem, QAbstractItemView, QApplication
|
||||
|
||||
from nw.project.item import NWItem
|
||||
from nw.enum import nwItemType, nwItemClass, nwAlert
|
||||
|
||||
+12
-5
@@ -13,8 +13,8 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from PyQt5.QtWidgets import qApp, QMenuBar, QAction, QMessageBox
|
||||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5.QtWidgets import QMenuBar, QAction, QMessageBox
|
||||
|
||||
from nw.enum import nwItemType, nwItemClass, nwDocAction
|
||||
|
||||
@@ -91,8 +91,7 @@ class GuiMainMenu(QMenuBar):
|
||||
|
||||
def _menuExit(self):
|
||||
self.theParent.closeMain()
|
||||
qApp.quit()
|
||||
return True
|
||||
return
|
||||
|
||||
def _toggleSpellCheck(self):
|
||||
self.theProject.setSpellCheck(self.toolsSpellCheck.isChecked())
|
||||
@@ -155,8 +154,9 @@ class GuiMainMenu(QMenuBar):
|
||||
self.projMenu.addAction(menuItem)
|
||||
|
||||
# Project > Close Project
|
||||
menuItem = QAction("Close Project", self)
|
||||
menuItem = QAction(QIcon.fromTheme("document-revert"), "Close Project", self)
|
||||
menuItem.setStatusTip("Close Project")
|
||||
menuItem.setShortcut("Ctrl+Shift+W")
|
||||
menuItem.triggered.connect(lambda : self.theParent.closeProject(False))
|
||||
self.projMenu.addAction(menuItem)
|
||||
|
||||
@@ -204,7 +204,7 @@ class GuiMainMenu(QMenuBar):
|
||||
# Project > Edit
|
||||
menuItem = QAction(QIcon.fromTheme("document-properties"), "&Edit Item", self)
|
||||
menuItem.setStatusTip("Change Item Settings")
|
||||
menuItem.setShortcut("Ctrl+E")
|
||||
menuItem.setShortcuts(["Ctrl+E", "F2"])
|
||||
menuItem.triggered.connect(self.theParent.editItem)
|
||||
self.projMenu.addAction(menuItem)
|
||||
|
||||
@@ -263,6 +263,13 @@ class GuiMainMenu(QMenuBar):
|
||||
menuItem.triggered.connect(lambda : self.theParent.viewDocument(None))
|
||||
self.docuMenu.addAction(menuItem)
|
||||
|
||||
# Document > Close Preview
|
||||
menuItem = QAction(QIcon.fromTheme("text-html"), "Close Document View", self)
|
||||
menuItem.setStatusTip("Close Document View Pane")
|
||||
menuItem.setShortcut("Ctrl+Shift+R")
|
||||
menuItem.triggered.connect(self.theParent.closeDocViewer)
|
||||
self.docuMenu.addAction(menuItem)
|
||||
|
||||
# # Document > Separator
|
||||
# self.docuMenu.addSeparator()
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtWidgets import QStatusBar, QLabel, QFrame
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
+38
-7
@@ -14,9 +14,12 @@ import logging
|
||||
import nw
|
||||
|
||||
from os import path
|
||||
from PyQt5.QtWidgets import QWidget, QMainWindow, QVBoxLayout, QFrame, QSplitter, QFileDialog, QStackedWidget, QShortcut, QMessageBox
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QColor
|
||||
from PyQt5.QtCore import Qt, QTimer
|
||||
from PyQt5.QtGui import QIcon, QPixmap, QColor
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QWidget, QMainWindow, QVBoxLayout, QFrame, QSplitter, QFileDialog,
|
||||
QShortcut, QMessageBox
|
||||
)
|
||||
|
||||
from nw.theme import Theme
|
||||
from nw.gui.doctree import GuiDocTree
|
||||
@@ -75,6 +78,7 @@ class GuiMain(QMainWindow):
|
||||
self.splitView = QSplitter(Qt.Horizontal)
|
||||
self.splitView.addWidget(self.docEditor)
|
||||
self.splitView.addWidget(self.docViewer)
|
||||
self.splitView.splitterMoved.connect(self._splitViewMove)
|
||||
|
||||
self.splitMain = QSplitter(Qt.Horizontal)
|
||||
self.splitMain.addWidget(self.treePane)
|
||||
@@ -171,8 +175,7 @@ class GuiMain(QMainWindow):
|
||||
def clearGUI(self):
|
||||
self.treeView.clearTree()
|
||||
self.docEditor.clearEditor()
|
||||
self.docViewer.clearViewer()
|
||||
self.docViewer.setVisible(False)
|
||||
self.closeDocViewer()
|
||||
return True
|
||||
|
||||
##
|
||||
@@ -428,7 +431,17 @@ class GuiMain(QMainWindow):
|
||||
# Main Window Actions
|
||||
##
|
||||
|
||||
def closeMain(self):
|
||||
def closeMain(self, isYes=False):
|
||||
|
||||
if not isYes:
|
||||
msgBox = QMessageBox()
|
||||
msgRes = msgBox.question(
|
||||
self, "Exit",
|
||||
"Do you want to exit %s?" % nw.__package__
|
||||
)
|
||||
if msgRes != QMessageBox.Yes:
|
||||
return False
|
||||
|
||||
logger.info("Exiting %s" % nw.__package__)
|
||||
if self._takeDocumentAction():
|
||||
self.saveDocument()
|
||||
@@ -439,7 +452,10 @@ class GuiMain(QMainWindow):
|
||||
self.mainConf.setMainPanePos(self.splitMain.sizes())
|
||||
self.mainConf.setDocPanePos(self.splitView.sizes())
|
||||
self.mainConf.saveConfig()
|
||||
return
|
||||
|
||||
qApp.quit()
|
||||
|
||||
return True
|
||||
|
||||
def setFocus(self, paneNo):
|
||||
if paneNo == 1:
|
||||
@@ -450,6 +466,16 @@ class GuiMain(QMainWindow):
|
||||
self.docViewer.setFocus()
|
||||
return
|
||||
|
||||
def closeDocViewer(self):
|
||||
self.docViewer.clearViewer()
|
||||
self.theProject.setLastViewed(None)
|
||||
bPos = self.splitMain.sizes()
|
||||
self.docViewer.setVisible(False)
|
||||
vPos = [bPos[1],0]
|
||||
self.splitView.setSizes(vPos)
|
||||
self.docEditor.changeWidth()
|
||||
return not self.docViewer.isVisible()
|
||||
|
||||
##
|
||||
# Internal Functions
|
||||
##
|
||||
@@ -516,7 +542,6 @@ class GuiMain(QMainWindow):
|
||||
|
||||
def closeEvent(self, theEvent):
|
||||
self.closeMain()
|
||||
QMainWindow.closeEvent(self,theEvent)
|
||||
return
|
||||
|
||||
##
|
||||
@@ -557,4 +582,10 @@ class GuiMain(QMainWindow):
|
||||
self.docEditor.changeWidth()
|
||||
return
|
||||
|
||||
def _splitViewMove(self, pWidth, pHeight):
|
||||
"""Alert dependent GUI elements that the main pane splitter has been moved.
|
||||
"""
|
||||
self.docEditor.changeWidth()
|
||||
return
|
||||
|
||||
# END Class GuiMain
|
||||
|
||||
+7
-2
@@ -76,7 +76,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef):
|
||||
assert nwGUI.treeView._getTreeItem("811786ad1ae74") is not None
|
||||
|
||||
# Select the 'New Scene' file
|
||||
nwGUI.treeView.setFocus()
|
||||
nwGUI.setFocus(1)
|
||||
nwGUI.treeView._getTreeItem("73475cb40a568").setExpanded(True)
|
||||
nwGUI.treeView._getTreeItem("25fc0e7096fc6").setExpanded(True)
|
||||
nwGUI.treeView._getTreeItem("31489056e0916").setSelected(True)
|
||||
@@ -85,7 +85,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef):
|
||||
assert nwGUI.mainMenu._toggleSpellCheck()
|
||||
|
||||
# Type something into the document
|
||||
nwGUI.docEditor.setFocus()
|
||||
nwGUI.setFocus(2)
|
||||
for c in "# Hello World!":
|
||||
qtbot.keyClick(nwGUI.docEditor, c, delay=keyDelay)
|
||||
qtbot.keyClick(nwGUI.docEditor, Qt.Key_Return, delay=keyDelay)
|
||||
@@ -142,10 +142,12 @@ def testMainWindows(qtbot, nwTempGUI, nwRef):
|
||||
qtbot.wait(stepDelay)
|
||||
|
||||
# Open and view the edited document
|
||||
nwGUI.setFocus(3)
|
||||
assert nwGUI.openDocument("31489056e0916")
|
||||
assert nwGUI.viewDocument("31489056e0916")
|
||||
qtbot.wait(stepDelay)
|
||||
assert nwGUI.saveProject()
|
||||
assert nwGUI.closeDocViewer()
|
||||
|
||||
# Check the files
|
||||
projFile = path.join(nwTempGUI,"nwProject.nwx")
|
||||
@@ -153,6 +155,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef):
|
||||
sceneFile = path.join(nwTempGUI,"data_3","1489056e0916_main.nwd")
|
||||
assert cmpFiles(sceneFile, path.join(nwRef,"gui","1_1489056e0916_main.nwd"))
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -214,6 +217,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef):
|
||||
projFile = path.join(nwTempGUI,"nwProject.nwx")
|
||||
assert cmpFiles(projFile, path.join(nwRef,"gui","2_nwProject.nwx"), [2])
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
@pytest.mark.gui
|
||||
@@ -259,4 +263,5 @@ def testItemEditor(qtbot, nwTempGUI, nwRef):
|
||||
projFile = path.join(nwTempGUI,"nwProject.nwx")
|
||||
assert cmpFiles(projFile, path.join(nwRef,"gui","3_nwProject.nwx"), [2])
|
||||
|
||||
nwGUI.closeMain(True)
|
||||
# qtbot.stopForInteraction()
|
||||
|
||||
Reference in New Issue
Block a user