3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
10 1. Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12 2. Redistributions in binary form must reproduce the above copyright
13 notice, this list of conditions and the following disclaimer in the
14 documentation and/or other materials provided with the distribution.
16 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <kpMainWindow.h>
30 #include <kpMainWindowPrivate.h>
32 #include <kactioncollection.h>
33 #include <kapplication.h>
35 #include <kconfiggroup.h>
37 #include <kedittoolbar.h>
40 #include <kmessagebox.h>
41 #include <kshortcutsdialog.h>
42 #include <kstandardaction.h>
43 #include <ktogglefullscreenaction.h>
46 #include <kpDocument.h>
47 #include <kpToolAction.h>
48 #include <kpToolToolBar.h>
52 void kpMainWindow::setupSettingsMenuActions ()
54 KActionCollection
*ac
= actionCollection ();
57 // Settings/Toolbars |> %s
58 setStandardToolBarMenuEnabled (true);
60 // Settings/Show Statusbar
61 createStandardStatusBarAction ();
64 d
->actionFullScreen
= KStandardAction::fullScreen (this, SLOT (slotFullScreen ()),
68 d
->actionShowPath
= ac
->add
<KToggleAction
> ("settings_show_path");
69 d
->actionShowPath
->setText (i18n ("Show &Path"));
70 connect(d
->actionShowPath
, SIGNAL(triggered(bool) ), SLOT (slotShowPathToggled ()));
71 //d->actionShowPath->setCheckedState (KGuiItem(i18n ("Hide &Path")));
72 slotEnableSettingsShowPath ();
75 d
->actionKeyBindings
= KStandardAction::keyBindings (this, SLOT (slotKeyBindings ()), ac
);
76 d
->actionConfigureToolbars
= KStandardAction::configureToolbars (this, SLOT (slotConfigureToolBars ()), ac
);
77 // d->actionConfigure = KStandardAction::preferences (this, SLOT (slotConfigure ()), ac);
80 enableSettingsMenuDocumentActions (false);
84 void kpMainWindow::enableSettingsMenuDocumentActions (bool /*enable*/)
90 void kpMainWindow::slotFullScreen ()
92 KToggleFullScreenAction::setFullScreen( this, d
->actionFullScreen
->isChecked ());
97 void kpMainWindow::slotEnableSettingsShowPath ()
99 #if DEBUG_KP_MAIN_WINDOW
100 kDebug () << "kpMainWindow::slotEnableSettingsShowPath()";
103 const bool enable
= (d
->document
&& !d
->document
->url ().isEmpty ());
105 d
->actionShowPath
->setEnabled (enable
);
106 d
->actionShowPath
->setChecked (enable
&& d
->configShowPath
);
110 void kpMainWindow::slotShowPathToggled ()
112 #if DEBUG_KP_MAIN_WINDOW
113 kDebug () << "kpMainWindow::slotShowPathToggled()";
116 d
->configShowPath
= d
->actionShowPath
->isChecked ();
118 slotUpdateCaption ();
121 KConfigGroup
cfg (KGlobal::config (), kpSettingsGroupGeneral
);
123 cfg
.writeEntry (kpSettingShowPath
, d
->configShowPath
);
129 void kpMainWindow::slotKeyBindings ()
131 #if DEBUG_KP_MAIN_WINDOW
132 kDebug () << "kpMainWindow::slotKeyBindings()";
137 if (KShortcutsDialog::configure (actionCollection (),
138 KShortcutsEditor::LetterShortcutsAllowed
,
141 #if DEBUG_KP_MAIN_WINDOW
142 kDebug () << "\tdialog accepted";
144 // TODO: PROPAGATE: thru mainWindow's and interprocess
146 kpToolAction::updateAllActionsToolTips (actionCollection ());
152 void kpMainWindow::slotConfigureToolBars ()
154 #if DEBUG_KP_MAIN_WINDOW
155 kDebug () << "kpMainWindow::slotConfigureToolBars()";
160 // TODO: Do we need this?
162 // KConfig::readEntry() does not actually reread from disk, hence doesn't
163 // realize what other processes have done e.g. Settings / Show Path
164 KGlobal::config ()->reparseConfiguration ();
167 saveMainWindowSettings (KGlobal::config ()->group (autoSaveGroup ()));
169 KEditToolBar
dialog (actionCollection (), this);
171 connect (&dialog
, SIGNAL (newToolbarConfig ()),
172 this, SLOT (slotNewToolBarConfig ()));
178 void kpMainWindow::slotNewToolBarConfig ()
180 #if DEBUG_KP_MAIN_WINDOW
181 kDebug () << "kpMainWindow::slotNewToolBarConfig()";
185 applyMainWindowSettings (KGlobal::config ()->group (autoSaveGroup ()));
190 void kpMainWindow::slotConfigure ()