[finished] Move restart handling to Config
This commit is contained in:
parent
9d6d8ecaea
commit
7d024cf72b
@ -12,6 +12,8 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
const NamedEnumTable< Config::RestartMode >&
|
const NamedEnumTable< Config::RestartMode >&
|
||||||
restartModes()
|
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
|
void
|
||||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
@ -14,8 +14,6 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class Config : public QObject
|
class Config : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -50,6 +48,14 @@ public slots:
|
|||||||
void setRestartNowMode( RestartMode m );
|
void setRestartNowMode( RestartMode m );
|
||||||
void setRestartNowWanted( bool w );
|
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:
|
signals:
|
||||||
void restartModeChanged( RestartMode m );
|
void restartModeChanged( RestartMode m );
|
||||||
void restartNowWantedChanged( bool w );
|
void restartNowWantedChanged( bool w );
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "utils/NamedEnum.h"
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include <QVariantMap>
|
#include <QApplication>
|
||||||
#include <QtDBus/QDBusConnection>
|
#include <QtDBus/QDBusConnection>
|
||||||
#include <QtDBus/QDBusInterface>
|
#include <QtDBus/QDBusInterface>
|
||||||
#include <QtDBus/QDBusReply>
|
#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
|
void
|
||||||
FinishedViewStep::onActivate()
|
FinishedViewStep::onActivate()
|
||||||
{
|
{
|
||||||
// m_widget->setUpRestart();
|
|
||||||
|
|
||||||
if ( m_config->notifyOnFinished() )
|
if ( m_config->notifyOnFinished() )
|
||||||
{
|
{
|
||||||
sendNotification();
|
sendNotification();
|
||||||
}
|
}
|
||||||
|
connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user