Yank out compact mode, refactor layout, fix strings.

main
Teo Mrnjavac 9 years ago
parent c6a7c54904
commit 3bf1fe716f

@ -45,8 +45,6 @@
#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
@ -55,9 +53,8 @@
* will show up as a list view.
* @param parent the QWidget parent.
*/
ChoicePage::ChoicePage( bool compactMode, QWidget* parent )
ChoicePage::ChoicePage( QWidget* parent )
: QWidget( parent )
, m_compactMode( compactMode )
, m_choice( NoChoice )
, m_nextEnabled( false )
, m_core( nullptr )
@ -69,34 +66,17 @@ ChoicePage::ChoicePage( bool compactMode, QWidget* parent )
, m_isEfi( false )
{
setupUi( this );
if ( m_compactMode )
{
// Set up drives combo
m_mainLayout->setDirection( QBoxLayout::TopToBottom );
m_drivesLayout->setDirection( QBoxLayout::LeftToRight );
m_drivesView = new QComboBox( this );
m_drivesCombo = 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 );
drivesList->setWrapping( false );
drivesList->setFlow( QListView::TopToBottom );
drivesList->setSelectionRectVisible( false );
drivesList->setWordWrap( true );
drivesList->setUniformItemSizes( true );
drivesList->setSelectionMode( QAbstractItemView::SingleSelection );
drivesList->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
drivesList->setIconSize( CalamaresUtils::defaultIconSize() / 2 );
}
m_drivesLabel->setBuddy( m_drivesCombo );
m_drivesLayout->addWidget( m_drivesView );
m_drivesLayout->addWidget( m_drivesCombo );
if ( m_compactMode )
m_drivesLayout->addStretch();
m_messageLabel->setWordWrap( true );
@ -104,7 +84,12 @@ ChoicePage::ChoicePage( bool compactMode, QWidget* parent )
CalamaresUtils::unmarginLayout( m_itemsLayout );
// 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_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
@ -133,36 +118,19 @@ ChoicePage::init( PartitionCoreModule* core,
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 );
m_drivesCombo->setModel( core->deviceModel() );
m_drivesCombo->setCurrentIndex( m_lastSelectedDeviceIndex );
} );
drivesCombo->setModel( core->deviceModel() );
m_drivesCombo->setModel( core->deviceModel() );
connect( drivesCombo,
connect( m_drivesCombo,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
this, &ChoicePage::applyDeviceChoice );
}
else
{
// Same as above.
connect( core, &PartitionCoreModule::reverted,
this, [=]
{
drivesList->setModel( core->deviceModel() );
drivesList->selectionModel()->setCurrentIndex(
core->deviceModel()->index( m_lastSelectedDeviceIndex ), QItemSelectionModel::ClearAndSelect );
} );
drivesList->setModel( core->deviceModel() );
connect( drivesList->selectionModel(),
&QItemSelectionModel::currentChanged,
this, &ChoicePage::applyDeviceChoice );
}
ChoicePage::applyDeviceChoice();
}
@ -392,7 +360,7 @@ ChoicePage::createReplaceButton()
QVBoxLayout* mainReplaceLayout = new QVBoxLayout;
replaceContainer->setLayout( mainReplaceLayout );
CalamaresUtils::unmarginLayout( mainReplaceLayout );
ReplaceWidget* replaceWidget = new ReplaceWidget( m_core, drivesCombo );
ReplaceWidget* replaceWidget = new ReplaceWidget( m_core, m_drivesCombo );
mainReplaceLayout->addWidget( replaceWidget );
if ( !m_isEfi )
@ -426,25 +394,10 @@ ChoicePage::createReplaceButton()
Device*
ChoicePage::selectedDevice()
{
if ( !compact() &&
drivesList->selectionModel()->currentIndex() == QModelIndex() )
{
cDebug() << "No disk selected, bailing out.";
return nullptr;
}
Device* currentDevice = nullptr;
if ( compact() )
{
currentDevice = m_core->deviceModel()->deviceForIndex(
m_core->deviceModel()->index(
drivesCombo->currentIndex() ) );
}
else
{
currentDevice = m_core->deviceModel()->deviceForIndex(
drivesList->selectionModel()->currentIndex() );
}
m_drivesCombo->currentIndex() ) );
return currentDevice;
}
@ -476,10 +429,7 @@ ChoicePage::applyDeviceChoice()
setupActions( currd );
if ( compact() )
m_lastSelectedDeviceIndex = drivesCombo->currentIndex();
else
m_lastSelectedDeviceIndex = drivesList->selectionModel()->currentIndex().row();
m_lastSelectedDeviceIndex = m_drivesCombo->currentIndex();
emit actionChosen();
emit deviceChosen( currd );
@ -566,20 +516,16 @@ ChoicePage::updateActionChoicePreview( Device* currentDevice, ChoicePage::Choice
m_previewAfterFrame->setLayout( layout );
layout->setMargin( 0 );
QLabel* label = new QLabel;
layout->addWidget( label );
switch ( choice )
{
case Alongside:
// split widget goes here
label->setText( tr( "Drag to split:" ) );
//label->setText( tr( "Drag to split:" ) );
break;
case Erase:
case Replace:
{
label->setText( tr( "Preview:" ) );
PartitionPreview* preview = new PartitionPreview( m_previewAfterFrame );
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
ChoicePage::setNextEnabled( bool enabled )
{

@ -51,7 +51,7 @@ public:
Manual
};
explicit ChoicePage( bool compactMode = false, QWidget* parent = nullptr );
explicit ChoicePage( QWidget* parent = nullptr );
virtual ~ChoicePage();
void init( PartitionCoreModule* core,
@ -67,7 +67,6 @@ signals:
void deviceChosen( Device* );
private:
bool compact();
void setNextEnabled( bool enabled );
void setupChoices();
QComboBox* createBootloaderComboBox( ExpandableRadioButton* parentButton );
@ -88,9 +87,8 @@ private:
Choice m_choice;
bool m_compactMode;
bool m_isEfi;
QWidget* m_drivesView;
QComboBox* m_drivesCombo;
PrettyRadioButton* m_alongsideButton;
ExpandableRadioButton* m_eraseButton;

@ -13,9 +13,12 @@
<property name="windowTitle">
<string>Form</string>
</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>
<layout class="QVBoxLayout" name="m_drivesLayout">
<layout class="QHBoxLayout" name="m_drivesLayout">
<item>
<widget class="QLabel" name="m_drivesLabel">
<property name="toolTip">
@ -29,10 +32,7 @@
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,0,1,0">
<item>
<widget class="QWidget" name="m_previewBeforeFrame" native="true"/>
</item>
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,1,0">
<item>
<widget class="QLabel" name="m_messageLabel">
<property name="toolTip">
@ -62,8 +62,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>481</width>
<height>456</height>
<width>729</width>
<height>386</height>
</rect>
</property>
<layout class="QVBoxLayout" name="m_itemsLayout">
@ -84,7 +84,51 @@
</widget>
</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>
</layout>
</item>

Loading…
Cancel
Save