diff --git a/src/modules/partition/gui/EraseDiskPage.cpp b/src/modules/partition/gui/EraseDiskPage.cpp index 03bd16902..5e46f587a 100644 --- a/src/modules/partition/gui/EraseDiskPage.cpp +++ b/src/modules/partition/gui/EraseDiskPage.cpp @@ -224,11 +224,13 @@ EraseDiskPage::updatePreviews() layout->addRow( new QLabel( info.deviceName ) ); preview = new PartitionPreview; + preview->setLabelsVisible( true ); preview->setModel( info.partitionModelBefore ); info.partitionModelBefore->setParent( m_previewFrame ); layout->addRow( tr( "Before:" ), preview ); preview = new PartitionPreview; + preview->setLabelsVisible( true ); preview->setModel( info.partitionModelAfter ); info.partitionModelAfter->setParent( m_previewFrame ); layout->addRow( tr( "After:" ), preview ); diff --git a/src/modules/partition/gui/PartitionPreview.cpp b/src/modules/partition/gui/PartitionPreview.cpp index 939f890cb..1ea1fd49d 100644 --- a/src/modules/partition/gui/PartitionPreview.cpp +++ b/src/modules/partition/gui/PartitionPreview.cpp @@ -35,7 +35,8 @@ static const int EXTENDED_PARTITION_MARGIN = 4; PartitionPreview::PartitionPreview( QWidget* parent ) - : QAbstractItemView( parent ) + : m_showLabels( false ) + , QAbstractItemView( parent ) { setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); setFrameStyle( QFrame::NoFrame ); @@ -57,7 +58,9 @@ PartitionPreview::minimumSizeHint() const QSize PartitionPreview::sizeHint() const { - return QSize( -1, VIEW_HEIGHT + LAYOUT_MARGIN + labelsHeight() ); + if ( m_showLabels ) + return QSize( -1, VIEW_HEIGHT + LAYOUT_MARGIN + labelsHeight() ); + return QSize( -1, VIEW_HEIGHT ); } @@ -75,7 +78,8 @@ PartitionPreview::paintEvent( QPaintEvent* event ) painter.save(); drawPartitions( &painter, partitionsRect, QModelIndex() ); painter.restore(); - drawLabels( &painter, labelsRect, QModelIndex() ); + if ( m_showLabels ) + drawLabels( &painter, labelsRect, QModelIndex() ); } @@ -284,6 +288,14 @@ PartitionPreview::scrollTo( const QModelIndex& index, ScrollHint hint ) } +void +PartitionPreview::setLabelsVisible( bool visible ) +{ + m_showLabels = visible; + repaint(); +} + + QModelIndex PartitionPreview::moveCursor( CursorAction cursorAction, Qt::KeyboardModifiers modifiers ) { diff --git a/src/modules/partition/gui/PartitionPreview.h b/src/modules/partition/gui/PartitionPreview.h index e18d910af..60026ecbd 100644 --- a/src/modules/partition/gui/PartitionPreview.h +++ b/src/modules/partition/gui/PartitionPreview.h @@ -31,7 +31,7 @@ class PartitionPreview : public QAbstractItemView { public: - explicit PartitionPreview( QWidget* parent = 0 ); + explicit PartitionPreview( QWidget* parent = nullptr ); ~PartitionPreview(); QSize minimumSizeHint() const override; @@ -45,6 +45,8 @@ public: QRect visualRect( const QModelIndex& index ) const override; void scrollTo( const QModelIndex& index, ScrollHint hint = EnsureVisible ) override; + void setLabelsVisible( bool visible = true ); + protected: // QAbstractItemView API QRegion visualRegionForSelection( const QItemSelection& selection ) const override; @@ -58,6 +60,7 @@ private: void drawPartitions( QPainter* painter, const QRect& rect, const QModelIndex& parent ); void drawLabels( QPainter* painter, const QRect& rect, const QModelIndex& parent ); static int labelsHeight(); + bool m_showLabels; }; #endif /* PARTITIONPREVIEW_H */ diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index 4df684256..4b92e85ec 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -262,11 +262,13 @@ PartitionViewStep::createSummaryWidget() const PartitionPreview* preview; preview = new PartitionPreview; + preview->setLabelsVisible( true ); preview->setModel( info.partitionModelBefore ); info.partitionModelBefore->setParent( widget ); formLayout->addRow( tr( "Before:" ), preview ); preview = new PartitionPreview; + preview->setLabelsVisible( true ); preview->setModel( info.partitionModelAfter ); info.partitionModelAfter->setParent( widget ); formLayout->addRow( tr( "After:" ), preview ); diff --git a/src/modules/partition/gui/ReplacePage.cpp b/src/modules/partition/gui/ReplacePage.cpp index a6d3a61ec..f0a51b8ff 100644 --- a/src/modules/partition/gui/ReplacePage.cpp +++ b/src/modules/partition/gui/ReplacePage.cpp @@ -42,6 +42,7 @@ ReplacePage::ReplacePage( PartitionCoreModule* core, QWidget* parent ) { m_ui->setupUi( this ); m_ui->deviceComboBox->setModel( m_core->deviceModel() ); + m_ui->partitionPreview->setLabelsVisible( true ); // updateButtons();