]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/generalsettingspage.cpp
* allow to toggle the content of split views by the context menu
[dolphin.git] / src / generalsettingspage.cpp
index ba5473054c9efcf513905955b8a3525e3b3da2ac..ccb06cd09ce034b837fbad0f88877c0fc0e4817a 100644 (file)
 
 #include "generalsettingspage.h"
 
+#include "dolphinsettings.h"
+#include "dolphinmainwindow.h"
+#include "dolphinview.h"
+#include "dolphinviewcontainer.h"
+
+#include "dolphin_generalsettings.h"
+
 #include <kdialog.h>
 #include <kfiledialog.h>
 #include <klocale.h>
 #include <QPushButton>
 #include <QRadioButton>
 
-#include "dolphinsettings.h"
-#include "dolphinmainwindow.h"
-#include "dolphinview.h"
-
-#include "dolphin_generalsettings.h"
-
-GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* parent) :
+GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin, QWidget* parent) :
     SettingsPageBase(parent),
     m_mainWindow(mainWin),
     m_homeUrl(0),
-    m_startSplit(0),
-    m_startEditable(0),
-    m_showDeleteCommand(0)
+    m_splitView(0),
+    m_editableUrl(0),
+    m_filterBar(0),
+    m_showDeleteCommand(0),
+    m_confirmMoveToTrash(0),
+    m_confirmDelete(0)
 {
     const int spacing = KDialog::spacingHint();
-    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
 
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     KVBox* vBox = new KVBox(this);
     vBox->setSpacing(spacing);
 
     // create 'Home URL' editor
-    QGroupBox* homeBox = new QGroupBox(i18n("Home folder"), vBox);
+    QGroupBox* homeBox = new QGroupBox(i18n("Home Folder"), vBox);
 
     KHBox* homeUrlBox = new KHBox(homeBox);
     homeUrlBox->setSpacing(spacing);
 
     new QLabel(i18n("Location:"), homeUrlBox);
-    m_homeUrl = new QLineEdit(settings->homeUrl(), homeUrlBox);
+    m_homeUrl = new QLineEdit(homeUrlBox);
 
-    QPushButton* selectHomeUrlButton = new QPushButton(SmallIcon("folder"), QString(), homeUrlBox);
+    QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox);
     connect(selectHomeUrlButton, SIGNAL(clicked()),
             this, SLOT(selectHomeUrl()));
 
     KHBox* buttonBox = new KHBox(homeBox);
     buttonBox->setSpacing(spacing);
 
-    QPushButton* useCurrentButton = new QPushButton(i18n("Use current location"), buttonBox);
+    QPushButton* useCurrentButton = new QPushButton(i18n("Use Current Location"), buttonBox);
     connect(useCurrentButton, SIGNAL(clicked()),
             this, SLOT(useCurrentLocation()));
-    QPushButton* useDefaultButton = new QPushButton(i18n("Use default location"), buttonBox);
+    QPushButton* useDefaultButton = new QPushButton(i18n("Use Default Location"), buttonBox);
     connect(useDefaultButton, SIGNAL(clicked()),
             this, SLOT(useDefaultLocation()));
 
@@ -80,23 +83,39 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* par
     homeBoxLayout->addWidget(homeUrlBox);
     homeBoxLayout->addWidget(buttonBox);
 
-    QGroupBox* startBox = new QGroupBox(i18n("Start"), vBox);
+    QGroupBox* startBox = new QGroupBox(i18n("Startup Settings"), vBox);
 
-    // create 'Start with split view' checkbox
-    m_startSplit = new QCheckBox(i18n("Start with split view"), startBox);
-    m_startSplit->setChecked(settings->splitView());
-
-    // create 'Start with editable navigation bar' checkbox
-    m_startEditable = new QCheckBox(i18n("Start with editable navigation bar"), startBox);
-    m_startEditable->setChecked(settings->editableUrl());
+    // create 'Split view', 'Editable location' and 'Filter bar' checkboxes
+    m_splitView = new QCheckBox(i18n("Split view mode"), startBox);
+    m_editableUrl = new QCheckBox(i18n("Editable location bar"), startBox);
+    m_filterBar = new QCheckBox(i18n("Show filter bar"),startBox);
 
     QVBoxLayout* startBoxLayout = new QVBoxLayout(startBox);
-    startBoxLayout->addWidget(m_startSplit);
-    startBoxLayout->addWidget(m_startEditable);
+    startBoxLayout->addWidget(m_splitView);
+    startBoxLayout->addWidget(m_editableUrl);
+    startBoxLayout->addWidget(m_filterBar);
+
+    // create 'Ask Confirmation For' group
+    KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
+    const KConfigGroup trashConfig(konqConfig, "Trash");
+
+    QGroupBox* confirmBox = new QGroupBox(i18n("Ask For Confirmation When"), vBox);
+
+    m_confirmMoveToTrash = new QCheckBox(i18n("Moving files or folders to trash"), confirmBox);
+    m_confirmMoveToTrash->setChecked(trashConfig.readEntry("ConfirmTrash", false));
 
-    m_showDeleteCommand = new QCheckBox(i18n("Show the command 'Delete' in context menu"), vBox);
-    // TODO: use global config like in Konqueror or is this a custom setting for Dolphin?
-    m_showDeleteCommand->setChecked(settings->showDeleteCommand());
+    m_confirmDelete = new QCheckBox(i18n("Deleting files or folders"), confirmBox);
+    m_confirmDelete->setChecked(trashConfig.readEntry("ConfirmDelete", true));
+
+    QVBoxLayout* confirmBoxLayout = new QVBoxLayout(confirmBox);
+    confirmBoxLayout->addWidget(m_confirmMoveToTrash);
+    confirmBoxLayout->addWidget(m_confirmDelete);
+
+    // create 'Show the command 'Delete' in context menu' checkbox
+    m_showDeleteCommand = new QCheckBox(i18n("Show 'Delete' command in context menu"), vBox);
+    const KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
+    const KConfigGroup kdeConfig(globalConfig, "KDE");
+    m_showDeleteCommand->setChecked(kdeConfig.readEntry("ShowDeleteCommand", false));
 
     // Add a dummy widget with no restriction regarding
     // a vertical resizing. This assures that the dialog layout
@@ -104,8 +123,9 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* par
     new QWidget(vBox);
 
     topLayout->addWidget(vBox);
-}
 
+    loadSettings();
+}
 
 GeneralSettingsPage::~GeneralSettingsPage()
 {
@@ -121,15 +141,39 @@ void GeneralSettingsPage::applySettings()
         settings->setHomeUrl(url.prettyUrl());
     }
 
-    settings->setSplitView(m_startSplit->isChecked());
-    settings->setEditableUrl(m_startEditable->isChecked());
-    settings->setShowDeleteCommand(m_showDeleteCommand->isChecked());
+    settings->setSplitView(m_splitView->isChecked());
+    settings->setEditableUrl(m_editableUrl->isChecked());
+    settings->setFilterBar(m_filterBar->isChecked());
+
+    KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
+    KConfigGroup trashConfig(konqConfig, "Trash");
+    trashConfig.writeEntry("ConfirmTrash", m_confirmMoveToTrash->isChecked());
+    trashConfig.writeEntry("ConfirmDelete", m_confirmDelete->isChecked());
+
+    KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
+    KConfigGroup kdeConfig(globalConfig, "KDE");
+    kdeConfig.writeEntry("ShowDeleteCommand", m_showDeleteCommand->isChecked());
+    kdeConfig.sync();
+}
+
+void GeneralSettingsPage::restoreDefaults()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    settings->setDefaults();
+
+    // TODO: reset default settings for trash and show delete command...
+    //KSharedConfig::Ptr konqConfig = KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals);
+    //KConfigGroup trashConfig(konqConfig, "Trash");
+    //KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
+    //KConfigGroup kdeConfig(globalConfig, "KDE");
+
+    loadSettings();
 }
 
 void GeneralSettingsPage::selectHomeUrl()
 {
     const QString homeUrl(m_homeUrl->text());
-    KUrl url(KFileDialog::getExistingUrl(homeUrl));
+    KUrl url(KFileDialog::getExistingDirectoryUrl(homeUrl));
     if (!url.isEmpty()) {
         m_homeUrl->setText(url.prettyUrl());
     }
@@ -137,7 +181,7 @@ void GeneralSettingsPage::selectHomeUrl()
 
 void GeneralSettingsPage::useCurrentLocation()
 {
-    const DolphinView* view = m_mainWindow->activeView();
+    const DolphinView* view = m_mainWindow->activeViewContainer()->view();
     m_homeUrl->setText(view->url().prettyUrl());
 }
 
@@ -146,4 +190,13 @@ void GeneralSettingsPage::useDefaultLocation()
     m_homeUrl->setText("file://" + QDir::homePath());
 }
 
+void GeneralSettingsPage::loadSettings()
+{
+    GeneralSettings* settings = DolphinSettings::instance().generalSettings();
+    m_homeUrl->setText(settings->homeUrl());
+    m_splitView->setChecked(settings->splitView());
+    m_editableUrl->setChecked(settings->editableUrl());
+    m_filterBar->setChecked(settings->filterBar());
+}
+
 #include "generalsettingspage.moc"