2 * Copyright (c) 2001 David Faure <david@mandrakesoft.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 // Behaviour options for konqueror
22 #include "behaviour.h"
25 #include <QtDBus/QtDBus>
26 #include <QtGui/QCheckBox>
27 #include <QtGui/QLayout>
28 #include <QtGui/QLabel>
32 #include <kstandarddirs.h>
33 #include <kurlrequester.h>
34 #include <kconfiggroup.h>
37 #include "konqkcmfactory.h"
39 static bool DEFAULT_CONFIRMDELETE
= true;
40 static bool DEFAULT_CONFIRMTRASH
= true;
42 KBehaviourOptions::KBehaviourOptions(QWidget
*parent
, const QVariantList
&)
43 : KCModule(KonqKcmFactory::componentData(), parent
)
44 , g_pConfig(KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals
))
45 , groupname("FMSettings")
47 setQuickHelp(i18n("<h1>Konqueror Behavior</h1> You can configure how Konqueror behaves as a file manager here."));
49 QVBoxLayout
*mainLayout
= new QVBoxLayout(this);
51 QGroupBox
* miscGb
= new QGroupBox(i18n("Misc Options"), this);
52 QHBoxLayout
*miscHLayout
= new QHBoxLayout
;
53 QVBoxLayout
*miscLayout
= new QVBoxLayout
;
55 winPixmap
= new QLabel(this);
56 winPixmap
->setFrameStyle(QFrame::StyledPanel
| QFrame::Sunken
);
57 winPixmap
->setPixmap(QPixmap(KStandardDirs::locate("data", "kcontrol/pics/onlyone.png")));
58 winPixmap
->setFixedSize(winPixmap
->sizeHint());
60 cbNewWin
= new QCheckBox(i18n("Open folders in separate &windows"), this);
61 cbNewWin
->setWhatsThis(i18n("If this option is checked, Konqueror will open a new window when "
62 "you open a folder, rather than showing that folder's contents in the current window."));
63 connect(cbNewWin
, SIGNAL(toggled(bool)), this, SLOT(changed()));
64 connect(cbNewWin
, SIGNAL(toggled(bool)), SLOT(updateWinPixmap(bool)));
66 miscLayout
->addWidget(cbNewWin
);
68 QHBoxLayout
*previewLayout
= new QHBoxLayout
;
69 QWidget
* spacer
= new QWidget(this);
70 spacer
->setMinimumSize( 20, 0 );
71 spacer
->setSizePolicy( QSizePolicy::Fixed
, QSizePolicy::Minimum
);
73 previewLayout
->addWidget(spacer
);
75 miscLayout
->addLayout(previewLayout
);
77 miscHLayout
->addLayout(miscLayout
);
78 miscHLayout
->addWidget(winPixmap
);
80 miscGb
->setLayout(miscHLayout
);
82 mainLayout
->addWidget(miscGb
);
84 QGroupBox
*bg
= new QGroupBox(this);
85 bg
->setTitle(i18nc("@title:group what to do when a file is deleted", "Ask Confirmation For"));
86 bg
->setWhatsThis(i18n("This option tells Konqueror whether to ask"
87 " for a confirmation when you \"delete\" a file."
88 " <ul><li><em>Move To Trash:</em> moves the file to your trash folder,"
89 " from where it can be recovered very easily.</li>"
90 " <li><em>Delete:</em> simply deletes the file.</li>"
93 cbMoveToTrash
= new QCheckBox(i18nc("@option:check Ask for confirmation when moving to trash", "&Move to trash"), bg
);
94 connect(cbMoveToTrash
, SIGNAL(toggled(bool)), this, SLOT(changed()));
96 cbDelete
= new QCheckBox(i18nc("@option:check Ask for confirmation when deleting", "D&elete"), bg
);
97 connect(cbDelete
, SIGNAL(toggled(bool)), this, SLOT(changed()));
99 QVBoxLayout
*confirmationLayout
= new QVBoxLayout
;
100 confirmationLayout
->addWidget(cbMoveToTrash
);
101 confirmationLayout
->addWidget(cbDelete
);
102 bg
->setLayout(confirmationLayout
);
104 mainLayout
->addWidget(bg
);
106 cbShowDeleteCommand
= new QCheckBox(i18n("Show 'Delete' context me&nu entries which bypass the trashcan"), this);
107 mainLayout
->addWidget(cbShowDeleteCommand
);
108 connect(cbShowDeleteCommand
, SIGNAL(toggled(bool)), this, SLOT(changed()));
110 cbShowDeleteCommand
->setWhatsThis(i18n("Check this if you want 'Delete' menu commands to be displayed "
111 "on the desktop and in the file manager's context menus. "
112 "You can always delete files by holding the Shift key "
113 "while calling 'Move to Trash'."));
115 mainLayout
->addStretch();
118 KBehaviourOptions::~KBehaviourOptions()
122 void KBehaviourOptions::load()
124 KConfigGroup
cg(g_pConfig
, groupname
);
125 cbNewWin
->setChecked( cg
.readEntry("AlwaysNewWin", false) );
126 updateWinPixmap(cbNewWin
->isChecked());
128 KSharedConfig::Ptr globalconfig
= KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals
);
129 KConfigGroup
cg2(globalconfig
, "KDE");
130 cbShowDeleteCommand
->setChecked( cg2
.readEntry("ShowDeleteCommand", false) );
132 KSharedConfigPtr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
133 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
134 cbMoveToTrash
->setChecked(confirmationGroup
.readEntry("ConfirmTrash", DEFAULT_CONFIRMTRASH
));
135 cbDelete
->setChecked(confirmationGroup
.readEntry("ConfirmDelete", DEFAULT_CONFIRMDELETE
));
138 void KBehaviourOptions::defaults()
140 cbNewWin
->setChecked(false);
142 cbMoveToTrash
->setChecked(DEFAULT_CONFIRMTRASH
);
143 cbDelete
->setChecked(DEFAULT_CONFIRMDELETE
);
144 cbShowDeleteCommand
->setChecked( false );
147 void KBehaviourOptions::save()
149 KConfigGroup
cg(g_pConfig
, groupname
);
151 cg
.writeEntry( "AlwaysNewWin", cbNewWin
->isChecked() );
153 KSharedConfig::Ptr globalconfig
= KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals
);
154 KConfigGroup
cg2(globalconfig
, "KDE");
155 cg2
.writeEntry( "ShowDeleteCommand", cbShowDeleteCommand
->isChecked());
158 KSharedConfigPtr kioConfig
= KSharedConfig::openConfig("kiorc", KConfig::NoGlobals
);
159 KConfigGroup
confirmationGroup(kioConfig
, "Confirmations");
160 confirmationGroup
.writeEntry( "ConfirmTrash", cbMoveToTrash
->isChecked());
161 confirmationGroup
.writeEntry( "ConfirmDelete", cbDelete
->isChecked());
162 confirmationGroup
.sync();
164 // Send signal to all konqueror instances
165 QDBusMessage message
=
166 QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
167 QDBusConnection::sessionBus().send(message
);
170 void KBehaviourOptions::updateWinPixmap(bool b
)
173 winPixmap
->setPixmap(QPixmap(KStandardDirs::locate("data",
174 "kcontrol/pics/overlapping.png")));
176 winPixmap
->setPixmap(QPixmap(KStandardDirs::locate("data",
177 "kcontrol/pics/onlyone.png")));
180 #include "behaviour.moc"