[finished] Add a restart-anyway API to Config
It's possible to ignore the "user setting" for restart-now and call doRestart(true) directly. This is intended for use with specific UIs that make that choice clear for the user. Hook up both [finished] and [finishedq] to the "traditional" restart-if-the-box-is-ticked logic although the example QML doesn't expose that box.
This commit is contained in:
parent
aa004503c5
commit
bd775a16e2
@ -109,12 +109,13 @@ Config::onInstallationFailed( const QString& message, const QString& details )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::doRestart()
|
Config::doRestart( bool restartAnyway )
|
||||||
{
|
{
|
||||||
cDebug() << "Restart requested, mode=" << restartModes().find( restartNowMode() ) << " want?" << restartNowWanted();
|
cDebug() << "mode=" << restartModes().find( restartNowMode() ) << " user?" << restartNowWanted() << "arg?"
|
||||||
if ( restartNowWanted() )
|
<< restartAnyway;
|
||||||
|
if ( restartNowMode() != RestartMode::Never && restartAnyway )
|
||||||
{
|
{
|
||||||
cDebug() << "Running restart command" << m_restartNowCommand;
|
cDebug() << Logger::SubEntry << "Running restart command" << m_restartNowCommand;
|
||||||
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
QProcess::execute( "/bin/sh", { "-c", m_restartNowCommand } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,13 @@ public Q_SLOTS:
|
|||||||
* The "if desired" part is: only if the restart mode allows it,
|
* The "if desired" part is: only if the restart mode allows it,
|
||||||
* **and** the user has checked the box (or done whatever to
|
* **and** the user has checked the box (or done whatever to
|
||||||
* turn on restartNowWanted()).
|
* turn on restartNowWanted()).
|
||||||
|
*
|
||||||
|
* - The one-argument form ignores what the user wants and restarts
|
||||||
|
* if @p restartAnyway is @c true **unless** the mode is Never
|
||||||
|
* - The no-argument form uses the user setting
|
||||||
*/
|
*/
|
||||||
void doRestart();
|
void doRestart( bool restartAnyway );
|
||||||
|
void doRestart() { doRestart( restartNowWanted() ); }
|
||||||
|
|
||||||
/** @brief Send DBus notification
|
/** @brief Send DBus notification
|
||||||
*
|
*
|
||||||
|
@ -86,7 +86,7 @@ void
|
|||||||
FinishedViewStep::onActivate()
|
FinishedViewStep::onActivate()
|
||||||
{
|
{
|
||||||
m_config->doNotify();
|
m_config->doNotify();
|
||||||
connect( qApp, &QApplication::aboutToQuit, m_config, &Config::doRestart );
|
connect( qApp, &QApplication::aboutToQuit, m_config, qOverload<>( &Config::doRestart ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ void
|
|||||||
FinishedQmlViewStep::onActivate()
|
FinishedQmlViewStep::onActivate()
|
||||||
{
|
{
|
||||||
m_config->doNotify();
|
m_config->doNotify();
|
||||||
|
connect( qApp, &QApplication::aboutToQuit, m_config, qOverload<>( &Config::doRestart ) );
|
||||||
QmlViewStep::onActivate();
|
QmlViewStep::onActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ Page {
|
|||||||
Button {
|
Button {
|
||||||
text: qsTr("Restart System")
|
text: qsTr("Restart System")
|
||||||
icon.name: "system-reboot"
|
icon.name: "system-reboot"
|
||||||
onClicked: { config.doRestart(); }
|
onClicked: { config.doRestart(true); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,11 +93,6 @@ Page {
|
|||||||
|
|
||||||
function onActivate()
|
function onActivate()
|
||||||
{
|
{
|
||||||
// This QML page has a **button** for restarting,
|
|
||||||
// so just pretend the setting is clicked; this is a
|
|
||||||
// poor solution, recommended is to set restartNowMode to Always
|
|
||||||
// in the config.
|
|
||||||
config.setRestartNowWanted(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLeave()
|
function onLeave()
|
||||||
|
Loading…
Reference in New Issue
Block a user