Yank out compact mode, refactor layout, fix strings.
This commit is contained in:
parent
c6a7c54904
commit
3bf1fe716f
@ -45,8 +45,6 @@
|
|||||||
#include <QListView>
|
#include <QListView>
|
||||||
|
|
||||||
|
|
||||||
#define drivesList qobject_cast< QListView* >( m_drivesView )
|
|
||||||
#define drivesCombo qobject_cast< QComboBox* >( m_drivesView )
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
|
* @brief ChoicePage::ChoicePage is the default constructor. Called on startup as part of
|
||||||
@ -55,9 +53,8 @@
|
|||||||
* will show up as a list view.
|
* will show up as a list view.
|
||||||
* @param parent the QWidget parent.
|
* @param parent the QWidget parent.
|
||||||
*/
|
*/
|
||||||
ChoicePage::ChoicePage( bool compactMode, QWidget* parent )
|
ChoicePage::ChoicePage( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_compactMode( compactMode )
|
|
||||||
, m_choice( NoChoice )
|
, m_choice( NoChoice )
|
||||||
, m_nextEnabled( false )
|
, m_nextEnabled( false )
|
||||||
, m_core( nullptr )
|
, m_core( nullptr )
|
||||||
@ -69,42 +66,30 @@ ChoicePage::ChoicePage( bool compactMode, QWidget* parent )
|
|||||||
, m_isEfi( false )
|
, m_isEfi( false )
|
||||||
{
|
{
|
||||||
setupUi( this );
|
setupUi( this );
|
||||||
if ( m_compactMode )
|
|
||||||
{
|
|
||||||
m_mainLayout->setDirection( QBoxLayout::TopToBottom );
|
|
||||||
m_drivesLayout->setDirection( QBoxLayout::LeftToRight );
|
|
||||||
m_drivesView = new QComboBox( this );
|
|
||||||
m_mainLayout->setStretchFactor( m_drivesLayout, 0 );
|
|
||||||
m_mainLayout->setStretchFactor( m_rightLayout, 1 );
|
|
||||||
m_drivesLabel->setBuddy( m_drivesView );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_drivesView = new QListView( this );
|
|
||||||
|
|
||||||
drivesList->setViewMode( QListView::ListMode );
|
// Set up drives combo
|
||||||
drivesList->setWrapping( false );
|
m_mainLayout->setDirection( QBoxLayout::TopToBottom );
|
||||||
drivesList->setFlow( QListView::TopToBottom );
|
m_drivesLayout->setDirection( QBoxLayout::LeftToRight );
|
||||||
drivesList->setSelectionRectVisible( false );
|
m_drivesCombo = new QComboBox( this );
|
||||||
drivesList->setWordWrap( true );
|
m_mainLayout->setStretchFactor( m_drivesLayout, 0 );
|
||||||
drivesList->setUniformItemSizes( true );
|
m_mainLayout->setStretchFactor( m_rightLayout, 1 );
|
||||||
drivesList->setSelectionMode( QAbstractItemView::SingleSelection );
|
m_drivesLabel->setBuddy( m_drivesCombo );
|
||||||
drivesList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
|
|
||||||
|
|
||||||
drivesList->setIconSize( CalamaresUtils::defaultIconSize() / 2 );
|
m_drivesLayout->addWidget( m_drivesCombo );
|
||||||
}
|
|
||||||
|
|
||||||
m_drivesLayout->addWidget( m_drivesView );
|
m_drivesLayout->addStretch();
|
||||||
|
|
||||||
if ( m_compactMode )
|
|
||||||
m_drivesLayout->addStretch();
|
|
||||||
|
|
||||||
m_messageLabel->setWordWrap( true );
|
m_messageLabel->setWordWrap( true );
|
||||||
|
|
||||||
CalamaresUtils::unmarginLayout( m_itemsLayout );
|
CalamaresUtils::unmarginLayout( m_itemsLayout );
|
||||||
|
|
||||||
// Drive selector + preview
|
// Drive selector + preview
|
||||||
CALAMARES_RETRANSLATE( m_drivesLabel->setText( tr( "Storage de&vice:" ) ); )
|
CALAMARES_RETRANSLATE(
|
||||||
|
retranslateUi( this );
|
||||||
|
m_drivesLabel->setText( tr( "Storage de&vice:" ) );
|
||||||
|
m_previewBeforeLabel->setText( tr( "Current state:" ) );
|
||||||
|
m_previewAfterLabel->setText( tr( "Your changes:" ) );
|
||||||
|
)
|
||||||
|
|
||||||
m_previewBeforeFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
m_previewBeforeFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||||
m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||||
@ -133,36 +118,19 @@ ChoicePage::init( PartitionCoreModule* core,
|
|||||||
|
|
||||||
setupChoices();
|
setupChoices();
|
||||||
|
|
||||||
if ( compact() )
|
|
||||||
{
|
|
||||||
// We need to do this because a PCM revert invalidates the deviceModel.
|
|
||||||
connect( core, &PartitionCoreModule::reverted,
|
|
||||||
this, [=]
|
|
||||||
{
|
|
||||||
drivesCombo->setModel( core->deviceModel() );
|
|
||||||
drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
|
|
||||||
} );
|
|
||||||
drivesCombo->setModel( core->deviceModel() );
|
|
||||||
|
|
||||||
connect( drivesCombo,
|
// We need to do this because a PCM revert invalidates the deviceModel.
|
||||||
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
connect( core, &PartitionCoreModule::reverted,
|
||||||
this, &ChoicePage::applyDeviceChoice );
|
this, [=]
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// Same as above.
|
m_drivesCombo->setModel( core->deviceModel() );
|
||||||
connect( core, &PartitionCoreModule::reverted,
|
m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
|
||||||
this, [=]
|
} );
|
||||||
{
|
m_drivesCombo->setModel( core->deviceModel() );
|
||||||
drivesList->setModel( core->deviceModel() );
|
|
||||||
drivesList->selectionModel()->setCurrentIndex(
|
connect( m_drivesCombo,
|
||||||
core->deviceModel()->index( m_lastSelectedDeviceIndex ), QItemSelectionModel::ClearAndSelect );
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
||||||
} );
|
this, &ChoicePage::applyDeviceChoice );
|
||||||
drivesList->setModel( core->deviceModel() );
|
|
||||||
connect( drivesList->selectionModel(),
|
|
||||||
&QItemSelectionModel::currentChanged,
|
|
||||||
this, &ChoicePage::applyDeviceChoice );
|
|
||||||
}
|
|
||||||
|
|
||||||
ChoicePage::applyDeviceChoice();
|
ChoicePage::applyDeviceChoice();
|
||||||
}
|
}
|
||||||
@ -392,7 +360,7 @@ ChoicePage::createReplaceButton()
|
|||||||
QVBoxLayout* mainReplaceLayout = new QVBoxLayout;
|
QVBoxLayout* mainReplaceLayout = new QVBoxLayout;
|
||||||
replaceContainer->setLayout( mainReplaceLayout );
|
replaceContainer->setLayout( mainReplaceLayout );
|
||||||
CalamaresUtils::unmarginLayout( mainReplaceLayout );
|
CalamaresUtils::unmarginLayout( mainReplaceLayout );
|
||||||
ReplaceWidget* replaceWidget = new ReplaceWidget( m_core, drivesCombo );
|
ReplaceWidget* replaceWidget = new ReplaceWidget( m_core, m_drivesCombo );
|
||||||
mainReplaceLayout->addWidget( replaceWidget );
|
mainReplaceLayout->addWidget( replaceWidget );
|
||||||
|
|
||||||
if ( !m_isEfi )
|
if ( !m_isEfi )
|
||||||
@ -426,25 +394,10 @@ ChoicePage::createReplaceButton()
|
|||||||
Device*
|
Device*
|
||||||
ChoicePage::selectedDevice()
|
ChoicePage::selectedDevice()
|
||||||
{
|
{
|
||||||
if ( !compact() &&
|
|
||||||
drivesList->selectionModel()->currentIndex() == QModelIndex() )
|
|
||||||
{
|
|
||||||
cDebug() << "No disk selected, bailing out.";
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Device* currentDevice = nullptr;
|
Device* currentDevice = nullptr;
|
||||||
if ( compact() )
|
currentDevice = m_core->deviceModel()->deviceForIndex(
|
||||||
{
|
m_core->deviceModel()->index(
|
||||||
currentDevice = m_core->deviceModel()->deviceForIndex(
|
m_drivesCombo->currentIndex() ) );
|
||||||
m_core->deviceModel()->index(
|
|
||||||
drivesCombo->currentIndex() ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentDevice = m_core->deviceModel()->deviceForIndex(
|
|
||||||
drivesList->selectionModel()->currentIndex() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentDevice;
|
return currentDevice;
|
||||||
}
|
}
|
||||||
@ -476,10 +429,7 @@ ChoicePage::applyDeviceChoice()
|
|||||||
|
|
||||||
setupActions( currd );
|
setupActions( currd );
|
||||||
|
|
||||||
if ( compact() )
|
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
|
||||||
m_lastSelectedDeviceIndex = drivesCombo->currentIndex();
|
|
||||||
else
|
|
||||||
m_lastSelectedDeviceIndex = drivesList->selectionModel()->currentIndex().row();
|
|
||||||
|
|
||||||
emit actionChosen();
|
emit actionChosen();
|
||||||
emit deviceChosen( currd );
|
emit deviceChosen( currd );
|
||||||
@ -566,20 +516,16 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
|
|||||||
m_previewAfterFrame->setLayout( layout );
|
m_previewAfterFrame->setLayout( layout );
|
||||||
layout->setMargin( 0 );
|
layout->setMargin( 0 );
|
||||||
|
|
||||||
QLabel* label = new QLabel;
|
|
||||||
layout->addWidget( label );
|
|
||||||
|
|
||||||
switch ( choice )
|
switch ( choice )
|
||||||
{
|
{
|
||||||
case Alongside:
|
case Alongside:
|
||||||
// split widget goes here
|
// split widget goes here
|
||||||
label->setText( tr( "Drag to split:" ) );
|
//label->setText( tr( "Drag to split:" ) );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case Erase:
|
case Erase:
|
||||||
case Replace:
|
case Replace:
|
||||||
{
|
{
|
||||||
label->setText( tr( "Preview:" ) );
|
|
||||||
PartitionPreview* preview = new PartitionPreview( m_previewAfterFrame );
|
PartitionPreview* preview = new PartitionPreview( m_previewAfterFrame );
|
||||||
preview->setLabelsVisible( true );
|
preview->setLabelsVisible( true );
|
||||||
|
|
||||||
@ -778,24 +724,6 @@ ChoicePage::currentChoice() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
ChoicePage::compact()
|
|
||||||
{
|
|
||||||
if ( m_compactMode )
|
|
||||||
{
|
|
||||||
Q_ASSERT( drivesCombo );
|
|
||||||
Q_ASSERT( !drivesList );
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Q_ASSERT( drivesList );
|
|
||||||
Q_ASSERT( !drivesCombo );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::setNextEnabled( bool enabled )
|
ChoicePage::setNextEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
|
@ -51,7 +51,7 @@ public:
|
|||||||
Manual
|
Manual
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit ChoicePage( bool compactMode = false, QWidget* parent = nullptr );
|
explicit ChoicePage( QWidget* parent = nullptr );
|
||||||
virtual ~ChoicePage();
|
virtual ~ChoicePage();
|
||||||
|
|
||||||
void init( PartitionCoreModule* core,
|
void init( PartitionCoreModule* core,
|
||||||
@ -67,7 +67,6 @@ signals:
|
|||||||
void deviceChosen( Device* );
|
void deviceChosen( Device* );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool compact();
|
|
||||||
void setNextEnabled( bool enabled );
|
void setNextEnabled( bool enabled );
|
||||||
void setupChoices();
|
void setupChoices();
|
||||||
QComboBox* createBootloaderComboBox( ExpandableRadioButton* parentButton );
|
QComboBox* createBootloaderComboBox( ExpandableRadioButton* parentButton );
|
||||||
@ -88,9 +87,8 @@ private:
|
|||||||
|
|
||||||
Choice m_choice;
|
Choice m_choice;
|
||||||
|
|
||||||
bool m_compactMode;
|
|
||||||
bool m_isEfi;
|
bool m_isEfi;
|
||||||
QWidget* m_drivesView;
|
QComboBox* m_drivesCombo;
|
||||||
|
|
||||||
PrettyRadioButton* m_alongsideButton;
|
PrettyRadioButton* m_alongsideButton;
|
||||||
ExpandableRadioButton* m_eraseButton;
|
ExpandableRadioButton* m_eraseButton;
|
||||||
|
@ -13,9 +13,12 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="m_mainLayout" stretch="1,2">
|
<layout class="QVBoxLayout" name="m_mainLayout" stretch="0,1">
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="m_drivesLayout">
|
<layout class="QHBoxLayout" name="m_drivesLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_drivesLabel">
|
<widget class="QLabel" name="m_drivesLabel">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -29,10 +32,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,0,1,0">
|
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,1,0">
|
||||||
<item>
|
|
||||||
<widget class="QWidget" name="m_previewBeforeFrame" native="true"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_messageLabel">
|
<widget class="QLabel" name="m_messageLabel">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -62,8 +62,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>481</width>
|
<width>729</width>
|
||||||
<height>456</height>
|
<height>386</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="m_itemsLayout">
|
<layout class="QVBoxLayout" name="m_itemsLayout">
|
||||||
@ -84,7 +84,51 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="m_previewAfterFrame" native="true"/>
|
<layout class="QGridLayout" name="beforeAfterGridLayout">
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QWidget" name="m_previewAfterFrame" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QWidget" name="m_previewBeforeFrame" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="m_previewBeforeLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">Before:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="m_previewAfterLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">After:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user