/*************************************************************************** source::worx raDIYo Copyright © 2020-2022 c.holzheuer chris@sourceworx.org This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ***************************************************************************/ #include #include #include #ifdef Q_OS_LINUX #include #include #endif #include #include SWShutdownControl::SWShutdownControl( QWidget* parent, QSettings* settings ) : SWDialControl( parent, settings ) { Ui_SWShutdownControl::setupUi( this ); setHeaderText( "Shutdown?" ); QString sysName = "raDIYo"; #ifdef Q_OS_LINUX char buf[20]; ::gethostname( buf, 20 ); sysName = buf; #endif _buttonShutdown->setText( _buttonShutdown->text().arg( sysName ) ); _buttonReboot->setText( _buttonReboot->text().arg( sysName ) ); connect( _buttonReboot, SIGNAL( widgetClicked( SWDialWidget* ) ), this, SLOT( onWidgetClicked( SWDialWidget* ) ) ); connect( _buttonShutdown, SIGNAL( widgetClicked( SWDialWidget* ) ), this, SLOT( onWidgetClicked( SWDialWidget* ) ) ); connect( _buttonExit, SIGNAL( widgetClicked( SWDialWidget* ) ), this, SLOT( onWidgetClicked( SWDialWidget* ) ) ); collectDialWidgets(); } /** * @brief Implementiert SWDialControl::onWidgetClicked und behandelt * Drücken/Klicken der Kindwidgets. */ void SWShutdownControl::onWidgetClicked( SWDialWidget* child ) { if( _buttonExit == child ) { qDebug() << "good bye!"; ::exit( 0 ); return; } if( _buttonShutdown == child ) { qDebug() << "shutdown"; ::system( raDIYo::CmdShutDown ); return; } if( _buttonReboot == child ) { qDebug() << "restart"; ::system( raDIYo::CmdReboot); return; } }