Only show the labels section where it's relevant.

main
Teo Mrnjavac 10 years ago
parent 966ccdaafc
commit 45d5c5bbde

@ -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 );

@ -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 )
{

@ -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 */

@ -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 );

@ -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();

Loading…
Cancel
Save