2010-02-17 13:18:25 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* 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"
|
|
|
|
|
2010-03-11 14:17:21 +00:00
|
|
|
#include "fs/filesystem.h"
|
|
|
|
#include "fs/filesystemfactory.h"
|
|
|
|
|
|
|
|
#include "util/helpers.h"
|
|
|
|
|
2010-02-17 13:18:25 +00:00
|
|
|
#include "ui_configurepagegeneral.h"
|
2010-02-17 19:39:24 +00:00
|
|
|
#include "ui_configurepagefilesystemcolors.h"
|
2010-02-17 13:18:25 +00:00
|
|
|
|
2010-03-03 10:46:23 +00:00
|
|
|
#include <kiconloader.h>
|
2010-03-11 19:40:42 +00:00
|
|
|
|
2010-03-11 14:17:21 +00:00
|
|
|
#include <config.h>
|
2010-03-03 10:46:23 +00:00
|
|
|
|
2010-02-17 13:18:25 +00:00
|
|
|
class GeneralPageWidget : public QWidget, public Ui::ConfigurePageGeneral
|
|
|
|
{
|
|
|
|
public:
|
2010-03-11 14:17:21 +00:00
|
|
|
GeneralPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); setupDialog(); }
|
|
|
|
|
|
|
|
public:
|
|
|
|
QComboBox& comboDefaultFileSystem() { return *m_ComboDefaultFileSystem; }
|
2010-03-11 19:40:42 +00:00
|
|
|
const QComboBox& comboDefaultFileSystem() const { return *m_ComboDefaultFileSystem; }
|
|
|
|
|
|
|
|
FileSystem::Type defaultFileSystem() const
|
|
|
|
{
|
|
|
|
return FileSystem::typeForName(comboDefaultFileSystem().currentText());
|
|
|
|
}
|
|
|
|
|
|
|
|
void setDefaultFileSystem(FileSystem::Type t)
|
|
|
|
{
|
|
|
|
comboDefaultFileSystem().setCurrentIndex(comboDefaultFileSystem().findText(FileSystem::nameForType(t)));
|
|
|
|
}
|
2010-03-11 14:17:21 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2010-03-11 19:40:42 +00:00
|
|
|
setDefaultFileSystem(FileSystem::defaultFileSystem());
|
2010-03-11 14:17:21 +00:00
|
|
|
}
|
2010-02-17 13:18:25 +00:00
|
|
|
};
|
|
|
|
|
2010-02-17 19:39:24 +00:00
|
|
|
class FileSystemColorsPageWidget : public QWidget, public Ui::ConfigurePageFileSystemColors
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FileSystemColorsPageWidget(QWidget* parent) : QWidget(parent) { setupUi(this); }
|
|
|
|
};
|
|
|
|
|
2010-03-11 19:40:42 +00:00
|
|
|
ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const QString& name) :
|
|
|
|
KConfigDialog(parent, name, Config::self()),
|
2010-03-11 14:17:21 +00:00
|
|
|
m_GeneralPageWidget(new GeneralPageWidget(this)),
|
|
|
|
m_FileSystemColorsPageWidget(new FileSystemColorsPageWidget(this))
|
2010-02-17 13:18:25 +00:00
|
|
|
{
|
2010-03-03 10:46:23 +00:00
|
|
|
setFaceType(List);
|
|
|
|
|
|
|
|
KPageWidgetItem* item = NULL;
|
|
|
|
|
2010-03-11 16:34:48 +00:00
|
|
|
item = addPage(&generalPageWidget(), i18nc("@title:tab general application settings", "General"), QString(), i18n("General Settings"));
|
2010-03-09 22:39:03 +00:00
|
|
|
item->setIcon(KIcon(DesktopIcon("configure")));
|
2010-03-03 10:46:23 +00:00
|
|
|
|
2010-03-11 19:40:42 +00:00
|
|
|
connect(&generalPageWidget().comboDefaultFileSystem(), SIGNAL(activated(int)), SLOT(onComboDefaultFileSystemActivated(int)));
|
2010-03-11 16:34:48 +00:00
|
|
|
item = addPage(&fileSystemColorsPageWidget(), i18nc("@title:tab", "File System Colors"), QString(), i18n("File System Color Settings"));
|
2010-03-03 10:46:23 +00:00
|
|
|
item->setIcon(KIcon(DesktopIcon("format-fill-color")));
|
|
|
|
|
2010-02-21 17:03:22 +00:00
|
|
|
restoreDialogSize(KConfigGroup(KGlobal::config(), "configureOptionsDialog"));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Destroys a ConfigureOptionsDialog instance */
|
|
|
|
ConfigureOptionsDialog::~ConfigureOptionsDialog()
|
|
|
|
{
|
|
|
|
KConfigGroup kcg(KGlobal::config(), "configureOptionsDialog");
|
|
|
|
saveDialogSize(kcg);
|
2010-02-17 13:18:25 +00:00
|
|
|
}
|
2010-03-11 19:40:42 +00:00
|
|
|
|
|
|
|
void ConfigureOptionsDialog::updateSettings()
|
|
|
|
{
|
|
|
|
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem());
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureOptionsDialog::isDefault()
|
|
|
|
{
|
|
|
|
bool result = !hasChanged();
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
const bool useDefaults = Config::self()->useDefaults(true);
|
|
|
|
KConfigSkeletonItem* kcItem = Config::self()->findItem("defaultFileSystem");
|
|
|
|
if (kcItem != NULL)
|
|
|
|
result = kcItem->isEqual(generalPageWidget().defaultFileSystem());
|
|
|
|
else
|
|
|
|
kWarning() << "the kcitem for defaultFileSytstem is gone.";
|
|
|
|
|
|
|
|
Config::self()->useDefaults(useDefaults);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureOptionsDialog::updateWidgetsDefault()
|
|
|
|
{
|
|
|
|
bool useDefaults = Config::self()->useDefaults(true);
|
|
|
|
generalPageWidget().setDefaultFileSystem(FileSystem::defaultFileSystem());
|
|
|
|
Config::self()->useDefaults(useDefaults);
|
|
|
|
}
|
|
|
|
|