Make a branch to make krunner Good Enough For Aaron™.
[kdebase/uwolfer.git] / apps / konqueror / settings / konq / behaviour.cpp
blobe5b3f0ab8505ceffef28004f066059428ac54eef
1 /**
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
21 // Own
22 #include "behaviour.h"
24 // Qt
25 #include <QtDBus/QtDBus>
26 #include <QtGui/QCheckBox>
27 #include <QtGui/QLayout>
28 #include <QtGui/QLabel>
30 // KDE
31 #include <klocale.h>
32 #include <konq_defaults.h>
33 #include <kstandarddirs.h>
34 #include <kurlrequester.h>
35 #include <kconfiggroup.h>
37 // Local
38 #include "konqkcmfactory.h"
40 KBehaviourOptions::KBehaviourOptions(QWidget *parent, const QVariantList &)
41 : KCModule(KonqKcmFactory::componentData(), parent)
42 , g_pConfig(KSharedConfig::openConfig("konquerorrc", KConfig::IncludeGlobals))
43 , groupname("FMSettings")
45 setQuickHelp(i18n("<h1>Konqueror Behavior</h1> You can configure how Konqueror behaves as a file manager here."));
47 QVBoxLayout *mainLayout = new QVBoxLayout(this);
49 QGroupBox * miscGb = new QGroupBox(i18n("Misc Options"), this);
50 QHBoxLayout *miscHLayout = new QHBoxLayout;
51 QVBoxLayout *miscLayout = new QVBoxLayout;
53 winPixmap = new QLabel(this);
54 winPixmap->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
55 winPixmap->setPixmap(QPixmap(KStandardDirs::locate("data", "kcontrol/pics/onlyone.png")));
56 winPixmap->setFixedSize(winPixmap->sizeHint());
58 cbNewWin = new QCheckBox(i18n("Open folders in separate &windows"), this);
59 cbNewWin->setWhatsThis(i18n("If this option is checked, Konqueror will open a new window when "
60 "you open a folder, rather than showing that folder's contents in the current window."));
61 connect(cbNewWin, SIGNAL(toggled(bool)), this, SLOT(changed()));
62 connect(cbNewWin, SIGNAL(toggled(bool)), SLOT(updateWinPixmap(bool)));
64 miscLayout->addWidget(cbNewWin);
66 cbShowTips = new QCheckBox(i18n("Show file &tips"), this);
67 connect(cbShowTips, SIGNAL(toggled(bool)), this, SLOT(changed()));
69 cbShowTips->setWhatsThis( i18n("Here you can control if, when moving the mouse over a file, you want to see a "
70 "small popup window with additional information about that file"));
72 connect(cbShowTips, SIGNAL(toggled(bool)), SLOT(slotShowTips(bool)));
74 miscLayout->addWidget(cbShowTips);
76 //connect(cbShowTips, SIGNAL(toggled(bool)), sbToolTip, SLOT(setEnabled(bool)));
77 //connect(cbShowTips, SIGNAL(toggled(bool)), fileTips, SLOT(setEnabled(bool)));
78 fileTips->setBuddy(sbToolTip);
79 QString tipstr = i18n("If you move the mouse over a file, you usually see a small popup window that shows some "
80 "additional information about that file. Here, you can set how many items of information "
81 "are displayed");
82 QWhatsThis::add( fileTips, tipstr );
83 QWhatsThis::add( sbToolTip, tipstr );
86 QHBoxLayout *previewLayout = new QHBoxLayout;
87 QWidget* spacer = new QWidget(this);
88 spacer->setMinimumSize( 20, 0 );
89 spacer->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
91 previewLayout->addWidget(spacer);
93 cbShowPreviewsInTips = new QCheckBox(i18n("Show &previews in file tips"), this);
94 connect(cbShowPreviewsInTips, SIGNAL(toggled(bool)), this, SLOT(changed()));
96 cbShowPreviewsInTips->setWhatsThis( i18n("Here you can control if you want the "
97 "popup window to contain a larger preview for the file, "
98 "when moving the mouse over it."));
100 previewLayout->addWidget(cbShowPreviewsInTips);
102 miscLayout->addLayout(previewLayout);
104 miscHLayout->addLayout(miscLayout);
105 miscHLayout->addWidget(winPixmap);
107 miscGb->setLayout(miscHLayout);
109 mainLayout->addWidget(miscGb);
111 QGroupBox *bg = new QGroupBox(this);
112 bg->setTitle(i18n("Ask Confirmation For"));
113 bg->setWhatsThis(i18n("This option tells Konqueror whether to ask"
114 " for a confirmation when you \"delete\" a file."
115 " <ul><li><em>Move To Trash:</em> moves the file to your trash folder,"
116 " from where it can be recovered very easily.</li>"
117 " <li><em>Delete:</em> simply deletes the file.</li>"
118 " </ul>"));
120 cbMoveToTrash = new QCheckBox(i18n("&Move to trash"), bg);
121 connect(cbMoveToTrash, SIGNAL(toggled(bool)), this, SLOT(changed()));
123 cbDelete = new QCheckBox(i18n("D&elete"), bg);
124 connect(cbDelete, SIGNAL(toggled(bool)), this, SLOT(changed()));
126 QVBoxLayout *confirmationLayout = new QVBoxLayout;
127 confirmationLayout->addWidget(cbMoveToTrash);
128 confirmationLayout->addWidget(cbDelete);
129 bg->setLayout(confirmationLayout);
131 mainLayout->addWidget(bg);
133 cbShowDeleteCommand = new QCheckBox(i18n("Show 'Delete' context me&nu entries which bypass the trashcan"), this);
134 mainLayout->addWidget(cbShowDeleteCommand);
135 connect(cbShowDeleteCommand, SIGNAL(toggled(bool)), this, SLOT(changed()));
137 cbShowDeleteCommand->setWhatsThis(i18n("Check this if you want 'Delete' menu commands to be displayed "
138 "on the desktop and in the file manager's context menus. "
139 "You can always delete files by holding the Shift key "
140 "while calling 'Move to Trash'."));
142 mainLayout->addStretch();
144 load();
147 KBehaviourOptions::~KBehaviourOptions()
151 void KBehaviourOptions::slotShowTips(bool b)
153 // sbToolTip->setEnabled( b );
154 cbShowPreviewsInTips->setEnabled( b );
155 // fileTips->setEnabled( b );
159 void KBehaviourOptions::load()
161 KConfigGroup cg(g_pConfig, groupname);
162 cbNewWin->setChecked( cg.readEntry("AlwaysNewWin", false) );
163 updateWinPixmap(cbNewWin->isChecked());
165 bool stips = cg.readEntry( "ShowFileTips", true);
166 cbShowTips->setChecked( stips );
167 slotShowTips( stips );
169 bool showPreviewsIntips = cg.readEntry( "ShowPreviewsInFileTips", true);
170 cbShowPreviewsInTips->setChecked( showPreviewsIntips );
172 KSharedConfig::Ptr globalconfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
173 KConfigGroup cg2(globalconfig, "KDE");
174 cbShowDeleteCommand->setChecked( cg2.readEntry("ShowDeleteCommand", false) );
176 // if (!stips) sbToolTip->setEnabled( false );
177 if (!stips) cbShowPreviewsInTips->setEnabled( false );
179 // sbToolTip->setValue( g_pConfig->readEntry( "FileTipItems", 6 ) );
181 KConfigGroup cg4(g_pConfig, "Trash");
182 cbMoveToTrash->setChecked( cg4.readEntry("ConfirmTrash", bool(DEFAULT_CONFIRMTRASH)) );
183 cbDelete->setChecked( cg4.readEntry("ConfirmDelete", bool(DEFAULT_CONFIRMDELETE)) );
186 void KBehaviourOptions::defaults()
188 cbNewWin->setChecked(false);
190 cbShowTips->setChecked( true );
191 //sbToolTip->setEnabled( true );
192 //sbToolTip->setValue( 6 );
194 cbShowPreviewsInTips->setChecked( true );
195 cbShowPreviewsInTips->setEnabled( true );
197 cbMoveToTrash->setChecked( DEFAULT_CONFIRMTRASH );
198 cbDelete->setChecked( DEFAULT_CONFIRMDELETE );
199 cbShowDeleteCommand->setChecked( false );
202 void KBehaviourOptions::save()
204 KConfigGroup cg(g_pConfig, groupname);
206 cg.writeEntry( "AlwaysNewWin", cbNewWin->isChecked() );
207 cg.writeEntry( "ShowFileTips", cbShowTips->isChecked() );
208 cg.writeEntry( "ShowPreviewsInFileTips", cbShowPreviewsInTips->isChecked() );
209 // g_pConfig->writeEntry( "FileTipsItems", sbToolTip->value() );
211 KSharedConfig::Ptr globalconfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
212 KConfigGroup cg2(globalconfig, "KDE");
213 cg2.writeEntry( "ShowDeleteCommand", cbShowDeleteCommand->isChecked());
214 cg2.sync();
216 KConfigGroup cg3(globalconfig, "Trash");
217 cg3.writeEntry( "ConfirmTrash", cbMoveToTrash->isChecked());
218 cg3.writeEntry( "ConfirmDelete", cbDelete->isChecked());
219 cg3.sync();
221 // Send signal to all konqueror instances
222 QDBusMessage message =
223 QDBusMessage::createSignal("/KonqMain", "org.kde.Konqueror.Main", "reparseConfiguration");
224 QDBusConnection::sessionBus().send(message);
227 void KBehaviourOptions::updateWinPixmap(bool b)
229 if (b)
230 winPixmap->setPixmap(QPixmap(KStandardDirs::locate("data",
231 "kcontrol/pics/overlapping.png")));
232 else
233 winPixmap->setPixmap(QPixmap(KStandardDirs::locate("data",
234 "kcontrol/pics/onlyone.png")));
237 #include "behaviour.moc"