Adjusted fixes for python 3.10 to not crash immediately

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
TheJackiMonster 2021-12-13 14:27:59 +01:00
parent c9c18fae57
commit dc86e3b14e
No known key found for this signature in database
GPG Key ID: D850A5F772E880F9
8 changed files with 32 additions and 32 deletions

View File

@ -89,7 +89,7 @@ def drawProgress(painter, rect, progress, radius=0):
painter.setBrush(QBrush(colorFromProgress(progress)))
r2 = QRect(rect)
r2.setWidth(r2.width() * min(progress, 1))
r2.setWidth(int(r2.width() * min(progress, 1)))
painter.drawRoundedRect(r2, radius, radius)
@ -405,7 +405,7 @@ def statusMessage(message, duration=5000, importance=1):
MW.statusLabel.adjustSize()
g = MW.statusLabel.geometry()
# g.moveCenter(MW.mapFromGlobal(MW.geometry().center()))
s = MW.layout().spacing() / 2
s = int(MW.layout().spacing() / 2)
g.setLeft(s)
g.moveBottom(MW.mapFromGlobal(MW.geometry().bottomLeft()).y() - s)
MW.statusLabel.setGeometry(g)

View File

@ -1189,7 +1189,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
def centerChildWindow(self, win):
r = win.geometry()
r2 = self.geometry()
win.move(r2.center() - QPoint(r.width()/2, r.height()/2))
win.move(r2.center() - QPoint(int(r.width()/2), int(r.height()/2)))
def support(self):
openURL("https://github.com/olivierkes/manuskript/wiki/Technical-Support")

View File

@ -143,15 +143,15 @@ class settingsWindow(QWidget, Ui_Settings):
self.chkRevisionsKeep.stateChanged.connect(self.revisionsSettingsChanged)
self.chkRevisionRemove.setChecked(opt["smartremove"])
self.chkRevisionRemove.toggled.connect(self.revisionsSettingsChanged)
self.spnRevisions10Mn.setValue(60 / opt["rules"][10 * 60])
self.spnRevisions10Mn.setValue(int(60 / opt["rules"][10 * 60]))
self.spnRevisions10Mn.valueChanged.connect(self.revisionsSettingsChanged)
self.spnRevisionsHour.setValue(60 * 10 / opt["rules"][60 * 60])
self.spnRevisionsHour.setValue(int(60 * 10 / opt["rules"][60 * 60]))
self.spnRevisionsHour.valueChanged.connect(self.revisionsSettingsChanged)
self.spnRevisionsDay.setValue(60 * 60 / opt["rules"][60 * 60 * 24])
self.spnRevisionsDay.setValue(int(60 * 60 / opt["rules"][60 * 60 * 24]))
self.spnRevisionsDay.valueChanged.connect(self.revisionsSettingsChanged)
self.spnRevisionsMonth.setValue(60 * 60 * 24 / opt["rules"][60 * 60 * 24 * 30])
self.spnRevisionsMonth.setValue(int(60 * 60 * 24 / opt["rules"][60 * 60 * 24 * 30]))
self.spnRevisionsMonth.valueChanged.connect(self.revisionsSettingsChanged)
self.spnRevisionsEternity.setValue(60 * 60 * 24 * 7 / opt["rules"][None])
self.spnRevisionsEternity.setValue(int(60 * 60 * 24 * 7 / opt["rules"][None]))
self.spnRevisionsEternity.valueChanged.connect(self.revisionsSettingsChanged)
# Views

View File

@ -215,7 +215,7 @@ class fullScreenEditor(QWidget):
self._bgcolor = QColor(self._themeDatas["Background/Color"])
else:
self._bgcolor = QColor(self._themeDatas["Foreground/Color"])
self._bgcolor.setAlpha(self._themeDatas["Foreground/Opacity"] * 255 / 100)
self._bgcolor.setAlpha(int(self._themeDatas["Foreground/Opacity"] * 255 / 100))
self._fgcolor = QColor(self._themeDatas["Text/Color"])
if self._themeDatas["Text/Color"] == self._themeDatas["Foreground/Color"]:
self._fgcolor = QColor(self._themeDatas["Background/Color"])
@ -239,7 +239,7 @@ class fullScreenEditor(QWidget):
r = self.locker.geometry()
r.moveTopLeft(QPoint(
0,
self.geometry().height() / 2 - r.height() / 2
int(self.geometry().height() / 2 - r.height() / 2)
))
self.leftPanel.setGeometry(r)
self.hideWidget(self.leftPanel)

View File

@ -83,7 +83,7 @@ def themeTextRect(themeDatas, screenRect):
elif themeDatas["Foreground/Position"] == 3: # Stretched
x = margin
width = screenRect.width() - 2 * margin
return QRect(x, y, width, height)
return QRect(int(x), int(y), int(width), int(height))
def createThemePreview(theme, screenRect, size=QSize(200, 120)):
@ -116,13 +116,13 @@ def createThemePreview(theme, screenRect, size=QSize(200, 120)):
px = QPixmap(pixmap).scaled(size, Qt.KeepAspectRatio)
w = px.width() / 10
h = px.height() / 10
w = int(px.width() / 10)
h = int(px.height() / 10)
r = themeTextRect(themeDatas, screenRect)
painter = QPainter(px)
painter.drawPixmap(QRect(w, h, w * 4, h * 5), pixmap,
QRect(r.topLeft() - QPoint(w / 3, h / 3), QSize(w * 4, h * 5)))
QRect(r.topLeft() - QPoint(int(w / 3), int(h / 3)), QSize(w * 4, h * 5)))
painter.setPen(Qt.white)
painter.drawRect(QRect(w, h, w * 4, h * 5))
painter.end()
@ -164,15 +164,15 @@ def generateTheme(themeDatas, screenRect):
elif _type == 5: # Zoomed
scaled.scale(screenRect.size(), Qt.KeepAspectRatioByExpanding)
painter.drawImage((screenRect.width() - scaled.width()) / 2,
(screenRect.height() - scaled.height()) / 2, img.scaled(scaled))
painter.drawImage(int((screenRect.width() - scaled.width()) / 2),
int((screenRect.height() - scaled.height()) / 2), img.scaled(scaled))
# Text Background
textRect = themeTextRect(themeDatas, screenRect)
painter.save()
color = QColor(themeDatas["Foreground/Color"])
color.setAlpha(themeDatas["Foreground/Opacity"] * 255 / 100)
color.setAlpha(int(themeDatas["Foreground/Opacity"] * 255 / 100))
painter.setBrush(color)
painter.setPen(Qt.NoPen)
r = themeDatas["Foreground/Rounding"]

View File

@ -138,7 +138,7 @@ class exporterDialog(QWidget, Ui_exporter):
r = self.dialog.geometry()
r2 = self.geometry()
self.dialog.move(r2.center() - QPoint(r.width()/2, r.height()/2))
self.dialog.move(r2.center() - QPoint(int(r.width()/2), int(r.height()/2)))
self.dialog.exportersMightHaveChanged.connect(self.populateExportList)

View File

@ -153,15 +153,15 @@ class corkDelegate(QStyledItemDelegate):
self.updateRects_v1(option, index)
def updateRects_v2(self, option, index):
margin = self.margin * 2
iconSize = max(24 * self.factor, 18)
margin = int(self.margin * 2)
iconSize = int(max(24 * self.factor, 18))
item = index.internalPointer()
fm = QFontMetrics(option.font)
h = fm.lineSpacing()
h = int(fm.lineSpacing())
self.itemRect = option.rect.adjusted(margin, margin, -margin, -margin)
top = 15 * self.factor
top = int(15 * self.factor)
self.topRect = QRect(self.itemRect)
self.topRect.setHeight(top)
@ -169,8 +169,8 @@ class corkDelegate(QStyledItemDelegate):
self.itemRect.bottomRight())
self.iconRect = QRect(self.cardRect.topLeft() + QPoint(margin, margin),
QSize(iconSize, iconSize))
self.labelRect = QRect(self.cardRect.topRight() - QPoint(margin + self.factor * 18, 1),
self.cardRect.topRight() + QPoint(- margin - self.factor * 4, self.factor * 24))
self.labelRect = QRect(self.cardRect.topRight() - QPoint(int(margin + self.factor * 18), 1),
self.cardRect.topRight() + QPoint(int(-margin - self.factor * 4), int(self.factor * 24)))
self.titleRect = QRect(self.iconRect.topRight() + QPoint(margin, 0),
self.labelRect.bottomLeft() - QPoint(margin, margin))
self.titleRect.setBottom(self.iconRect.bottom())
@ -185,8 +185,8 @@ class corkDelegate(QStyledItemDelegate):
self.mainTextRect.setTopLeft(self.mainLineRect.topLeft())
def updateRects_v1(self, option, index):
margin = self.margin
iconSize = max(16 * self.factor, 12)
margin = int(self.margin)
iconSize = int(max(16 * self.factor, 12))
item = index.internalPointer()
self.itemRect = option.rect.adjusted(margin, margin, -margin, -margin)
self.iconRect = QRect(self.itemRect.topLeft() + QPoint(margin, margin), QSize(iconSize, iconSize))
@ -270,8 +270,8 @@ class corkDelegate(QStyledItemDelegate):
if item.isFolder():
itemPoly = QPolygonF([
self.topRect.topLeft(),
self.topRect.topLeft() + QPoint(self.topRect.width() * .35, 0),
self.cardRect.topLeft() + QPoint(self.topRect.width() * .45, 0),
self.topRect.topLeft() + QPoint(int(self.topRect.width() * .35), 0),
self.cardRect.topLeft() + QPoint(int(self.topRect.width() * .45), 0),
self.cardRect.topRight(),
self.cardRect.bottomRight(),
self.cardRect.bottomLeft()

View File

@ -237,11 +237,11 @@ class outlineGoalPercentageDelegate(QStyledItemDelegate):
rect = option.rect.adjusted(margin, margin, -margin, -margin)
# Move
rect.translate(level * rect.width() / 10, 0)
rect.setWidth(rect.width() - level * rect.width() / 10)
rect.translate(int(level * rect.width() / 10), 0)
rect.setWidth(int(rect.width() - level * rect.width() / 10))
rect.setHeight(height)
rect.setTop(option.rect.top() + (option.rect.height() - height) / 2)
rect.setHeight(int(height))
rect.setTop(int(option.rect.top() + (option.rect.height() - height) / 2))
drawProgress(painter, rect, p) # from functions