]> cloud.milkyroute.net Git - dolphin.git/blob - src/generalviewsettingspage.cpp
Do a custom error handling in for the 'Create New...' submenu. Thanks to David for...
[dolphin.git] / src / generalviewsettingspage.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
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. *
9 * *
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. *
14 * *
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 ***************************************************************************/
20
21 #include "generalviewsettingspage.h"
22 #include "dolphinmainwindow.h"
23 #include "dolphinsettings.h"
24 #include "generalsettings.h"
25 #include "viewproperties.h"
26
27 #include <assert.h>
28
29 #include <QGroupBox>
30 #include <QRadioButton>
31 #include <QVBoxLayout>
32
33 #include <kdialog.h>
34 #include <klocale.h>
35 #include <kvbox.h>
36
37 GeneralViewSettingsPage::GeneralViewSettingsPage(DolphinMainWindow* mainWindow,
38 QWidget* parent) :
39 KVBox(parent),
40 m_mainWindow(mainWindow),
41 m_localProps(0),
42 m_globalProps(0)
43 {
44 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
45 assert(settings != 0);
46
47 const int spacing = KDialog::spacingHint();
48 const int margin = KDialog::marginHint();
49 const QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
50
51 setSpacing(spacing);
52 setMargin(margin);
53
54 QGroupBox* propsBox = new QGroupBox(i18n("View Properties"), this);
55
56 m_localProps = new QRadioButton(i18n("Remember view properties for each folder."), propsBox);
57 m_globalProps = new QRadioButton(i18n("Use common view properties for all folders."), propsBox);
58 if (settings->globalViewProps()) {
59 m_globalProps->setChecked(true);
60 }
61 else {
62 m_localProps->setChecked(true);
63 }
64
65 QVBoxLayout* propsBoxLayout = new QVBoxLayout(propsBox);
66 propsBoxLayout->addWidget(m_localProps);
67 propsBoxLayout->addWidget(m_globalProps);
68
69 QGroupBox* previewBox = new QGroupBox(i18n("File Previews"), this);
70
71 // Add a dummy widget with no restriction regarding
72 // a vertical resizing. This assures that the dialog layout
73 // is not stretched vertically.
74 new QWidget(this);
75 }
76
77
78 GeneralViewSettingsPage::~GeneralViewSettingsPage()
79 {
80 }
81
82 void GeneralViewSettingsPage::applySettings()
83 {
84 const KUrl& url = m_mainWindow->activeView()->url();
85 ViewProperties props(url); // read current view properties
86
87 const bool useGlobalProps = m_globalProps->isChecked();
88
89 GeneralSettings* settings = DolphinSettings::instance().generalSettings();
90 assert(settings != 0);
91 settings->setGlobalViewProps(useGlobalProps);
92
93 if (useGlobalProps) {
94 // Remember the global view properties by applying the current view properties.
95 // It is important that GeneralSettings::globalViewProps() is set before
96 // the class ViewProperties is used, as ViewProperties uses this setting
97 // to find the destination folder for storing the view properties.
98 ViewProperties globalProps(url);
99 globalProps.setDirProperties(props);
100 }
101 }
102
103 #include "generalviewsettingspage.moc"