Add page for erase+install operation.

main
Teo Mrnjavac 10 years ago
parent dab5a05116
commit ef703b0859

@ -33,6 +33,7 @@ calamares_add_plugin( partition
gui/ChoicePage.cpp
gui/CreatePartitionDialog.cpp
gui/EditExistingPartitionDialog.cpp
gui/EraseDiskPage.cpp
gui/PartitionPage.cpp
gui/PartitionPreview.cpp
gui/PartitionSizeController.cpp

@ -48,7 +48,7 @@ public:
Choice currentChoice();
signals:
void nextStatusChanged( bool enabled );
void nextStatusChanged( bool );
private:
void setNextEnabled( bool enabled );

@ -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 );
}

@ -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/PartitionModel.h>
#include <gui/ChoicePage.h>
#include <gui/EraseDiskPage.h>
#include <gui/PartitionPage.h>
#include <gui/PartitionPreview.h>
@ -43,6 +44,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
, m_widget( new QStackedWidget() )
, m_core( new PartitionCoreModule( this ) )
, m_choicePage( new ChoicePage() )
, m_erasePage( new EraseDiskPage() )
, m_manualPartitionPage( new PartitionPage( m_core ) )
{
m_widget->setContentsMargins( 0, 0, 0, 0 );
@ -78,9 +80,11 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
QStringList osproberLines = osproberOutput.split( '\n' );
m_choicePage->init( m_core, osproberLines );
m_erasePage->init( m_core );
m_widget->addWidget( m_choicePage );
m_widget->addWidget( m_manualPartitionPage );
m_widget->addWidget( m_erasePage );
m_widget->removeWidget( waitingWidget );
waitingWidget->deleteLater();
@ -88,10 +92,12 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
} );
timer->start( 0 );
connect( m_core, &PartitionCoreModule::hasRootMountPointChanged,
this, &PartitionViewStep::nextStatusChanged );
connect( m_choicePage, &ChoicePage::nextStatusChanged,
this, &PartitionViewStep::nextStatusChanged );
connect( m_core, &PartitionCoreModule::hasRootMountPointChanged,
this, &PartitionViewStep::nextStatusChanged );
connect( m_choicePage, &ChoicePage::nextStatusChanged,
this, &PartitionViewStep::nextStatusChanged );
connect( m_erasePage, &EraseDiskPage::nextStatusChanged,
this, &PartitionViewStep::nextStatusChanged );
}
@ -151,7 +157,14 @@ PartitionViewStep::next()
{
if ( m_choicePage == m_widget->currentWidget() )
{
m_widget->setCurrentWidget( m_manualPartitionPage );
if ( m_choicePage->currentChoice() == ChoicePage::Manual )
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();
}
else
@ -173,6 +186,9 @@ PartitionViewStep::isNextEnabled() const
if ( m_choicePage && m_choicePage == m_widget->currentWidget() )
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();
}

@ -25,6 +25,7 @@
#include "PluginDllMacro.h"
class ChoicePage;
class EraseDiskPage;
class PartitionPage;
class PartitionCoreModule;
class QStackedWidget;
@ -62,6 +63,7 @@ private:
PartitionCoreModule* m_core;
QStackedWidget* m_widget;
ChoicePage* m_choicePage;
EraseDiskPage* m_erasePage;
PartitionPage* m_manualPartitionPage;
};

Loading…
Cancel
Save