add a details widget for the size dialog base and use it for first and last
sector svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1104707
This commit is contained in:
parent
a892c765cb
commit
edca30b707
2
TODO
2
TODO
|
@ -20,7 +20,7 @@ Plans and ideas for 1.1:
|
|||
* offer a) no alignment of partition boundaries at all or b) legacy cylinder
|
||||
alignment or c) sector based alignment (the name is misleading, though)
|
||||
|
||||
* offer to skip aligning the partition when creating it in that details widget?
|
||||
* align partitions while changing size and position in the size dialog base
|
||||
|
||||
===============================================================================
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ InsertDialog::InsertDialog(QWidget* parent, Device& device, Partition& insertedP
|
|||
SizeDialogBase(parent, device, insertedPartition, destpartition.firstSector(), destpartition.lastSector()),
|
||||
m_DestPartition(destpartition)
|
||||
{
|
||||
setMainWidget(&dialogWidget());
|
||||
setCaption(i18nc("@title:window", "Insert a partition"));
|
||||
|
||||
partition().move(destPartition().firstSector());
|
||||
|
|
|
@ -43,7 +43,6 @@ NewDialog::NewDialog(QWidget* parent, Device& device, Partition& unallocatedPart
|
|||
SizeDialogBase(parent, device, unallocatedPartition, unallocatedPartition.firstSector(), unallocatedPartition.lastSector()),
|
||||
m_PartitionRoles(r)
|
||||
{
|
||||
setMainWidget(&dialogWidget());
|
||||
setCaption(i18nc("@title:window", "Create a new partition"));
|
||||
|
||||
setupConstraints();
|
||||
|
|
|
@ -38,7 +38,6 @@ ResizeDialog::ResizeDialog(QWidget* parent, Device& device, Partition& p, qint64
|
|||
m_OriginalFirstSector(p.firstSector()),
|
||||
m_OriginalLastSector(p.lastSector())
|
||||
{
|
||||
setMainWidget(&dialogWidget());
|
||||
setCaption(i18nc("@title:window", "Resize/move partition: <filename>%1</filename>", partition().deviceNode()));
|
||||
|
||||
dialogWidget().hideRole();
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program 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 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "gui/sizedetailswidget.h"
|
|
@ -0,0 +1,44 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* *
|
||||
* This program 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 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program 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 this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
||||
***************************************************************************/
|
||||
|
||||
#if !defined(SIZEDETAILSWIDGET__H)
|
||||
|
||||
#define SIZEDETAILSWIDGET__H
|
||||
|
||||
#include "ui_sizedetailswidgetbase.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <qdebug.h>
|
||||
|
||||
/** @brief Details widget for the SizeDetailsBase
|
||||
@author vl@fidra.de
|
||||
*/
|
||||
class SizeDetailsWidget : public QWidget, public Ui::SizeDetailsWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SizeDetailsWidget(QWidget* parent) : QWidget(parent), Ui::SizeDetailsWidgetBase() { setupUi(this); }
|
||||
|
||||
public:
|
||||
QDoubleSpinBox& spinFirstSector() { Q_ASSERT(m_SpinFirstSector); return *m_SpinFirstSector; }
|
||||
QDoubleSpinBox& spinLastSector() { Q_ASSERT(m_SpinLastSector); return *m_SpinLastSector; }
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SizeDetailsWidgetBase</class>
|
||||
<widget class="QWidget" name="SizeDetailsWidgetBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>134</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="@label:listbox">First sector:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_SpinFreeBefore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinFirstSector">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="@label:listbox">Last sector:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_SpinFreeBefore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinLastSector">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<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>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<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>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_5">
|
||||
<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>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -18,6 +18,7 @@
|
|||
***************************************************************************/
|
||||
|
||||
#include "gui/sizedialogbase.h"
|
||||
#include "gui/sizedetailswidget.h"
|
||||
#include "gui/partresizerwidget.h"
|
||||
#include "gui/sizedialogwidget.h"
|
||||
|
||||
|
@ -32,11 +33,17 @@
|
|||
SizeDialogBase::SizeDialogBase(QWidget* parent, Device& d, Partition& part, qint64 minFirst, qint64 maxLast) :
|
||||
KDialog(parent),
|
||||
m_SizeDialogWidget(new SizeDialogWidget(this)),
|
||||
m_SizeDetailsWidget(new SizeDetailsWidget(this)),
|
||||
m_Device(d),
|
||||
m_Partition(part),
|
||||
m_MinimumFirstSector(minFirst),
|
||||
m_MaximumLastSector(maxLast)
|
||||
{
|
||||
setMainWidget(&dialogWidget());
|
||||
setDetailsWidget(&detailsWidget());
|
||||
|
||||
showButtonSeparator(true);
|
||||
setButtons(KDialog::Ok | KDialog::Cancel | KDialog::Details);
|
||||
}
|
||||
|
||||
qint64 SizeDialogBase::minimumLength() const
|
||||
|
@ -86,8 +93,8 @@ void SizeDialogBase::setupDialog()
|
|||
dialogWidget().spinFreeAfter().setSuffix(QString(" ") + Capacity::unitName(Capacity::preferredUnit()));
|
||||
dialogWidget().spinCapacity().setSuffix(QString(" ") + Capacity::unitName(Capacity::preferredUnit()));
|
||||
|
||||
dialogWidget().spinFirstSector().setValue(partition().firstSector());
|
||||
dialogWidget().spinLastSector().setValue(partition().lastSector());
|
||||
detailsWidget().spinFirstSector().setValue(partition().firstSector());
|
||||
detailsWidget().spinLastSector().setValue(partition().lastSector());
|
||||
}
|
||||
|
||||
void SizeDialogBase::setupConstraints()
|
||||
|
@ -118,8 +125,8 @@ void SizeDialogBase::setupConstraints()
|
|||
dialogWidget().spinFreeBefore().setRange(0, maxFree);
|
||||
dialogWidget().spinFreeAfter().setRange(0, maxFree);
|
||||
|
||||
dialogWidget().spinFirstSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
dialogWidget().spinLastSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
detailsWidget().spinFirstSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
detailsWidget().spinLastSector().setRange(minimumFirstSector(), maximumLastSector());
|
||||
}
|
||||
|
||||
void SizeDialogBase::setupConnections()
|
||||
|
@ -131,8 +138,8 @@ void SizeDialogBase::setupConnections()
|
|||
connect(&dialogWidget().spinFreeAfter(), SIGNAL(valueChanged(int)), SLOT(onFreeSpaceAfterChanged(int)));
|
||||
connect(&dialogWidget().spinCapacity(), SIGNAL(valueChanged(int)), SLOT(onCapacityChanged(int)));
|
||||
|
||||
connect(&dialogWidget().spinFirstSector(), SIGNAL(valueChanged(double)), SLOT(onSpinFirstSectorChanged(double)));
|
||||
connect(&dialogWidget().spinLastSector(), SIGNAL(valueChanged(double)), SLOT(onSpinLastSectorChanged(double)));
|
||||
connect(&detailsWidget().spinFirstSector(), SIGNAL(valueChanged(double)), SLOT(onSpinFirstSectorChanged(double)));
|
||||
connect(&detailsWidget().spinLastSector(), SIGNAL(valueChanged(double)), SLOT(onSpinLastSectorChanged(double)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -160,9 +167,9 @@ void SizeDialogBase::onFirstSectorChanged(qint64 newFirst)
|
|||
dialogWidget().spinFreeBefore().setValue(sectorsToDialogUnit(partition(), newFirst - minimumFirstSector()));
|
||||
dialogWidget().spinFreeBefore().blockSignals(state);
|
||||
|
||||
state = dialogWidget().spinFirstSector().blockSignals(true);
|
||||
dialogWidget().spinFirstSector().setValue(newFirst);
|
||||
dialogWidget().spinFirstSector().blockSignals(state);
|
||||
state = detailsWidget().spinFirstSector().blockSignals(true);
|
||||
detailsWidget().spinFirstSector().setValue(newFirst);
|
||||
detailsWidget().spinFirstSector().blockSignals(state);
|
||||
|
||||
updateLength(partition().length());
|
||||
setDirty();
|
||||
|
@ -174,9 +181,9 @@ void SizeDialogBase::onLastSectorChanged(qint64 newLast)
|
|||
dialogWidget().spinFreeAfter().setValue(sectorsToDialogUnit(partition(), maximumLastSector() - newLast));
|
||||
dialogWidget().spinFreeAfter().blockSignals(state);
|
||||
|
||||
state = dialogWidget().spinLastSector().blockSignals(true);
|
||||
dialogWidget().spinLastSector().setValue(newLast);
|
||||
dialogWidget().spinLastSector().blockSignals(state);
|
||||
state = detailsWidget().spinLastSector().blockSignals(true);
|
||||
detailsWidget().spinLastSector().setValue(newLast);
|
||||
detailsWidget().spinLastSector().blockSignals(state);
|
||||
|
||||
updateLength(partition().length());
|
||||
setDirty();
|
||||
|
|
|
@ -32,6 +32,7 @@ class Device;
|
|||
class Partition;
|
||||
class PartitionTable;
|
||||
class SizeDialogWidget;
|
||||
class SizeDetailsWidget;
|
||||
|
||||
/** @brief Base class for all dialogs moving or resizing Partitions.
|
||||
@author vl@fidra.de
|
||||
|
@ -48,6 +49,9 @@ class SizeDialogBase : public KDialog
|
|||
SizeDialogWidget& dialogWidget() { Q_ASSERT(m_SizeDialogWidget); return *m_SizeDialogWidget; }
|
||||
const SizeDialogWidget& dialogWidget() const { Q_ASSERT(m_SizeDialogWidget); return *m_SizeDialogWidget; }
|
||||
|
||||
SizeDetailsWidget& detailsWidget() { Q_ASSERT(m_SizeDetailsWidget); return *m_SizeDetailsWidget; }
|
||||
const SizeDetailsWidget& detailsWidget() const { Q_ASSERT(m_SizeDetailsWidget); return *m_SizeDetailsWidget; }
|
||||
|
||||
virtual const PartitionTable& partitionTable() const;
|
||||
virtual bool canGrow() const { return true; }
|
||||
virtual bool canShrink() const { return true; }
|
||||
|
@ -79,6 +83,7 @@ class SizeDialogBase : public KDialog
|
|||
|
||||
protected:
|
||||
SizeDialogWidget* m_SizeDialogWidget;
|
||||
SizeDetailsWidget* m_SizeDetailsWidget;
|
||||
Device& m_Device;
|
||||
Partition& m_Partition;
|
||||
qint64 m_MinimumFirstSector;
|
||||
|
|
|
@ -43,9 +43,6 @@ class SizeDialogWidget : public QWidget, public Ui::SizeDialogWidgetBase
|
|||
QSpinBox& spinFreeAfter() { Q_ASSERT(m_SpinFreeAfter); return *m_SpinFreeAfter; }
|
||||
QSpinBox& spinCapacity() { Q_ASSERT(m_SpinCapacity); return *m_SpinCapacity; }
|
||||
|
||||
QDoubleSpinBox& spinFirstSector() { Q_ASSERT(m_SpinFirstSector); return *m_SpinFirstSector; }
|
||||
QDoubleSpinBox& spinLastSector() { Q_ASSERT(m_SpinLastSector); return *m_SpinLastSector; }
|
||||
|
||||
QLabel& labelMinSize() { Q_ASSERT(m_LabelMinSize); return *m_LabelMinSize; }
|
||||
QLabel& labelMaxSize() { Q_ASSERT(m_LabelMaxSize); return *m_LabelMaxSize; }
|
||||
|
||||
|
|
|
@ -302,83 +302,6 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="3">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="@label:listbox">First sector:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_SpinFreeBefore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="11" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinFirstSector">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string comment="@label:listbox">Last sector:</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_SpinFreeBefore</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="12" column="1" colspan="2">
|
||||
<widget class="QDoubleSpinBox" name="m_SpinLastSector">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
<number>0</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="13" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -389,7 +312,7 @@
|
|||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
|
|
Loading…
Reference in New Issue