X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/f31a541925033c2ef5e27b85c099d47791b50121..b2547cf9a48356fa8db847bbb6b713f699d48814:/src/generalsettingspage.cpp diff --git a/src/generalsettingspage.cpp b/src/generalsettingspage.cpp index d858906cb..ccb06cd09 100644 --- a/src/generalsettingspage.cpp +++ b/src/generalsettingspage.cpp @@ -15,102 +15,107 @@ * 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #include "generalsettingspage.h" -#include -//Added by qt3to4: -#include -#include -#include -#include +#include "dolphinsettings.h" +#include "dolphinmainwindow.h" +#include "dolphinview.h" +#include "dolphinviewcontainer.h" -#include -#include -#include -#include -#include -#include +#include "dolphin_generalsettings.h" + +#include #include -#include +#include #include -#include "dolphinsettings.h" -#include "dolphinmainwindow.h" -#include "dolphinview.h" -#include "generalsettings.h" +#include +#include +#include +#include +#include +#include -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_splitView(0), + m_editableUrl(0), + m_filterBar(0), + m_showDeleteCommand(0), + m_confirmMoveToTrash(0), + m_confirmDelete(0) { - Q3VBoxLayout* topLayout = new Q3VBoxLayout(this, 2, KDialog::spacingHint()); - const int spacing = KDialog::spacingHint(); - const int margin = KDialog::marginHint(); - const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); - - GeneralSettings* settings = DolphinSettings::instance().generalSettings(); + QVBoxLayout* topLayout = new QVBoxLayout(this); KVBox* vBox = new KVBox(this); - vBox->setSizePolicy(sizePolicy); vBox->setSpacing(spacing); - vBox->setMargin(margin); - vBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored); - // create 'Home Url' editor - Q3GroupBox* homeGroup = new Q3GroupBox(1, Qt::Horizontal, i18n("Home Url"), vBox); - homeGroup->setSizePolicy(sizePolicy); - homeGroup->setMargin(margin); + // create 'Home URL' editor + QGroupBox* homeBox = new QGroupBox(i18n("Home Folder"), vBox); - KHBox* homeUrlBox = new KHBox(homeGroup); - homeUrlBox->setSizePolicy(sizePolicy); + 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::null, homeUrlBox); + QPushButton* selectHomeUrlButton = new QPushButton(KIcon("folder-open"), QString(), homeUrlBox); connect(selectHomeUrlButton, SIGNAL(clicked()), this, SLOT(selectHomeUrl())); - KHBox* buttonBox = new KHBox(homeGroup); - buttonBox->setSizePolicy(sizePolicy); + 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(useDefaulLocation())); + this, SLOT(useDefaultLocation())); - // create 'Default View Mode' group - Q3ButtonGroup* buttonGroup = new Q3ButtonGroup(3, Qt::Vertical, i18n("Default View Mode"), vBox); - buttonGroup->setSizePolicy(sizePolicy); - buttonGroup->setMargin(margin); + QVBoxLayout* homeBoxLayout = new QVBoxLayout(homeBox); + homeBoxLayout->addWidget(homeUrlBox); + homeBoxLayout->addWidget(buttonBox); - m_iconsView = new QRadioButton(i18n("Icons"), buttonGroup); - m_detailsView = new QRadioButton(i18n("Details"), buttonGroup); - m_previewsView = new QRadioButton(i18n("Previews"), buttonGroup); + QGroupBox* startBox = new QGroupBox(i18n("Startup Settings"), vBox); - switch (settings->defaultViewMode()) { - case DolphinView::IconsView: m_iconsView->setChecked(true); break; - case DolphinView::DetailsView: m_detailsView->setChecked(true); break; - case DolphinView::PreviewsView: m_previewsView->setChecked(true); break; - } + // 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_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"); - // create 'Start with split view' checkbox - m_startSplit = new QCheckBox(i18n("Start with split view"), vBox); - m_startSplit->setChecked(settings->splitView()); + QGroupBox* confirmBox = new QGroupBox(i18n("Ask For Confirmation When"), vBox); - // create 'Start with editable navigation bar' checkbox - m_startEditable = new QCheckBox(i18n("Start with editable navigation bar"), vBox); - m_startEditable->setChecked(settings->editableUrl()); + m_confirmMoveToTrash = new QCheckBox(i18n("Moving files or folders to trash"), confirmBox); + m_confirmMoveToTrash->setChecked(trashConfig.readEntry("ConfirmTrash", false)); + + 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 @@ -118,8 +123,9 @@ GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow* mainWin,QWidget* par new QWidget(vBox); topLayout->addWidget(vBox); -} + loadSettings(); +} GeneralSettingsPage::~GeneralSettingsPage() { @@ -135,23 +141,39 @@ void GeneralSettingsPage::applySettings() settings->setHomeUrl(url.prettyUrl()); } - DolphinView::Mode viewMode = DolphinView::IconsView; - if (m_detailsView->isChecked()) { - viewMode = DolphinView::DetailsView; - } - else if (m_previewsView->isChecked()) { - viewMode = DolphinView::PreviewsView; - } - settings->setDefaultViewMode(viewMode); + 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"); - settings->setSplitView(m_startSplit->isChecked()); - settings->setEditableUrl(m_startEditable->isChecked()); + 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()); } @@ -159,13 +181,22 @@ 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()); } -void GeneralSettingsPage::useDefaulLocation() +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"