From 7a3011e5efe45680acac9ad3f2493a5bed5ce85f Mon Sep 17 00:00:00 2001
From: cui-gaoleng <562344211@qq.com>
Date: Fri, 8 Nov 2024 01:23:08 +0800
Subject: [PATCH 3/4] =?UTF-8?q?libcalamaresui=E6=96=87=E4=BB=B6=E5=A4=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/libcalamaresui/Branding.h                 |  3 +-
 src/libcalamaresui/ViewManager.cpp            | 54 +++++++++++++++----
 src/libcalamaresui/ViewManager.h              |  5 +-
 src/libcalamaresui/libcalamaresui.qrc         |  2 +
 src/libcalamaresui/utils/Gui.cpp              |  6 ++-
 src/libcalamaresui/utils/Gui.h                |  5 +-
 .../viewpages/ExecutionViewStep.cpp           |  3 +-
 7 files changed, 63 insertions(+), 15 deletions(-)

diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h
index 3fffa02..e374fa1 100644
--- a/src/libcalamaresui/Branding.h
+++ b/src/libcalamaresui/Branding.h
@@ -68,7 +68,8 @@ public:
         ProductIcon,
         ProductLogo,
         ProductWallpaper,
-        ProductWelcome
+        ProductWelcome,
+        welcomebackground
     };
     Q_ENUM( ImageEntry )
 
diff --git a/src/libcalamaresui/ViewManager.cpp b/src/libcalamaresui/ViewManager.cpp
index 2fd7f45..1e097b5 100644
--- a/src/libcalamaresui/ViewManager.cpp
+++ b/src/libcalamaresui/ViewManager.cpp
@@ -21,6 +21,7 @@
 #include "utils/Paste.h"
 #include "utils/Retranslator.h"
 #include "utils/String.h"
+#include "utils/Gui.h"
 #include "viewpages/BlankViewStep.h"
 #include "viewpages/ExecutionViewStep.h"
 #include "viewpages/ViewStep.h"
@@ -34,6 +35,7 @@
 #include <QFile>
 #include <QMessageBox>
 #include <QMetaObject>
+#include <QProcess>
 
 #define UPDATE_BUTTON_PROPERTY( name, value ) \
     do \
@@ -220,7 +222,7 @@ ViewManager::onInitComplete()
         m_steps.first()->onActivate();
     }
 
-    emit currentStepChanged();
+    emit currentStepChanged(m_currentStep);
 }
 
 void
@@ -368,7 +370,7 @@ ViewManager::next()
         {
             m_steps.at( m_currentStep )->onActivate();
             executing = qobject_cast< ExecutionViewStep* >( m_steps.at( m_currentStep ) ) != nullptr;
-            emit currentStepChanged();
+            emit currentStepChanged(m_currentStep);
         }
         else
         {
@@ -466,7 +468,7 @@ ViewManager::back()
         m_stack->setCurrentIndex( m_currentStep );
         step->onLeave();
         m_steps.at( m_currentStep )->onActivate();
-        emit currentStepChanged();
+        emit currentStepChanged(m_currentStep);
     }
     else if ( !step->isAtBeginning() )
     {
@@ -486,6 +488,20 @@ ViewManager::back()
     updateButtonLabels();
 }
 
+void
+ViewManager::restartInstallation()
+{
+    QString restartNowCommand = QStringLiteral( "shutdown -r now" );
+    QProcess::execute( "/bin/sh", { "-c", restartNowCommand } );
+}
+
+void
+ViewManager::startDebugTerminal()
+{
+    //QProcess::startDetached("/bin/bash", QStringList());
+    QApplication::quit();
+}
+
 void
 ViewManager::quit()
 {
@@ -524,13 +540,33 @@ ViewManager::confirmCancelInstallation()
     QString title = settings->isSetupMode() ? tr( "Cancel Setup?", "@title" ) : tr( "Cancel Installation?", "@title" );
     QString question = settings->isSetupMode() ? tr( "Do you really want to cancel the current setup process?\n"
                                                      "The setup program will quit and all changes will be lost." )
-                                               : tr( "Do you really want to cancel the current install process?\n"
-                                                     "The installer will quit and all changes will be lost." );
-    QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::Yes | QMessageBox::No, m_widget );
-    mb.setDefaultButton( QMessageBox::No );
+                                               : tr( "Do you really want to cancel the current installation process?\n"
+                                                     "The system will reboot or you can enter the debug mode for further investigation." );
+    QMessageBox mb( QMessageBox::Question, title, question, QMessageBox::NoButton, m_widget );
+    QPushButton* rebootButton = mb.addButton( tr( "&Reboot", "@button" ), QMessageBox::ActionRole );
+    QPushButton* debugButton = mb.addButton( tr( "&Try Now", "@button" ), QMessageBox::ActionRole );
+    QPushButton* cancelButton = mb.addButton( QMessageBox::Cancel );
+    mb.setIconPixmap(
+    Calamares::defaultPixmap( Calamares::BigLogo,//Biglogo.svgz
+                                Calamares::Original,
+                                QSize( 321/5, 297/5 ) ));
+    mb.setDefaultButton( cancelButton );
+    mb.setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
     Calamares::fixButtonLabels( &mb );
-    int response = mb.exec();
-    return response == QMessageBox::Yes;
+
+    mb.exec();
+
+    if ( mb.clickedButton() == rebootButton )
+    {
+        restartInstallation();
+        return false;
+    }
+    else if ( mb.clickedButton() == debugButton )
+    {
+        startDebugTerminal();
+        return true;
+    }
+    return false;
 }
 
 void
diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h
index 5a449a1..da9e9bd 100644
--- a/src/libcalamaresui/ViewManager.h
+++ b/src/libcalamaresui/ViewManager.h
@@ -87,6 +87,9 @@ public:
      */
     ViewStepList viewSteps() const;
 
+    void restartInstallation();
+    void startDebugTerminal();
+
     /**
      * @brief currentStep returns the currently active ViewStep, i.e. the ViewStep
      * which owns the currently visible view page.
@@ -213,7 +216,7 @@ public Q_SLOTS:
     QString logFilePath() const;
 
 signals:
-    void currentStepChanged();
+    void currentStepChanged(int m_currentStep);
     void ensureSize( QSize size ) const;  // See ViewStep::ensureSize()
     void cancelEnabled( bool enabled ) const;
 
diff --git a/src/libcalamaresui/libcalamaresui.qrc b/src/libcalamaresui/libcalamaresui.qrc
index 62a7df2..ddb197d 100644
--- a/src/libcalamaresui/libcalamaresui.qrc
+++ b/src/libcalamaresui/libcalamaresui.qrc
@@ -24,5 +24,7 @@
         <file alias="images/state-ok.svg">../../data/images/state-ok.svg</file>
         <file alias="images/state-warning.svg">../../data/images/state-warning.svg</file>
         <file alias="images/state-error.svg">../../data/images/state-error.svg</file>
+        <file alias="images/Biglogo.svg">../../data/images/Biglogo.svg</file>
+        <file alias="images/Biglogo.svgz">../../data/images/Biglogo.svgz</file>
     </qresource>
 </RCC>
diff --git a/src/libcalamaresui/utils/Gui.cpp b/src/libcalamaresui/utils/Gui.cpp
index 57f67ae..3915cb7 100644
--- a/src/libcalamaresui/utils/Gui.cpp
+++ b/src/libcalamaresui/utils/Gui.cpp
@@ -101,7 +101,7 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
         break;
 
     case Squid:
-        pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/squid.svg", size );
+        pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/Biglogo.svg", size );
         break;
 
     case StatusOk:
@@ -115,6 +115,10 @@ defaultPixmap( ImageType type, ImageMode mode, const QSize& size )
     case StatusError:
         pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/state-error.svg", size );
         break;
+
+    case BigLogo:
+        pixmap = ImageRegistry::instance()->pixmap( RESPATH "images/Biglogo.svgz", size );
+        break;
     }
 
     if ( pixmap.isNull() )
diff --git a/src/libcalamaresui/utils/Gui.h b/src/libcalamaresui/utils/Gui.h
index 1264bc1..947be64 100644
--- a/src/libcalamaresui/utils/Gui.h
+++ b/src/libcalamaresui/utils/Gui.h
@@ -50,7 +50,8 @@ enum ImageType : int
     Squid,
     StatusOk,  // Icons for the requirements checker
     StatusWarning,
-    StatusError
+    StatusError,
+    BigLogo
 };
 
 /**
@@ -94,7 +95,7 @@ UIDLLEXPORT QSize defaultIconSize();
  */
 constexpr int windowMinimumWidth = 800;
 constexpr int windowMinimumHeight = 520;
-constexpr int windowPreferredWidth = 1024;
+constexpr int windowPreferredWidth = 912;
 constexpr int windowPreferredHeight = 520;
 
 }  // namespace Calamares
diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp
index 71ea85b..c34d308 100644
--- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp
+++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp
@@ -38,6 +38,7 @@
 #include <QToolBar>
 #include <QToolButton>
 #include <QVBoxLayout>
+#include <QCoreApplication>
 
 static Calamares::Slideshow*
 makeSlideshow( QWidget* parent )
@@ -101,7 +102,7 @@ ExecutionViewStep::ExecutionViewStep( QObject* parent )
         Branding::instance()->image(
             { "utilities-log-viewer", "utilities-terminal", "text-x-log", "text-x-changelog", "preferences-log" },
             QSize( 32, 32 ) ),
-        "Toggle log" );
+        QCoreApplication::translate("Calamares::ExecutionViewStep","Toggle log" ) );
     auto toggleLogButton = dynamic_cast< QToolButton* >( toolBar->widgetForAction( toggleLogAction ) );
     connect( toggleLogButton, &QToolButton::clicked, this, &ExecutionViewStep::toggleLog );
 
-- 
2.43.0

