[finished] Move restart handling to Config

main
Adriaan de Groot 4 years ago
parent 9d6d8ecaea
commit 7d024cf72b

@ -12,6 +12,8 @@
#include "utils/Logger.h"
#include "utils/Variant.h"
#include <QProcess>
const NamedEnumTable< Config::RestartMode >&
restartModes()
{
@ -75,6 +77,16 @@ Config::setRestartNowWanted( bool w )
}
}
void
Config::doRestart()
{
if ( restartNowMode() != RestartMode::Never && restartNowWanted() )
{
cDebug() << "Running restart command" << m_restartNowCommand;
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
}
}
void
Config::setConfigurationMap( const QVariantMap& configurationMap )

@ -14,8 +14,6 @@
#include <QObject>
#include <memory>
class Config : public QObject
{
Q_OBJECT
@ -50,6 +48,14 @@ public slots:
void setRestartNowMode( RestartMode m );
void setRestartNowWanted( bool w );
/** @brief Run the restart command, if desired.
*
* This should generally not be called somewhere during the
* application's execution, but only in response to QApplication::quit()
* or something like that when the user expects the system to restart.
*/
void doRestart();
signals:
void restartModeChanged( RestartMode m );
void restartNowWantedChanged( bool w );

@ -20,7 +20,7 @@
#include "utils/NamedEnum.h"
#include "utils/Variant.h"
#include <QVariantMap>
#include <QApplication>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
@ -128,34 +128,14 @@ FinishedViewStep::sendNotification()
}
#if 0
void
FinishedPage::setUpRestart()
{
cDebug() << "FinishedPage::setUpRestart(), Quit button"
<< "setup=" << restartModes().find( m_mode ) << "command=" << m_restartNowCommand;
connect( qApp, &QApplication::aboutToQuit, [this]()
{
if ( ui->restartCheckBox->isVisible() && ui->restartCheckBox->isChecked() )
{
cDebug() << "Running restart command" << m_restartNowCommand;
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
}
} );
}
#endif
void
FinishedViewStep::onActivate()
{
// m_widget->setUpRestart();
if ( m_config->notifyOnFinished() )
{
sendNotification();
}
connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart );
}

Loading…
Cancel
Save