[LYN-4288] Adding error page if resource mapping tool has invalid setup (#1219)

This commit is contained in:
Vincent Liu
2021-06-09 19:29:34 -07:00
committed by GitHub
parent 463e0cfff3
commit ac8ee00aff
16 changed files with 281 additions and 47 deletions
@@ -37,10 +37,12 @@ class NotificationFrame(QFrame):
self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
icon_label: QLabel = QLabel(self)
icon_label.setObjectName("NotificationIcon")
icon_label.setPixmap(pixmap)
self._title_label: QLabel = QLabel(title, self)
self._title_label.setObjectName("Title")
self._title_label.setOpenExternalLinks(True)
self._title_label.setObjectName("NotificationTitle")
self._title_label.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred))
self._title_label.setWordWrap(True)
@@ -0,0 +1,89 @@
"""
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
its licensors.
For complete copyright and license terms please see the LICENSE at the root of this
distribution (the "License"). All use of this software is governed by the License,
or, if provided, by the license below or the license accompanying this file. Do not
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
from PySide2.QtGui import QPixmap
from PySide2.QtWidgets import (QHBoxLayout, QLayout, QPushButton, QSizePolicy, QSpacerItem, QVBoxLayout, QWidget)
from model import (error_messages, notification_label_text, view_size_constants)
from view.common_view_components import NotificationFrame
class ErrorPage(QWidget):
"""
Error Page
"""
def __init__(self) -> None:
super().__init__()
self.setGeometry(0, 0,
view_size_constants.ERROR_PAGE_MAIN_WINDOW_WIDTH,
view_size_constants.ERROR_PAGE_MAIN_WINDOW_HEIGHT)
page_vertical_layout: QVBoxLayout = QVBoxLayout(self)
page_vertical_layout.setSizeConstraint(QLayout.SetMinimumSize)
page_vertical_layout.setMargin(0)
self._setup_notification_area()
page_vertical_layout.addWidget(self._notification_area)
self._setup_footer_area()
page_vertical_layout.addWidget(self._footer_area)
def _setup_notification_area(self) -> None:
self._notification_area: QWidget = QWidget(self)
self._notification_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
self._notification_area.setMinimumSize(view_size_constants.ERROR_PAGE_MAIN_WINDOW_WIDTH,
view_size_constants.ERROR_PAGE_NOTIFICATION_AREA_HEIGHT)
notification_area_layout: QVBoxLayout = QVBoxLayout(self._notification_area)
notification_area_layout.setSizeConstraint(QLayout.SetMinimumSize)
notification_area_layout.setContentsMargins(
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_LEFTRIGHT,
view_size_constants.MAIN_PAGE_LAYOUT_MARGIN_TOPBOTTOM,
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_LEFTRIGHT, 0)
notification_frame: NotificationFrame = \
NotificationFrame(self, QPixmap(":/error_report_warning.svg"),
error_messages.ERROR_PAGE_TOOL_SETUP_ERROR_MESSAGE, False)
notification_frame.setObjectName("ErrorPage")
notification_frame.setMinimumSize(view_size_constants.ERROR_PAGE_MAIN_WINDOW_WIDTH,
view_size_constants.ERROR_PAGE_NOTIFICATION_AREA_HEIGHT)
notification_frame.setVisible(True)
notification_area_layout.addWidget(notification_frame)
def _setup_footer_area(self) -> None:
self._footer_area: QWidget = QWidget(self)
self._footer_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
self._footer_area.setMaximumSize(view_size_constants.TOOL_APPLICATION_MAIN_WINDOW_WIDTH,
view_size_constants.ERROR_PAGE_FOOTER_AREA_HEIGHT)
footer_area_layout: QHBoxLayout = QHBoxLayout(self._footer_area)
footer_area_layout.setSizeConstraint(QLayout.SetMinimumSize)
footer_area_layout.setContentsMargins(
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_LEFTRIGHT,
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_TOPBOTTOM,
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_LEFTRIGHT,
view_size_constants.ERROR_PAGE_LAYOUT_MARGIN_TOPBOTTOM)
footer_area_spacer: QSpacerItem = QSpacerItem(view_size_constants.ERROR_PAGE_MAIN_WINDOW_WIDTH,
view_size_constants.INTERACTION_COMPONENT_HEIGHT,
QSizePolicy.MinimumExpanding, QSizePolicy.Minimum)
footer_area_layout.addItem(footer_area_spacer)
self._ok_button: QPushButton = QPushButton(self._footer_area)
self._ok_button.setObjectName("Secondary")
self._ok_button.setText(notification_label_text.ERROR_PAGE_OK_TEXT)
self._ok_button.setMinimumSize(view_size_constants.OK_BUTTON_WIDTH,
view_size_constants.INTERACTION_COMPONENT_HEIGHT)
footer_area_layout.addWidget(self._ok_button)
@property
def ok_button(self) -> QPushButton:
return self._ok_button