Allow setting a custom new root name in Labels view.

main
Teo Mrnjavac 9 years ago
parent e277467ed4
commit 0c840abdc5

@ -536,6 +536,8 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
{
PartitionBarsView* preview = new PartitionBarsView( m_previewAfterFrame );
PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewAfterFrame );
previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()->
string( Calamares::Branding::ShortProductName ) );
PartitionModel* model = new PartitionModel( preview );
model->init( currentDevice, m_core->osproberEntries() );

@ -147,20 +147,22 @@ PartitionLabelsView::buildTexts( const QModelIndex& index ) const
PartitionModel::MountPointColumn )
.data().toString();
if ( mountPoint == "/" )
firstLine = tr( "New root partition" );
firstLine = m_customNewRootLabel.isEmpty() ?
tr( "Root" ) :
m_customNewRootLabel;
else if ( mountPoint == "/home" )
firstLine = tr( "New home partition" );
firstLine = tr( "Home" );
else if ( mountPoint == "/boot" )
firstLine = tr( "New boot partition" );
firstLine = tr( "Boot" );
else if ( mountPoint.contains( "/efi" ) &&
index.sibling( index.row(),
PartitionModel::FileSystemColumn )
.data().toString() == "fat32" )
firstLine = tr( "New EFI system partition" );
firstLine = tr( "EFI system" );
else if ( index.sibling( index.row(),
PartitionModel::FileSystemColumn )
.data().toString() == "linuxswap" )
firstLine = tr( "New swap partition" );
firstLine = tr( "Swap" );
else
firstLine = tr( "New partition for %1" ).arg( mountPoint );
}
@ -354,6 +356,14 @@ PartitionLabelsView::scrollTo( const QModelIndex& index, ScrollHint hint )
}
void
PartitionLabelsView::setCustomNewRootLabel( const QString& text )
{
m_customNewRootLabel = text;
viewport()->repaint();
}
QModelIndex
PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
{

@ -46,7 +46,7 @@ public:
QRect visualRect( const QModelIndex& index ) const override;
void scrollTo( const QModelIndex& index, ScrollHint hint = EnsureVisible ) override;
void setLabelsVisible( bool visible = true );
void setCustomNewRootLabel( const QString& text );
protected:
// QAbstractItemView API
@ -67,6 +67,7 @@ private:
void drawLabel( QPainter* painter, const QStringList& text, const QColor& color, const QPoint& pos );
QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const;
QStringList buildTexts( const QModelIndex& index ) const;
QString m_customNewRootLabel;
};
#endif // PARTITIONLABELSVIEW_H

Loading…
Cancel
Save