Drop the qApp macro
This commit is contained in:
@@ -28,11 +28,11 @@ import logging
|
||||
from pathlib import Path
|
||||
from zipfile import ZipFile
|
||||
|
||||
from PyQt5.QtGui import QCloseEvent, QTextCursor
|
||||
from PyQt5.QtCore import pyqtSlot
|
||||
from PyQt5.QtGui import QCloseEvent, QTextCursor
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QDialogButtonBox, QFileDialog, QFrame, QHBoxLayout, QLabel,
|
||||
QLineEdit, QPlainTextEdit, QPushButton, QVBoxLayout, QWidget, qApp
|
||||
QApplication, QDialog, QDialogButtonBox, QFileDialog, QFrame, QHBoxLayout,
|
||||
QLabel, QLineEdit, QPlainTextEdit, QPushButton, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -158,7 +158,7 @@ class GuiDictionaries(QDialog):
|
||||
"Additional dictionaries found: {0}"
|
||||
).format(len(self._currDicts)))
|
||||
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
self.adjustSize()
|
||||
|
||||
return True
|
||||
|
||||
@@ -26,19 +26,19 @@ from __future__ import annotations
|
||||
import json
|
||||
import logging
|
||||
|
||||
from datetime import datetime
|
||||
from time import time
|
||||
from typing import TYPE_CHECKING
|
||||
from datetime import datetime
|
||||
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
||||
from PyQt5.QtCore import QTimer, QUrl, Qt, pyqtSignal, pyqtSlot
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QDialog, QFormLayout, QGridLayout, QHBoxLayout, QLabel,
|
||||
QListWidget, QListWidgetItem, QPushButton, QSizePolicy, QSplitter,
|
||||
QStackedWidget, QTabWidget, QTextBrowser, QTreeWidget, QTreeWidgetItem,
|
||||
QVBoxLayout, QWidget, qApp
|
||||
)
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QCursor, QFont, QPalette, QResizeEvent
|
||||
from PyQt5.QtPrintSupport import QPrintPreviewDialog, QPrinter
|
||||
from PyQt5.QtWidgets import (
|
||||
QAbstractItemView, QApplication, QDialog, QFormLayout, QGridLayout,
|
||||
QHBoxLayout, QLabel, QListWidget, QListWidgetItem, QPushButton,
|
||||
QSizePolicy, QSplitter, QStackedWidget, QTabWidget, QTextBrowser,
|
||||
QTreeWidget, QTreeWidgetItem, QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
from novelwriter.common import checkInt, fuzzyTime
|
||||
@@ -352,7 +352,7 @@ class GuiManuscript(QDialog):
|
||||
self.docPreview.beginNewBuild(len(docBuild))
|
||||
for step, _ in docBuild.iterBuildHTML(None):
|
||||
self.docPreview.buildStep(step + 1)
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
|
||||
buildObj = docBuild.lastBuild
|
||||
assert isinstance(buildObj, ToHtml)
|
||||
@@ -486,7 +486,7 @@ class GuiManuscript(QDialog):
|
||||
dlgSettings.setModal(False)
|
||||
dlgSettings.show()
|
||||
dlgSettings.raise_()
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
dlgSettings.loadContent()
|
||||
dlgSettings.newSettingsReady.connect(self._processNewSettings)
|
||||
|
||||
@@ -850,16 +850,16 @@ class _PreviewWidget(QTextBrowser):
|
||||
def buildStep(self, value: int) -> None:
|
||||
"""Update the progress bar value."""
|
||||
self.buildProgress.setValue(value)
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
return
|
||||
|
||||
def setContent(self, data: dict) -> None:
|
||||
"""Set the content of the preview widget."""
|
||||
sPos = self.verticalScrollBar().value()
|
||||
qApp.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||
|
||||
self.buildProgress.setCentreText(self.tr("Processing ..."))
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
|
||||
styles = "\n".join(data.get("styles", []))
|
||||
self.document().setDefaultStyleSheet(styles)
|
||||
@@ -867,7 +867,7 @@ class _PreviewWidget(QTextBrowser):
|
||||
html = "".join(data.get("html", []))
|
||||
html = html.replace("\t", "!!tab!!")
|
||||
self.setHtml(html)
|
||||
qApp.processEvents()
|
||||
QApplication.processEvents()
|
||||
while self.find("!!tab!!"):
|
||||
cursor = self.textCursor()
|
||||
cursor.insertText("\t")
|
||||
@@ -881,8 +881,8 @@ class _PreviewWidget(QTextBrowser):
|
||||
self.document().markContentsDirty(0, self.document().characterCount())
|
||||
|
||||
self.buildProgress.setCentreText(self.tr("Done"))
|
||||
qApp.restoreOverrideCursor()
|
||||
qApp.processEvents()
|
||||
QApplication.restoreOverrideCursor()
|
||||
QApplication.processEvents()
|
||||
QTimer.singleShot(300, self._hideProgress)
|
||||
|
||||
return
|
||||
@@ -904,10 +904,10 @@ class _PreviewWidget(QTextBrowser):
|
||||
@pyqtSlot("QPrinter*")
|
||||
def printPreview(self, printer: QPrinter) -> None:
|
||||
"""Connect the print preview painter to the document viewer."""
|
||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||
printer.setOrientation(QPrinter.Portrait)
|
||||
self.document().print(printer)
|
||||
qApp.restoreOverrideCursor()
|
||||
QApplication.restoreOverrideCursor()
|
||||
return
|
||||
|
||||
@pyqtSlot(str)
|
||||
|
||||
@@ -25,19 +25,19 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPaintEvent, QPainter, QPen
|
||||
from PyQt5.QtCore import (
|
||||
QAbstractListModel, QEvent, QModelIndex, QObject, QPoint, QSize, Qt,
|
||||
pyqtSignal, pyqtSlot
|
||||
)
|
||||
from PyQt5.QtGui import QCloseEvent, QColor, QFont, QPaintEvent, QPainter, QPen
|
||||
from PyQt5.QtWidgets import (
|
||||
QAction, QDialog, QFileDialog, QFormLayout, QHBoxLayout, QLabel, QLineEdit,
|
||||
QListView, QMenu, QPushButton, QScrollArea, QShortcut, QStackedWidget,
|
||||
QStyle, QStyleOptionViewItem, QStyledItemDelegate, QVBoxLayout, QWidget,
|
||||
qApp
|
||||
QAction, QApplication, QDialog, QFileDialog, QFormLayout, QHBoxLayout,
|
||||
QLabel, QLineEdit, QListView, QMenu, QPushButton, QScrollArea, QShortcut,
|
||||
QStackedWidget, QStyle, QStyleOptionViewItem, QStyledItemDelegate,
|
||||
QVBoxLayout, QWidget
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -411,11 +411,11 @@ class _ProjectListItem(QStyledItemDelegate):
|
||||
self._pPx = (mPx//2, 3*mPx//2, iPx + mPx, mPx, mPx + tPx) # Painter coordinates
|
||||
self._hPx = 2*mPx + tPx + fPx # Fixed height
|
||||
|
||||
self._tFont = qApp.font()
|
||||
self._tFont = QApplication.font()
|
||||
self._tFont.setPointSizeF(1.2*fPt)
|
||||
self._tFont.setWeight(QFont.Weight.Bold)
|
||||
|
||||
self._dFont = qApp.font()
|
||||
self._dFont = QApplication.font()
|
||||
self._dFont.setPointSizeF(fPt)
|
||||
self._dPen = QPen(SHARED.theme.helpText)
|
||||
|
||||
@@ -433,7 +433,7 @@ class _ProjectListItem(QStyledItemDelegate):
|
||||
painter.save()
|
||||
if opt.state & QStyle.StateFlag.State_Selected == QStyle.StateFlag.State_Selected:
|
||||
painter.setOpacity(0.25)
|
||||
painter.fillRect(rect, qApp.palette().highlight())
|
||||
painter.fillRect(rect, QApplication.palette().highlight())
|
||||
painter.setOpacity(1.0)
|
||||
|
||||
painter.drawPixmap(ix, rect.top() + iy, self._icon)
|
||||
|
||||
@@ -29,11 +29,12 @@ import logging
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from PyQt5.QtGui import QCloseEvent, QPixmap, QCursor
|
||||
from PyQt5.QtCore import Qt, pyqtSlot
|
||||
from PyQt5.QtGui import QCloseEvent, QCursor, QPixmap
|
||||
from PyQt5.QtWidgets import (
|
||||
qApp, QDialog, QTreeWidget, QTreeWidgetItem, QDialogButtonBox, QGridLayout,
|
||||
QLabel, QGroupBox, QMenu, QAction, QFileDialog, QSpinBox, QHBoxLayout
|
||||
QAction, QApplication, QDialog, QDialogButtonBox, QFileDialog, QGridLayout,
|
||||
QGroupBox, QHBoxLayout, QLabel, QMenu, QSpinBox, QTreeWidget,
|
||||
QTreeWidgetItem
|
||||
)
|
||||
|
||||
from novelwriter import CONFIG, SHARED
|
||||
@@ -301,10 +302,10 @@ class GuiWritingStats(QDialog):
|
||||
|
||||
def populateGUI(self) -> None:
|
||||
"""Populate list box with data from the log file."""
|
||||
qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||
QApplication.setOverrideCursor(QCursor(Qt.CursorShape.WaitCursor))
|
||||
self._loadLogFile()
|
||||
self._updateListBox()
|
||||
qApp.restoreOverrideCursor()
|
||||
QApplication.restoreOverrideCursor()
|
||||
return
|
||||
|
||||
##
|
||||
|
||||
Reference in New Issue
Block a user