From 0c840abdc5d86da3c75664694e1f3a587995b6cd Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Wed, 16 Dec 2015 11:13:03 +0100 Subject: [PATCH] Allow setting a custom new root name in Labels view. --- src/modules/partition/gui/ChoicePage.cpp | 2 ++ .../partition/gui/PartitionLabelsView.cpp | 20 ++++++++++++++----- .../partition/gui/PartitionLabelsView.h | 3 ++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index db1c67786..0e7dbb6c6 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -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() ); diff --git a/src/modules/partition/gui/PartitionLabelsView.cpp b/src/modules/partition/gui/PartitionLabelsView.cpp index 229a00622..5e9eedced 100644 --- a/src/modules/partition/gui/PartitionLabelsView.cpp +++ b/src/modules/partition/gui/PartitionLabelsView.cpp @@ -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 ) { diff --git a/src/modules/partition/gui/PartitionLabelsView.h b/src/modules/partition/gui/PartitionLabelsView.h index 20b7cc7f7..858f3131d 100644 --- a/src/modules/partition/gui/PartitionLabelsView.h +++ b/src/modules/partition/gui/PartitionLabelsView.h @@ -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