parent
7096213206
commit
c30ed3c9c1
@ -31,6 +31,7 @@ calamares_add_plugin( partition
|
||||
PMUtils.cpp
|
||||
UI
|
||||
CreatePartitionDialog.ui
|
||||
CreatePartitionTableDialog.ui
|
||||
PartitionPage.ui
|
||||
LINK_LIBRARIES
|
||||
calapm
|
||||
@ -55,6 +56,7 @@ set( partview_SRCS
|
||||
)
|
||||
qt5_wrap_ui( partview_SRCS
|
||||
CreatePartitionDialog.ui
|
||||
CreatePartitionTableDialog.ui
|
||||
PartitionPage.ui
|
||||
)
|
||||
|
||||
|
138
src/modules/partition/CreatePartitionTableDialog.ui
Normal file
138
src/modules/partition/CreatePartitionTableDialog.ui
Normal file
@ -0,0 +1,138 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CreatePartitionTableDialog</class>
|
||||
<widget class="QDialog" name="CreatePartitionTableDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>297</width>
|
||||
<height>182</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Create Partition Table</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="areYouSureLabel">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">[are-you-sure-message]</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Creating a new partition table will delete all existing data on the disk.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>What kind of partition table do you want to create?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="mbrRadioButton">
|
||||
<property name="text">
|
||||
<string>Master Boot Record (MBR)</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="gptRadioButton">
|
||||
<property name="text">
|
||||
<string>GUID Partition Table (GPT)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>mbrRadioButton</tabstop>
|
||||
<tabstop>gptRadioButton</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CreatePartitionTableDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>222</x>
|
||||
<y>141</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>155</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CreatePartitionTableDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>290</x>
|
||||
<y>147</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>155</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -35,8 +35,9 @@
|
||||
// Qt
|
||||
#include <QScopedPointer>
|
||||
|
||||
CreatePartitionTableJob::CreatePartitionTableJob( Device* device )
|
||||
CreatePartitionTableJob::CreatePartitionTableJob( Device* device, PartitionTable::TableType type )
|
||||
: m_device( device )
|
||||
, m_type( type )
|
||||
{
|
||||
}
|
||||
|
||||
@ -88,9 +89,8 @@ CreatePartitionTableJob::updatePreview()
|
||||
PartitionTable*
|
||||
CreatePartitionTableJob::createTable()
|
||||
{
|
||||
PartitionTable::TableType type = PartitionTable::msdos;
|
||||
return new PartitionTable( type,
|
||||
PartitionTable::defaultFirstUsable( *m_device, type ),
|
||||
PartitionTable::defaultLastUsable( *m_device, type )
|
||||
return new PartitionTable( m_type,
|
||||
PartitionTable::defaultFirstUsable( *m_device, m_type ),
|
||||
PartitionTable::defaultLastUsable( *m_device, m_type )
|
||||
);
|
||||
}
|
||||
|
@ -21,14 +21,16 @@
|
||||
|
||||
#include <Job.h>
|
||||
|
||||
// CalaPM
|
||||
#include <core/partitiontable.h>
|
||||
|
||||
class Device;
|
||||
class PartitionTable;
|
||||
|
||||
class CreatePartitionTableJob : public Calamares::Job
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CreatePartitionTableJob( Device* device );
|
||||
CreatePartitionTableJob( Device* device, PartitionTable::TableType type );
|
||||
QString prettyName() const override;
|
||||
Calamares::JobResult exec() override;
|
||||
|
||||
@ -40,6 +42,7 @@ public:
|
||||
|
||||
private:
|
||||
Device* m_device;
|
||||
PartitionTable::TableType m_type;
|
||||
PartitionTable* createTable();
|
||||
};
|
||||
|
||||
|
@ -128,14 +128,14 @@ PartitionCoreModule::partitionModelForDevice( Device* device ) const
|
||||
}
|
||||
|
||||
void
|
||||
PartitionCoreModule::createPartitionTable( Device* device )
|
||||
PartitionCoreModule::createPartitionTable( Device* device, PartitionTable::TableType type )
|
||||
{
|
||||
DeviceInfo* info = infoForDevice( device );
|
||||
// Creating a partition table wipes all the disk, so there is no need to
|
||||
// keep previous changes
|
||||
info->forgetChanges();
|
||||
|
||||
CreatePartitionTableJob* job = new CreatePartitionTableJob( device );
|
||||
CreatePartitionTableJob* job = new CreatePartitionTableJob( device, type );
|
||||
job->updatePreview();
|
||||
info->jobs << Calamares::job_ptr( job );
|
||||
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
|
||||
PartitionModel* partitionModelForDevice( Device* device ) const;
|
||||
|
||||
void createPartitionTable( Device* device );
|
||||
void createPartitionTable( Device* device, PartitionTable::TableType type );
|
||||
|
||||
/**
|
||||
* Takes ownership of partitionInfo
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include <PartitionModel.h>
|
||||
#include <PMUtils.h>
|
||||
#include <ui_PartitionPage.h>
|
||||
#include <ui_CreatePartitionTableDialog.h>
|
||||
|
||||
// CalaPM
|
||||
#include <core/device.h>
|
||||
@ -108,18 +109,17 @@ PartitionPage::onNewPartitionTableClicked()
|
||||
Q_ASSERT( index.isValid() );
|
||||
Device* device = m_core->deviceModel()->deviceForIndex( index );
|
||||
|
||||
auto answer = QMessageBox::warning( this,
|
||||
tr( "New Partition Table" ),
|
||||
tr( "Are you sure you want to create a new partition table on %1?\n"
|
||||
"Creating a new partition table will delete all existing data on the disk." )
|
||||
.arg( device->name() ),
|
||||
QMessageBox::Ok | QMessageBox::Cancel,
|
||||
QMessageBox::Cancel
|
||||
);
|
||||
|
||||
if ( answer != QMessageBox::Ok )
|
||||
return;
|
||||
m_core->createPartitionTable( device );
|
||||
QPointer<QDialog> dlg = new QDialog( this );
|
||||
Ui_CreatePartitionTableDialog ui;
|
||||
ui.setupUi( dlg.data() );
|
||||
QString areYouSure = tr( "Are you sure you want to create a new partition table on %1?" ).arg( device->name() );
|
||||
ui.areYouSureLabel->setText( areYouSure );
|
||||
if ( dlg->exec() == QDialog::Accepted )
|
||||
{
|
||||
PartitionTable::TableType type = ui.mbrRadioButton->isChecked() ? PartitionTable::msdos : PartitionTable::gpt;
|
||||
m_core->createPartitionTable( device, type );
|
||||
}
|
||||
delete dlg;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user