From 2cb2d91f1332007bb6a1957c2f1ccb5128995fb4 Mon Sep 17 00:00:00 2001 From: AccentuSoft Date: Wed, 2 Feb 2022 20:31:07 +0200 Subject: [PATCH] Fix some stylesheet issues. Allow user to export image of entire canvas. --- Core/Interface/CentralPane.py | 3 ++- Core/Interface/MenuBar.py | 27 +++++++++++++++++++++++++-- Core/Interface/Stylesheets.py | 3 +-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/Core/Interface/CentralPane.py b/Core/Interface/CentralPane.py index 157a72e..c10176e 100644 --- a/Core/Interface/CentralPane.py +++ b/Core/Interface/CentralPane.py @@ -1010,7 +1010,8 @@ class CanvasView(QtWidgets.QGraphicsView): # to avoid visual artifacts. picture.fill(QtGui.QColor(0, 0, 0, 0)) picturePainter = QtGui.QPainter(picture) - tempBrush = self.scene().backgroundBrush() + # The scene's background brush is transparent by default (for now at least, 2022/2/2) + tempBrush = self.backgroundBrush() if transparentBackground: self.scene().setBackgroundBrush(QtGui.QBrush(QtGui.QColor.fromRgba64(0, 0, 0, 0))) self.scene().render(picturePainter, QtCore.QRectF(0, 0, rectToPrint.width(), rectToPrint.height()), diff --git a/Core/Interface/MenuBar.py b/Core/Interface/MenuBar.py index 5c420ee..f6ad447 100644 --- a/Core/Interface/MenuBar.py +++ b/Core/Interface/MenuBar.py @@ -670,10 +670,14 @@ class MenuBar(QtWidgets.QMenuBar): if canvasSaveDialogAccept and fileDirectory != '': canvas = canvasSaveDialog.chosenCanvasDropdown.currentText() - transparentBackground = False - justViewport = True + if canvasSaveDialog.justViewportChoice.isChecked(): + justViewport = True + else: + justViewport = False if canvasSaveDialog.transparentChoice.isChecked(): transparentBackground = True + else: + transparentBackground = False picture = self.parent().getPictureOfCanvas(canvas, justViewport, transparentBackground) picture.save(fileDirectory, "PNG") @@ -2073,14 +2077,31 @@ class CanvasPictureDialog(QtWidgets.QDialog): self.fileDirectoryButton = QtWidgets.QPushButton("Select directory...") self.fileDirectoryLine = QtWidgets.QLineEdit() self.fileDirectoryLine.setReadOnly(True) + + self.backgroundButtonsGroup = QtWidgets.QButtonGroup() + self.canvasViewportButtonsGroup = QtWidgets.QButtonGroup() + self.transparentChoice = QtWidgets.QRadioButton('Transparent') + self.backgroundButtonsGroup.addButton(self.transparentChoice) self.transparentChoice.setChecked(True) self.withBackgroundChoice = QtWidgets.QRadioButton('With Background') + self.backgroundButtonsGroup.addButton(self.withBackgroundChoice) + self.justViewportChoice = QtWidgets.QRadioButton('Just Viewport') + self.justViewportChoice.setToolTip('Save a picture of only the contents of the scene that are currently ' + 'visible (through the viewport).') + self.justViewportChoice.setChecked(True) + self.canvasViewportButtonsGroup.addButton(self.justViewportChoice) + self.entireCanvasChoice = QtWidgets.QRadioButton('Entire Canvas') + self.entireCanvasChoice.setToolTip('Save a picture of the entire contents of the canvas, not just the current ' + 'viewport contents.') + self.canvasViewportButtonsGroup.addButton(self.entireCanvasChoice) dialogLayout.addWidget(self.fileDirectoryLine, 1, 0, 1, 2) dialogLayout.addWidget(self.fileDirectoryButton, 2, 0, 1, 2) dialogLayout.addWidget(self.transparentChoice, 3, 0, 1, 1) dialogLayout.addWidget(self.withBackgroundChoice, 3, 1, 1, 1) + dialogLayout.addWidget(self.justViewportChoice, 4, 0, 1, 1) + dialogLayout.addWidget(self.entireCanvasChoice, 4, 1, 1, 1) canvasLabel = QtWidgets.QLabel('Canvas:') canvasLabel.setWordWrap(False) @@ -2113,6 +2134,8 @@ class CanvasPictureDialog(QtWidgets.QDialog): saveAsDialog.setViewMode(QtWidgets.QFileDialog.List) saveAsDialog.setNameFilter("Image (*.png)") saveAsDialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave) + saveAsDialog.setDirectory(str(Path.home())) + saveAsDialog.setStyleSheet(Stylesheets.MAIN_WINDOW_STYLESHEET) saveAsDialog.exec() self.fileDirectory = saveAsDialog.selectedFiles()[0] if self.fileDirectory != '': diff --git a/Core/Interface/Stylesheets.py b/Core/Interface/Stylesheets.py index 4651a51..feef6ba 100644 --- a/Core/Interface/Stylesheets.py +++ b/Core/Interface/Stylesheets.py @@ -15,9 +15,8 @@ TOOLBAR_STYLESHEET = """QToolBar {background-color: rgb(41, 45, 62); """ MAIN_WINDOW_STYLESHEET = """ - QObject{ + QWidget{ background-color: rgb(41, 45, 62); - border-width: 0px; color: rgba(248, 248, 242, 1) !important; font-size: 15px; }