diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp
index 1711c5e12..a90ed6be3 100644
--- a/src/modules/partition/gui/ChoicePage.cpp
+++ b/src/modules/partition/gui/ChoicePage.cpp
@@ -97,8 +97,16 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
iconSize ) );
grp->addButton( eraseButton->buttonWidget() );
+ PrettyRadioButton* replaceButton = new PrettyRadioButton;
+ replaceButton->setIconSize( iconSize );
+ replaceButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Replace,
+ CalamaresUtils::Original,
+ iconSize ) );
+ grp->addButton( replaceButton->buttonWidget() );
+
m_itemsLayout->addWidget( eraseButton );
m_itemsLayout->addWidget( alongsideButton );
+ m_itemsLayout->addWidget( replaceButton );
m_itemsLayout->setSpacing( CalamaresUtils::defaultFontHeight() / 2 );
if ( osproberEntries.count() == 0 )
@@ -114,6 +122,7 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
string( Calamares::Branding::VersionedName ) ) );
)
+ replaceButton->hide();
alongsideButton->hide();
}
else if ( osproberEntries.count() == 1 )
@@ -135,13 +144,19 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
- eraseButton->setText( tr( "Replace %1 with %2
"
+ eraseButton->setText( tr( "Erase entire disk with %1 and install %2
"
"Warning: This will erase the whole disk and "
"delete all of your %1 programs, "
"documents, photos, music, and any other files." )
.arg( osName )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
+
+ replaceButton->setText( tr( "Install %1 on an existing partition
"
+ "Warning: This will delete all files "
+ "on the selected partition." )
+ .arg( Calamares::Branding::instance()->
+ string( Calamares::Branding::VersionedName ) ) );
)
}
else
@@ -162,6 +177,12 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
"documents, photos, music, and any other files." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
+
+ replaceButton->setText( tr( "Install %1 on an existing partition
"
+ "Warning: This will delete all files "
+ "on the selected partition." )
+ .arg( Calamares::Branding::instance()->
+ string( Calamares::Branding::VersionedName ) ) );
)
}
if ( !osproberEntries.first().canBeResized )
@@ -198,6 +219,12 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
"documents, photos, music, and any other files." )
.arg( Calamares::Branding::instance()->
string( Calamares::Branding::VersionedName ) ) );
+
+ replaceButton->setText( tr( "Install %1 on an existing partition
"
+ "Warning: This will delete all files "
+ "on the selected partition." )
+ .arg( Calamares::Branding::instance()->
+ string( Calamares::Branding::VersionedName ) ) );
)
if ( !atLeastOneCanBeResized )
@@ -239,6 +266,14 @@ ChoicePage::init( PartitionCoreModule* core, const OsproberEntryList& osproberEn
setNextEnabled( true );
} );
+ connect( replaceButton->buttonWidget(), &QRadioButton::toggled,
+ this, [ this ]( bool checked )
+ {
+ if ( checked )
+ m_choice = Replace;
+ setNextEnabled( true );
+ } );
+
connect( somethingElseButton->buttonWidget(), &QRadioButton::toggled,
this, [ this ]( bool checked )
{
diff --git a/src/modules/partition/gui/ChoicePage.h b/src/modules/partition/gui/ChoicePage.h
index af758ed4e..0ff69f6bc 100644
--- a/src/modules/partition/gui/ChoicePage.h
+++ b/src/modules/partition/gui/ChoicePage.h
@@ -37,6 +37,7 @@ public:
NoChoice,
Alongside,
Erase,
+ Replace,
Manual
};
diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp
index 8dad7c1e8..b25e69486 100644
--- a/src/modules/partition/gui/PartitionViewStep.cpp
+++ b/src/modules/partition/gui/PartitionViewStep.cpp
@@ -1,6 +1,7 @@
/* === This file is part of Calamares - ===
*
* Copyright 2014, Aurélien Gâteau
+ * Copyright 2014, Teo Mrnjavac
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,6 +29,7 @@
#include
#include
#include
+#include
#include
#include "OsproberEntry.h"
@@ -55,6 +57,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
, m_erasePage( new EraseDiskPage() )
, m_alongsidePage( new AlongsidePage() )
, m_manualPartitionPage( new PartitionPage( m_core ) )
+ , m_replacePage( new ReplacePage( m_core ) )
{
m_widget->setContentsMargins( 0, 0, 0, 0 );
@@ -118,6 +121,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
m_widget->addWidget( m_manualPartitionPage );
m_widget->addWidget( m_alongsidePage );
m_widget->addWidget( m_erasePage );
+ m_widget->addWidget( m_replacePage );
m_widget->removeWidget( waitingWidget );
waitingWidget->deleteLater();
@@ -133,6 +137,8 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
this, &PartitionViewStep::nextStatusChanged );
connect( m_alongsidePage, &AlongsidePage::nextStatusChanged,
this, &PartitionViewStep::nextStatusChanged );
+ connect( m_replacePage, &ReplacePage::nextStatusChanged,
+ this, &PartitionViewStep::nextStatusChanged );
}
@@ -206,6 +212,12 @@ PartitionViewStep::next()
m_core->revert();
m_widget->setCurrentWidget( m_alongsidePage );
}
+ else if ( m_choicePage->currentChoice() == ChoicePage::Replace )
+ {
+ if ( m_core->isDirty() )
+ m_core->revert();
+ m_widget->setCurrentWidget( m_replacePage );
+ }
cDebug() << "Choice applied: " << m_choicePage->currentChoice();
return;
}
@@ -248,7 +260,8 @@ PartitionViewStep::isAtBeginning() const
{
if ( m_widget->currentWidget() == m_manualPartitionPage ||
m_widget->currentWidget() == m_erasePage ||
- m_widget->currentWidget() == m_alongsidePage )
+ m_widget->currentWidget() == m_alongsidePage ||
+ m_widget->currentWidget() == m_replacePage )
return false;
return true;
}
@@ -270,6 +283,10 @@ PartitionViewStep::onLeave()
{
m_alongsidePage->applyChanges();
}
+ else if ( m_widget->currentWidget() == m_replacePage )
+ {
+ m_replacePage->applyChanges();
+ }
}
diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/gui/PartitionViewStep.h
index b27b42e10..93377a0ba 100644
--- a/src/modules/partition/gui/PartitionViewStep.h
+++ b/src/modules/partition/gui/PartitionViewStep.h
@@ -1,6 +1,7 @@
/* === This file is part of Calamares - ===
*
* Copyright 2014, Aurélien Gâteau
+ * Copyright 2014, Teo Mrnjavac
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,6 +29,7 @@ class ChoicePage;
class EraseDiskPage;
class AlongsidePage;
class PartitionPage;
+class ReplacePage;
class PartitionCoreModule;
class QStackedWidget;
@@ -71,6 +73,7 @@ private:
EraseDiskPage* m_erasePage;
AlongsidePage* m_alongsidePage;
PartitionPage* m_manualPartitionPage;
+ ReplacePage* m_replacePage;
};
#endif // PARTITIONVIEWSTEP_H