Start creating EditExistingPartitionDialog
This commit is contained in:
parent
5daa1b82e8
commit
ec6703b9cd
@ -22,6 +22,7 @@ calamares_add_plugin( partition
|
|||||||
CreatePartitionJob.cpp
|
CreatePartitionJob.cpp
|
||||||
CreatePartitionTableJob.cpp
|
CreatePartitionTableJob.cpp
|
||||||
DeletePartitionJob.cpp
|
DeletePartitionJob.cpp
|
||||||
|
EditExistingPartitionDialog.cpp
|
||||||
DeviceModel.cpp
|
DeviceModel.cpp
|
||||||
PartitionCoreModule.cpp
|
PartitionCoreModule.cpp
|
||||||
PartitionInfo.cpp
|
PartitionInfo.cpp
|
||||||
@ -32,6 +33,7 @@ calamares_add_plugin( partition
|
|||||||
UI
|
UI
|
||||||
CreatePartitionDialog.ui
|
CreatePartitionDialog.ui
|
||||||
CreatePartitionTableDialog.ui
|
CreatePartitionTableDialog.ui
|
||||||
|
EditExistingPartitionDialog.ui
|
||||||
PartitionPage.ui
|
PartitionPage.ui
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
calapm
|
calapm
|
||||||
@ -47,6 +49,7 @@ set( partview_SRCS
|
|||||||
CreatePartitionTableJob.cpp
|
CreatePartitionTableJob.cpp
|
||||||
DeletePartitionJob.cpp
|
DeletePartitionJob.cpp
|
||||||
DeviceModel.cpp
|
DeviceModel.cpp
|
||||||
|
EditExistingPartitionDialog.cpp
|
||||||
PartitionCoreModule.cpp
|
PartitionCoreModule.cpp
|
||||||
PartitionInfo.cpp
|
PartitionInfo.cpp
|
||||||
PartitionModel.cpp
|
PartitionModel.cpp
|
||||||
@ -57,6 +60,7 @@ set( partview_SRCS
|
|||||||
qt5_wrap_ui( partview_SRCS
|
qt5_wrap_ui( partview_SRCS
|
||||||
CreatePartitionDialog.ui
|
CreatePartitionDialog.ui
|
||||||
CreatePartitionTableDialog.ui
|
CreatePartitionTableDialog.ui
|
||||||
|
EditExistingPartitionDialog.ui
|
||||||
PartitionPage.ui
|
PartitionPage.ui
|
||||||
)
|
)
|
||||||
|
|
||||||
|
64
src/modules/partition/EditExistingPartitionDialog.cpp
Normal file
64
src/modules/partition/EditExistingPartitionDialog.cpp
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <EditExistingPartitionDialog.h>
|
||||||
|
|
||||||
|
#include <PartitionInfo.h>
|
||||||
|
#include <ui_EditExistingPartitionDialog.h>
|
||||||
|
#include <utils/Logger.h>
|
||||||
|
|
||||||
|
// CalaPM
|
||||||
|
#include <core/device.h>
|
||||||
|
#include <core/partition.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
EditExistingPartitionDialog::EditExistingPartitionDialog( Device* device, Partition* partition, QWidget* parentWidget )
|
||||||
|
: QDialog( parentWidget )
|
||||||
|
, m_ui( new Ui_EditExistingPartitionDialog )
|
||||||
|
, m_device( device )
|
||||||
|
, m_partition( partition )
|
||||||
|
{
|
||||||
|
m_ui->setupUi( this );
|
||||||
|
|
||||||
|
PartitionTable* table = m_device->partitionTable();
|
||||||
|
qint64 minSector = partition->firstSector() - table->freeSectorsBefore( *partition );
|
||||||
|
qint64 maxSector = partition->lastSector() + table->freeSectorsAfter( *partition );
|
||||||
|
|
||||||
|
m_ui->sizeSpinBox->setMaximum( mbSizeForSectorRange( minSector, maxSector ) );
|
||||||
|
m_ui->sizeSpinBox->setValue( mbSizeForSectorRange( partition->firstSector(), partition->lastSector() ) );
|
||||||
|
|
||||||
|
// Mount point
|
||||||
|
m_ui->mountPointComboBox->setCurrentText( PartitionInfo::mountPoint( partition ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
EditExistingPartitionDialog::~EditExistingPartitionDialog()
|
||||||
|
{}
|
||||||
|
|
||||||
|
qint64
|
||||||
|
EditExistingPartitionDialog::mbSizeForSectorRange( qint64 first, qint64 last ) const
|
||||||
|
{
|
||||||
|
return ( last - first + 1 ) * m_device->logicalSectorSize() / 1024 / 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
EditExistingPartitionDialog::applyChanges( PartitionCoreModule* module )
|
||||||
|
{
|
||||||
|
PartitionInfo::setMountPoint( m_partition, m_ui->mountPointComboBox->currentText() );
|
||||||
|
}
|
47
src/modules/partition/EditExistingPartitionDialog.h
Normal file
47
src/modules/partition/EditExistingPartitionDialog.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef EDITEXISTINGPARTITIONDIALOG_H
|
||||||
|
#define EDITEXISTINGPARTITIONDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
class PartitionCoreModule;
|
||||||
|
class Device;
|
||||||
|
class Partition;
|
||||||
|
class Ui_EditExistingPartitionDialog;
|
||||||
|
|
||||||
|
class EditExistingPartitionDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
EditExistingPartitionDialog( Device* device, Partition* partition, QWidget* parentWidget = nullptr );
|
||||||
|
~EditExistingPartitionDialog();
|
||||||
|
|
||||||
|
void applyChanges( PartitionCoreModule* module );
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer< Ui_EditExistingPartitionDialog > m_ui;
|
||||||
|
Device* m_device;
|
||||||
|
Partition* m_partition;
|
||||||
|
|
||||||
|
qint64 mbSizeForSectorRange( qint64 first, qint64 last ) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* EDITEXISTINGPARTITIONDIALOG_H */
|
185
src/modules/partition/EditExistingPartitionDialog.ui
Normal file
185
src/modules/partition/EditExistingPartitionDialog.ui
Normal file
@ -0,0 +1,185 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>EditExistingPartitionDialog</class>
|
||||||
|
<widget class="QDialog" name="EditExistingPartitionDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>350</width>
|
||||||
|
<height>203</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Edit Existing Partition</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<layout class="QFormLayout" name="formLayout">
|
||||||
|
<property name="fieldGrowthPolicy">
|
||||||
|
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Si&ze:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>sizeSpinBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QSpinBox" name="sizeSpinBox">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> MB</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Content:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QRadioButton" name="radioButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Keep</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QRadioButton" name="radioButton_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Format</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Warning: Formatting the partition will erase all existing data.</string>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="mountPointLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>&Mount Point:</string>
|
||||||
|
</property>
|
||||||
|
<property name="buddy">
|
||||||
|
<cstring>mountPointComboBox</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="mountPointComboBox">
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="currentIndex">
|
||||||
|
<number>-1</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/boot</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/home</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/opt</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/usr</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string>/var</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</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>sizeSpinBox</tabstop>
|
||||||
|
<tabstop>radioButton</tabstop>
|
||||||
|
<tabstop>radioButton_2</tabstop>
|
||||||
|
<tabstop>mountPointComboBox</tabstop>
|
||||||
|
<tabstop>buttonBox</tabstop>
|
||||||
|
</tabstops>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>EditExistingPartitionDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>EditExistingPartitionDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Local
|
// Local
|
||||||
#include <CreatePartitionDialog.h>
|
#include <CreatePartitionDialog.h>
|
||||||
|
#include <EditExistingPartitionDialog.h>
|
||||||
#include <DeviceModel.h>
|
#include <DeviceModel.h>
|
||||||
#include <PartitionCoreModule.h>
|
#include <PartitionCoreModule.h>
|
||||||
#include <PartitionModel.h>
|
#include <PartitionModel.h>
|
||||||
@ -163,7 +164,7 @@ PartitionPage::onEditClicked()
|
|||||||
if ( PMUtils::isPartitionNew( partition ) )
|
if ( PMUtils::isPartitionNew( partition ) )
|
||||||
updatePartitionToCreate( model->device(), partition );
|
updatePartitionToCreate( model->device(), partition );
|
||||||
else
|
else
|
||||||
editExistingPartition( partition );
|
editExistingPartition( model->device(), partition );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -193,6 +194,12 @@ PartitionPage::updatePartitionToCreate( Device* device, Partition* partition )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionPage::editExistingPartition( Partition* partition )
|
PartitionPage::editExistingPartition( Device* device, Partition* partition )
|
||||||
{
|
{
|
||||||
|
QPointer<EditExistingPartitionDialog> dlg = new EditExistingPartitionDialog( device, partition, this );
|
||||||
|
if ( dlg->exec() == QDialog::Accepted )
|
||||||
|
{
|
||||||
|
dlg->applyChanges( m_core );
|
||||||
|
}
|
||||||
|
delete dlg;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ private:
|
|||||||
void onDeleteClicked();
|
void onDeleteClicked();
|
||||||
|
|
||||||
void updatePartitionToCreate( Device*, Partition* );
|
void updatePartitionToCreate( Device*, Partition* );
|
||||||
void editExistingPartition( Partition* );
|
void editExistingPartition( Device*, Partition* );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITIONPAGE_H
|
#endif // PARTITIONPAGE_H
|
||||||
|
Loading…
Reference in New Issue
Block a user