1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
|
/***************************************************************************
kimepart.cpp - description
-------------------
begin : Mon Aug 5 2002
copyright : (C) 2002 by Jan Sch�er
email : janschaefer@users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <iostream>
#include <tdeaction.h>
#include <kiconloader.h>
#include <kstandarddirs.h>
#include <tdefiledialog.h>
#include <tdemessagebox.h>
#include <kkeydialog.h>
#include <kedittoolbar.h>
#include <kstatusbar.h>
#include <tdeapplication.h>
#include <kdebug.h>
#include <tqhbox.h>
#include "drawzone.h"
#include "kimagemapeditor.h" // the KPart
#include "kimeshell.h"
#include "kimeshell.moc"
KimeShell::KimeShell(const char *name )
: KParts::DockMainWindow( 0L, name )
{
setXMLFile("kimagemapeditorui.rc");
KDockWidget* mainDock;
mainDock = createDockWidget( "MainDockWidget", 0L, 0L, "main_dock_widget");
TQWidget *w = new TQHBox( mainDock );
// TQLayout* layout = new TQGridLayout( mainDock );
mainDock->setWidget( w );
// allow others to dock to the 4 sides
mainDock->setDockSite(KDockWidget::DockCorner);
// forbit docking abilities of mainDock itself
mainDock->setEnableDocking(KDockWidget::DockNone);
setView( mainDock); // central widget in a KDE mainwindow
setMainDockWidget( mainDock); // master dockwidget
m_part = new KImageMapEditor( w, "kimagemapeditor", this, "kimagemapeditor");
// setCentralWidget( part->widget() );
setupActions();
_stdout=false;
// createGUI( part );
createShellGUI( true );
guiFactory()->addClient( m_part );
KParts::GUIActivateEvent ev( true );
TQApplication::sendEvent( m_part, &ev );
//setCentralWidget(part->widget());
if (!initialGeometrySet())
resize( TQSize(725, 525).expandedTo(minimumSizeHint()));
connect( m_part, TQT_SIGNAL(setStatusBarText(const TQString &)),
this, TQT_SLOT(slotSetStatusBarText ( const TQString & )));
connect( m_part, TQT_SIGNAL(setWindowCaption(const TQString &)),
this, TQT_SLOT(setCaption( const TQString &)));
setAutoSaveSettings( "General Options" );
}
KimeShell::~KimeShell()
{
// delete part;
}
bool KimeShell::queryClose()
{
if (_stdout) {
std::cout << m_part->getHtmlCode().local8Bit() << std::endl;
}
return m_part->queryClose();
}
bool KimeShell::queryExit()
{
// writeConfig();
saveProperties(kapp->config());
return true;
}
void KimeShell::setupActions()
{
(void)KStdAction::openNew(this, TQT_SLOT(fileNew()), actionCollection());
// File Quit
(void)KStdAction::quit(this, TQT_SLOT(close()),actionCollection());
(void)KStdAction::showToolbar(this, TQT_SLOT(optionsShowToolbar()), actionCollection());
(void)KStdAction::keyBindings(this, TQT_SLOT(optionsConfigureKeys()), actionCollection());
(void)KStdAction::configureToolbars(this, TQT_SLOT(optionsConfigureToolbars()), actionCollection());
(void)KStdAction::showStatusbar(this, TQT_SLOT(optionsShowStatusbar()), actionCollection());
}
void KimeShell::fileNew()
{
// this slot is called whenever the File->New menu is selected,
// the New shortcut is pressed (usually CTRL+N) or the New toolbar
// button is clicked
// About this function, the style guide (
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
// says that it should open a new window if the document is _not_
// in its initial state. This is what we do here..
if ( ! m_part->url().isEmpty() || m_part->isModified() )
{
KimeShell * newShell = new KimeShell();
newShell->show();
newShell->readConfig();
};
}
void KimeShell::openFile(const KURL & url)
{
m_part->openFile(url);
}
void KimeShell::openLastFile()
{
if (m_part->config()->readBoolEntry("start-with-last-used-document",true))
m_part->openLastURL(m_part->config());
}
void KimeShell::fileOpen()
{
KURL url=KFileDialog::getOpenURL(TQString(),
"*.png *.jpg *.jpeg *.gif *.htm *.html|" + i18n( "Web Files" ) + "\n"
"*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng|" + i18n( "Images" ) + "\n"
"*.htm *.html|" + i18n( "HTML Files" ) + "\n"
"*.png|" + i18n( "PNG Images" ) + "\n*.jpg *.jpeg|" + i18n( "JPEG Images" ) + "\n*.gif|" + i18n( "GIF Images" ) + "\n*|" + i18n( "All Files" )
,this,i18n("Choose Picture to Open"));
if (!url.isEmpty()) {
// About this function, the style guide (
// http://developer.kde.org/documentation/standards/kde/style/basics/index.html )
// says that it should open a new window if the document is _not_
// in its initial state. This is what we do here..
if ( m_part->url().isEmpty() && ! m_part->isModified() )
{
// we open the file in this window...
m_part->openURL(url);
}
else
{
// we open the file in a new window...
KimeShell* newWin = new KimeShell;
newWin->openFile( url );
newWin->show();
}
}
}
void KimeShell::readConfig() {
TDEConfig *config;
config = kapp->config();
config->setGroup("General Options");
readConfig(config);
}
void KimeShell::readConfig(TDEConfig* config) {
// applyMainWindowSettings(config);
// restoreWindowSize(config);
readDockConfig(config);
}
void KimeShell::writeConfig() {
TDEConfig *config;
config = kapp->config();
config->setGroup("General Options");
writeConfig(config);
}
void KimeShell::writeConfig(TDEConfig* config) {
saveMainWindowSettings(config);
saveWindowSize(config);
writeDockConfig(config);
config->sync();
}
void KimeShell::saveProperties(TDEConfig *config)
{
//writeConfig(config);
m_part->saveProperties(config);
writeConfig();
}
void KimeShell::readProperties(TDEConfig *config)
{
readConfig();
m_part->readProperties(config);
}
void KimeShell::optionsConfigureKeys() {
// KKeyDialog::configureKeys(actionCollection(), "testprog_shell.rc");
KKeyDialog dlg;
dlg.insert(actionCollection());
dlg.insert(m_part->actionCollection());
dlg.configure();
}
void KimeShell::optionsConfigureToolbars()
{
#if defined(TDE_MAKE_VERSION)
# if TDE_VERSION >= TDE_MAKE_VERSION(3,1,0)
saveMainWindowSettings(TDEGlobal::config(), autoSaveGroup());
# else
saveMainWindowSettings(TDEGlobal::config() );
# endif
#else
saveMainWindowSettings(TDEGlobal::config() );
#endif
// use the standard toolbar editor
KEditToolbar dlg(factory());
connect(&dlg, TQT_SIGNAL(newToolbarConfig()),
this, TQT_SLOT(applyNewToolbarConfig()));
dlg.exec();
}
void KimeShell::applyNewToolbarConfig()
{
#if defined(TDE_MAKE_VERSION)
# if TDE_VERSION >= TDE_MAKE_VERSION(3,1,0)
applyMainWindowSettings(TDEGlobal::config(), autoSaveGroup());
# else
applyMainWindowSettings(TDEGlobal::config());
# endif
#else
applyMainWindowSettings(TDEGlobal::config());
#endif
}
void KimeShell::optionsShowToolbar()
{
if (toolBar()->isVisible())
toolBar()->hide();
else
toolBar()->show();
}
void KimeShell::optionsShowStatusbar()
{
if (statusBar()->isVisible())
statusBar()->hide();
else
statusBar()->show();
}
|