Add page for erase+install operation.
This commit is contained in:
parent
dab5a05116
commit
ef703b0859
@ -33,6 +33,7 @@ calamares_add_plugin( partition
|
|||||||
gui/ChoicePage.cpp
|
gui/ChoicePage.cpp
|
||||||
gui/CreatePartitionDialog.cpp
|
gui/CreatePartitionDialog.cpp
|
||||||
gui/EditExistingPartitionDialog.cpp
|
gui/EditExistingPartitionDialog.cpp
|
||||||
|
gui/EraseDiskPage.cpp
|
||||||
gui/PartitionPage.cpp
|
gui/PartitionPage.cpp
|
||||||
gui/PartitionPreview.cpp
|
gui/PartitionPreview.cpp
|
||||||
gui/PartitionSizeController.cpp
|
gui/PartitionSizeController.cpp
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
Choice currentChoice();
|
Choice currentChoice();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextStatusChanged( bool enabled );
|
void nextStatusChanged( bool );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setNextEnabled( bool enabled );
|
void setNextEnabled( bool enabled );
|
||||||
|
100
src/modules/partition/gui/EraseDiskPage.cpp
Normal file
100
src/modules/partition/gui/EraseDiskPage.cpp
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2014, 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 "EraseDiskPage.h"
|
||||||
|
|
||||||
|
#include "core/DeviceModel.h"
|
||||||
|
#include "core/PartitionCoreModule.h"
|
||||||
|
|
||||||
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
#include <QBoxLayout>
|
||||||
|
#include <QListView>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
EraseDiskPage::EraseDiskPage( QWidget* parent )
|
||||||
|
: QWidget( parent )
|
||||||
|
, m_nextEnabled( false )
|
||||||
|
, m_core( nullptr )
|
||||||
|
{
|
||||||
|
QVBoxLayout* mainLayout = new QVBoxLayout;
|
||||||
|
setLayout( mainLayout );
|
||||||
|
|
||||||
|
QLabel* driveLabel = new QLabel( tr( "Select drive:" ) );
|
||||||
|
mainLayout->addWidget( driveLabel );
|
||||||
|
|
||||||
|
m_drivesView = new QListView;
|
||||||
|
mainLayout->addWidget( m_drivesView );
|
||||||
|
m_drivesView->setViewMode( QListView::IconMode );
|
||||||
|
m_drivesView->setWrapping( false );
|
||||||
|
m_drivesView->setFlow( QListView::LeftToRight );
|
||||||
|
m_drivesView->setSelectionRectVisible( false );
|
||||||
|
m_drivesView->setWordWrap( true );
|
||||||
|
m_drivesView->setUniformItemSizes( true );
|
||||||
|
m_drivesView->setSelectionMode( QAbstractItemView::SingleSelection );
|
||||||
|
|
||||||
|
m_drivesView->setIconSize( CalamaresUtils::defaultIconSize() * 3 );
|
||||||
|
m_drivesView->setGridSize( QSize( CalamaresUtils::defaultFontHeight() * 8,
|
||||||
|
m_drivesView->iconSize().height() +
|
||||||
|
CalamaresUtils::defaultFontHeight() * 4 ) );
|
||||||
|
m_drivesView->setMinimumHeight( m_drivesView->gridSize().height() + 2 );
|
||||||
|
|
||||||
|
mainLayout->addStretch();
|
||||||
|
setNextEnabled( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EraseDiskPage::init( PartitionCoreModule* core )
|
||||||
|
{
|
||||||
|
if ( m_core ) //this should probably never happen
|
||||||
|
{
|
||||||
|
m_core->revert();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_core = core;
|
||||||
|
m_drivesView->setModel( core->deviceModel() );
|
||||||
|
|
||||||
|
connect( m_drivesView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||||
|
this, [ this ]()
|
||||||
|
{
|
||||||
|
setNextEnabled( m_drivesView->selectionModel()->hasSelection() );
|
||||||
|
|
||||||
|
//TODO: show a before/after view before this model, update it on selection changed
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
EraseDiskPage::isNextEnabled()
|
||||||
|
{
|
||||||
|
return m_nextEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EraseDiskPage::setNextEnabled( bool enabled )
|
||||||
|
{
|
||||||
|
if ( enabled == m_nextEnabled )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_nextEnabled = enabled;
|
||||||
|
emit nextStatusChanged( enabled );
|
||||||
|
}
|
49
src/modules/partition/gui/EraseDiskPage.h
Normal file
49
src/modules/partition/gui/EraseDiskPage.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2014, 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 ERASEDISKPAGE_H
|
||||||
|
#define ERASEDISKPAGE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class PartitionCoreModule;
|
||||||
|
class QListView;
|
||||||
|
|
||||||
|
class EraseDiskPage : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit EraseDiskPage( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
void init( PartitionCoreModule* core );
|
||||||
|
|
||||||
|
bool isNextEnabled();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void nextStatusChanged( bool );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setNextEnabled( bool enabled );
|
||||||
|
|
||||||
|
QListView* m_drivesView;
|
||||||
|
PartitionCoreModule* m_core;
|
||||||
|
|
||||||
|
bool m_nextEnabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ERASEDISKPAGE_H
|
@ -22,6 +22,7 @@
|
|||||||
#include <core/PartitionCoreModule.h>
|
#include <core/PartitionCoreModule.h>
|
||||||
#include <core/PartitionModel.h>
|
#include <core/PartitionModel.h>
|
||||||
#include <gui/ChoicePage.h>
|
#include <gui/ChoicePage.h>
|
||||||
|
#include <gui/EraseDiskPage.h>
|
||||||
#include <gui/PartitionPage.h>
|
#include <gui/PartitionPage.h>
|
||||||
#include <gui/PartitionPreview.h>
|
#include <gui/PartitionPreview.h>
|
||||||
|
|
||||||
@ -43,6 +44,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
|||||||
, m_widget( new QStackedWidget() )
|
, m_widget( new QStackedWidget() )
|
||||||
, m_core( new PartitionCoreModule( this ) )
|
, m_core( new PartitionCoreModule( this ) )
|
||||||
, m_choicePage( new ChoicePage() )
|
, m_choicePage( new ChoicePage() )
|
||||||
|
, m_erasePage( new EraseDiskPage() )
|
||||||
, m_manualPartitionPage( new PartitionPage( m_core ) )
|
, m_manualPartitionPage( new PartitionPage( m_core ) )
|
||||||
{
|
{
|
||||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
@ -78,9 +80,11 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
|||||||
QStringList osproberLines = osproberOutput.split( '\n' );
|
QStringList osproberLines = osproberOutput.split( '\n' );
|
||||||
|
|
||||||
m_choicePage->init( m_core, osproberLines );
|
m_choicePage->init( m_core, osproberLines );
|
||||||
|
m_erasePage->init( m_core );
|
||||||
|
|
||||||
m_widget->addWidget( m_choicePage );
|
m_widget->addWidget( m_choicePage );
|
||||||
m_widget->addWidget( m_manualPartitionPage );
|
m_widget->addWidget( m_manualPartitionPage );
|
||||||
|
m_widget->addWidget( m_erasePage );
|
||||||
m_widget->removeWidget( waitingWidget );
|
m_widget->removeWidget( waitingWidget );
|
||||||
waitingWidget->deleteLater();
|
waitingWidget->deleteLater();
|
||||||
|
|
||||||
@ -92,6 +96,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
|||||||
this, &PartitionViewStep::nextStatusChanged );
|
this, &PartitionViewStep::nextStatusChanged );
|
||||||
connect( m_choicePage, &ChoicePage::nextStatusChanged,
|
connect( m_choicePage, &ChoicePage::nextStatusChanged,
|
||||||
this, &PartitionViewStep::nextStatusChanged );
|
this, &PartitionViewStep::nextStatusChanged );
|
||||||
|
connect( m_erasePage, &EraseDiskPage::nextStatusChanged,
|
||||||
|
this, &PartitionViewStep::nextStatusChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -151,7 +157,14 @@ PartitionViewStep::next()
|
|||||||
{
|
{
|
||||||
if ( m_choicePage == m_widget->currentWidget() )
|
if ( m_choicePage == m_widget->currentWidget() )
|
||||||
{
|
{
|
||||||
|
if ( m_choicePage->currentChoice() == ChoicePage::Manual )
|
||||||
m_widget->setCurrentWidget( m_manualPartitionPage );
|
m_widget->setCurrentWidget( m_manualPartitionPage );
|
||||||
|
else if ( m_choicePage->currentChoice() == ChoicePage::Erase )
|
||||||
|
{
|
||||||
|
if ( m_core->isDirty() )
|
||||||
|
m_core->revert();
|
||||||
|
m_widget->setCurrentWidget( m_erasePage );
|
||||||
|
}
|
||||||
cDebug() << "Choice applied: " << m_choicePage->currentChoice();
|
cDebug() << "Choice applied: " << m_choicePage->currentChoice();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -173,6 +186,9 @@ PartitionViewStep::isNextEnabled() const
|
|||||||
if ( m_choicePage && m_choicePage == m_widget->currentWidget() )
|
if ( m_choicePage && m_choicePage == m_widget->currentWidget() )
|
||||||
return m_choicePage->isNextEnabled();
|
return m_choicePage->isNextEnabled();
|
||||||
|
|
||||||
|
if ( m_erasePage && m_erasePage == m_widget->currentWidget() )
|
||||||
|
return m_erasePage->isNextEnabled(); //FIXME: also check for mount point
|
||||||
|
|
||||||
return m_core->hasRootMountPoint();
|
return m_core->hasRootMountPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "PluginDllMacro.h"
|
#include "PluginDllMacro.h"
|
||||||
|
|
||||||
class ChoicePage;
|
class ChoicePage;
|
||||||
|
class EraseDiskPage;
|
||||||
class PartitionPage;
|
class PartitionPage;
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
@ -62,6 +63,7 @@ private:
|
|||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
QStackedWidget* m_widget;
|
QStackedWidget* m_widget;
|
||||||
ChoicePage* m_choicePage;
|
ChoicePage* m_choicePage;
|
||||||
|
EraseDiskPage* m_erasePage;
|
||||||
PartitionPage* m_manualPartitionPage;
|
PartitionPage* m_manualPartitionPage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user