Ejemplo n.º 1
0
ReplaceWidget::ReplaceWidget( PartitionCoreModule* core,
                              QComboBox* devicesComboBox,
                              QWidget* parent )
    : QWidget( parent )
    , m_ui( new Ui_ReplaceWidget )
    , m_core( core )
    , m_isEfi( false )
{
    m_ui->setupUi( this );

    m_ui->bootComboBox->hide();
    m_ui->bootComboBox->clear();
    m_ui->bootStatusLabel->hide();
    m_ui->bootStatusLabel->clear();

    updateFromCurrentDevice( devicesComboBox );
    connect( devicesComboBox, &QComboBox::currentTextChanged,
             this, [=]( const QString& /* text */ )
    {
        updateFromCurrentDevice( devicesComboBox );
    } );

    CALAMARES_RETRANSLATE(
        onPartitionSelected();
    )
}
Ejemplo n.º 2
0
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
    : QWidget( parent )
    , m_ui( new Ui_PartitionPage )
    , m_lastSelectedBootLoaderIndex(-1)
    , m_core( core )
    , m_isEfi( false )
{
    m_isEfi = QDir( "/sys/firmware/efi/efivars" ).exists();

    m_ui->setupUi( this );
    m_ui->partitionLabelsView->setVisible(
            Calamares::JobQueue::instance()->globalStorage()->
                    value( "alwaysShowPartitionLabels" ).toBool() );
    m_ui->deviceComboBox->setModel( m_core->deviceModel() );
    m_ui->bootLoaderComboBox->setModel( m_core->bootLoaderModel() );
    PartitionBarsView::NestedPartitionsMode mode = Calamares::JobQueue::instance()->globalStorage()->
                                                   value( "drawNestedPartitions" ).toBool() ?
                                                       PartitionBarsView::DrawNestedPartitions :
                                                       PartitionBarsView::NoNestedPartitions;
    m_ui->partitionBarsView->setNestedPartitionsMode( mode );
    updateButtons();
    updateBootLoaderInstallPath();

    updateFromCurrentDevice();

    connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
             [ this ]( const QString& /* text */ )
    {
        updateFromCurrentDevice();
    } );
    connect( m_ui->bootLoaderComboBox, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
                [ this ]( const QString& /* text */ )
    {
        m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
    } );

    connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
             [ this ]( const QString& /* text */ )
    {
        updateBootLoaderInstallPath();
    } );

    connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );

    connect( m_ui->partitionTreeView, &QAbstractItemView::doubleClicked, this, &PartitionPage::onPartitionViewActivated );
    connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
    connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
    connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
    connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
    connect( m_ui->deleteButton, &QAbstractButton::clicked, this, &PartitionPage::onDeleteClicked );

    if ( m_isEfi ) {
        m_ui->bootLoaderComboBox->hide();
        m_ui->label_3->hide();
    }

    CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
}
Ejemplo n.º 3
0
void
PartitionPage::onRevertClicked()
{
    int oldIndex = m_ui->deviceComboBox->currentIndex();
    m_core->revert();
    m_ui->deviceComboBox->setCurrentIndex( oldIndex );
    updateFromCurrentDevice();
}
Ejemplo n.º 4
0
void
PartitionPage::onNewVolumeGroupClicked()
{
    QString vgName;
    QVector< const Partition* > selectedPVs;
    qint64 peSize = 4;

    QVector< const Partition* > availablePVs;

    for ( const Partition* p : m_core->lvmPVs() )
        if ( !m_core->isInVG( p ) )
            availablePVs << p;

    QPointer< CreateVolumeGroupDialog > dlg = new CreateVolumeGroupDialog( vgName,
                                                                           selectedPVs,
                                                                           availablePVs,
                                                                           peSize,
                                                                           this );

    if ( dlg->exec() == QDialog::Accepted )
    {
        QModelIndex partitionIndex = m_ui->partitionTreeView->currentIndex();

        if ( partitionIndex.isValid() )
        {
            const PartitionModel* model = static_cast< const PartitionModel* >( partitionIndex.model() );
            Q_ASSERT( model );
            Partition* partition = model->partitionForIndex( partitionIndex );
            Q_ASSERT( partition );

            // Disable delete button if current partition was selected to be in VG
            // TODO: Should Calamares edit LVM PVs which are in VGs?
            if ( selectedPVs.contains( partition ) )
                m_ui->deleteButton->setEnabled( false );
        }

        QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
        Q_ASSERT( deviceIndex.isValid() );

        QVariant previousIndexDeviceData = m_core->deviceModel()->data( deviceIndex, Qt::ToolTipRole );

        // Creating new VG
        m_core->createVolumeGroup( vgName, selectedPVs, peSize );

        // As createVolumeGroup method call resets deviceModel,
        // is needed to set the current index in deviceComboBox as the previous one
        int previousIndex = m_ui->deviceComboBox->findData( previousIndexDeviceData, Qt::ToolTipRole );

        m_ui->deviceComboBox->setCurrentIndex( ( previousIndex < 0  ) ? 0 : previousIndex );
        updateFromCurrentDevice();
    }

    delete dlg;
}
Ejemplo n.º 5
0
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
    : QWidget( parent )
    , m_ui( new Ui_PartitionPage )
    , m_core( core )
{
    m_ui->setupUi( this );
    m_ui->deviceComboBox->setModel( m_core->deviceModel() );
    m_ui->bootLoaderComboBox->setModel( m_core->bootLoaderModel() );
    updateButtons();
    updateBootLoaderInstallPath();

    updateFromCurrentDevice();

    connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
             [ this ]( const QString& /* text */ )
    {
        updateFromCurrentDevice();
    } );

    connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
             [ this ]( const QString& /* text */ )
    {
        updateBootLoaderInstallPath();
    } );

    connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );

    connect( m_ui->partitionTreeView, &QAbstractItemView::activated, this, &PartitionPage::onPartitionViewActivated );
    connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
    connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
    connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
    connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
    connect( m_ui->deleteButton, &QAbstractButton::clicked, this, &PartitionPage::onDeleteClicked );

    if ( QDir( "/sys/firmware/efi/efivars" ).exists() ) {
        m_ui->bootLoaderComboBox->setDisabled( true );
        m_ui->label_3->setDisabled( true );
    }
    
    CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
}
Ejemplo n.º 6
0
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
    : QWidget( parent )
    , m_ui( new Ui_PartitionPage )
    , m_core( core )
    , m_lastSelectedBootLoaderIndex(-1)
    , m_isEfi( false )
{
    m_isEfi = PartUtils::isEfiSystem();

    m_ui->setupUi( this );
    m_ui->partitionLabelsView->setVisible(
            Calamares::JobQueue::instance()->globalStorage()->
                    value( "alwaysShowPartitionLabels" ).toBool() );
    m_ui->deviceComboBox->setModel( m_core->deviceModel() );
    m_ui->bootLoaderComboBox->setModel( m_core->bootLoaderModel() );
    connect( m_core->bootLoaderModel(), &QAbstractItemModel::modelReset, this, &PartitionPage::restoreSelectedBootLoader );
    PartitionBarsView::NestedPartitionsMode mode = Calamares::JobQueue::instance()->globalStorage()->
                                                   value( "drawNestedPartitions" ).toBool() ?
                                                       PartitionBarsView::DrawNestedPartitions :
                                                       PartitionBarsView::NoNestedPartitions;
    m_ui->partitionBarsView->setNestedPartitionsMode( mode );
    updateButtons();
    updateBootLoaderInstallPath();

    updateFromCurrentDevice();

    connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateFromCurrentDevice );
    connect( m_ui->bootLoaderComboBox, QOverload<int>::of(&QComboBox::activated), this, &PartitionPage::updateSelectedBootLoaderIndex );
    connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged, this, &PartitionPage::updateBootLoaderInstallPath );

    connect( m_core, &PartitionCoreModule::isDirtyChanged, m_ui->revertButton, &QWidget::setEnabled );

    connect( m_ui->partitionTreeView, &QAbstractItemView::doubleClicked, this, &PartitionPage::onPartitionViewActivated );
    connect( m_ui->revertButton, &QAbstractButton::clicked, this, &PartitionPage::onRevertClicked );
    connect( m_ui->newVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onNewVolumeGroupClicked );
    connect( m_ui->resizeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onResizeVolumeGroupClicked );
    connect( m_ui->deactivateVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onDeactivateVolumeGroupClicked );
    connect( m_ui->removeVolumeGroupButton, &QAbstractButton::clicked, this, &PartitionPage::onRemoveVolumeGroupClicked );
    connect( m_ui->newPartitionTableButton, &QAbstractButton::clicked, this, &PartitionPage::onNewPartitionTableClicked );
    connect( m_ui->createButton, &QAbstractButton::clicked, this, &PartitionPage::onCreateClicked );
    connect( m_ui->editButton, &QAbstractButton::clicked, this, &PartitionPage::onEditClicked );
    connect( m_ui->deleteButton, &QAbstractButton::clicked, this, &PartitionPage::onDeleteClicked );

    if ( m_isEfi ) {
        m_ui->bootLoaderComboBox->hide();
        m_ui->label_3->hide();
    }

    CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
}
Ejemplo n.º 7
0
void
PartitionPage::onDeactivateVolumeGroupClicked()
{
    QModelIndex deviceIndex = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
    LvmDevice* device = dynamic_cast< LvmDevice* >( m_core->deviceModel()->deviceForIndex( deviceIndex ) );

    Q_ASSERT( device && device->type() == Device::Type::LVM_Device );

    m_core->deactivateVolumeGroup( device );

    updateFromCurrentDevice();

    PartitionModel* model = m_core->partitionModelForDevice( device );
    model->update();
}
Ejemplo n.º 8
0
void
PartitionPage::onRevertClicked()
{
    ScanningDialog::run(
        QtConcurrent::run( [ this ]
        {
            QMutexLocker locker( &m_revertMutex );

            int oldIndex = m_ui->deviceComboBox->currentIndex();
            m_core->revertAllDevices();
            m_ui->deviceComboBox->setCurrentIndex( oldIndex );
            updateFromCurrentDevice();
        } ),
        [ this ]{
            m_lastSelectedBootLoaderIndex = -1;
            if( m_ui->bootLoaderComboBox->currentIndex() < 0 ) {
                m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
            }
        },
        this );
}