MessageWindow.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #if !defined(Q_MOC_RUN)
  9. #include <ui/MessageWindow.h>
  10. #include <QWidget>
  11. #include <QDialog>
  12. #include <QStyle>
  13. #include <QDesktopServices>
  14. #include <QFile>
  15. #include <QUrl>
  16. #include <AzCore/IO/FileIO.h>
  17. #include <AzCore/IO/SystemFile.h>
  18. #include <native/assetprocessor.h>
  19. #include <QPushButton>
  20. #endif
  21. MessageWindow::MessageWindow(QWidget* parent)
  22. : QDialog(parent), m_ui(new Ui::MessageWindow())
  23. {
  24. m_ui->setupUi(this);
  25. const auto& standardIcon = style()->standardIcon(QStyle::SP_MessageBoxCritical);
  26. m_ui->icon->setPixmap(standardIcon.pixmap(QSize(64, 64)));
  27. connect(m_ui->okButton, &QPushButton::clicked, this, &MessageWindow::accept);
  28. connect(m_ui->logButton, &QPushButton::clicked, this, &MessageWindow::ViewLogsClicked);
  29. }
  30. MessageWindow::~MessageWindow()
  31. {
  32. delete m_ui;
  33. }
  34. void MessageWindow::SetHeaderText(QString headerText)
  35. {
  36. m_ui->headerText->setText(headerText);
  37. }
  38. void MessageWindow::SetMessageText(QStringList messageText)
  39. {
  40. m_messageText = messageText;
  41. m_ui->messageBox->setPlainText(m_messageText.join("\n\n"));
  42. }
  43. void MessageWindow::SetTitleText(QString titleText)
  44. {
  45. setWindowTitle(titleText);
  46. }
  47. void MessageWindow::ViewLogsClicked()
  48. {
  49. char resolvedDir[AZ_MAX_PATH_LEN * 2];
  50. QString currentDir;
  51. AZ::IO::FileIOBase::GetInstance()->ResolvePath("@log@", resolvedDir, sizeof(resolvedDir));
  52. currentDir = QString::fromUtf8(resolvedDir);
  53. if (QFile::exists(currentDir))
  54. {
  55. QDesktopServices::openUrl(QUrl::fromLocalFile(currentDir));
  56. }
  57. else
  58. {
  59. AZ_TracePrintf(AssetProcessor::ConsoleChannel, "[Error] Logs folder (%s) does not exist.\n", currentDir.toUtf8().constData());
  60. }
  61. }