there is no moc file generated for this class
[kdegraphics.git] / kolourpaint / mainWindow / kpMainWindow_Settings.cpp
blob169666a3cfd0bcc62567c644cfe03bbee4fb1ea4
2 /*
3 Copyright (c) 2003-2007 Clarence Dang <dang@kde.org>
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
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>
34 #include <kconfig.h>
35 #include <kconfiggroup.h>
36 #include <kdebug.h>
37 #include <kedittoolbar.h>
38 #include <kglobal.h>
39 #include <klocale.h>
40 #include <kmessagebox.h>
41 #include <kshortcutsdialog.h>
42 #include <kstandardaction.h>
43 #include <ktogglefullscreenaction.h>
45 #include <kpDefs.h>
46 #include <kpDocument.h>
47 #include <kpToolAction.h>
48 #include <kpToolToolBar.h>
51 // private
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 ()),
65 this/*window*/, ac);
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);
83 // private
84 void kpMainWindow::enableSettingsMenuDocumentActions (bool /*enable*/)
89 // private slot
90 void kpMainWindow::slotFullScreen ()
92 KToggleFullScreenAction::setFullScreen( this, d->actionFullScreen->isChecked ());
96 // private slot
97 void kpMainWindow::slotEnableSettingsShowPath ()
99 #if DEBUG_KP_MAIN_WINDOW
100 kDebug () << "kpMainWindow::slotEnableSettingsShowPath()";
101 #endif
103 const bool enable = (d->document && !d->document->url ().isEmpty ());
105 d->actionShowPath->setEnabled (enable);
106 d->actionShowPath->setChecked (enable && d->configShowPath);
109 // private slot
110 void kpMainWindow::slotShowPathToggled ()
112 #if DEBUG_KP_MAIN_WINDOW
113 kDebug () << "kpMainWindow::slotShowPathToggled()";
114 #endif
116 d->configShowPath = d->actionShowPath->isChecked ();
118 slotUpdateCaption ();
121 KConfigGroup cfg (KGlobal::config (), kpSettingsGroupGeneral);
123 cfg.writeEntry (kpSettingShowPath, d->configShowPath);
124 cfg.sync ();
128 // private slot
129 void kpMainWindow::slotKeyBindings ()
131 #if DEBUG_KP_MAIN_WINDOW
132 kDebug () << "kpMainWindow::slotKeyBindings()";
133 #endif
135 toolEndShape ();
137 if (KShortcutsDialog::configure (actionCollection (),
138 KShortcutsEditor::LetterShortcutsAllowed,
139 this))
141 #if DEBUG_KP_MAIN_WINDOW
142 kDebug () << "\tdialog accepted";
143 #endif
144 // TODO: PROPAGATE: thru mainWindow's and interprocess
146 kpToolAction::updateAllActionsToolTips (actionCollection ());
151 // private slot
152 void kpMainWindow::slotConfigureToolBars ()
154 #if DEBUG_KP_MAIN_WINDOW
155 kDebug () << "kpMainWindow::slotConfigureToolBars()";
156 #endif
158 toolEndShape ();
160 // TODO: Do we need this?
161 #if 0
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 ();
165 #endif
167 saveMainWindowSettings (KGlobal::config ()->group (autoSaveGroup ()));
169 KEditToolBar dialog (actionCollection (), this);
171 connect (&dialog, SIGNAL (newToolbarConfig ()),
172 this, SLOT (slotNewToolBarConfig ()));
174 dialog.exec ();
177 // private slot
178 void kpMainWindow::slotNewToolBarConfig ()
180 #if DEBUG_KP_MAIN_WINDOW
181 kDebug () << "kpMainWindow::slotNewToolBarConfig()";
182 #endif
184 createGUI();
185 applyMainWindowSettings (KGlobal::config ()->group (autoSaveGroup ()));
189 // private slot
190 void kpMainWindow::slotConfigure ()
192 // TODO