Skip to content

Commit

Permalink
Fixed compilation errors for reboot changes
Browse files Browse the repository at this point in the history
  • Loading branch information
erinharrington-12 committed Jun 14, 2024
1 parent e31663b commit 3900976
Showing 1 changed file with 51 additions and 51 deletions.
102 changes: 51 additions & 51 deletions src/HomeWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <QProcess>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QTimer>

#include "ui_HomeWidget.h"
#include "MenuBar.h"
Expand Down Expand Up @@ -100,56 +101,56 @@ void HomeWidget::shutDown()
void HomeWidget::reboot()
{
#ifdef WOMBAT
if (QMessageBox::question(this, "Reboot?", "Please wait up to 10 seconds for the system to begin rebooting.\n\nContinue?", QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;

QMessageBox msgBox(this);
msgBox.setWindowTitle("Reboot");
msgBox.setText("Rebooting now...");

// msgBox.setText("Rebooting...");
msgBox.setMaximumSize(500, 480);
// msgBox.setStyleSheet("QLabel{min-width: 450px; min-height: 280px;}");
msgBox.setStandardButtons(QMessageBox::NoButton);

QLabel *gifLabel = new QLabel();
QLabel *messageLabel = new QLabel(msgBox.text());

QGridLayout *msgBoxLayout = qobject_cast<QGridLayout *>(msgBox.layout());

msgBoxLayout->setVerticalSpacing(0);

QWidget *container = new QWidget();
QVBoxLayout *vLayout = new QVBoxLayout(container);

vLayout->addWidget(gifLabel);

vLayout->addWidget(messageLabel);
vLayout->setAlignment(Qt::AlignCenter);
gifLabel->setAlignment(Qt::AlignCenter);
messageLabel->setAlignment(Qt::AlignCenter);

msgBoxLayout->setSpacing(0);
vLayout->setSpacing(10);

container->setLayout(vLayout);

if (msgBoxLayout)
{
msgBoxLayout->addWidget(container, 0, 0, 1, msgBoxLayout->columnCount());
}

gifLabel->move(200, -50);
gifLabel->resize(400, 1100);

QMovie *movie = new QMovie("://qml/botguy_noMargin.gif");
movie->setScaledSize(QSize(200, 240));
gifLabel->setMovie(movie);
movie->start();

msgBox.setText("");
msgBox.show();
// Use a QTimer to delay the reboot process
if (QMessageBox::question(this, "Reboot?", "Please wait up to 10 seconds for the system to begin rebooting.\n\nContinue?", QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
return;

// Create the QMessageBox
QMessageBox *msgBox = new QMessageBox(this);
msgBox->setWindowTitle("Reboot");
msgBox->setMaximumSize(500, 480); // Limit the size of the QMessageBox
msgBox->setStandardButtons(QMessageBox::NoButton);

// Create QLabel for the GIF
QLabel *gifLabel = new QLabel();
gifLabel->setAlignment(Qt::AlignCenter); // Center the GIF label

// Create QLabel for the message text
QLabel *messageLabel = new QLabel("Rebooting now...");
messageLabel->setAlignment(Qt::AlignCenter); // Center the message label

// Create a container widget and a new vertical layout
QWidget *container = new QWidget();
QVBoxLayout *vLayout = new QVBoxLayout(container);

// Add the GIF label and message label to the vertical layout
vLayout->addWidget(gifLabel);
vLayout->addWidget(messageLabel);

// Adjust the vertical layout spacing and margins
vLayout->setSpacing(10);
vLayout->setContentsMargins(10, 10, 10, 10);

// Set the layout of the container
container->setLayout(vLayout);

// Access the internal layout of the QMessageBox
QGridLayout *msgBoxLayout = qobject_cast<QGridLayout *>(msgBox->layout());
if (msgBoxLayout)
{
msgBoxLayout->addWidget(container, 0, 0, 1, msgBoxLayout->columnCount());
}

// Setup and start the GIF movie
QMovie *movie = new QMovie("://qml/botguy_noMargin.gif");
movie->setScaledSize(QSize(200, 240));
gifLabel->setMovie(movie);
movie->start();

// Show the QMessageBox non-blocking
msgBox->setText(""); // Hide the default text to avoid duplication
msgBox->show();

// Use a QTimer to delay the reboot process
QTimer::singleShot(2000, [this, msgBox]() {
// Stop create3_server.service
QProcess create3ServerStop;
Expand Down Expand Up @@ -177,7 +178,6 @@ void HomeWidget::reboot()
QMessageBox::information(this, "Not Available", "Reboot is only available on the kovan.");
#endif
}

void HomeWidget::lock()
{
LockScreen::lock();
Expand Down

0 comments on commit 3900976

Please sign in to comment.