add setting of default FS to config dialog

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1101986
This commit is contained in:
Volker Lanz 2010-03-11 14:17:21 +00:00
parent a4488119d5
commit ebf1612dc8
7 changed files with 100 additions and 8 deletions

8
TODO
View File

@ -26,8 +26,10 @@ Random plans and ideas for 1.1 and beyond:
in the kernel. that should cover all cases where we actually need root
privileges now. (not for 1.1)
* make sure we actually need CoreBackend::about() and can't use something from
the KPlugin* stuff for that
* offer a) no alignment of partition boundaries at all or b) legacy cylinder
alignment or c) sector based alignment (the name is misleading, though)
Bugs:
* copy&paste seems broken wrt alignment when copying from cylinder aligned to
sector aligned drives (maybe even more than that)

View File

@ -4,6 +4,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 http://www.kde.org/standards/kcfg/1.0/kcfg.xsd">
<kcfgfile arg="true"/>
<include>fs/filesystem.h</include>
<group name="KDE Partition Manager">
<entry name="treePartitionColumnWidths" type="IntList" hidden="true">
<default>140,90,90,90,0,90,90,0,0,0,0,0</default>
@ -80,5 +81,8 @@
<label context="@label">Backend Plugin</label>
<default>pluginpmlibparted</default>
</entry>
<entry key="defaultFileSystem" type="Int">
<default>FileSystem::Ext3</default>
</entry>
</group>
</kcfg>

View File

@ -26,6 +26,8 @@
#include <klocale.h>
#include <kdebug.h>
#include <config.h>
/** Creates a new FileSystem object
@param firstsector the first sector used by this FileSystem on the Device
@param lastsector the last sector used by this FileSystem on the Device
@ -346,3 +348,8 @@ bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, i
return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode;
}
FileSystem::Type FileSystem::defaultFileSystem()
{
return static_cast<FileSystem::Type>(Config::defaultFileSystem());
}

View File

@ -128,7 +128,7 @@ class FileSystem
static QString nameForType(FileSystem::Type t);
static QList<FileSystem::Type> types();
static FileSystem::Type typeForName(const QString& s);
static FileSystem::Type defaultFileSystem() { return Ext2; } /**< @return the default FileSystem type */
static FileSystem::Type defaultFileSystem(); /**< @return the default FileSystem type */
virtual bool canMount(const QString&) const { return false; } /**< @return true if this FileSystem can be mounted */
virtual bool canUnmount(const QString&) const { return false; } /**< @return true if this FileSystem can be unmounted */

View File

@ -19,15 +19,42 @@
#include "gui/configureoptionsdialog.h"
#include "fs/filesystem.h"
#include "fs/filesystemfactory.h"
#include "util/helpers.h"
#include "ui_configurepagegeneral.h"
#include "ui_configurepagefilesystemcolors.h"
#include <kiconloader.h>
#include <config.h>
class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
{
public:
GeneralPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); }
GeneralPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); setupDialog(); }
public:
QComboBox& comboDefaultFileSystem() { return *m_ComboDefaultFileSystem; }
private:
void setupDialog()
{
QStringList fsNames;
foreach (const FileSystem* fs, FileSystemFactory::map())
if (fs->supportCreate() != FileSystem::cmdSupportNone && fs->type() != FileSystem::Extended)
fsNames.append(fs->name());
qSort(fsNames.begin(), fsNames.end(), caseInsensitiveLessThan);
foreach (const QString& fsName, fsNames)
comboDefaultFileSystem().addItem(createFileSystemColor(FileSystem::typeForName(fsName), 8), fsName);
const QString selected = FileSystem::nameForType(FileSystem::defaultFileSystem());
comboDefaultFileSystem().setCurrentIndex(comboDefaultFileSystem().findText(selected));
}
};
class FileSystemColorsPageWidget : public QWidget, public Ui::ConfigurePageFileSystemColors
@ -37,21 +64,28 @@ class FileSystemColorsPageWidget : public QWidget, public Ui::ConfigurePageFileS
};
ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const QString& name, KConfigSkeleton* cfg) :
KConfigDialog(parent, name, cfg)
KConfigDialog(parent, name, cfg),
m_GeneralPageWidget(new GeneralPageWidget(this)),
m_FileSystemColorsPageWidget(new FileSystemColorsPageWidget(this))
{
setFaceType(List);
KPageWidgetItem* item = NULL;
item = addPage(new GeneralPageWidget(this), i18n("General"), QString(), i18n("General Settings"));
item = addPage(&generalPageWidget(), i18n("General"), QString(), i18n("General Settings"));
item->setIcon(KIcon(DesktopIcon("configure")));
item = addPage(new FileSystemColorsPageWidget(this), i18n("File System Colors"), QString(), i18n("File System Color Settings"));
item = addPage(&fileSystemColorsPageWidget(), i18n("File System Colors"), QString(), i18n("File System Color Settings"));
item->setIcon(KIcon(DesktopIcon("format-fill-color")));
restoreDialogSize(KConfigGroup(KGlobal::config(), "configureOptionsDialog"));
}
void ConfigureOptionsDialog::updateSettings()
{
Config::setDefaultFileSystem(FileSystem::typeForName(generalPageWidget().comboDefaultFileSystem().currentText()));
}
/** Destroys a ConfigureOptionsDialog instance */
ConfigureOptionsDialog::~ConfigureOptionsDialog()
{

View File

@ -22,12 +22,29 @@
#define CONFIGUREOPTIONSDIALOG__H
#include <kconfigdialog.h>
#include <kdebug.h>
class GeneralPageWidget;
class FileSystemColorsPageWidget;
class ConfigureOptionsDialog : public KConfigDialog
{
Q_OBJECT
public:
ConfigureOptionsDialog(QWidget* parent, const QString& name, KConfigSkeleton* cfg);
~ConfigureOptionsDialog();
protected slots:
void updateSettings();
protected:
GeneralPageWidget& generalPageWidget() { Q_ASSERT(m_GeneralPageWidget); return *m_GeneralPageWidget; }
FileSystemColorsPageWidget& fileSystemColorsPageWidget() { Q_ASSERT(m_FileSystemColorsPageWidget); return *m_FileSystemColorsPageWidget; }
private:
GeneralPageWidget* m_GeneralPageWidget;
FileSystemColorsPageWidget* m_FileSystemColorsPageWidget;
};
#endif

View File

@ -139,6 +139,34 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>File Systems</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default File System:</string>
</property>
<property name="buddy">
<cstring>kcfg_minLogLevel</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="m_ComboDefaultFileSystem"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>