Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix viewer resizing issue #559

Merged
merged 5 commits into from
Oct 14, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Updated pyside6 to 6.4, which further broke mypy
  • Loading branch information
abey79 committed Oct 14, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit fdde490556cab90f0f21b478c9322595a02b5072
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ matplotlib = { version = ">=3.3.2", optional = true }
glcontext = { version = ">=2.3.2", optional = true } # 2.3.2 needed to fix #200
moderngl = { version = ">=5.6.2", optional = true }
Pillow = { version = ">=9.0.1", optional = true }
PySide6 = { version = ">=6.3.2", optional = true }
PySide6 = { version = ">=6.4.0", optional = true }


[tool.poetry.group.dev.dependencies]
3 changes: 1 addition & 2 deletions vpype_viewer/qtviewer/utils.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,6 @@
from typing import Callable

from PySide6 import QtNetwork
from PySide6.QtCore import QCoreApplication
from PySide6.QtGui import QAction, QActionGroup, QGuiApplication, QIcon, QPalette


@@ -22,7 +21,7 @@ def load_icon(path: str) -> QIcon:
if app is None or not isinstance(app, QGuiApplication):
raise EnvironmentError("no Qt application available")

base_color = app.palette().color(QPalette.Base)
base_color = app.palette().color(QPalette.ColorRole.Base)
if base_color.lightnessF() < 0.5:
file, ext = os.path.splitext(path)
path = file + "-dark" + ext
18 changes: 11 additions & 7 deletions vpype_viewer/qtviewer/viewer.py
Original file line number Diff line number Diff line change
@@ -57,7 +57,7 @@ def _configure_ui_scaling():
# set default format
default_format = QSurfaceFormat()
default_format.setVersion(3, 2)
default_format.setProfile(QSurfaceFormat.CoreProfile)
default_format.setProfile(QSurfaceFormat.OpenGLContextProfile.CoreProfile)
default_format.setSamples(4)
QSurfaceFormat.setDefaultFormat(default_format)

@@ -77,7 +77,7 @@ def __init__(self, document: vp.Document | None = None, parent=None):

super().__init__(parent=parent)

self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)

self.setMouseTracking(True)

@@ -380,7 +380,7 @@ def __init__(
view_mode_btn.setMenu(view_mode_menu)
view_mode_btn.setIcon(load_icon("eye-outline.svg"))
view_mode_btn.setText("View")
view_mode_btn.setPopupMode(QToolButton.InstantPopup)
view_mode_btn.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
view_mode_btn.setStyleSheet("QToolButton::menu-indicator { image: none; }")
self._toolbar.addWidget(view_mode_btn)

@@ -389,7 +389,7 @@ def __init__(
self._layer_visibility_btn.setIcon(load_icon("layers-triple-outline.svg"))
self._layer_visibility_btn.setText("Layer")
self._layer_visibility_btn.setMenu(QMenu(self._layer_visibility_btn))
self._layer_visibility_btn.setPopupMode(QToolButton.InstantPopup)
self._layer_visibility_btn.setPopupMode(QToolButton.ToolButtonPopupMode.InstantPopup)
self._layer_visibility_btn.setStyleSheet(
"QToolButton::menu-indicator { image: none; }"
)
@@ -406,8 +406,12 @@ def __init__(
# MOUSE COORDINATES
self._mouse_coord_lbl = QLabel("")
self._mouse_coord_lbl.setContentsMargins(6, 6, 6, 6)
self._mouse_coord_lbl.setAlignment(Qt.AlignVCenter | Qt.AlignRight)
self._mouse_coord_lbl.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
self._mouse_coord_lbl.setAlignment(
Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignRight
)
self._mouse_coord_lbl.setSizePolicy(
QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum
)
self._toolbar.addWidget(self._mouse_coord_lbl)
# noinspection PyUnresolvedReferences
self._viewer_widget.mouse_coords.connect(self.set_mouse_coords) # type: ignore
@@ -529,7 +533,7 @@ def show(
app.setOrganizationName("abey79")
app.setOrganizationDomain("abey79.github.io")
app.setApplicationName("vpype")
app.setAttribute(Qt.AA_UseHighDpiPixmaps)
app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps)

widget = QtViewer(
document, view_mode=view_mode, show_pen_up=show_pen_up, show_points=show_points