Add some basic configuration dialog stuff.

Remove the option to create msdos-vista-compatible partition tables. Instead,
use a global config to determine which alignment to use.

Add a device properties dialog.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1091755
This commit is contained in:
Volker Lanz 2010-02-17 13:18:25 +00:00
parent 360131aba1
commit 51faaebb38
22 changed files with 745 additions and 71 deletions

5
TODO
View File

@ -20,3 +20,8 @@ Random plans and ideas for 1.1 and beyond:
* Information about file system on a separate tab in the properties, unique
to the file system in use.
* Check if no of sectors fits in an unsigned 32 bit int for msdos partition tables.
* Add more columns to the partition tree now that columns can be hidden. Find a
suitable default set of columns to show.

View File

@ -16,10 +16,10 @@
<entry name="firstRun" type="Bool">
<default>true</default>
</entry>
<entry name="vistaSectorAlignment" type="Int">
<entry name="sectorAlignment" type="Int">
<default>2048</default>
</entry>
<entry name="allowCreateVistaPartitionTable" type="Bool">
<entry name="useLegacyMsDosAlignment" type="Bool">
<default>false</default>
</entry>
<entry name="allowApplyOperationsAsNonRoot" type="Bool">

View File

@ -308,14 +308,14 @@ static void scanDevicePartitions(PedDevice* pedDevice, Device& d, PedDisk* pedDi
parent->append(part);
if (d.partitionTable()->isVistaDiskLabel())
d.partitionTable()->setType(PartitionTable::msdos_vista);
PartitionTable::isSnapped(d, *part);
}
d.partitionTable()->updateUnallocated(d);
if (d.partitionTable()->isVistaDiskLabel())
d.partitionTable()->setType(d, PartitionTable::msdos_vista);
ped_disk_destroy(pedDisk);
}

View File

@ -210,7 +210,7 @@ QStringList PartitionTable::flagNames(Flags flags)
*/
static qint64 sectorAlignment(const Device& d)
{
return d.partitionTable()->type() == PartitionTable::msdos ? d.cylinderSize() : Config::vistaSectorAlignment();
return d.partitionTable()->type() == PartitionTable::msdos ? d.cylinderSize() : Config::sectorAlignment();
}
/** Checks if a given Partition on a given Device is snapped to cylinder boundaries.
@ -226,28 +226,29 @@ static qint64 sectorAlignment(const Device& d)
*/
bool PartitionTable::isSnapped(const Device& d, const Partition& p)
{
// only msdos and msdos_vista get snapped
if (d.partitionTable()->type() != msdos && d.partitionTable()->type() != msdos_vista)
return true;
// don't bother with unallocated space here.
if (p.roles().has(PartitionRole::Unallocated))
return true;
qint64 delta = 0;
// TODO: verify the following comment and code both for msdos and msdos_vista
// There are some special cases for snapping partitions:
// 1) If an extended partition starts at the beginning of the device (that would be sector 63
// on modern drives, equivalent to sectorsPerTrack() in any case), the first logical partition
// at the beginning of this extended partition starts at 2 * sectorsPerTrack().
// 2) If a primary or extended starts at the beginning of a device, it starts at sectorsPerTrack().
// 3) Any logical partition is always preceded by the extended partition table entry in the
// sectorsPerTrack() before it, so it's always sectorsPerTrack() "late"
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * d.sectorsPerTrack())
delta = (p.firstSector() - (2 * d.sectorsPerTrack())) % sectorAlignment(d);
else if (p.roles().has(PartitionRole::Logical) || p.firstSector() == d.sectorsPerTrack())
delta = (p.firstSector() - d.sectorsPerTrack()) % sectorAlignment(d);
if (d.partitionTable()->type() == msdos)
{
// TODO: verify the following comment and code
// There are some special cases for snapping partitions:
// 1) If an extended partition starts at the beginning of the device (that would be sector 63
// on modern drives, equivalent to sectorsPerTrack() in any case), the first logical partition
// at the beginning of this extended partition starts at 2 * sectorsPerTrack().
// 2) If a primary or extended starts at the beginning of a device, it starts at sectorsPerTrack().
// 3) Any logical partition is always preceded by the extended partition table entry in the
// sectorsPerTrack() before it, so it's always sectorsPerTrack() "late"
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * d.sectorsPerTrack())
delta = (p.firstSector() - (2 * d.sectorsPerTrack())) % sectorAlignment(d);
else if (p.roles().has(PartitionRole::Logical) || p.firstSector() == d.sectorsPerTrack())
delta = (p.firstSector() - d.sectorsPerTrack()) % sectorAlignment(d);
else
delta = p.firstSector() % sectorAlignment(d);
}
else
delta = p.firstSector() % sectorAlignment(d);
@ -255,7 +256,7 @@ bool PartitionTable::isSnapped(const Device& d, const Partition& p)
if (delta)
{
Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not start at the recommended boundary (first sector: %2, modulo: %3).", p.deviceNode(), p.firstSector(), delta);
Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), p.firstSector(), delta);
rval = false;
}
@ -263,7 +264,7 @@ bool PartitionTable::isSnapped(const Device& d, const Partition& p)
if (delta)
{
Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> does not end at the recommended boundary (last sector: %2, modulo: %3).", p.deviceNode(), p.lastSector(), delta);
Log(Log::warning) << i18nc("@info/plain", "Partition <filename>%1</filename> is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), p.lastSector(), delta);
rval = false;
}
@ -314,31 +315,35 @@ static bool canSnapToSector(const Device& d, const Partition& p, qint64 s, const
*/
bool PartitionTable::snap(const Device& d, Partition& p, const Partition* originalPartition)
{
if (d.partitionTable()->type() != msdos && d.partitionTable()->type() != msdos_vista)
return true;
const qint64 originalLength = p.length();
qint64 delta = 0;
bool lengthIsSnapped = false;
// TODO: verify for msdos and msdos_vista
// This is the same as in isSnapped(), only we additionally have to remember if the
// partition's _length_ is "snapped", so to speak (i.e., evenly divisable by
// the cylinder size)
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * d.sectorsPerTrack())
if (d.partitionTable()->type() == msdos)
{
delta = (p.firstSector() - (2 * d.sectorsPerTrack())) % sectorAlignment(d);
lengthIsSnapped = (p.length() + (2 * d.sectorsPerTrack())) % sectorAlignment(d) == 0;
}
else if (p.roles().has(PartitionRole::Logical) || p.firstSector() == d.sectorsPerTrack())
{
delta = (p.firstSector() - d.sectorsPerTrack()) % sectorAlignment(d);
lengthIsSnapped = (p.length() + d.sectorsPerTrack()) % sectorAlignment(d) == 0;
// This is the same as in isSnapped(), only we additionally have to remember if the
// partition's _length_ is "snapped", so to speak (i.e., evenly divisable by
// the cylinder size)
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * d.sectorsPerTrack())
{
delta = (p.firstSector() - (2 * d.sectorsPerTrack())) % sectorAlignment(d);
lengthIsSnapped = (p.length() + (2 * d.sectorsPerTrack())) % sectorAlignment(d) == 0;
}
else if (p.roles().has(PartitionRole::Logical) || p.firstSector() == d.sectorsPerTrack())
{
delta = (p.firstSector() - d.sectorsPerTrack()) % sectorAlignment(d);
lengthIsSnapped = (p.length() + d.sectorsPerTrack()) % sectorAlignment(d) == 0;
}
else
{
delta = p.firstSector() % sectorAlignment(d);
lengthIsSnapped = p.length() % sectorAlignment(d) == 0;
}
}
else
{
delta = p.firstSector() % sectorAlignment(d);
lengthIsSnapped = p.length() % sectorAlignment(d) == 0;
delta = p.firstSector() % sectorAlignment(d);
lengthIsSnapped = p.length() % sectorAlignment(d) == 0;
}
if (delta)
@ -561,10 +566,10 @@ void PartitionTable::updateUnallocated(const Device& d)
qint64 PartitionTable::defaultFirstUsable(const Device& d, LabelType t)
{
if (t == msdos_vista)
return Config::vistaSectorAlignment();
if (t == msdos && Config::useLegacyMsDosAlignment())
return d.sectorsPerTrack();
return d.sectorsPerTrack() - 1;
return Config::sectorAlignment();
}
qint64 PartitionTable::defaultLastUsable(const Device& d, LabelType t)
@ -643,26 +648,35 @@ bool PartitionTable::diskLabelIsReadOnly(LabelType l)
return false;
}
/** Simple heuristic to determine if the PartitionTable is MS Vista compatible (i.e.
if its Partitions begin at sectors evenly divisable by Config::sectorAlignment().
@return true if is msdos_vista, otherwise false
*/
bool PartitionTable::isVistaDiskLabel() const
{
if (type() == PartitionTable::msdos)
{
const Partition* part = findPartitionBySector(Config::vistaSectorAlignment(), PartitionRole(PartitionRole::Primary));
if (part && part->firstSector() == Config::vistaSectorAlignment())
// user has turned ms dos legacy off and partition table is empty
if (Config::useLegacyMsDosAlignment() == false && children().size() == 0)
return true;
// if not all partitions start at a point evenlty divisable by sectorAlignment it's
// a legay disk label
foreach(const Partition* p, children())
if (p->firstSector() % Config::sectorAlignment() != 0)
return false;
// must be vista
return true;
}
return false;
}
void PartitionTable::setType(LabelType t)
void PartitionTable::setType(const Device& d, LabelType t)
{
// hack: if the type has been msdos and is now set to vista, make sure to also
// set the first usable sector to Config::vistaSectorAlignment (which defaults to
// Vista's default, 2048) now.
if (type() == msdos && t == msdos_vista)
setFirstUsableSector(Config::vistaSectorAlignment());
setFirstUsableSector(defaultFirstUsable(d, t));
setLastUsableSector(defaultLastUsable(d, t));
m_Type = t;
}

View File

@ -98,7 +98,7 @@ class PartitionTable : public PartitionNode
Partitions& children() { return m_Children; } /**< @return the children in this PartitionTable */
const Partitions& children() const { return m_Children; } /**< @return the children in this PartitionTable */
void setType(LabelType t);
void setType(const Device& d, LabelType t);
void append(Partition* partition);
@ -146,6 +146,7 @@ class PartitionTable : public PartitionNode
protected:
void setMaxPrimaries(qint32 n) { m_MaxPrimaries = n; }
void setFirstUsableSector(qint64 s) { m_FirstUsable = s; }
void setLastUsableSector(qint64 s) { m_LastUsable = s; }
private:
Partitions m_Children;

View File

@ -0,0 +1,43 @@
/***************************************************************************
* 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/configureoptionsdialog.h"
#include "ui_configurepagegeneral.h"
#include "ui_configurepageadvanced.h"
class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
{
public:
GeneralPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); }
};
class AdvancedPageWidget : public QWidget, public Ui::ConfigurePageAdvanced
{
public:
AdvancedPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); }
};
ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const QString& name, KConfigSkeleton* cfg) :
KConfigDialog(parent, name, cfg)
{
setFaceType(KPageDialog::Tabbed);
addPage(new GeneralPageWidget(this), i18n("General"), QString(), i18n("General Settings"));
addPage(new AdvancedPageWidget(this), i18n("Advanced"), QString(), i18n("Advanced Settings"));
}

View File

@ -0,0 +1,32 @@
/***************************************************************************
* 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(CONFIGUREOPTIONSDIALOG__H)
#define CONFIGUREOPTIONSDIALOG__H
#include <kconfigdialog.h>
class ConfigureOptionsDialog : public KConfigDialog
{
public:
ConfigureOptionsDialog(QWidget* parent, const QString& name, KConfigSkeleton* cfg);
};
#endif

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigurePageAdvanced</class>
<widget class="QWidget" name="ConfigurePageAdvanced">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>477</width>
<height>194</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_useLegacyMsDosAlignment">
<property name="text">
<string>Use Legacy MS-Dos Partition Alignment (Windows XP compatible)</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Partition Sector Aligment:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="kcfg_sectorAlignment">
<property name="enabled">
<bool>true</bool>
</property>
<property name="maximum">
<number>16777215</number>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ConfigurePageGeneral</class>
<widget class="QWidget" name="ConfigurePageGeneral">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_allowApplyOperationsAsNonRoot">
<property name="text">
<string>Allow Applying OperationsWithout Administrator Privileges</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -35,9 +35,6 @@ CreatePartitionTableDialog::CreatePartitionTableDialog(QWidget* parent, const De
setMainWidget(&widget());
setCaption(i18nc("@title:window", "Create a New Partition Table on <filename>%1</filename>", device().deviceNode()));
setButtonText(KDialog::Ok, i18nc("@action:button", "&Create New Partition Table"));
if (!Config::allowCreateVistaPartitionTable())
widget().radioMSDOSVista().hide();
}
PartitionTable::LabelType CreatePartitionTableDialog::type() const
@ -45,8 +42,8 @@ PartitionTable::LabelType CreatePartitionTableDialog::type() const
if (widget().radioGPT().isChecked())
return PartitionTable::gpt;
if (widget().radioMSDOSVista().isChecked())
return PartitionTable::msdos_vista;
if (widget().radioMSDOS().isChecked() && Config::useLegacyMsDosAlignment() == true)
return PartitionTable::msdos;
return PartitionTable::msdos;
return PartitionTable::msdos_vista;
}

View File

@ -38,9 +38,6 @@ class CreatePartitionTableWidget : public QWidget, public Ui::CreatePartitionTab
QRadioButton& radioMSDOS() { return *m_RadioMSDOS; }
const QRadioButton& radioMSDOS() const { return *m_RadioMSDOS; }
QRadioButton& radioMSDOSVista() { return *m_RadioMSDOSVista; }
const QRadioButton& radioMSDOSVista() const { return *m_RadioMSDOSVista; }
QRadioButton& radioGPT() { return *m_RadioGPT; }
const QRadioButton& radioGPT() const { return *m_RadioGPT; }

View File

@ -25,7 +25,7 @@
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QRadioButton" name="m_RadioMSDOS">
<property name="text">
@ -36,13 +36,6 @@
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_RadioMSDOSVista">
<property name="text">
<string>MS-Dos (Windows Vista compatible)</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="m_RadioGPT">
<property name="text">

View File

@ -0,0 +1,86 @@
/***************************************************************************
* Copyright (C) 2008,2009 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/devicepropsdialog.h"
#include "gui/devicepropswidget.h"
#include "core/device.h"
#include "core/partitiontable.h"
#include "util/capacity.h"
#include "util/helpers.h"
#include <kdebug.h>
#include <kpushbutton.h>
/** Creates a new DevicePropsDialog
@param parent pointer to the parent widget
@param d the Device the Partition is on
@param p the Partition to show properties for
*/
DevicePropsDialog::DevicePropsDialog(QWidget* parent, Device& d) :
KDialog(parent),
m_Device(d),
m_DialogWidget(new DevicePropsWidget(this))
{
setMainWidget(&dialogWidget());
setCaption(i18nc("@title:window", "Device properties: <filename>%1</filename>", device().deviceNode()));
setupDialog();
restoreDialogSize(KConfigGroup(KGlobal::config(), "devicePropsDialog"));
}
/** Destroys a DevicePropsDialog */
DevicePropsDialog::~DevicePropsDialog()
{
KConfigGroup kcg(KGlobal::config(), "devicePropsDialog");
saveDialogSize(kcg);
}
void DevicePropsDialog::setupDialog()
{
setDefaultButton(KDialog::Cancel);
enableButtonOk(false);
button(KDialog::Cancel)->setFocus();
dialogWidget().partTableWidget().setReadOnly(true);
dialogWidget().partTableWidget().setPartitionTable(device().partitionTable());
dialogWidget().capacity().setText(Capacity(device()).toString(Capacity::AppendUnit | Capacity::AppendBytes));
const QString cyls = KGlobal::locale()->formatNumber(device().cylinders(), 0);
const QString heads = QString::number(device().heads());
const QString sectors = KGlobal::locale()->formatNumber(device().sectorsPerTrack(), 0);
dialogWidget().chs().setText(QString("%1/%2/%3").arg(cyls).arg(heads).arg(sectors));
dialogWidget().cylinderSize().setText(i18ncp("@label", "1 Sector", "%1 Sectors", device().cylinderSize()));
dialogWidget().primariesMax().setText(QString("%1/%2").arg(device().partitionTable()->numPrimaries()).arg(device().partitionTable()->maxPrimaries()));
dialogWidget().sectorSize().setText(Capacity(device().sectorSize()).toString(Capacity::Byte, Capacity::AppendUnit));
dialogWidget().totalSectors().setText(KGlobal::locale()->formatNumber(device().totalSectors(), 0));
const QString type = device().partitionTable()->isReadOnly()
? i18nc("@label device", "%1 (read only)", device().partitionTable()->typeName())
: device().partitionTable()->typeName();
dialogWidget().type().setText(type);
setMinimumSize(dialogWidget().size());
resize(dialogWidget().size());
}

View File

@ -0,0 +1,61 @@
/***************************************************************************
* 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(DEVICEPROPSDIALOG__H)
#define DEVICEPROPSDIALOG__H
#include <kdialog.h>
class Device;
class DevicePropsWidget;
class QWidget;
class QString;
/** @brief Show Device properties.
Dialog that shows a Device's properties.
@author vl@fidra.de
*/
class DevicePropsDialog : public KDialog
{
Q_OBJECT
Q_DISABLE_COPY(DevicePropsDialog)
public:
DevicePropsDialog(QWidget* parent, Device& d);
~DevicePropsDialog();
protected:
void setupDialog();
Device& device() { return m_Device; }
const Device& device() const { return m_Device; }
DevicePropsWidget& dialogWidget() { Q_ASSERT(m_DialogWidget); return *m_DialogWidget; }
const DevicePropsWidget& dialogWidget() const { Q_ASSERT(m_DialogWidget); return *m_DialogWidget; }
private:
Device& m_Device;
DevicePropsWidget* m_DialogWidget;
};
#endif

View File

@ -0,0 +1,48 @@
/***************************************************************************
* 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(DEVICEPROPSWIDGET__H)
#define DEVICEPROPSWIDGET__H
#include "ui_devicepropswidgetbase.h"
class PartTableWidget;
/** @brief Central widget in the DevicePropsDialog.
@author vl@fidra.de
*/
class DevicePropsWidget : public QWidget, public Ui::DevicePropsWidgetBase
{
public:
DevicePropsWidget(QWidget* parent) : QWidget(parent) { setupUi(this); }
public:
PartTableWidget& partTableWidget() { Q_ASSERT(m_PartTableWidget); return *m_PartTableWidget; }
QLabel& chs() { Q_ASSERT(m_LabelCHS); return *m_LabelCHS; }
QLabel& capacity() { Q_ASSERT(m_LabelCapacity); return *m_LabelCapacity; }
QLabel& cylinderSize() { Q_ASSERT(m_LabelCylinderSize); return *m_LabelCylinderSize; }
QLabel& primariesMax() { Q_ASSERT(m_LabelPrimariesMax); return *m_LabelPrimariesMax; }
QLabel& sectorSize() { Q_ASSERT(m_LabelSectorSize); return *m_LabelSectorSize; }
QLabel& totalSectors() { Q_ASSERT(m_LabelTotalSectors); return *m_LabelTotalSectors; }
QLabel& type() { Q_ASSERT(m_LabelType); return *m_LabelType; }
};
#endif

View File

@ -0,0 +1,268 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>DevicePropsWidgetBase</class>
<widget class="QWidget" name="DevicePropsWidgetBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>406</width>
<height>283</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0">
<widget class="QLabel" name="m_LabelTextType">
<property name="text">
<string>Type:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="m_LabelType">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="m_LabelCapacity">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="m_LabelTextTotalSectors">
<property name="text">
<string>Total Sectors:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="m_LabelTotalSectors">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="m_LabelTextCHS">
<property name="text">
<string>Cylinders/Heads/Sectors:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="m_LabelCHS">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QLabel" name="m_LabelTextSectorSize">
<property name="text">
<string>Logical Sector Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="m_LabelSectorSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="m_LabelTextCylinderSize">
<property name="text">
<string>Cylinder Size:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="10" column="1">
<widget class="QLabel" name="m_LabelCylinderSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="12" column="0">
<widget class="QLabel" name="m_LabelTextPrimariesMax">
<property name="text">
<string>Primaries/Max:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QLabel" name="m_LabelPrimariesMax">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="m_LabelTextCapacity">
<property name="text">
<string>Capacity:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2">
<spacer name="verticalSpacer_2">
<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>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="PartTableWidget" name="m_PartTableWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>80</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>80</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<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>20</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0" colspan="2">
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="11" column="0" colspan="2">
<widget class="Line" name="line_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>PartTableWidget</class>
<extends>QWidget</extends>
<header>gui/parttablewidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -96,3 +96,11 @@ void ListDevices::on_m_ListDevices_customContextMenuRequested(const QPoint& pos)
deviceMenu.exec(listDevices().viewport()->mapToGlobal(pos));
}
}
void ListDevices::on_m_ListDevices_itemActivated(QListWidgetItem* list_item)
{
ListDeviceWidgetItem* item = dynamic_cast<ListDeviceWidgetItem*>(list_item);
if (item != NULL)
emit deviceActivated(item->deviceNode);
}

View File

@ -46,6 +46,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT ListDevices : public QWidget, public Ui:
signals:
void selectionChanged(const QString& device_node);
void deviceActivated(const QString& device_node);
public:
void setActionCollection(KActionCollection* coll) { m_ActionCollection = coll; }
@ -61,6 +62,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT ListDevices : public QWidget, public Ui:
protected slots:
void on_m_ListDevices_itemSelectionChanged();
void on_m_ListDevices_customContextMenuRequested(const QPoint& pos);
void on_m_ListDevices_itemActivated(QListWidgetItem* list_item);
private:
KActionCollection* m_ActionCollection;

View File

@ -143,6 +143,7 @@ void MainWindow::setupActions()
void MainWindow::setupConnections()
{
connect(&listDevices(), SIGNAL(selectionChanged(const QString&)), &pmWidget(), SLOT(setSelectedDevice(const QString&)));
connect(&listDevices(), SIGNAL(deviceActivated(const QString&)), &pmWidget(), SLOT(onPropertiesDevice(const QString&)));
}
void MainWindow::setupStatusBar()

View File

@ -28,6 +28,8 @@
#include "gui/editmountpointdialog.h"
#include "gui/createpartitiontabledialog.h"
#include "gui/scanprogressdialog.h"
#include "gui/configureoptionsdialog.h"
#include "gui/devicepropsdialog.h"
#include "core/partition.h"
#include "core/device.h"
@ -308,6 +310,9 @@ void PartitionManagerWidget::setupActions()
fileSystemSupport->setText(i18nc("@action:inmenu", "File System Support"));
fileSystemSupport->setToolTip(i18nc("@info:tooltip", "View file system support information"));
fileSystemSupport->setStatusTip(i18nc("@info:status", "Show information about supported file systems."));
// Settings actions
KStandardAction::preferences(this, SLOT(onConfigureOptions()), actionCollection());
}
void PartitionManagerWidget::setupConnections()
@ -1166,3 +1171,33 @@ void PartitionManagerWidget::onFileSystemSupport()
FileSystemSupportDialog dlg(this);
dlg.exec();
}
void PartitionManagerWidget::onSettingsChanged(const QString&)
{
enableActions();
}
void PartitionManagerWidget::onConfigureOptions()
{
if (ConfigureOptionsDialog::showDialog("Settings"))
return;
QPointer<ConfigureOptionsDialog> dlg = new ConfigureOptionsDialog(this, "Settings", Config::self());
connect(dlg, SIGNAL(settingsChanged(const QString&)), SLOT(onSettingsChanged(const QString&)));
dlg->show();
}
void PartitionManagerWidget::onPropertiesDevice(const QString&)
{
Q_ASSERT(selectedDevice());
if (selectedDevice())
{
QPointer<DevicePropsDialog> dlg = new DevicePropsDialog(this, *selectedDevice());
dlg->exec();
delete dlg;
}
}

View File

@ -129,6 +129,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionManagerWidget : public QWidget,
void onScanDevicesProgressChanged(const QString& device_node, int percent);
void onPropertiesPartition();
void onPropertiesDevice(const QString& device_node);
void onMountPartition();
void onEditMountPoint();
void onNewPartition();
@ -146,6 +147,8 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT PartitionManagerWidget : public QWidget,
void onFileSystemSupport();
void onBackupPartition();
void onRestorePartition();
void onConfigureOptions();
void onSettingsChanged(const QString&);
void onHeaderContextMenu(const QPoint& p);
private:

View File

@ -106,6 +106,7 @@ void PartitionManagerKCM::onNewLogMessage(Log::Level, const QString& s)
void PartitionManagerKCM::setupConnections()
{
connect(&listDevices(), SIGNAL(selectionChanged(const QString&)), &pmWidget(), SLOT(setSelectedDevice(const QString&)));
connect(&listDevices(), SIGNAL(deviceActivated(const QString&)), &pmWidget(), SLOT(onPropertiesDevice(const QString&)));
}
void PartitionManagerKCM::on_m_PartitionManagerWidget_operationsChanged()