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
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
#include "generalsettingspage.h"
25
#include <Q3VBoxLayout>
28
#include <qlineedit.h>
31
#include <q3groupbox.h>
33
#include <qcheckbox.h>
34
#include <q3buttongroup.h>
35
#include <qpushbutton.h>
36
#include <kfiledialog.h>
37
#include <qradiobutton.h>
39
#include "dolphinsettings.h"
41
#include "dolphinview.h"
42
#include "generalsettings.h"
44
GeneralSettingsPage::GeneralSettingsPage(QWidget* parent) :
45
SettingsPageBase(parent),
50
Q3VBoxLayout* topLayout = new Q3VBoxLayout(parent, 2, KDialog::spacingHint());
52
const int spacing = KDialog::spacingHint();
53
const int margin = KDialog::marginHint();
54
const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
56
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
58
Q3VBox* vBox = new Q3VBox(parent);
59
vBox->setSizePolicy(sizePolicy);
60
vBox->setSpacing(spacing);
61
vBox->setMargin(margin);
62
vBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
64
// create 'Home URL' editor
65
Q3GroupBox* homeGroup = new Q3GroupBox(1, Qt::Horizontal, i18n("Home URL"), vBox);
66
homeGroup->setSizePolicy(sizePolicy);
67
homeGroup->setMargin(margin);
69
Q3HBox* homeURLBox = new Q3HBox(homeGroup);
70
homeURLBox->setSizePolicy(sizePolicy);
71
homeURLBox->setSpacing(spacing);
73
new QLabel(i18n("Location:"), homeURLBox);
74
m_homeURL = new QLineEdit(settings->homeURL(), homeURLBox);
76
QPushButton* selectHomeURLButton = new QPushButton(SmallIcon("folder"), QString::null, homeURLBox);
77
connect(selectHomeURLButton, SIGNAL(clicked()),
78
this, SLOT(selectHomeURL()));
80
Q3HBox* buttonBox = new Q3HBox(homeGroup);
81
buttonBox->setSizePolicy(sizePolicy);
82
buttonBox->setSpacing(spacing);
83
QPushButton* useCurrentButton = new QPushButton(i18n("Use current location"), buttonBox);
84
connect(useCurrentButton, SIGNAL(clicked()),
85
this, SLOT(useCurrentLocation()));
86
QPushButton* useDefaultButton = new QPushButton(i18n("Use default location"), buttonBox);
87
connect(useDefaultButton, SIGNAL(clicked()),
88
this, SLOT(useDefaulLocation()));
90
// create 'Default View Mode' group
91
Q3ButtonGroup* buttonGroup = new Q3ButtonGroup(3, Qt::Vertical, i18n("Default View Mode"), vBox);
92
buttonGroup->setSizePolicy(sizePolicy);
93
buttonGroup->setMargin(margin);
95
m_iconsView = new QRadioButton(i18n("Icons"), buttonGroup);
96
m_detailsView = new QRadioButton(i18n("Details"), buttonGroup);
97
m_previewsView = new QRadioButton(i18n("Previews"), buttonGroup);
99
switch (settings->defaultViewMode()) {
100
case DolphinView::IconsView: m_iconsView->setChecked(true); break;
101
case DolphinView::DetailsView: m_detailsView->setChecked(true); break;
102
case DolphinView::PreviewsView: m_previewsView->setChecked(true); break;
105
// create 'Start with split view' checkbox
106
m_startSplit = new QCheckBox(i18n("Start with split view"), vBox);
107
m_startSplit->setChecked(settings->splitView());
109
// create 'Start with editable navigation bar' checkbox
110
m_startEditable = new QCheckBox(i18n("Start with editable navigation bar"), vBox);
111
m_startEditable->setChecked(settings->editableURL());
113
// Add a dummy widget with no restriction regarding
114
// a vertical resizing. This assures that the dialog layout
115
// is not stretched vertically.
118
topLayout->addWidget(vBox);
122
GeneralSettingsPage::~GeneralSettingsPage()
126
void GeneralSettingsPage::applySettings()
128
GeneralSettings* settings = DolphinSettings::instance().generalSettings();
130
const KURL url(m_homeURL->text());
131
KFileItem fileItem(S_IFDIR, KFileItem::Unknown, url);
132
if (url.isValid() && fileItem.isDir()) {
133
settings->setHomeURL(url.prettyURL());
136
DolphinView::Mode viewMode = DolphinView::IconsView;
137
if (m_detailsView->isChecked()) {
138
viewMode = DolphinView::DetailsView;
140
else if (m_previewsView->isChecked()) {
141
viewMode = DolphinView::PreviewsView;
143
settings->setDefaultViewMode(viewMode);
145
settings->setSplitView(m_startSplit->isChecked());
146
settings->setEditableURL(m_startEditable->isChecked());
149
void GeneralSettingsPage::selectHomeURL()
151
const QString homeURL(m_homeURL->text());
152
KURL url(KFileDialog::getExistingURL(homeURL));
153
if (!url.isEmpty()) {
154
m_homeURL->setText(url.prettyURL());
158
void GeneralSettingsPage::useCurrentLocation()
160
const DolphinView* view = Dolphin::mainWin().activeView();
161
m_homeURL->setText(view->url().prettyURL());
164
void GeneralSettingsPage::useDefaulLocation()
166
m_homeURL->setText("file://" + QDir::homeDirPath());
169
#include "generalsettingspage.moc"