From edca30b707af6248f9e4a94487f487956126fbe4 Mon Sep 17 00:00:00 2001 From: Volker Lanz Date: Thu, 18 Mar 2010 11:04:13 +0000 Subject: [PATCH] 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 --- TODO | 2 +- src/gui/insertdialog.cpp | 1 - src/gui/newdialog.cpp | 1 - src/gui/resizedialog.cpp | 1 - src/gui/sizedetailswidget.cpp | 20 +++++ src/gui/sizedetailswidget.h | 44 ++++++++++ src/gui/sizedetailswidgetbase.ui | 143 +++++++++++++++++++++++++++++++ src/gui/sizedialogbase.cpp | 31 ++++--- src/gui/sizedialogbase.h | 5 ++ src/gui/sizedialogwidget.h | 3 - src/gui/sizedialogwidgetbase.ui | 79 +---------------- 11 files changed, 233 insertions(+), 97 deletions(-) create mode 100644 src/gui/sizedetailswidget.cpp create mode 100644 src/gui/sizedetailswidget.h create mode 100644 src/gui/sizedetailswidgetbase.ui diff --git a/TODO b/TODO index 3cbf3c1..24a5cfe 100644 --- a/TODO +++ b/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 =============================================================================== diff --git a/src/gui/insertdialog.cpp b/src/gui/insertdialog.cpp index 8b7272c..d2c2552 100644 --- a/src/gui/insertdialog.cpp +++ b/src/gui/insertdialog.cpp @@ -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()); diff --git a/src/gui/newdialog.cpp b/src/gui/newdialog.cpp index c2c4d4d..ab873f3 100644 --- a/src/gui/newdialog.cpp +++ b/src/gui/newdialog.cpp @@ -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(); diff --git a/src/gui/resizedialog.cpp b/src/gui/resizedialog.cpp index c034b00..7f29bfd 100644 --- a/src/gui/resizedialog.cpp +++ b/src/gui/resizedialog.cpp @@ -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: %1", partition().deviceNode())); dialogWidget().hideRole(); diff --git a/src/gui/sizedetailswidget.cpp b/src/gui/sizedetailswidget.cpp new file mode 100644 index 0000000..2e885f1 --- /dev/null +++ b/src/gui/sizedetailswidget.cpp @@ -0,0 +1,20 @@ +/*************************************************************************** + * Copyright (C) 2010 by Volker Lanz * + * * + * 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" diff --git a/src/gui/sizedetailswidget.h b/src/gui/sizedetailswidget.h new file mode 100644 index 0000000..86e09f0 --- /dev/null +++ b/src/gui/sizedetailswidget.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2010 by Volker Lanz * + * * + * 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 +#include + +/** @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 diff --git a/src/gui/sizedetailswidgetbase.ui b/src/gui/sizedetailswidgetbase.ui new file mode 100644 index 0000000..7f904dc --- /dev/null +++ b/src/gui/sizedetailswidgetbase.ui @@ -0,0 +1,143 @@ + + + SizeDetailsWidgetBase + + + + 0 + 0 + 428 + 134 + + + + + + + + 0 + 0 + + + + First sector: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + m_SpinFreeBefore + + + + + + + + 3 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + + + + + + 0 + 0 + + + + Last sector: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + m_SpinFreeBefore + + + + + + + + 3 + 0 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 0 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Qt::Horizontal + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + + diff --git a/src/gui/sizedialogbase.cpp b/src/gui/sizedialogbase.cpp index 18f79c0..730cba0 100644 --- a/src/gui/sizedialogbase.cpp +++ b/src/gui/sizedialogbase.cpp @@ -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(); diff --git a/src/gui/sizedialogbase.h b/src/gui/sizedialogbase.h index 8c9261b..d3cbb3a 100644 --- a/src/gui/sizedialogbase.h +++ b/src/gui/sizedialogbase.h @@ -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; diff --git a/src/gui/sizedialogwidget.h b/src/gui/sizedialogwidget.h index 5ec3f6d..e9a94da 100644 --- a/src/gui/sizedialogwidget.h +++ b/src/gui/sizedialogwidget.h @@ -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; } diff --git a/src/gui/sizedialogwidgetbase.ui b/src/gui/sizedialogwidgetbase.ui index 09591da..dc7754d 100644 --- a/src/gui/sizedialogwidgetbase.ui +++ b/src/gui/sizedialogwidgetbase.ui @@ -302,83 +302,6 @@ - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - First sector: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_SpinFreeBefore - - - - - - - - 3 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - - - - - - 0 - 0 - - - - Last sector: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_SpinFreeBefore - - - - - - - - 3 - 0 - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - - Qt::Vertical @@ -389,7 +312,7 @@ 20 - 20 + 10