- fixed fullscreen functionality for PyQt6 and a few other fixes regarding the port to PyQt6

This commit is contained in:
Marius Stanciu
2021-08-05 02:00:54 +03:00
committed by Marius
parent ffce6b437f
commit e0a7afb2cd
11 changed files with 107 additions and 89 deletions

View File

@@ -3178,11 +3178,12 @@ class FCDetachableTab(QtWidgets.QTabWidget):
:param event: a mouse press event
:return:
"""
if event.button() == QtCore.Qt.MouseButton.RightButton and self.prev_index == self.tabAt(event.pos()):
if event.button() == QtCore.Qt.MouseButton.RightButton and \
self.prev_index == self.tabAt(event.position().toPoint()):
self.right_click.emit(self.prev_index)
if event.button() == QtCore.Qt.MouseButton.MiddleButton:
self.onCloseTabSignal.emit(int(self.tabAt(event.pos())))
self.onCloseTabSignal.emit(int(self.tabAt(event.position().toPoint())))
self.prev_index = -1
@@ -4701,13 +4702,13 @@ class FCJog(QtWidgets.QFrame):
super(FCJog, self).__init__(*args, **kwargs)
self.app = app
self.setFrameShape(QtWidgets.QFrame.Box)
self.setFrameShape(QtWidgets.QFrame.Shape.Box)
self.setLineWidth(1)
# JOG axes
grbl_jog_grid = QtWidgets.QGridLayout()
grbl_jog_grid.setAlignment(QtCore.Qt.AlignmentFlag.AlignCenter)
grbl_jog_grid.setSizeConstraint(QtWidgets.QLayout.SetMinimumSize)
grbl_jog_grid.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetMinimumSize)
grbl_jog_grid.setContentsMargins(2, 4, 2, 4)
self.setLayout(grbl_jog_grid)
@@ -4780,7 +4781,7 @@ class FCZeroAxes(QtWidgets.QFrame):
super(FCZeroAxes, self).__init__(*args, **kwargs)
self.app = app
self.setFrameShape(QtWidgets.QFrame.Box)
self.setFrameShape(QtWidgets.QFrame.Shape.Box)
self.setLineWidth(1)
# Zero the axes
@@ -5152,9 +5153,9 @@ def message_dialog(title, message, kind="info", parent=None):
:param parent: parent
:return: None
"""
icon = {"info": QtWidgets.QMessageBox.Information,
"warning": QtWidgets.QMessageBox.Warning,
"error": QtWidgets.QMessageBox.Critical}[str(kind)]
icon = {"info": QtWidgets.QMessageBox.Icon.Information,
"warning": QtWidgets.QMessageBox.Icon.Warning,
"error": QtWidgets.QMessageBox.Icon.Critical}[str(kind)]
dlg = QtWidgets.QMessageBox(icon, title, message, parent=parent)
dlg.setText(message)
dlg.exec()

View File

@@ -2201,10 +2201,10 @@ class MainGUI(QtWidgets.QMainWindow):
msgbox.setText(_("Are you sure you want to delete the GUI Settings? \n"))
msgbox.setWindowTitle(_("Clear GUI Settings"))
msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/trash32.png'))
msgbox.setIcon(QtWidgets.QMessageBox.Question)
msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole)
bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole)
msgbox.setDefaultButton(bt_no)
msgbox.exec()
@@ -3080,10 +3080,10 @@ class MainGUI(QtWidgets.QMainWindow):
messagebox.setText(msg)
messagebox.setWindowTitle(_("Warning"))
messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
messagebox.setIcon(QtWidgets.QMessageBox.Question)
messagebox.setIcon(QtWidgets.QMessageBox.Icon.Question)
messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.exec()
return
# SHIFT
@@ -3240,10 +3240,10 @@ class MainGUI(QtWidgets.QMainWindow):
messagebox.setText(msg)
messagebox.setWindowTitle(_("Warning"))
messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
messagebox.setIcon(QtWidgets.QMessageBox.Warning)
messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.exec()
# Paint
@@ -3287,10 +3287,10 @@ class MainGUI(QtWidgets.QMainWindow):
messagebox.setText(msg)
messagebox.setWindowTitle(_("Warning"))
messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
messagebox.setIcon(QtWidgets.QMessageBox.Warning)
messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.exec()
# Add Text Tool
@@ -3309,10 +3309,10 @@ class MainGUI(QtWidgets.QMainWindow):
messagebox.setText(msg)
messagebox.setWindowTitle(_("Warning"))
messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
messagebox.setIcon(QtWidgets.QMessageBox.Warning)
messagebox.setIcon(QtWidgets.QMessageBox.Icon.Warning)
messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
messagebox.setStandardButtons(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.setDefaultButton(QtWidgets.QMessageBox.StandardButton.Ok)
messagebox.exec()
# Flip on X axis
@@ -4041,7 +4041,10 @@ class MainGUI(QtWidgets.QMainWindow):
if not self.isMaximized():
self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
self.final_save.emit()
try:
self.final_save.emit()
except SystemError:
sys.exit(0)
event.ignore()
def on_fullscreen(self, disable=False):
@@ -4059,24 +4062,27 @@ class MainGUI(QtWidgets.QMainWindow):
self.y_pos = a.y()
self.width = a.width()
self.height = a.height()
self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PM_TitleBarHeight)
self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PixelMetric.PM_TitleBarHeight)
# set new geometry to full desktop rect
# Subtracting and adding the pixels below it's hack to bypass a bug in Qt5 and OpenGL that made that a
# window drawn with OpenGL in fullscreen will not show any other windows on top which means that menus and
# everything else will not work without this hack. This happen in Windows.
# https://bugreports.qt.io/browse/QTBUG-41309
desktop = self.app.qapp.desktop()
screen = desktop.screenNumber(QtGui.QCursor.pos())
# desktop = self.app.qapp.desktop()
# screen = desktop.screenNumber(QtGui.QCursor.pos())
rec = desktop.screenGeometry(screen)
x = rec.x() - 1
y = rec.y() - 1
h = rec.height() + 2
w = rec.width() + 2
# rec = desktop.screenGeometry(screen)
self.setGeometry(x, y, w, h)
self.show()
# x = rec.x() - 1
# y = rec.y() - 1
# h = rec.height() + 2
# w = rec.width() + 2
#
# self.setGeometry(x, y, w, h)
# self.show()
self.app.ui.showFullScreen()
# hide all Toolbars
for tb in self.findChildren(QtWidgets.QToolBar):
@@ -4092,7 +4098,9 @@ class MainGUI(QtWidgets.QMainWindow):
elif self.toggle_fscreen is True or disable is True:
self.setWindowFlags(flags & ~Qt.WindowType.FramelessWindowHint)
# the additions are made to account for the pixels we subtracted/added above in the (x, y, h, w)
self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height)
# self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height)
self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+13, self.width, self.height)
self.showNormal()
self.restore_toolbar_view()
self.toggle_fscreen = False

View File

@@ -71,7 +71,8 @@ class VisPyCanvas(scene.SceneCanvas):
orientation='bottom', axis_color=tick_color, text_color=tick_color, font_size=a_fsize, axis_width=1,
anchors=['center', 'bottom']
)
self.xaxis.height_max = 30
self.xaxis.height_min = 5
self.xaxis.height_max = 35
self.grid_widget.add_widget(self.xaxis, row=2, col=1)
right_padding = self.grid_widget.add_widget(row=0, col=2, row_span=2)

View File

@@ -1035,10 +1035,10 @@ class PreferencesUIManager:
msgbox.setText(_("Are you sure you want to continue?"))
msgbox.setWindowTitle(_("Application will restart"))
msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/warning.png'))
msgbox.setIcon(QtWidgets.QMessageBox.Question)
msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.NoRole)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole)
msgbox.addButton(_('Cancel'), QtWidgets.QMessageBox.ButtonRole.NoRole)
msgbox.setDefaultButton(bt_yes)
msgbox.exec()
@@ -1284,10 +1284,10 @@ class PreferencesUIManager:
"Do you want to save?"))
msgbox.setWindowTitle(_("Save Preferences"))
msgbox.setWindowIcon(QtGui.QIcon(self.ui.app.resource_location + '/save_as.png'))
msgbox.setIcon(QtWidgets.QMessageBox.Question)
msgbox.setIcon(QtWidgets.QMessageBox.Icon.Question)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.ButtonRole.YesRole)
msgbox.addButton(_('No'), QtWidgets.QMessageBox.ButtonRole.NoRole)
msgbox.setDefaultButton(bt_yes)
msgbox.exec()