[LYN-4288] Adding error page if resource mapping tool has invalid setup (#1219)
parent
463e0cfff3
commit
ac8ee00aff
@ -0,0 +1,33 @@
|
||||
"""
|
||||
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.QtCore import (QCoreApplication, QObject)
|
||||
|
||||
from manager.view_manager import ViewManager
|
||||
from view.error_page import ErrorPage
|
||||
|
||||
|
||||
class ErrorController(QObject):
|
||||
"""
|
||||
ErrorPage Controller
|
||||
"""
|
||||
def __init__(self) -> None:
|
||||
super(ErrorController, self).__init__()
|
||||
# Initialize manager references
|
||||
self._view_manager: ViewManager = ViewManager.get_instance()
|
||||
# Initialize view references
|
||||
self._error_page: ErrorPage = self._view_manager.get_error_page()
|
||||
|
||||
def _ok(self) -> None:
|
||||
QCoreApplication.instance().quit()
|
||||
|
||||
def setup(self) -> None:
|
||||
self._error_page.ok_button.clicked.connect(self._ok)
|
||||
@ -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
|
||||
Loading…
Reference in New Issue