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/PrettyRadioButton.cpp
|
||||
gui/ExpandableRadioButton.cpp
|
||||
gui/ReplacePage.cpp
|
||||
gui/ReplaceWidget.cpp
|
||||
jobs/CheckFileSystemJob.cpp
|
||||
jobs/ClearMountsJob.cpp
|
||||
jobs/ClearTempMountsJob.cpp
|
||||
@ -60,7 +60,7 @@ calamares_add_plugin( partition
|
||||
gui/CreatePartitionTableDialog.ui
|
||||
gui/EditExistingPartitionDialog.ui
|
||||
gui/PartitionPage.ui
|
||||
gui/ReplacePage.ui
|
||||
gui/ReplaceWidget.ui
|
||||
LINK_LIBRARIES
|
||||
kpmcore
|
||||
calamaresui
|
||||
|
@ -17,91 +17,73 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "ReplacePage.h"
|
||||
#include "ui_ReplacePage.h"
|
||||
#include "ReplaceWidget.h"
|
||||
#include "ui_ReplaceWidget.h"
|
||||
|
||||
#include "core/PartitionCoreModule.h"
|
||||
#include "core/KPMHelpers.h"
|
||||
#include "core/PartitionInfo.h"
|
||||
#include "core/DeviceModel.h"
|
||||
#include "core/PartitionCoreModule.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 "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/fs/filesystem.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QComboBox>
|
||||
|
||||
|
||||
ReplacePage::ReplacePage( PartitionCoreModule* core, QWidget* parent )
|
||||
ReplaceWidget::ReplaceWidget( PartitionCoreModule* core,
|
||||
QComboBox* devicesComboBox,
|
||||
QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_ui( new Ui_ReplacePage )
|
||||
, m_ui( new Ui_ReplaceWidget )
|
||||
, m_core( core )
|
||||
, m_isEfi( false )
|
||||
{
|
||||
m_ui->setupUi( this );
|
||||
m_ui->deviceComboBox->setModel( m_core->deviceModel() );
|
||||
m_ui->partitionPreview->setLabelsVisible( true );
|
||||
|
||||
m_ui->bootComboBox->hide();
|
||||
m_ui->bootComboBox->clear();
|
||||
m_ui->bootStatusLabel->hide();
|
||||
m_ui->bootStatusLabel->clear();
|
||||
|
||||
// updateButtons();
|
||||
|
||||
updateFromCurrentDevice();
|
||||
|
||||
connect( m_ui->deviceComboBox, &QComboBox::currentTextChanged,
|
||||
[ this ]( const QString& /* text */ )
|
||||
updateFromCurrentDevice( devicesComboBox );
|
||||
connect( devicesComboBox, &QComboBox::currentTextChanged,
|
||||
this, [=]( const QString& /* text */ )
|
||||
{
|
||||
updateFromCurrentDevice();
|
||||
updateFromCurrentDevice( devicesComboBox );
|
||||
} );
|
||||
|
||||
CALAMARES_RETRANSLATE(
|
||||
m_ui->retranslateUi( this );
|
||||
onPartitionSelected();
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
ReplacePage::~ReplacePage()
|
||||
ReplaceWidget::~ReplaceWidget()
|
||||
{}
|
||||
|
||||
|
||||
bool
|
||||
ReplacePage::isNextEnabled() const
|
||||
ReplaceWidget::isNextEnabled() const
|
||||
{
|
||||
return m_nextEnabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::reset()
|
||||
ReplaceWidget::reset()
|
||||
{
|
||||
int oldDeviceIndex = m_ui->deviceComboBox->currentIndex();
|
||||
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();
|
||||
//moo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::applyChanges()
|
||||
ReplaceWidget::applyChanges()
|
||||
{
|
||||
PartitionModel* model = qobject_cast< PartitionModel* >( m_ui->partitionTreeView->model() );
|
||||
if ( model )
|
||||
@ -141,7 +123,7 @@ ReplacePage::applyChanges()
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::onPartitionSelected()
|
||||
ReplaceWidget::onPartitionSelected()
|
||||
{
|
||||
if ( Calamares::JobQueue::instance()->globalStorage()->value( "firmwareType" ) == "efi" )
|
||||
m_isEfi = true;
|
||||
@ -341,7 +323,7 @@ ReplacePage::onPartitionSelected()
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::setNextEnabled( bool enabled )
|
||||
ReplaceWidget::setNextEnabled( bool enabled )
|
||||
{
|
||||
if ( enabled == m_nextEnabled )
|
||||
return;
|
||||
@ -352,7 +334,7 @@ ReplacePage::setNextEnabled( bool enabled )
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::updateStatus( CalamaresUtils::ImageType imageType, const QString& text )
|
||||
ReplaceWidget::updateStatus( CalamaresUtils::ImageType imageType, const QString& text )
|
||||
{
|
||||
int iconSize = CalamaresUtils::defaultFontHeight() * 8;
|
||||
m_ui->selectedIconLabel->setPixmap( CalamaresUtils::defaultPixmap( imageType,
|
||||
@ -363,10 +345,11 @@ ReplacePage::updateStatus( CalamaresUtils::ImageType imageType, const QString& t
|
||||
}
|
||||
|
||||
|
||||
|
||||
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() )
|
||||
return;
|
||||
|
||||
@ -377,7 +360,6 @@ ReplacePage::updateFromCurrentDevice()
|
||||
disconnect( oldModel, 0, this, 0 );
|
||||
|
||||
PartitionModel* model = m_core->partitionModelForDevice( device );
|
||||
m_ui->partitionPreview->setModel( model );
|
||||
m_ui->partitionTreeView->setModel( model );
|
||||
m_ui->partitionTreeView->expandAll();
|
||||
|
||||
@ -391,14 +373,14 @@ ReplacePage::updateFromCurrentDevice()
|
||||
// Establish connection here because selection model is destroyed when
|
||||
// model changes
|
||||
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
|
||||
ReplacePage::onPartitionViewActivated()
|
||||
ReplaceWidget::onPartitionViewActivated()
|
||||
{
|
||||
QModelIndex index = m_ui->partitionTreeView->currentIndex();
|
||||
if ( !index.isValid() )
|
||||
@ -414,7 +396,7 @@ ReplacePage::onPartitionViewActivated()
|
||||
|
||||
|
||||
void
|
||||
ReplacePage::onPartitionModelReset()
|
||||
ReplaceWidget::onPartitionModelReset()
|
||||
{
|
||||
m_ui->partitionTreeView->expandAll();
|
||||
onPartitionSelected();
|
@ -17,13 +17,14 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef REPLACEPAGE_H
|
||||
#define REPLACEPAGE_H
|
||||
#ifndef REPLACEWIDGET_H
|
||||
#define REPLACEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
class Ui_ReplacePage;
|
||||
class Ui_ReplaceWidget;
|
||||
class QComboBox;
|
||||
class PartitionCoreModule;
|
||||
class Partition;
|
||||
|
||||
@ -32,12 +33,14 @@ namespace CalamaresUtils
|
||||
enum ImageType : int;
|
||||
}
|
||||
|
||||
class ReplacePage : public QWidget
|
||||
class ReplaceWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ReplacePage( PartitionCoreModule* core , QWidget* parent = nullptr );
|
||||
virtual ~ReplacePage();
|
||||
explicit ReplaceWidget( PartitionCoreModule* core,
|
||||
QComboBox* devicesComboBox,
|
||||
QWidget* parent = nullptr );
|
||||
virtual ~ReplaceWidget();
|
||||
|
||||
bool isNextEnabled() const;
|
||||
|
||||
@ -52,7 +55,7 @@ private slots:
|
||||
void onPartitionSelected();
|
||||
|
||||
private:
|
||||
QScopedPointer< Ui_ReplacePage > m_ui;
|
||||
QScopedPointer< Ui_ReplaceWidget > m_ui;
|
||||
void setNextEnabled( bool enabled );
|
||||
|
||||
void updateStatus( CalamaresUtils::ImageType imageType, const QString& text );
|
||||
@ -63,9 +66,9 @@ private:
|
||||
|
||||
bool m_isEfi;
|
||||
|
||||
void updateFromCurrentDevice();
|
||||
void updateFromCurrentDevice( QComboBox* devicesComboBox );
|
||||
void onPartitionViewActivated();
|
||||
void onPartitionModelReset();
|
||||
};
|
||||
|
||||
#endif // REPLACEPAGE_H
|
||||
#endif // REPLACEWIDGET_H
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ReplacePage</class>
|
||||
<widget class="QWidget" name="ReplacePage">
|
||||
<class>ReplaceWidget</class>
|
||||
<widget class="QWidget" name="ReplaceWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@ -14,39 +14,6 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<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>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
@ -144,17 +111,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</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/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue
Block a user