New Finish view module, with restart capability.
This commit is contained in:
parent
2782328036
commit
b5f9b5a66e
13
src/modules/finished/CMakeLists.txt
Normal file
13
src/modules/finished/CMakeLists.txt
Normal file
@ -0,0 +1,13 @@
|
||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
||||
calamares_add_plugin( finished
|
||||
TYPE viewmodule
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
FinishedViewStep.cpp
|
||||
FinishedPage.cpp
|
||||
UI
|
||||
FinishedPage.ui
|
||||
LINK_LIBRARIES
|
||||
calamaresui
|
||||
SHARED_LIB
|
||||
)
|
104
src/modules/finished/FinishedPage.cpp
Normal file
104
src/modules/finished/FinishedPage.cpp
Normal file
@ -0,0 +1,104 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FinishedPage.h"
|
||||
|
||||
#include "ui_FinishedPage.h"
|
||||
#include "CalamaresVersion.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Retranslator.h"
|
||||
#include "ViewManager.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBoxLayout>
|
||||
#include <QFocusEvent>
|
||||
#include <QLabel>
|
||||
#include <QProcess>
|
||||
|
||||
#include "Branding.h"
|
||||
|
||||
|
||||
FinishedPage::FinishedPage( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, ui( new Ui::FinishedPage )
|
||||
, m_restartSetUp( false )
|
||||
{
|
||||
ui->setupUi( this );
|
||||
|
||||
ui->mainText->setAlignment( Qt::AlignCenter );
|
||||
ui->mainText->setWordWrap( true );
|
||||
ui->mainText->setOpenExternalLinks( true );
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
ui->retranslateUi( this );
|
||||
ui->mainText->setText( tr( "<h1>All done.</h1><br/>"
|
||||
"%1 has been installed on your computer.<br/>"
|
||||
"You may now restart into your new system, or continue "
|
||||
"using the %2 Live environment." )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::VersionedName ) )
|
||||
.arg( Calamares::Branding::instance()->
|
||||
string( Calamares::Branding::ProductName ) ) );
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedPage::setRestartNowEnabled( bool enabled )
|
||||
{
|
||||
ui->restartCheckBox->setVisible( enabled );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedPage::setRestartNowChecked( bool checked )
|
||||
{
|
||||
ui->restartCheckBox->setChecked( checked );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedPage::setRestartNowCommand( const QString& command )
|
||||
{
|
||||
m_restartNowCommand = command;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedPage::setUpRestart()
|
||||
{
|
||||
if ( !m_restartSetUp )
|
||||
{
|
||||
connect( qApp, &QApplication::aboutToQuit,
|
||||
this, [this]
|
||||
{
|
||||
if ( ui->restartCheckBox->isVisible() &&
|
||||
ui->restartCheckBox->isChecked() )
|
||||
QProcess::execute( "/bin/sh", { m_restartNowCommand } );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedPage::focusInEvent( QFocusEvent* e )
|
||||
{
|
||||
e->accept();
|
||||
}
|
||||
|
52
src/modules/finished/FinishedPage.h
Normal file
52
src/modules/finished/FinishedPage.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FINISHEDPAGE_H
|
||||
#define FINISHEDPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class FinishedPage;
|
||||
}
|
||||
|
||||
class FinishedPage : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FinishedPage( QWidget* parent = nullptr );
|
||||
|
||||
void setRestartNowEnabled( bool enabled );
|
||||
void setRestartNowChecked( bool checked );
|
||||
void setRestartNowCommand( const QString& command );
|
||||
|
||||
void setUpRestart();
|
||||
|
||||
protected:
|
||||
void focusInEvent( QFocusEvent* e ) override; //choose the child widget to focus
|
||||
|
||||
private:
|
||||
Ui::FinishedPage* ui;
|
||||
|
||||
QString m_restartNowCommand;
|
||||
|
||||
bool m_restartSetUp;
|
||||
};
|
||||
|
||||
#endif // FINISHEDPAGE_H
|
106
src/modules/finished/FinishedPage.ui
Normal file
106
src/modules/finished/FinishedPage.ui
Normal file
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FinishedPage</class>
|
||||
<widget class="QWidget" name="FinishedPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>593</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mainText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true"><Calamares finished text></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>49</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="restartCheckBox">
|
||||
<property name="text">
|
||||
<string>&Restart now</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
131
src/modules/finished/FinishedViewStep.cpp
Normal file
131
src/modules/finished/FinishedViewStep.cpp
Normal file
@ -0,0 +1,131 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "FinishedViewStep.h"
|
||||
|
||||
#include "FinishedPage.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
FinishedViewStep::FinishedViewStep( QObject* parent )
|
||||
: Calamares::ViewStep( parent )
|
||||
, m_widget( new FinishedPage() )
|
||||
{
|
||||
emit nextStatusChanged( true );
|
||||
}
|
||||
|
||||
|
||||
FinishedViewStep::~FinishedViewStep()
|
||||
{
|
||||
if ( m_widget && m_widget->parent() == nullptr )
|
||||
m_widget->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
FinishedViewStep::prettyName() const
|
||||
{
|
||||
return tr( "All done" );
|
||||
}
|
||||
|
||||
|
||||
QWidget*
|
||||
FinishedViewStep::widget()
|
||||
{
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedViewStep::next()
|
||||
{
|
||||
emit done();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedViewStep::back()
|
||||
{}
|
||||
|
||||
|
||||
bool
|
||||
FinishedViewStep::isNextEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FinishedViewStep::isBackEnabled() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FinishedViewStep::isAtBeginning() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
FinishedViewStep::isAtEnd() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedViewStep::onActivate()
|
||||
{
|
||||
m_widget->setUpRestart();
|
||||
}
|
||||
|
||||
|
||||
QList< Calamares::job_ptr >
|
||||
FinishedViewStep::jobs() const
|
||||
{
|
||||
return QList< Calamares::job_ptr >();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FinishedViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||
{
|
||||
if ( configurationMap.contains( "restartNowEnabled" ) &&
|
||||
configurationMap.value( "restartNowEnabled" ).type() == QVariant::Bool )
|
||||
{
|
||||
bool restartNowEnabled = configurationMap.value( "restartNowEnabled" ).toBool();
|
||||
|
||||
if ( restartNowEnabled )
|
||||
{
|
||||
m_widget->setRestartNowEnabled( restartNowEnabled );
|
||||
|
||||
if ( configurationMap.contains( "restartNowChecked" ) &&
|
||||
configurationMap.value( "restartNowChecked" ).type() == QVariant::Bool &&
|
||||
configurationMap.contains( "restartNowCommand" ) &&
|
||||
configurationMap.value( "restartNowCommand" ).type() == QVariant::String )
|
||||
{
|
||||
m_widget->setRestartNowChecked( configurationMap.value( "restartNowChecked" ).toBool() );
|
||||
m_widget->setRestartNowCommand( configurationMap.value( "restartNowCommand" ).toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
63
src/modules/finished/FinishedViewStep.h
Normal file
63
src/modules/finished/FinishedViewStep.h
Normal file
@ -0,0 +1,63 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef FINISHEDPAGEPLUGIN_H
|
||||
#define FINISHEDPAGEPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "PluginDllMacro.h"
|
||||
|
||||
class FinishedPage;
|
||||
|
||||
class PLUGINDLLEXPORT FinishedViewStep : public Calamares::ViewStep
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA( IID "calamares.ViewModule/1.0" )
|
||||
|
||||
Q_INTERFACES( Calamares::ViewStep )
|
||||
|
||||
public:
|
||||
explicit FinishedViewStep( QObject* parent = nullptr );
|
||||
virtual ~FinishedViewStep();
|
||||
|
||||
QString prettyName() const override;
|
||||
|
||||
QWidget* widget() override;
|
||||
|
||||
void next() override;
|
||||
void back() override;
|
||||
|
||||
bool isNextEnabled() const override;
|
||||
bool isBackEnabled() const override;
|
||||
|
||||
bool isAtBeginning() const override;
|
||||
bool isAtEnd() const override;
|
||||
|
||||
void onActivate() override;
|
||||
|
||||
QList< Calamares::job_ptr > jobs() const override;
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
FinishedPage* m_widget;
|
||||
};
|
||||
|
||||
#endif // FINISHEDPAGEPLUGIN_H
|
4
src/modules/finished/finished.conf
Normal file
4
src/modules/finished/finished.conf
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
restartNowEnabled: true
|
||||
restartNowChecked: false
|
||||
restartNowCommand: "systemctl -i reboot"
|
7
src/modules/finished/module.desc
Normal file
7
src/modules/finished/module.desc
Normal file
@ -0,0 +1,7 @@
|
||||
# Module metadata file for greeting viewmodule
|
||||
# Syntax is YAML 1.2
|
||||
---
|
||||
type: "view" #core or view
|
||||
name: "finished" #the module name. must be unique and same as the parent directory
|
||||
interface: "qtplugin" #can be: qtplugin, python, process, ...
|
||||
load: "libcalamares_viewmodule_finished.so"
|
Loading…
Reference in New Issue
Block a user