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 *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2010-03-21 11:32:31 +00:00
|
|
|
#include "config/configureoptionsdialog.h"
|
2010-03-21 11:52:07 +00:00
|
|
|
#include "config/generalpagewidget.h"
|
|
|
|
#include "config/filesystemcolorspagewidget.h"
|
2010-06-02 15:35:02 +01:00
|
|
|
#include "config/advancedpagewidget.h"
|
2010-02-17 13:18:25 +00:00
|
|
|
|
2010-03-21 10:50:44 +00:00
|
|
|
#include "backend/corebackendmanager.h"
|
|
|
|
|
2010-03-24 23:30:20 +00:00
|
|
|
#include "core/operationstack.h"
|
|
|
|
|
2010-03-11 14:17:21 +00:00
|
|
|
#include "fs/filesystem.h"
|
|
|
|
#include "fs/filesystemfactory.h"
|
|
|
|
|
|
|
|
#include "util/helpers.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-21 10:50:44 +00:00
|
|
|
#include <kservice.h>
|
2010-03-24 23:30:20 +00:00
|
|
|
#include <kmessagebox.h>
|
2010-06-02 21:39:25 +01:00
|
|
|
#include <kcmdlineargs.h>
|
2014-05-13 23:53:37 +01:00
|
|
|
#include <KLocalizedString>
|
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-03-24 23:30:20 +00:00
|
|
|
ConfigureOptionsDialog::ConfigureOptionsDialog(QWidget* parent, const OperationStack& ostack, const QString& name) :
|
2010-03-11 19:40:42 +00:00
|
|
|
KConfigDialog(parent, name, Config::self()),
|
2010-03-11 14:17:21 +00:00
|
|
|
m_GeneralPageWidget(new GeneralPageWidget(this)),
|
2010-03-24 23:30:20 +00:00
|
|
|
m_FileSystemColorsPageWidget(new FileSystemColorsPageWidget(this)),
|
2010-06-02 15:35:02 +01:00
|
|
|
m_AdvancedPageWidget(new AdvancedPageWidget(this)),
|
2010-03-24 23:30:20 +00:00
|
|
|
m_OperationStack(ostack)
|
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-06-02 15:35:02 +01:00
|
|
|
item->setIcon(KIcon(DesktopIcon("partitionmanager")));
|
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-21 10:50:44 +00:00
|
|
|
|
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-06-02 21:39:25 +01:00
|
|
|
if (KCmdLineArgs::parsedArgs()->isSet("advconfig"))
|
|
|
|
{
|
|
|
|
item = addPage(&advancedPageWidget(), i18nc("@title:tab advanced application settings", "Advanced"), QString(), i18n("Advanced Settings"));
|
|
|
|
item->setIcon(KIcon(DesktopIcon("configure")));
|
2010-06-02 15:35:02 +01:00
|
|
|
|
2010-06-02 21:39:25 +01:00
|
|
|
connect(&advancedPageWidget().comboBackend(), SIGNAL(activated(int)), SLOT(onComboBackendActivated(int)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
advancedPageWidget().setVisible(false);
|
2010-06-02 15:35:02 +01:00
|
|
|
|
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()
|
|
|
|
{
|
2010-03-21 10:50:44 +00:00
|
|
|
KConfigDialog::updateSettings();
|
|
|
|
|
|
|
|
bool changed = false;
|
|
|
|
|
|
|
|
if (generalPageWidget().defaultFileSystem() != Config::defaultFileSystem())
|
|
|
|
{
|
|
|
|
Config::setDefaultFileSystem(generalPageWidget().defaultFileSystem());
|
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
2010-06-02 21:39:25 +01:00
|
|
|
if (advancedPageWidget().isVisible() && advancedPageWidget().backend() != Config::backend())
|
2010-03-21 10:50:44 +00:00
|
|
|
{
|
2010-06-02 15:35:02 +01:00
|
|
|
Config::setBackend(advancedPageWidget().backend());
|
2010-03-21 10:50:44 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changed)
|
|
|
|
emit KConfigDialog::settingsChanged(i18n("General Settings"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureOptionsDialog::hasChanged()
|
|
|
|
{
|
|
|
|
bool result = KConfigDialog::hasChanged();
|
|
|
|
|
|
|
|
KConfigSkeletonItem* kcItem = Config::self()->findItem("defaultFileSystem");
|
|
|
|
result = result || !kcItem->isEqual(generalPageWidget().defaultFileSystem());
|
|
|
|
|
2010-06-02 21:39:25 +01:00
|
|
|
if (advancedPageWidget().isVisible())
|
|
|
|
{
|
|
|
|
kcItem = Config::self()->findItem("backend");
|
|
|
|
result = result || !kcItem->isEqual(advancedPageWidget().backend());
|
|
|
|
}
|
2010-03-21 10:50:44 +00:00
|
|
|
|
|
|
|
return result;
|
2010-03-11 19:40:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureOptionsDialog::isDefault()
|
|
|
|
{
|
2010-03-21 10:50:44 +00:00
|
|
|
bool result = KConfigDialog::isDefault();
|
2010-03-11 19:40:42 +00:00
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
const bool useDefaults = Config::self()->useDefaults(true);
|
2010-03-21 10:50:44 +00:00
|
|
|
result = !hasChanged();
|
2010-03-11 19:40:42 +00:00
|
|
|
Config::self()->useDefaults(useDefaults);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigureOptionsDialog::updateWidgetsDefault()
|
|
|
|
{
|
|
|
|
bool useDefaults = Config::self()->useDefaults(true);
|
|
|
|
generalPageWidget().setDefaultFileSystem(FileSystem::defaultFileSystem());
|
2010-06-02 21:39:25 +01:00
|
|
|
|
|
|
|
if (advancedPageWidget().isVisible())
|
|
|
|
advancedPageWidget().setBackend(CoreBackendManager::defaultBackendName());
|
|
|
|
|
2010-03-11 19:40:42 +00:00
|
|
|
Config::self()->useDefaults(useDefaults);
|
|
|
|
}
|
2010-03-24 23:30:20 +00:00
|
|
|
|
|
|
|
void ConfigureOptionsDialog::onComboBackendActivated(int)
|
|
|
|
{
|
2010-06-02 21:39:25 +01:00
|
|
|
Q_ASSERT(advancedPageWidget().isVisible());
|
|
|
|
|
2010-03-24 23:30:20 +00:00
|
|
|
if (operationStack().size() == 0 || KMessageBox::warningContinueCancel(this,
|
|
|
|
i18nc("@info",
|
|
|
|
"<para>Do you really want to change the backend?</para>"
|
|
|
|
"<para><warning>This will also rescan devices and thus clear the list of pending operations.</warning></para>"),
|
|
|
|
i18nc("@title:window", "Really Change Backend?"),
|
2010-04-11 19:19:24 +01:00
|
|
|
KGuiItem(i18nc("@action:button", "Change the Backend"), "arrow-right"),
|
|
|
|
KGuiItem(i18nc("@action:button", "Do Not Change the Backend"), "dialog-cancel"), "reallyChangeBackend") == KMessageBox::Continue)
|
2010-03-24 23:30:20 +00:00
|
|
|
{
|
|
|
|
settingsChangedSlot();
|
|
|
|
}
|
|
|
|
else
|
2010-06-02 15:35:02 +01:00
|
|
|
advancedPageWidget().setBackend(CoreBackendManager::defaultBackendName());
|
2010-03-24 23:30:20 +00:00
|
|
|
}
|