Refactor ReplacePage into new ReplaceWidget.
This commit is contained in:
parent
351c69c300
commit
46fcca63c3
@ -42,7 +42,7 @@ calamares_add_plugin( partition
|
|||||||
gui/PartitionViewStep.cpp
|
gui/PartitionViewStep.cpp
|
||||||
gui/PrettyRadioButton.cpp
|
gui/PrettyRadioButton.cpp
|
||||||
gui/ExpandableRadioButton.cpp
|
gui/ExpandableRadioButton.cpp
|
||||||
gui/ReplacePage.cpp
|
gui/ReplaceWidget.cpp
|
||||||
jobs/CheckFileSystemJob.cpp
|
jobs/CheckFileSystemJob.cpp
|
||||||
jobs/ClearMountsJob.cpp
|
jobs/ClearMountsJob.cpp
|
||||||
jobs/ClearTempMountsJob.cpp
|
jobs/ClearTempMountsJob.cpp
|
||||||
@ -60,7 +60,7 @@ calamares_add_plugin( partition
|
|||||||
gui/CreatePartitionTableDialog.ui
|
gui/CreatePartitionTableDialog.ui
|
||||||
gui/EditExistingPartitionDialog.ui
|
gui/EditExistingPartitionDialog.ui
|
||||||
gui/PartitionPage.ui
|
gui/PartitionPage.ui
|
||||||
gui/ReplacePage.ui
|
gui/ReplaceWidget.ui
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
kpmcore
|
kpmcore
|
||||||
calamaresui
|
calamaresui
|
||||||
|
@ -17,91 +17,73 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ReplacePage.h"
|
#include "ReplaceWidget.h"
|
||||||
#include "ui_ReplacePage.h"
|
#include "ui_ReplaceWidget.h"
|
||||||
|
|
||||||
#include "core/PartitionCoreModule.h"
|
|
||||||
#include "core/KPMHelpers.h"
|
|
||||||
#include "core/PartitionInfo.h"
|
|
||||||
#include "core/DeviceModel.h"
|
#include "core/DeviceModel.h"
|
||||||
|
#include "core/PartitionCoreModule.h"
|
||||||
#include "core/PartitionActions.h"
|
#include "core/PartitionActions.h"
|
||||||
|
#include "core/PartitionInfo.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
|
||||||
#include "utils/Retranslator.h"
|
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
|
||||||
#include "utils/Logger.h"
|
|
||||||
#include "Branding.h"
|
#include "Branding.h"
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
#include "utils/Retranslator.h"
|
||||||
|
|
||||||
#include <kpmcore/core/device.h>
|
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QComboBox>
|
||||||
#include <QProcess>
|
|
||||||
|
|
||||||
|
ReplaceWidget::ReplaceWidget( PartitionCoreModule* core,
|
||||||
ReplacePage::ReplacePage( PartitionCoreModule* core, QWidget* parent )
|
QComboBox* devicesComboBox,
|
||||||
|
QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_ui( new Ui_ReplacePage )
|
, m_ui( new Ui_ReplaceWidget )
|
||||||
, m_core( core )
|
, m_core( core )
|
||||||
, m_isEfi( false )
|
, m_isEfi( false )
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
m_ui->deviceComboBox->setModel( m_core->deviceModel() );
|
|
||||||
m_ui->partitionPreview->setLabelsVisible( true );
|
|
||||||
|
|
||||||
m_ui->bootComboBox->hide();
|
m_ui->bootComboBox->hide();
|
||||||
m_ui->bootComboBox->clear();
|
m_ui->bootComboBox->clear();
|
||||||
m_ui->bootStatusLabel->hide();
|
m_ui->bootStatusLabel->hide();
|
||||||
m_ui->bootStatusLabel->clear();
|
m_ui->bootStatusLabel->clear();
|
||||||
|
|
||||||
// updateButtons();
|
updateFromCurrentDevice( devicesComboBox );
|
||||||
|
connect( devicesComboBox, &QComboBox::currentTextChanged,
|
||||||
updateFromCurrentDevice();
|
this, [=]( const QString& /* text */ )
|
||||||
|
|
||||||
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
|
|
||||||
[ this ]( const QString& /* text */ )
|
|
||||||
{
|
{
|
||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice( devicesComboBox );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE(
|
CALAMARES_RETRANSLATE(
|
||||||
m_ui->retranslateUi( this );
|
|
||||||
onPartitionSelected();
|
onPartitionSelected();
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ReplacePage::~ReplacePage()
|
ReplaceWidget::~ReplaceWidget()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ReplacePage::isNextEnabled() const
|
ReplaceWidget::isNextEnabled() const
|
||||||
{
|
{
|
||||||
return m_nextEnabled;
|
return m_nextEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::reset()
|
ReplaceWidget::reset()
|
||||||
{
|
{
|
||||||
int oldDeviceIndex = m_ui->deviceComboBox->currentIndex();
|
//moo;
|
||||||
m_core->revert();
|
|
||||||
|
|
||||||
m_ui->bootComboBox->hide();
|
|
||||||
m_ui->bootComboBox->clear();
|
|
||||||
m_ui->bootStatusLabel->hide();
|
|
||||||
m_ui->bootStatusLabel->clear();
|
|
||||||
|
|
||||||
m_ui->deviceComboBox->setCurrentIndex( oldDeviceIndex );
|
|
||||||
updateFromCurrentDevice();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::applyChanges()
|
ReplaceWidget::applyChanges()
|
||||||
{
|
{
|
||||||
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
|
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
|
||||||
if ( model )
|
if ( model )
|
||||||
@ -141,7 +123,7 @@ ReplacePage::applyChanges()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::onPartitionSelected()
|
ReplaceWidget::onPartitionSelected()
|
||||||
{
|
{
|
||||||
if ( Calamares::JobQueue::instance()->globalStorage()->value( "firmwareType" ) == "efi" )
|
if ( Calamares::JobQueue::instance()->globalStorage()->value( "firmwareType" ) == "efi" )
|
||||||
m_isEfi = true;
|
m_isEfi = true;
|
||||||
@ -341,7 +323,7 @@ ReplacePage::onPartitionSelected()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::setNextEnabled( bool enabled )
|
ReplaceWidget::setNextEnabled( bool enabled )
|
||||||
{
|
{
|
||||||
if ( enabled == m_nextEnabled )
|
if ( enabled == m_nextEnabled )
|
||||||
return;
|
return;
|
||||||
@ -352,7 +334,7 @@ ReplacePage::setNextEnabled( bool enabled )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::updateStatus( CalamaresUtils::ImageType imageType, const QString& text )
|
ReplaceWidget::updateStatus( CalamaresUtils::ImageType imageType, const QString& text )
|
||||||
{
|
{
|
||||||
int iconSize = CalamaresUtils::defaultFontHeight() * 8;
|
int iconSize = CalamaresUtils::defaultFontHeight() * 8;
|
||||||
m_ui->selectedIconLabel->setPixmap( CalamaresUtils::defaultPixmap( imageType,
|
m_ui->selectedIconLabel->setPixmap( CalamaresUtils::defaultPixmap( imageType,
|
||||||
@ -363,10 +345,11 @@ ReplacePage::updateStatus( CalamaresUtils::ImageType imageType, const QString& t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::updateFromCurrentDevice()
|
ReplaceWidget::updateFromCurrentDevice( QComboBox* devicesComboBox )
|
||||||
{
|
{
|
||||||
QModelIndex index = m_core->deviceModel()->index( m_ui->deviceComboBox->currentIndex(), 0 );
|
QModelIndex index = m_core->deviceModel()->index( devicesComboBox->currentIndex(), 0 );
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -377,7 +360,6 @@ ReplacePage::updateFromCurrentDevice()
|
|||||||
disconnect( oldModel, 0, this, 0 );
|
disconnect( oldModel, 0, this, 0 );
|
||||||
|
|
||||||
PartitionModel* model = m_core->partitionModelForDevice( device );
|
PartitionModel* model = m_core->partitionModelForDevice( device );
|
||||||
m_ui->partitionPreview->setModel( model );
|
|
||||||
m_ui->partitionTreeView->setModel( model );
|
m_ui->partitionTreeView->setModel( model );
|
||||||
m_ui->partitionTreeView->expandAll();
|
m_ui->partitionTreeView->expandAll();
|
||||||
|
|
||||||
@ -391,14 +373,14 @@ ReplacePage::updateFromCurrentDevice()
|
|||||||
// Establish connection here because selection model is destroyed when
|
// Establish connection here because selection model is destroyed when
|
||||||
// model changes
|
// model changes
|
||||||
connect( m_ui->partitionTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
connect( m_ui->partitionTreeView->selectionModel(), &QItemSelectionModel::currentRowChanged,
|
||||||
this, &ReplacePage::onPartitionViewActivated );
|
this, &ReplaceWidget::onPartitionViewActivated );
|
||||||
|
|
||||||
connect( model, &QAbstractItemModel::modelReset, this, &ReplacePage::onPartitionModelReset );
|
connect( model, &QAbstractItemModel::modelReset, this, &ReplaceWidget::onPartitionModelReset );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::onPartitionViewActivated()
|
ReplaceWidget::onPartitionViewActivated()
|
||||||
{
|
{
|
||||||
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
@ -414,7 +396,7 @@ ReplacePage::onPartitionViewActivated()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ReplacePage::onPartitionModelReset()
|
ReplaceWidget::onPartitionModelReset()
|
||||||
{
|
{
|
||||||
m_ui->partitionTreeView->expandAll();
|
m_ui->partitionTreeView->expandAll();
|
||||||
onPartitionSelected();
|
onPartitionSelected();
|
@ -17,13 +17,14 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef REPLACEPAGE_H
|
#ifndef REPLACEWIDGET_H
|
||||||
#define REPLACEPAGE_H
|
#define REPLACEWIDGET_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class Ui_ReplacePage;
|
class Ui_ReplaceWidget;
|
||||||
|
class QComboBox;
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
class Partition;
|
class Partition;
|
||||||
|
|
||||||
@ -32,12 +33,14 @@ namespace CalamaresUtils
|
|||||||
enum ImageType : int;
|
enum ImageType : int;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReplacePage : public QWidget
|
class ReplaceWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ReplacePage( PartitionCoreModule* core , QWidget* parent = nullptr );
|
explicit ReplaceWidget( PartitionCoreModule* core,
|
||||||
virtual ~ReplacePage();
|
QComboBox* devicesComboBox,
|
||||||
|
QWidget* parent = nullptr );
|
||||||
|
virtual ~ReplaceWidget();
|
||||||
|
|
||||||
bool isNextEnabled() const;
|
bool isNextEnabled() const;
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ private slots:
|
|||||||
void onPartitionSelected();
|
void onPartitionSelected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer< Ui_ReplacePage > m_ui;
|
QScopedPointer< Ui_ReplaceWidget > m_ui;
|
||||||
void setNextEnabled( bool enabled );
|
void setNextEnabled( bool enabled );
|
||||||
|
|
||||||
void updateStatus( CalamaresUtils::ImageType imageType, const QString& text );
|
void updateStatus( CalamaresUtils::ImageType imageType, const QString& text );
|
||||||
@ -63,9 +66,9 @@ private:
|
|||||||
|
|
||||||
bool m_isEfi;
|
bool m_isEfi;
|
||||||
|
|
||||||
void updateFromCurrentDevice();
|
void updateFromCurrentDevice( QComboBox* devicesComboBox );
|
||||||
void onPartitionViewActivated();
|
void onPartitionViewActivated();
|
||||||
void onPartitionModelReset();
|
void onPartitionModelReset();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // REPLACEPAGE_H
|
#endif // REPLACEWIDGET_H
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>ReplacePage</class>
|
<class>ReplaceWidget</class>
|
||||||
<widget class="QWidget" name="ReplacePage">
|
<widget class="QWidget" name="ReplaceWidget">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
@ -14,39 +14,6 @@
|
|||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_2">
|
|
||||||
<property name="text">
|
|
||||||
<string>Dis&k:</string>
|
|
||||||
</property>
|
|
||||||
<property name="buddy">
|
|
||||||
<cstring>deviceComboBox</cstring>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="deviceComboBox"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>40</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="PartitionPreview" name="partitionPreview"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
@ -144,17 +111,6 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>PartitionPreview</class>
|
|
||||||
<extends>QFrame</extends>
|
|
||||||
<header location="global">gui/PartitionPreview.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<tabstops>
|
|
||||||
<tabstop>deviceComboBox</tabstop>
|
|
||||||
</tabstops>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
Loading…
Reference in New Issue
Block a user