1
/***************************************************************************
2
* Copyright (C) 2004 by Alexander Dymo *
3
* cloudtemple@mksat.net *
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. *
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. *
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
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19
***************************************************************************/
21
#include "kdevdesigner.h"
23
#include <kxmlguiclient.h>
24
#include <kkeydialog.h>
25
#include <kfiledialog.h>
30
#include <kedittoolbar.h>
33
#include <kstdaction.h>
35
#include <klibloader.h>
36
#include <kmessagebox.h>
37
#include <kstatusbar.h>
40
KDevDesigner::KDevDesigner()
41
: KParts::MainWindow( 0L, "KDevDesigner" )
43
// set the shell's ui resource file
44
setXMLFile("kdevdesigner_shell.rc");
46
// then, setup our actions
52
// this routine will find and load our Part. it finds the Part by
53
// name which is a bad idea usually.. but it's alright in this
54
// case since our Part is made for this Shell
55
KLibFactory *factory = KLibLoader::self()->factory("libkdevdesignerpart");
58
// now that the Part is loaded, we cast it to a Part to get
61
args.append("in shell");
62
m_part = static_cast<KParts::ReadWritePart *>(factory->create(this,
63
"kdevdesigner_part", "KParts::ReadWritePart", args));
67
// tell the KParts::MainWindow that this is indeed the main widget
68
setCentralWidget(m_part->widget());
70
// and integrate the part's GUI with the shell's
76
// if we couldn't find our Part, we exit since the Shell by
77
// itself can't do anything useful
78
KMessageBox::error(this, i18n("Could not find the KDevDesigner part."));
80
// we return here, cause kapp->quit() only means "exit the
81
// next time we enter the event loop...
85
// apply the saved mainwindow settings, if any, and ask the mainwindow
86
// to automatically save settings if changed: window size, toolbar
87
// position, icon size, etc.
88
setAutoSaveSettings();
91
KDevDesigner::~KDevDesigner()
95
void KDevDesigner::load(const KURL& url)
97
m_part->openURL( url );
100
void KDevDesigner::setupActions()
102
/* KStdAction::openNew(this, SLOT(fileNew()), actionCollection());
103
KStdAction::open(this, SLOT(fileOpen()), actionCollection());*/
105
KStdAction::quit(kapp, SLOT(quit()), actionCollection());
107
m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
108
m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
110
KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
111
KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
114
void KDevDesigner::saveProperties(KConfig* /*config*/)
116
// the 'config' object points to the session managed
117
// config file. anything you write here will be available
118
// later when this app is restored
121
void KDevDesigner::readProperties(KConfig* /*config*/)
123
// the 'config' object points to the session managed
124
// config file. this function is automatically called whenever
125
// the app is being restored. read in here whatever you wrote
126
// in 'saveProperties'
129
void KDevDesigner::fileNew()
131
// this slot is called whenever the File->New menu is selected,
132
// the New shortcut is pressed (usually CTRL+N) or the New toolbar
135
// About this function, the style guide (
136
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
137
// says that it should open a new window if the document is _not_
138
// in its initial state. This is what we do here..
139
if ( ! m_part->url().isEmpty() || m_part->isModified() )
141
(new KDevDesigner)->show();
146
void KDevDesigner::optionsShowToolbar()
148
// this is all very cut and paste code for showing/hiding the
150
if (m_toolbarAction->isChecked())
156
void KDevDesigner::optionsShowStatusbar()
158
// this is all very cut and paste code for showing/hiding the
160
if (m_statusbarAction->isChecked())
166
void KDevDesigner::optionsConfigureKeys()
168
KKeyDialog::configureKeys(m_part->actionCollection(), "kdevdesigner_part.rc");
171
void KDevDesigner::optionsConfigureToolbars()
173
saveMainWindowSettings(KGlobal::config(), autoSaveGroup());
175
// use the standard toolbar editor
176
KEditToolbar dlg(factory());
177
connect(&dlg, SIGNAL(newToolbarConfig()),
178
this, SLOT(applyNewToolbarConfig()));
182
void KDevDesigner::applyNewToolbarConfig()
184
applyMainWindowSettings(KGlobal::config(), autoSaveGroup());
187
void KDevDesigner::fileOpen()
189
// this slot is called whenever the File->Open menu is selected,
190
// the Open shortcut is pressed (usually CTRL+O) or the Open toolbar
193
KFileDialog::getOpenURL( QString::null, QString::null, this );
195
if (url.isEmpty() == false)
197
// About this function, the style guide (
198
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
199
// says that it should open a new window if the document is _not_
200
// in its initial state. This is what we do here..
201
if ( m_part->url().isEmpty() && ! m_part->isModified() )
203
// we open the file in this window...
208
// we open the file in a new window...
209
KDevDesigner* newWin = new KDevDesigner;
216
#include "kdevdesigner.moc"