]>
cloud.milkyroute.net Git - dolphin.git/blob - src/generalsettingspage.cpp
2961cf0d6743747398ac2971b0e5a6eb74c2ab18
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and *
3 * and Patrice Tremblay *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
21 #include "generalsettingspage.h"
24 #include <kfiledialog.h>
32 #include <QPushButton>
33 #include <QRadioButton>
35 #include "dolphinsettings.h"
36 #include "dolphinmainwindow.h"
37 #include "dolphinview.h"
39 #include "dolphin_generalsettings.h"
41 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow
* mainWin
,QWidget
* parent
) :
42 SettingsPageBase(parent
),
43 m_mainWindow(mainWin
),
47 m_showDeleteCommand(0)
49 const int spacing
= KDialog::spacingHint();
50 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
52 QVBoxLayout
* topLayout
= new QVBoxLayout(this);
53 KVBox
* vBox
= new KVBox(this);
54 vBox
->setSpacing(spacing
);
56 // create 'Home URL' editor
57 QGroupBox
* homeBox
= new QGroupBox(i18n("Home Folder"), vBox
);
59 KHBox
* homeUrlBox
= new KHBox(homeBox
);
60 homeUrlBox
->setSpacing(spacing
);
62 new QLabel(i18n("Location:"), homeUrlBox
);
63 m_homeUrl
= new QLineEdit(settings
->homeUrl(), homeUrlBox
);
65 QPushButton
* selectHomeUrlButton
= new QPushButton(KIcon("folder"), QString(), homeUrlBox
);
66 connect(selectHomeUrlButton
, SIGNAL(clicked()),
67 this, SLOT(selectHomeUrl()));
69 KHBox
* buttonBox
= new KHBox(homeBox
);
70 buttonBox
->setSpacing(spacing
);
72 QPushButton
* useCurrentButton
= new QPushButton(i18n("Use Current Location"), buttonBox
);
73 connect(useCurrentButton
, SIGNAL(clicked()),
74 this, SLOT(useCurrentLocation()));
75 QPushButton
* useDefaultButton
= new QPushButton(i18n("Use Default Location"), buttonBox
);
76 connect(useDefaultButton
, SIGNAL(clicked()),
77 this, SLOT(useDefaultLocation()));
79 QVBoxLayout
* homeBoxLayout
= new QVBoxLayout(homeBox
);
80 homeBoxLayout
->addWidget(homeUrlBox
);
81 homeBoxLayout
->addWidget(buttonBox
);
83 QGroupBox
* startBox
= new QGroupBox(i18n("Start"), vBox
);
85 // create 'Start with split view' checkbox
86 m_startSplit
= new QCheckBox(i18n("Start with split view"), startBox
);
87 m_startSplit
->setChecked(settings
->splitView());
89 // create 'Start with editable navigation bar' checkbox
90 m_startEditable
= new QCheckBox(i18n("Start with editable navigation bar"), startBox
);
91 m_startEditable
->setChecked(settings
->editableUrl());
93 QVBoxLayout
* startBoxLayout
= new QVBoxLayout(startBox
);
94 startBoxLayout
->addWidget(m_startSplit
);
95 startBoxLayout
->addWidget(m_startEditable
);
97 m_showDeleteCommand
= new QCheckBox(i18n("Show the command 'Delete' in context menu"), vBox
);
98 const KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals
);
99 const KConfigGroup
kdeConfig(globalConfig
, "KDE");
100 m_showDeleteCommand
->setChecked(kdeConfig
.readEntry("ShowDeleteCommand", false));
102 // Add a dummy widget with no restriction regarding
103 // a vertical resizing. This assures that the dialog layout
104 // is not stretched vertically.
107 topLayout
->addWidget(vBox
);
111 GeneralSettingsPage::~GeneralSettingsPage()
115 void GeneralSettingsPage::applySettings()
117 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
119 const KUrl
url(m_homeUrl
->text());
120 KFileItem
fileItem(S_IFDIR
, KFileItem::Unknown
, url
);
121 if (url
.isValid() && fileItem
.isDir()) {
122 settings
->setHomeUrl(url
.prettyUrl());
125 settings
->setSplitView(m_startSplit
->isChecked());
126 settings
->setEditableUrl(m_startEditable
->isChecked());
128 KSharedConfig::Ptr globalConfig
= KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals
);
129 KConfigGroup
kdeConfig(globalConfig
, "KDE");
130 kdeConfig
.writeEntry("ShowDeleteCommand", m_showDeleteCommand
->isChecked());
134 void GeneralSettingsPage::selectHomeUrl()
136 const QString
homeUrl(m_homeUrl
->text());
137 KUrl
url(KFileDialog::getExistingDirectoryUrl(homeUrl
));
138 if (!url
.isEmpty()) {
139 m_homeUrl
->setText(url
.prettyUrl());
143 void GeneralSettingsPage::useCurrentLocation()
145 const DolphinView
* view
= m_mainWindow
->activeView();
146 m_homeUrl
->setText(view
->url().prettyUrl());
149 void GeneralSettingsPage::useDefaultLocation()
151 m_homeUrl
->setText("file://" + QDir::homePath());
154 #include "generalsettingspage.moc"