Allow setting a custom new root name in Labels view.
This commit is contained in:
parent
e277467ed4
commit
0c840abdc5
@ -536,6 +536,8 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
|
|||||||
{
|
{
|
||||||
PartitionBarsView* preview = new PartitionBarsView( m_previewAfterFrame );
|
PartitionBarsView* preview = new PartitionBarsView( m_previewAfterFrame );
|
||||||
PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewAfterFrame );
|
PartitionLabelsView* previewLabels = new PartitionLabelsView( m_previewAfterFrame );
|
||||||
|
previewLabels->setCustomNewRootLabel( Calamares::Branding::instance()->
|
||||||
|
string( Calamares::Branding::ShortProductName ) );
|
||||||
|
|
||||||
PartitionModel* model = new PartitionModel( preview );
|
PartitionModel* model = new PartitionModel( preview );
|
||||||
model->init( currentDevice, m_core->osproberEntries() );
|
model->init( currentDevice, m_core->osproberEntries() );
|
||||||
|
@ -147,20 +147,22 @@ PartitionLabelsView::buildTexts( const QModelIndex& index ) const
|
|||||||
PartitionModel::MountPointColumn )
|
PartitionModel::MountPointColumn )
|
||||||
.data().toString();
|
.data().toString();
|
||||||
if ( mountPoint == "/" )
|
if ( mountPoint == "/" )
|
||||||
firstLine = tr( "New root partition" );
|
firstLine = m_customNewRootLabel.isEmpty() ?
|
||||||
|
tr( "Root" ) :
|
||||||
|
m_customNewRootLabel;
|
||||||
else if ( mountPoint == "/home" )
|
else if ( mountPoint == "/home" )
|
||||||
firstLine = tr( "New home partition" );
|
firstLine = tr( "Home" );
|
||||||
else if ( mountPoint == "/boot" )
|
else if ( mountPoint == "/boot" )
|
||||||
firstLine = tr( "New boot partition" );
|
firstLine = tr( "Boot" );
|
||||||
else if ( mountPoint.contains( "/efi" ) &&
|
else if ( mountPoint.contains( "/efi" ) &&
|
||||||
index.sibling( index.row(),
|
index.sibling( index.row(),
|
||||||
PartitionModel::FileSystemColumn )
|
PartitionModel::FileSystemColumn )
|
||||||
.data().toString() == "fat32" )
|
.data().toString() == "fat32" )
|
||||||
firstLine = tr( "New EFI system partition" );
|
firstLine = tr( "EFI system" );
|
||||||
else if ( index.sibling( index.row(),
|
else if ( index.sibling( index.row(),
|
||||||
PartitionModel::FileSystemColumn )
|
PartitionModel::FileSystemColumn )
|
||||||
.data().toString() == "linuxswap" )
|
.data().toString() == "linuxswap" )
|
||||||
firstLine = tr( "New swap partition" );
|
firstLine = tr( "Swap" );
|
||||||
else
|
else
|
||||||
firstLine = tr( "New partition for %1" ).arg( mountPoint );
|
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
|
QModelIndex
|
||||||
PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
|
PartitionLabelsView::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers )
|
||||||
{
|
{
|
||||||
|
@ -46,7 +46,7 @@ public:
|
|||||||
QRect visualRect( const QModelIndex& index ) const override;
|
QRect visualRect( const QModelIndex& index ) const override;
|
||||||
void scrollTo( const QModelIndex& index, ScrollHint hint = EnsureVisible ) override;
|
void scrollTo( const QModelIndex& index, ScrollHint hint = EnsureVisible ) override;
|
||||||
|
|
||||||
void setLabelsVisible( bool visible = true );
|
void setCustomNewRootLabel( const QString& text );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// QAbstractItemView API
|
// QAbstractItemView API
|
||||||
@ -67,6 +67,7 @@ private:
|
|||||||
void drawLabel( QPainter* painter, const QStringList& text, const QColor& color, const QPoint& pos );
|
void drawLabel( QPainter* painter, const QStringList& text, const QColor& color, const QPoint& pos );
|
||||||
QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const;
|
QModelIndexList getIndexesToDraw( const QModelIndex& parent ) const;
|
||||||
QStringList buildTexts( const QModelIndex& index ) const;
|
QStringList buildTexts( const QModelIndex& index ) const;
|
||||||
|
QString m_customNewRootLabel;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITIONLABELSVIEW_H
|
#endif // PARTITIONLABELSVIEW_H
|
||||||
|
Loading…
Reference in New Issue
Block a user