]>
cloud.milkyroute.net Git - dolphin.git/blob - src/generalsettingspage.cpp
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"
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>
40 #include "dolphinsettings.h"
41 #include "dolphinmainwindow.h"
42 #include "dolphinview.h"
43 #include "dolphin_generalsettings.h"
45 GeneralSettingsPage::GeneralSettingsPage(DolphinMainWindow
* mainWin
,QWidget
* parent
) :
46 SettingsPageBase(parent
),
47 m_mainWindow(mainWin
),
52 Q3VBoxLayout
* topLayout
= new Q3VBoxLayout(this, 2, KDialog::spacingHint());
54 const int spacing
= KDialog::spacingHint();
55 const int margin
= KDialog::marginHint();
56 const QSizePolicy
sizePolicy(QSizePolicy::Preferred
, QSizePolicy::Fixed
);
58 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
60 KVBox
* vBox
= new KVBox(this);
61 vBox
->setSizePolicy(sizePolicy
);
62 vBox
->setSpacing(spacing
);
63 vBox
->setMargin(margin
);
64 vBox
->setSizePolicy(QSizePolicy::Preferred
, QSizePolicy::Ignored
);
66 // create 'Home Url' editor
67 Q3GroupBox
* homeGroup
= new Q3GroupBox(1, Qt::Horizontal
, i18n("Home Folder"), vBox
);
68 homeGroup
->setSizePolicy(sizePolicy
);
69 homeGroup
->setMargin(margin
);
71 KHBox
* homeUrlBox
= new KHBox(homeGroup
);
72 homeUrlBox
->setSizePolicy(sizePolicy
);
73 homeUrlBox
->setSpacing(spacing
);
75 new QLabel(i18n("Location:"), homeUrlBox
);
76 m_homeUrl
= new QLineEdit(settings
->homeUrl(), homeUrlBox
);
78 QPushButton
* selectHomeUrlButton
= new QPushButton(SmallIcon("folder"), QString(), homeUrlBox
);
79 connect(selectHomeUrlButton
, SIGNAL(clicked()),
80 this, SLOT(selectHomeUrl()));
82 KHBox
* buttonBox
= new KHBox(homeGroup
);
83 buttonBox
->setSizePolicy(sizePolicy
);
84 buttonBox
->setSpacing(spacing
);
85 QPushButton
* useCurrentButton
= new QPushButton(i18n("Use current location"), buttonBox
);
86 connect(useCurrentButton
, SIGNAL(clicked()),
87 this, SLOT(useCurrentLocation()));
88 QPushButton
* useDefaultButton
= new QPushButton(i18n("Use default location"), buttonBox
);
89 connect(useDefaultButton
, SIGNAL(clicked()),
90 this, SLOT(useDefaulLocation()));
92 QGroupBox
* startBox
= new QGroupBox(i18n("Start"), vBox
);
94 // create 'Start with split view' checkbox
95 m_startSplit
= new QCheckBox(i18n("Start with split view"), startBox
);
96 m_startSplit
->setChecked(settings
->splitView());
98 // create 'Start with editable navigation bar' checkbox
99 m_startEditable
= new QCheckBox(i18n("Start with editable navigation bar"), startBox
);
100 m_startEditable
->setChecked(settings
->editableUrl());
102 QVBoxLayout
* startBoxLayout
= new QVBoxLayout(startBox
);
103 startBoxLayout
->addWidget(m_startSplit
);
104 startBoxLayout
->addWidget(m_startEditable
);
106 // Add a dummy widget with no restriction regarding
107 // a vertical resizing. This assures that the dialog layout
108 // is not stretched vertically.
111 topLayout
->addWidget(vBox
);
115 GeneralSettingsPage::~GeneralSettingsPage()
119 void GeneralSettingsPage::applySettings()
121 GeneralSettings
* settings
= DolphinSettings::instance().generalSettings();
123 const KUrl
url(m_homeUrl
->text());
124 KFileItem
fileItem(S_IFDIR
, KFileItem::Unknown
, url
);
125 if (url
.isValid() && fileItem
.isDir()) {
126 settings
->setHomeUrl(url
.prettyUrl());
129 settings
->setSplitView(m_startSplit
->isChecked());
130 settings
->setEditableUrl(m_startEditable
->isChecked());
133 void GeneralSettingsPage::selectHomeUrl()
135 const QString
homeUrl(m_homeUrl
->text());
136 KUrl
url(KFileDialog::getExistingUrl(homeUrl
));
137 if (!url
.isEmpty()) {
138 m_homeUrl
->setText(url
.prettyUrl());
142 void GeneralSettingsPage::useCurrentLocation()
144 const DolphinView
* view
= m_mainWindow
->activeView();
145 m_homeUrl
->setText(view
->url().prettyUrl());
148 void GeneralSettingsPage::useDefaulLocation()
150 m_homeUrl
->setText("file://" + QDir::homePath());
153 #include "generalsettingspage.moc"