kmag.cpp 26.8 KB
Newer Older
Sarang Lakare's avatar
Sarang Lakare committed
1
2
3
4
/***************************************************************************
                          kmag.cpp  -  description
                             -------------------
    begin                : Mon Feb 12 23:45:41 EST 2001
5
    copyright            : (C) 2001-2003 by Sarang Lakare
Sarang Lakare's avatar
Sarang Lakare committed
6
    email                : sarang#users.sourceforge.net
7
    copyright            : (C) 2003-2004 by Olaf Schmidt
8
    email                : ojschmidt@kde.org
9
10
    copyright            : (C) 2008 by Matthew Woehlke
    email                : mw_triad@users.sourceforge.net
Sebastian Sauer's avatar
Sebastian Sauer committed
11
12
    copyright              (C) 2010 Sebastian Sauer
    email                  sebsauer@kdab.com
Sarang Lakare's avatar
Sarang Lakare committed
13
14
15
16
17
18
19
20
21
22
23
24
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 files for QT
Arto Hytönen's avatar
Arto Hytönen committed
25
#include <QtCore/QDir>
26
#include <QtCore/QPointer>
John Layt's avatar
John Layt committed
27
#include <QtGui/QPrintDialog>
Arto Hytönen's avatar
Arto Hytönen committed
28
29
30
31
32
33
#include <QtGui/QPainter>
#include <QtGui/QLayout>
#include <QtGui/QClipboard>
#include <QtGui/QContextMenuEvent>
#include <QtGui/QPixmap>
#include <QtGui/QDesktopWidget>
Laurent Montel's avatar
Laurent Montel committed
34

Arto Hytönen's avatar
Arto Hytönen committed
35
// include files for KDE
Laurent Montel's avatar
Laurent Montel committed
36
#include <kxmlguiclient.h>
Laurent Montel's avatar
Compile    
Laurent Montel committed
37
#include <ktoolbar.h>
Laurent Montel's avatar
Laurent Montel committed
38
#include <ktoggleaction.h>
Simon Hausmann's avatar
ported    
Simon Hausmann committed
39
#include <kactioncollection.h>
Laurent Montel's avatar
Laurent Montel committed
40
#include <kselectaction.h>
41
#include <kdeversion.h>
Laurent Montel's avatar
Laurent Montel committed
42
#include <kxmlguifactory.h>
Laurent Montel's avatar
Laurent Montel committed
43
#include <kicon.h>
Sarang Lakare's avatar
Sarang Lakare committed
44
#include <kapplication.h>
Laurent Montel's avatar
Laurent Montel committed
45
#include <kstandardshortcut.h>
Laurent Montel's avatar
Laurent Montel committed
46
#include <kshortcutsdialog.h>
Sarang Lakare's avatar
Sarang Lakare committed
47
48
49
50
51
52
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <kmenubar.h>
#include <klocale.h>
#include <kconfig.h>
Waldo Bastian's avatar
Waldo Bastian committed
53
#include <kdebug.h>
Laurent Montel's avatar
Laurent Montel committed
54
#include <kstandardaction.h>
Sarang Lakare's avatar
Sarang Lakare committed
55
#include <khelpmenu.h>
Sarang Lakare's avatar
Sarang Lakare committed
56
#include <kimageio.h>
57
58
#include <kio/job.h>
#include <kio/netaccess.h>
Jaison Lee's avatar
Jaison Lee committed
59
#include <ktemporaryfile.h>
Laurent Montel's avatar
Laurent Montel committed
60
#include <kmenu.h>
61
#include <kedittoolbar.h>
Laurent Montel's avatar
Laurent Montel committed
62
#include <kglobal.h>
63
#include <kdeprintdialog.h>
Sarang Lakare's avatar
Sarang Lakare committed
64
65
66

// application specific includes
#include "kmag.moc"
Sarang Lakare's avatar
Sarang Lakare committed
67
#include "kmagzoomview.h"
Sarang Lakare's avatar
Sarang Lakare committed
68
69
#include "kmagselrect.h"

70

71
KmagApp::KmagApp(QWidget* , const char* name)
72
73
  : KXmlGuiWindow(0) // Qt::WStyle_MinMax | Qt::WType_TopLevel | Qt::WDestructiveClose | Qt::WStyle_ContextHelp | Qt::WindowCloseButtonHint | Qt::WStyle_StaysOnTop
  , m_defaultMouseCursorType(2)
Sarang Lakare's avatar
Sarang Lakare committed
74
{
75
  setObjectName( QLatin1String( name ) );
76
  setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
Laurent Montel's avatar
Laurent Montel committed
77
  config=KGlobal::config();
Sarang Lakare's avatar
Sarang Lakare committed
78

79
80
  zoomArrayString << QLatin1String( "5:1" ) << QLatin1String( "2:1" ) << QLatin1String( "1:1" ) << QLatin1String( "1:1.5" ) << QLatin1String( "1:2" ) << QLatin1String( "1:3" ) << QLatin1String( "1:4" ) << QLatin1String( "1:5" )
    << QLatin1String( "1:6" ) << QLatin1String( "1:7" ) << QLatin1String( "1:8" ) << QLatin1String( "1:12" ) << QLatin1String( "1:16" ) << QLatin1String( "1:20" );
81

Christoph Feck's avatar
Christoph Feck committed
82
83
84
85
  zoomArray << 0.2 <<0.5 << 1.0;
  zoomArray << 1.5 << 2.0 << 3.0;
  zoomArray << 4.0 << 5.0 << 6.0 << 7.0;
  zoomArray << 8.0 << 12.0 << 16.0 << 20.0;
86

87
  fpsArrayString << i18nc("Zoom at very low", "&Very Low") << i18nc("Zoom at low", "&Low") << i18nc("Zoom at medium", "&Medium") << i18nc("Zoom at high", "&High") << i18nc("Zoom at very high", "V&ery High");
Sarang Lakare's avatar
Sarang Lakare committed
88

Christoph Feck's avatar
Christoph Feck committed
89
90
91
92
93
  fpsArray.append(2); // very low
  fpsArray.append(6); // low
  fpsArray.append(10); // medium
  fpsArray.append(15); // high
  fpsArray.append(25); // very high
Sarang Lakare's avatar
Sarang Lakare committed
94

95
  colorArrayString << i18nc("No color-blindness simulation, i.e. 'normal' vision", "&Normal") << i18n("&Protanopia") << i18n("&Deuteranopia") << i18n("&Tritanopia") << i18n("&Achromatopsia");
96

Christoph Feck's avatar
Christoph Feck committed
97
98
99
100
101
  colorArray.append(0);
  colorArray.append(1);
  colorArray.append(2);
  colorArray.append(3);
  colorArray.append(4);
102

103
  rotationArrayString << i18n("&No Rotation (0 Degrees)") << i18n("&Left (90 Degrees)") << i18n("&Upside Down (180 Degrees)") << i18n("&Right (270 Degrees)");
104

Christoph Feck's avatar
Christoph Feck committed
105
106
107
108
  rotationArray.append(0); // no rotation
  rotationArray.append(90); // left
  rotationArray.append(180); // upside down
  rotationArray.append(270); // right
109

Sarang Lakare's avatar
Sarang Lakare committed
110
111
112
  // call inits to invoke all other construction parts
  initView();
  initActions();
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
113
  initConnections();
Laurent Montel's avatar
Laurent Montel committed
114

115
  // read options from config file
Sarang Lakare's avatar
Sarang Lakare committed
116
117
  readOptions();

118
119
120
  #ifndef QT_NO_PRINTER
  m_printer = 0;
  #endif // QT_NO_PRINTER
Sarang Lakare's avatar
Sarang Lakare committed
121
122
}

Sarang Lakare's avatar
Sarang Lakare committed
123
124
125
/**
 * Default destructor.
 */
Sarang Lakare's avatar
Sarang Lakare committed
126
127
KmagApp::~KmagApp()
{
128
    m_zoomView->showSelRect(false);
129
130
131
132

    #ifndef QT_NO_PRINTER
    delete m_printer;
    #endif // QT_NO_PRINTER
Sarang Lakare's avatar
Sarang Lakare committed
133
134
135
136
}

void KmagApp::initActions()
{
137
138
  fileNewWindow = actionCollection()->addAction(QLatin1String( "new_window" ));
  fileNewWindow->setIcon(KIcon(QLatin1String( "window-new" )));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
139
  fileNewWindow->setText(i18n("New &Window"));
Laurent Montel's avatar
Laurent Montel committed
140
  connect(fileNewWindow, SIGNAL(triggered(bool)), SLOT(slotFileNewWindow()));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
141
  fileNewWindow->setShortcuts(KStandardShortcut::openNew());
142
  fileNewWindow->setToolTip(i18n("Open a new KMagnifier window"));
Sarang Lakare's avatar
Sarang Lakare committed
143

144
145
  refreshSwitch = actionCollection()->addAction(QLatin1String( "start_stop_refresh" ));
  refreshSwitch->setIcon(KIcon(QLatin1String( "process-stop" )));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
146
  refreshSwitch->setText(i18n("&Stop"));
Laurent Montel's avatar
Laurent Montel committed
147
  connect(refreshSwitch, SIGNAL(triggered(bool)), SLOT(slotToggleRefresh()));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
148
  refreshSwitch->setShortcuts(KStandardShortcut::reload());
Sarang Lakare's avatar
Sarang Lakare committed
149
  refreshSwitch->setToolTip(i18n("Click to stop window refresh"));
150
151
  refreshSwitch->setWhatsThis(i18n("Clicking on this icon will <b>start</b> / <b>stop</b>\
  updating of the display. Stopping the update will zero the processing power\
Sarang Lakare's avatar
Sarang Lakare committed
152
  required (CPU usage)"));
153

154
155
  m_pSnapshot = actionCollection()->addAction(QLatin1String( "snapshot" ));
  m_pSnapshot->setIcon(KIcon(QLatin1String( "ksnapshot" )));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
156
  m_pSnapshot->setText(i18n("&Save Snapshot As..."));
Laurent Montel's avatar
Laurent Montel committed
157
  connect(m_pSnapshot, SIGNAL(triggered(bool)), SLOT(saveZoomPixmap()));
Simon Hausmann's avatar
ported    
Simon Hausmann committed
158
  m_pSnapshot->setShortcuts(KStandardShortcut::save());
159
  m_pSnapshot->setWhatsThis(i18n("Saves the zoomed view to an image file."));
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
160
  m_pSnapshot->setToolTip(i18n("Save image to a file"));
Sarang Lakare's avatar
Sarang Lakare committed
161

Simon Hausmann's avatar
ported    
Simon Hausmann committed
162
  m_pPrint = actionCollection()->addAction(KStandardAction::Print, this, SLOT(slotFilePrint()));
Sarang Lakare's avatar
Sarang Lakare committed
163
  m_pPrint->setWhatsThis(i18n("Click on this button to print the current zoomed view."));
164

Simon Hausmann's avatar
ported    
Simon Hausmann committed
165
  m_pQuit = actionCollection()->addAction(KStandardAction::Quit, this, SLOT(slotFileQuit()));
Laurent Montel's avatar
Laurent Montel committed
166
  m_pQuit->setToolTip(i18n("Quits the application"));
167
168
  m_pQuit->setWhatsThis (i18n("Quits the application"));

Simon Hausmann's avatar
ported    
Simon Hausmann committed
169
  m_pCopy = actionCollection()->addAction(KStandardAction::Copy, this, SLOT(copyToClipBoard()));
Sarang Lakare's avatar
Sarang Lakare committed
170
  m_pCopy->setWhatsThis(i18n("Click on this button to copy the current zoomed view to the clipboard which you can paste in other applications."));
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
171
  m_pCopy->setToolTip(i18n("Copy zoomed image to clipboard"));
Sarang Lakare's avatar
Sarang Lakare committed
172

173
174
175
  m_pShowMenu = KStandardAction::showMenubar(this, SLOT(slotShowMenu()), actionCollection());

  setStandardToolBarMenuEnabled(true);
176

177
178
  m_modeFollowMouse = new KToggleAction(KIcon(QLatin1String( "followmouse" )), i18n("&Follow Mouse Mode"), this);
  actionCollection()->addAction(QLatin1String( "mode_followmouse" ), m_modeFollowMouse);
Stephan Kulow's avatar
Stephan Kulow committed
179
180
  connect(m_modeFollowMouse, SIGNAL(triggered(bool)), SLOT(slotModeFollowMouse()));
  m_modeFollowMouse->setShortcut(Qt::Key_F1);
Sebastian Sauer's avatar
Sebastian Sauer committed
181
  m_modeFollowMouse->setIconText(i18n("Mouse"));
182
183
  m_modeFollowMouse->setToolTip(i18n("Magnify around the mouse cursor"));
  m_modeFollowMouse->setWhatsThis(i18n("If selected, the area around the mouse cursor is magnified"));
184

185
#ifdef QAccessibilityClient_FOUND
186
187
  m_modeFollowFocus = new KToggleAction(KIcon(QLatin1String( "view-restore" )), i18n("&Follow Focus Mode"), this);
  actionCollection()->addAction(QLatin1String( "mode_followfocus" ), m_modeFollowFocus);
188
189
  connect(m_modeFollowFocus, SIGNAL(triggered(bool)), SLOT(slotModeFollowFocus()));
  m_modeFollowFocus->setShortcut(Qt::Key_F2);
Sebastian Sauer's avatar
Sebastian Sauer committed
190
  m_modeFollowFocus->setIconText(i18n("Focus"));
191
192
  m_modeFollowFocus->setToolTip(i18n("Magnify around the keyboard focus"));
  m_modeFollowFocus->setWhatsThis(i18n("If selected, the area around the keyboard cursor is magnified"));
193
#endif
194
195
196

  m_modeSelWin = new KToggleAction(KIcon(QLatin1String( "window" )), i18n("Se&lection Window Mode"), this);
  actionCollection()->addAction(QLatin1String( "mode_selectionwindow" ), m_modeSelWin);
Stephan Kulow's avatar
Stephan Kulow committed
197
  connect(m_modeSelWin, SIGNAL(triggered(bool)), SLOT(slotModeSelWin()));
198
  m_modeSelWin->setShortcut(Qt::Key_F3);
Sebastian Sauer's avatar
Sebastian Sauer committed
199
  m_modeSelWin->setIconText(i18n("Window"));
200
  m_modeSelWin->setToolTip(i18n("Show a window for selecting the magnified area"));
201

202
203
  m_modeWholeScreen = new KToggleAction(KIcon(QLatin1String( "view-fullscreen" )), i18n("&Whole Screen Mode"), this);
  actionCollection()->addAction(QLatin1String( "mode_wholescreen" ), m_modeWholeScreen);
Stephan Kulow's avatar
Stephan Kulow committed
204
  connect(m_modeWholeScreen, SIGNAL(triggered(bool)), SLOT(slotModeWholeScreen()));
205
  m_modeWholeScreen->setShortcut(Qt::Key_F4);
Sebastian Sauer's avatar
Sebastian Sauer committed
206
  m_modeWholeScreen->setIconText(i18n("Screen"));
207
208
  m_modeWholeScreen->setToolTip(i18n("Magnify the whole screen"));
  m_modeWholeScreen->setWhatsThis(i18n("Click on this button to fit the zoom view to the zoom window."));
209

210
211
  m_hideCursor = new KToggleAction(KIcon(QLatin1String( "hidemouse" )), i18n("Hide Mouse &Cursor"), this);
  actionCollection()->addAction(QLatin1String( "hidecursor" ), m_hideCursor);
Stephan Kulow's avatar
Stephan Kulow committed
212
  connect(m_hideCursor, SIGNAL(triggered(bool)), SLOT(slotToggleHideCursor()));
213
  m_hideCursor->setShortcut(Qt::Key_F5);
Sebastian Sauer's avatar
Sebastian Sauer committed
214
  #ifdef havesetCheckedStatef
Laurent Montel's avatar
Laurent Montel committed
215
  m_hideCursor->setCheckedState(KGuiItem(i18n("Show Mouse &Cursor")));
216
  #endif
Sebastian Sauer's avatar
Sebastian Sauer committed
217
  m_hideCursor->setIconText(i18n("Hide"));
218
  m_hideCursor->setToolTip(i18n("Hide the mouse cursor"));
219
220
221

  m_staysOnTop = new KToggleAction(KIcon(QLatin1String( "go-top" )), i18n("Stays On Top"), this);
  actionCollection()->addAction(QLatin1String( "staysontop" ), m_staysOnTop);
Sebastian Sauer's avatar
Sebastian Sauer committed
222
  connect(m_staysOnTop, SIGNAL(triggered(bool)), SLOT(slotStaysOnTop()));
Sebastian Sauer's avatar
Sebastian Sauer committed
223
  m_staysOnTop->setShortcut(Qt::Key_F6);
Sebastian Sauer's avatar
Sebastian Sauer committed
224
  m_staysOnTop->setToolTip(i18n("The KMagnifier Window stays on top of other windows."));
225

Simon Hausmann's avatar
ported    
Simon Hausmann committed
226
  m_pZoomIn = actionCollection()->addAction(KStandardAction::ZoomIn, this, SLOT(zoomIn()));
227
228
  m_pZoomIn->setWhatsThis(i18n("Click on this button to <b>zoom-in</b> on the selected region."));

Simon Hausmann's avatar
ported    
Simon Hausmann committed
229
  m_pZoomBox = new KSelectAction(i18n("&Zoom"), this);
230
  actionCollection()->addAction(QLatin1String( "zoom" ), m_pZoomBox);
231
  m_pZoomBox->setItems(zoomArrayString);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
232
233
  m_pZoomBox->setWhatsThis(i18n("Select the zoom factor."));
  m_pZoomBox->setToolTip(i18n("Zoom factor"));
234

Simon Hausmann's avatar
ported    
Simon Hausmann committed
235
  m_pZoomOut = actionCollection()->addAction(KStandardAction::ZoomOut, this, SLOT(zoomOut()));
Sarang Lakare's avatar
Sarang Lakare committed
236
  m_pZoomOut->setWhatsThis(i18n("Click on this button to <b>zoom-out</b> on the selected region."));
237

Simon Hausmann's avatar
ported    
Simon Hausmann committed
238
  m_pRotationBox = new KSelectAction(i18n("&Rotation"),this);
239
  actionCollection()->addAction(QLatin1String( "rotation" ), m_pRotationBox);
240
  m_pRotationBox->setItems(rotationArrayString);
Gunnar Schmidt's avatar
Gunnar Schmidt committed
241
242
  m_pRotationBox->setWhatsThis(i18n("Select the rotation degree."));
  m_pRotationBox->setToolTip(i18n("Rotation degree"));
243

Matthias Kretz's avatar
Matthias Kretz committed
244
  // KHelpMenu *newHelpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData());
Gunnar Schmidt's avatar
Gunnar Schmidt committed
245

Simon Hausmann's avatar
ported    
Simon Hausmann committed
246
247
  m_keyConf = actionCollection()->addAction(KStandardAction::KeyBindings, this, SLOT(slotConfKeys()));
  m_toolConf = actionCollection()->addAction(KStandardAction::ConfigureToolbars, this, SLOT(slotEditToolbars()));
248

Simon Hausmann's avatar
ported    
Simon Hausmann committed
249
  m_pFPSBox = new KSelectAction(i18n("&Refresh"),this);
250
  actionCollection()->addAction(QLatin1String( "fps_selector" ), m_pFPSBox);
Sarang Lakare's avatar
Sarang Lakare committed
251
  m_pFPSBox->setItems(fpsArrayString);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
252
253
  m_pFPSBox->setWhatsThis(i18n("Select the refresh rate. The higher the rate, the more computing power (CPU) will be needed."));
  m_pFPSBox->setToolTip(i18n("Refresh rate"));
Sarang Lakare's avatar
Sarang Lakare committed
254

255
  m_pColorBox = new KSelectAction(i18nc("Color-blindness simulation mode", "&Color"),this);
256
  actionCollection()->addAction(QLatin1String( "color_mode" ), m_pColorBox);
257
258
259
260
  m_pColorBox->setItems(colorArrayString);
  m_pColorBox->setWhatsThis(i18n("Select a mode to simulate various types of color-blindness."));
  m_pColorBox->setToolTip(i18n("Color-blindness Simulation Mode"));

261
  setupGUI(ToolBar | Keys | Save | Create);
Sarang Lakare's avatar
Sarang Lakare committed
262
263
}

Sarang Lakare's avatar
Sarang Lakare committed
264
265
void KmagApp::initView()
{
266
  m_zoomView = new KMagZoomView( this, "ZoomView" );
267
//m_zoomView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, m_zoomView->sizePolicy().hasHeightForWidth() ) );
268
  m_zoomView->setFrameShape( QFrame::NoFrame );
Sarang Lakare's avatar
Sarang Lakare committed
269

270
  setCentralWidget(m_zoomView);
Sarang Lakare's avatar
Sarang Lakare committed
271
272
}

Laurent Montel's avatar
Laurent Montel committed
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288

void KmagApp::slotChangeZoomBoxIndex(int index)
{
   m_pZoomBox->setCurrentItem(index);
}

void KmagApp::slotChangeRotationBoxIndex(int index)
{
  m_pRotationBox->setCurrentItem(index);
}

void KmagApp::slotChangeFPSIndex(int index)
{
  m_pFPSBox->setCurrentItem(index);
}

289
290
291
292
void KmagApp::slotChangeColorIndex(int index)
{
  m_pColorBox->setCurrentItem(index);
}
Laurent Montel's avatar
Laurent Montel committed
293

Sarang Lakare's avatar
Sarang Lakare committed
294
295
296
/**
 * Initialize all connections.
 */
297
298
void KmagApp::initConnections()
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
299
300
  // change in zoom value -> update the view
  connect(this, SIGNAL(updateZoomValue(float)), m_zoomView, SLOT(setZoom(float)));
301
  connect(this, SIGNAL(updateRotationValue(int)), m_zoomView, SLOT(setRotation(int)));
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
302
  connect(this, SIGNAL(updateFPSValue(float)), m_zoomView, SLOT(setRefreshRate(float)));
303
  connect(this, SIGNAL(updateColorValue(int)), m_zoomView, SLOT(setColorMode(int)));
Sarang Lakare's avatar
Sarang Lakare committed
304

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
305
  // change in zoom index -> update the selector
Laurent Montel's avatar
Laurent Montel committed
306
307
308
  connect(this, SIGNAL(updateZoomIndex(int)), this, SLOT(slotChangeZoomBoxIndex(int)));
  connect(this, SIGNAL(updateRotationIndex(int)), this, SLOT(slotChangeRotationBoxIndex(int)));
  connect(this, SIGNAL(updateFPSIndex(int)), this, SLOT(slotChangeFPSIndex(int)));
309
  connect(this, SIGNAL(updateColorIndex(int)), this, SLOT(slotChangeColorIndex(int)));
Sarang Lakare's avatar
Sarang Lakare committed
310

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
311
  // selector selects a zoom index -> set the zoom index
312
313
314
  connect(m_pZoomBox, SIGNAL(triggered(int)), this, SLOT(setZoomIndex(int)));
  connect(m_pRotationBox, SIGNAL(triggered(int)), this, SLOT(setRotationIndex(int)));
  connect(m_pFPSBox, SIGNAL(triggered(int)), this, SLOT(setFPSIndex(int)));
315
  connect(m_pColorBox, SIGNAL(triggered(int)), this, SLOT(setColorIndex(int)));
316
317
}

318
319
320
/**
 * Save options to config file.
 */
Sarang Lakare's avatar
Sarang Lakare committed
321
void KmagApp::saveOptions()
Laurent Montel's avatar
Laurent Montel committed
322
{
Stephan Kulow's avatar
ported    
Stephan Kulow committed
323
324
325
326
327
  KConfigGroup cg( config, "General Options");
  cg.writeEntry("Geometry", size());
  cg.writeEntry("ZoomIndex", m_zoomIndex);
  cg.writeEntry("RotationIndex", m_rotationIndex);
  cg.writeEntry("FPSIndex", m_fpsIndex);
328
  cg.writeEntry("ColorIndex", m_colorIndex);
Stephan Kulow's avatar
ported    
Stephan Kulow committed
329
330
  cg.writeEntry("SelRect", m_zoomView->getSelRectPos());
  cg.writeEntry("ShowMouse", m_zoomView->getShowMouseType());
Sebastian Sauer's avatar
Sebastian Sauer committed
331
  cg.writeEntry("StaysOnTop", m_staysOnTop->isChecked());
332

333
  if (m_modeFollowMouse->isChecked())
Stephan Kulow's avatar
ported    
Stephan Kulow committed
334
     cg.writeEntry("Mode", "followmouse");
335
#ifdef QAccessibilityClient_FOUND
336
337
  else if (m_modeFollowFocus->isChecked())
     cg.writeEntry("Mode", "followfocus");
338
#endif
339
  else if (m_modeWholeScreen->isChecked())
Stephan Kulow's avatar
ported    
Stephan Kulow committed
340
     cg.writeEntry("Mode", "wholescreen");
341
  else if (m_modeSelWin->isChecked())
Stephan Kulow's avatar
ported    
Stephan Kulow committed
342
     cg.writeEntry("Mode", "selectionwindow");
Sarang Lakare's avatar
Sarang Lakare committed
343
344
345
}


346
347
348
/**
 * Read settings from config file.
 */
Sarang Lakare's avatar
Sarang Lakare committed
349
350
void KmagApp::readOptions()
{
351
352
353
354
  QColor blue (0,0,128);
  QColor yellow (255,255,0);
  QColor white (255,255,255);

Laurent Montel's avatar
Laurent Montel committed
355
  KConfigGroup cgWM( config, "WM");
356
  setTitleColors (
Laurent Montel's avatar
Laurent Montel committed
357
358
359
      cgWM.readEntry("inactiveBackground", blue),
      cgWM.readEntry("inactiveForeground", white),
      cgWM.readEntry("inactiveTitleBtnBg", yellow));
360

Laurent Montel's avatar
Laurent Montel committed
361
  KConfigGroup cg(config,"General Options");
Sarang Lakare's avatar
Sarang Lakare committed
362

363
  QSize defSize(460,390);
Stephan Kulow's avatar
ported    
Stephan Kulow committed
364
  QSize size=cg.readEntry("Geometry", defSize);
Sarang Lakare's avatar
Sarang Lakare committed
365
366
367
368
369
  if(!size.isEmpty())
  {
    resize(size);
  }

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
370
  // set zoom - defaults to 2x
Stephan Kulow's avatar
ported    
Stephan Kulow committed
371
  unsigned int zoomIndex = cg.readEntry("ZoomIndex", 4);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
372
373
  setZoomIndex(zoomIndex);
  emit updateZoomIndex(m_zoomIndex);
Sarang Lakare's avatar
Sarang Lakare committed
374

Stephan Kulow's avatar
ported    
Stephan Kulow committed
375
  unsigned int rotationIndex = cg.readEntry("RotationIndex", 0);
376
377
378
  setRotationIndex(rotationIndex);
  emit updateRotationIndex(m_rotationIndex);

Stephan Kulow's avatar
ported    
Stephan Kulow committed
379
  unsigned int fpsIndex = cg.readEntry("FPSIndex", 2);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
380
381
  setFPSIndex(fpsIndex);
  emit updateFPSIndex(m_fpsIndex);
Sarang Lakare's avatar
Sarang Lakare committed
382

383
384
385
386
  unsigned int colorIndex = cg.readEntry("ColorIndex", 0);
  setColorIndex(colorIndex);
  emit updateColorIndex(colorIndex);

Stephan Kulow's avatar
ported    
Stephan Kulow committed
387
  QString mode = cg.readEntry("Mode", "followmouse");
388
  if (mode == QLatin1String( "wholescreen" ))
389
    slotModeWholeScreen();
390
  else if (mode == QLatin1String( "selectionwindow" ))
391
    slotModeSelWin();
392
#ifdef QAccessibilityClient_FOUND
393
  else if (mode == QLatin1String( "followfocus" ))
394
    slotModeFollowFocus();
395
#endif
396
397
  else
    slotModeFollowMouse();
Sarang Lakare's avatar
Sarang Lakare committed
398

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
399
  QRect defaultRect(0,0,211,164);
Stephan Kulow's avatar
ported    
Stephan Kulow committed
400
  m_zoomView->setSelRectPos(cg.readEntry("SelRect", defaultRect));
401

Stephan Kulow's avatar
ported    
Stephan Kulow committed
402
  m_mouseCursorType = cg.readEntry("ShowMouse", m_defaultMouseCursorType);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
403
  m_zoomView->showMouse(m_mouseCursorType);
Sebastian Sauer's avatar
Sebastian Sauer committed
404
  m_hideCursor->setChecked(!m_mouseCursorType);
405

Sebastian Sauer's avatar
Sebastian Sauer committed
406
407
  m_staysOnTop->setChecked(cg.readEntry("StaysOnTop", true));
  slotStaysOnTop();
Stephan Binner's avatar
Stephan Binner committed
408

409
410
  // XMLGui has already read and set up the menuBar for us
  m_pShowMenu->setChecked(menuBar()->isVisible());
411
}
Sarang Lakare's avatar
Sarang Lakare committed
412
413
414

bool KmagApp::queryClose()
{
Sarang Lakare's avatar
Sarang Lakare committed
415
  return (true);
Sarang Lakare's avatar
Sarang Lakare committed
416
417
418
419
420
421
422
423
}

bool KmagApp::queryExit()
{
  saveOptions();
  return true;
}

424
425
426
427
428
/**
 * Called when mouse is clicked inside the window
 *
 * @param e
 */
429
void KmagApp::contextMenuEvent ( QContextMenuEvent * e )
430
{
431
432
 // show popup
 KXMLGUIFactory *factory = this->factory();
433
 QMenu *popup = (QMenu *)factory->container(QLatin1String( "mainPopUp" ),this);
434
 if (popup != 0)
435
   popup->popup(e->globalPos());
436
 e->accept();
437
438
439
}


Sarang Lakare's avatar
Sarang Lakare committed
440
441
442
443
/////////////////////////////////////////////////////////////////////
// SLOT IMPLEMENTATION
/////////////////////////////////////////////////////////////////////

Sarang Lakare's avatar
Sarang Lakare committed
444
445
446
447
448
/**
 * Shows/hides the mouse cursor
 */
void KmagApp::showMouseCursor(bool show)
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
449
  if(show) {
Sarang Lakare's avatar
Sarang Lakare committed
450
451
    if(m_mouseCursorType == 0)
      m_mouseCursorType = m_defaultMouseCursorType;
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
452
453
454
455
    m_zoomView->showMouse(m_mouseCursorType);
  } else {
    m_zoomView->showMouse(0);
  }
Sarang Lakare's avatar
Sarang Lakare committed
456
457
}

458
459
460
461
/**
 * Zoom in.
 */
void KmagApp::zoomIn()
462
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
463
464
465
466
  // set the new index .. checking will done inside setZoom
  setZoomIndex(m_zoomIndex+1);
  // signal change in zoom index
  emit updateZoomIndex((int)m_zoomIndex);
467
468
}

469
470
471
472
/**
 * Zoom out.
 */
void KmagApp::zoomOut()
473
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
474
475
476
477
  // set the new index .. checking will done inside setZoom
  setZoomIndex(m_zoomIndex-1);
  // signal change in zoom index
  emit updateZoomIndex((int)m_zoomIndex);
478
}
479
480
481
482
/**
 * Sets the zoom index to index
 */
void KmagApp::setZoomIndex(int index)
483
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
484
485
  if(index < 0 || index >= (int)zoomArray.size()) {
    // the index is invalid
486
    kWarning() << "Invalid index!" ;
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
487
    return;
488
  } else if((int)m_zoomIndex == index) {
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
489
490
491
492
493
    // do nothing!
    return;
  } else {
    m_zoomIndex = index;
  }
494
495
496
497
498
499

  if(m_zoomIndex == 0) {
    // meaning that no more zooming-out is possible
    // -> disable zoom-out icon
    m_pZoomOut->setEnabled(false);
  } else { // enable the icon
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
500
501
    m_pZoomOut->setEnabled(true);
  }
502

503
  if(m_zoomIndex == zoomArray.size()-1) {
504
505
    // meaning that no more zooming-in is possible
    // -> disable zoom-in icon
506
507
    m_pZoomIn->setEnabled(false);
  } else { // enable the icon
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
508
509
    m_pZoomIn->setEnabled(true);
  }
Laurent Montel's avatar
Laurent Montel committed
510

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
511
  // signal change in zoom value
Christoph Feck's avatar
Christoph Feck committed
512
  emit updateZoomValue(zoomArray.at(m_zoomIndex));
513
514
}

515
516
517
518
519
520
521
/**
 * Sets the rotation index to index
 */
void KmagApp::setRotationIndex(int index)
{
  if(index < 0 || index >= (int)rotationArray.size()) {
    // the index is invalid
522
    kWarning() << "Invalid index!" ;
523
524
525
526
527
528
529
530
531
    return;
  } else if((int)m_rotationIndex == index) {
    // do nothing!
    return;
  } else {
    m_rotationIndex = index;
  }

  // signal change in zoom value
Christoph Feck's avatar
Christoph Feck committed
532
  emit updateRotationValue(rotationArray.at(m_rotationIndex));
533
534
}

Sarang Lakare's avatar
Sarang Lakare committed
535
536
537
538
539
/**
 * Sets the fps index to index
 */
void KmagApp::setFPSIndex(int index)
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
540
541
  if(index < 0 || index >= (int)fpsArray.size()) {
    // the index is invalid
542
    kWarning() << "Invalid index!" ;
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
543
    return;
Sarang Lakare's avatar
Sarang Lakare committed
544
  } else if((int)m_fpsIndex == index) {
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
545
546
547
548
549
550
    // do nothing!
    return;
  } else {
    m_fpsIndex = index;
  }

551
  // signal change in fps value
Christoph Feck's avatar
Christoph Feck committed
552
  emit updateFPSValue(fpsArray.at(m_fpsIndex));
Sarang Lakare's avatar
Sarang Lakare committed
553
554
}

555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
/**
 * Sets the color index to index
 */
void KmagApp::setColorIndex(int index)
{
  if(index < 0 || index >= (int)colorArray.size()) {
    // the index is invalid
    kWarning() << "Invalid index!" ;
    return;
  } else if((int)m_colorIndex == index) {
    // do nothing!
    return;
  } else {
    m_colorIndex = index;
  }

  // signal change in fps value
Christoph Feck's avatar
Christoph Feck committed
572
  emit updateColorValue(colorArray.at(m_colorIndex));
573
}
574

Sarang Lakare's avatar
Sarang Lakare committed
575
576
577
578
579
/**
 * Save the zoomed image
 */
void KmagApp::saveZoomPixmap()
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
580
  bool toggled(false);
Sarang Lakare's avatar
Sarang Lakare committed
581

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
582
  // stop refresh temporarily
Sarang Lakare's avatar
Sarang Lakare committed
583
584
  if (m_zoomView->getRefreshStatus()) {
    slotToggleRefresh();
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
585
    toggled = true;
Sarang Lakare's avatar
Sarang Lakare committed
586
587
  }

Laurent Montel's avatar
Laurent Montel committed
588
  KUrl url = KFileDialog::getSaveUrl(QString(),
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
589
              KImageIO::pattern(KImageIO::Writing),
Stephan Binner's avatar
Stephan Binner committed
590
             0,i18n("Save Snapshot As"));
Sarang Lakare's avatar
Sarang Lakare committed
591

592
  if(!url.fileName().isEmpty()) {
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
593
594
    if(!url.isLocalFile()) {
      // create a temp file.. save image to it.. copy over the n/w and then delete the temp file.
Jaison Lee's avatar
Jaison Lee committed
595
      KTemporaryFile tempFile;
596
#ifdef __GNUC__
Laurent Montel's avatar
Laurent Montel committed
597
#warning "kde4: port KImageIO::type \n";
Stephan Kulow's avatar
ported    
Stephan Kulow committed
598
#endif
599
      if(!tempFile.open() || !m_zoomView->getImage().save(tempFile.fileName(),"png"/*, KImageIO::type(url.fileName()).latin1()*/)) {
600
        KMessageBox::error(0, i18n("Unable to save temporary file (before uploading to the network file you specified)."),
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
601
602
                          i18n("Error Writing File"));
      } else {
Jaison Lee's avatar
Jaison Lee committed
603
        if(!KIO::NetAccess::upload(tempFile.fileName(), url, this)) {
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
604
605
606
          KMessageBox::error(0, i18n("Unable to upload file over the network."),
                            i18n("Error Writing File"));
        } else {
Laurent Montel's avatar
Laurent Montel committed
607
          KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url.prettyUrl()),
608
                              i18n("Information"), QLatin1String( "save_confirm" ));
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
609
610
611
612
        }
      }

    } else {
613
#ifdef __GNUC__
Laurent Montel's avatar
Laurent Montel committed
614
#warning "kde4 : port KImageIO::type(...) \n";
Stephan Kulow's avatar
ported    
Stephan Kulow committed
615
#endif
616
      if(!m_zoomView->getImage().save(url.path(), "png"/*KImageIO::type(url.fileName()).latin1()*/)) {
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
617
618
619
        KMessageBox::error(0, i18n("Unable to save file. Please check if you have permission to write to the directory."),
                            i18n("Error Writing File"));
      } else {
Laurent Montel's avatar
Laurent Montel committed
620
        KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url.prettyUrl()),
621
                                i18n("Information"), QLatin1String( "save_confirm" ));
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
622
623
624
625
626
627
      }
    }
  }
  if(toggled) {
    slotToggleRefresh();
  }
Sarang Lakare's avatar
Sarang Lakare committed
628
629
630
}


631
632
void KmagApp::slotToggleRefresh()
{
Sarang Lakare's avatar
Sarang Lakare committed
633
634
  m_zoomView->toggleRefresh();
  if(m_zoomView->getRefreshStatus()) {
635
    refreshSwitch->setIcon(KIcon(QLatin1String( "process-stop" )));
636
    refreshSwitch->setText(i18n("Stop"));
Sarang Lakare's avatar
Sarang Lakare committed
637
    refreshSwitch->setToolTip(i18n("Click to stop window update"));
638
  } else {
639
    refreshSwitch->setIcon(KIcon(QLatin1String( "system-run" )));
640
    refreshSwitch->setText(i18nc("Start updating the window", "Start"));
Sarang Lakare's avatar
Sarang Lakare committed
641
    refreshSwitch->setToolTip(i18n("Click to start window update"));
642
643
644
  }
}

645
646

void KmagApp::slotModeWholeScreen()
647
{
648
  m_zoomView->followMouse(false);
649
  m_zoomView->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
650
651
652
  m_zoomView->showSelRect(false);
  m_zoomView->setFitToWindow (false);
  m_modeFollowMouse->setChecked(false);
653
#ifdef QAccessibilityClient_FOUND
654
  m_zoomView->followFocus(false);
655
  m_modeFollowFocus->setChecked(false);
656
#endif
657
658
  m_modeWholeScreen->setChecked(true);
  m_modeSelWin->setChecked(false);
659
660
}

661
662

void KmagApp::slotModeSelWin()
663
{
664
665
666
667
  m_zoomView->followMouse(false);
  m_zoomView->showSelRect(true);
  m_zoomView->setFitToWindow (false);
  m_modeFollowMouse->setChecked(false);
668
#ifdef QAccessibilityClient_FOUND
669
  m_zoomView->followFocus(false);
670
  m_modeFollowFocus->setChecked(false);
671
#endif
672
673
  m_modeWholeScreen->setChecked(false);
  m_modeSelWin->setChecked(true);
674
675
}

676
677
678
679
680
681
682

void KmagApp::slotModeFollowMouse()
{
  m_zoomView->followMouse(true);
  m_zoomView->showSelRect(false);
  m_zoomView->setFitToWindow (true);
  m_modeFollowMouse->setChecked(true);
683
#ifdef QAccessibilityClient_FOUND
684
  m_zoomView->followFocus(false);
685
  m_modeFollowFocus->setChecked(false);
686
#endif
687
688
689
690
691
  m_modeWholeScreen->setChecked(false);
  m_modeSelWin->setChecked(false);
}


692
#ifdef QAccessibilityClient_FOUND
693
694
695
696
697
698
699
700
void KmagApp::slotModeFollowFocus()
{
  m_zoomView->followMouse(false);
  m_zoomView->followFocus(true);
  m_zoomView->showSelRect(false);
  m_zoomView->setFitToWindow (true);
  m_modeFollowMouse->setChecked(false);
  m_modeFollowFocus->setChecked(true);
701
702
703
  m_modeWholeScreen->setChecked(false);
  m_modeSelWin->setChecked(false);
}
704
#endif
705
706

void KmagApp::slotToggleHideCursor()
707
{
708
  showMouseCursor(!m_hideCursor->isChecked());
709
710
}

711

Sebastian Sauer's avatar
Sebastian Sauer committed
712
713
714
void KmagApp::slotStaysOnTop()
{
  if (m_staysOnTop->isChecked())
715
      setWindowFlags( windowFlags() | Qt::WindowStaysOnTopHint );
Sebastian Sauer's avatar
Sebastian Sauer committed
716
  else
717
      setWindowFlags( windowFlags() & !Qt::WindowStaysOnTopHint );
Sebastian Sauer's avatar
Sebastian Sauer committed
718
719
720
721
  show();
}


Sarang Lakare's avatar
Sarang Lakare committed
722
void KmagApp::slotFileNewWindow()
Laurent Montel's avatar
Laurent Montel committed
723
{
Sarang Lakare's avatar
Sarang Lakare committed
724
725
726
727
728
729
730
  KmagApp *new_window= new KmagApp();
  new_window->show();
}


void KmagApp::slotFilePrint()
{
731
732
#ifndef QT_NO_PRINTER

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
733
  bool toggled(false);
734

735
736
737
  if (m_printer == 0) {
    m_printer = new QPrinter();
  }
738

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
739
  // stop refresh temporarily
740
741
  if (m_zoomView->getRefreshStatus()) {
    slotToggleRefresh();
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
742
    toggled = true;
Sarang Lakare's avatar
Sarang Lakare committed
743
  }
744

745
  const QImage pixmap(m_zoomView->getImage());
Sarang Lakare's avatar
Sarang Lakare committed
746

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
747
748
  // use some AI to get the best orientation
  if(pixmap.width() > pixmap.height()) {
749
    m_printer->setOrientation(QPrinter::Landscape);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
750
  } else {
751
    m_printer->setOrientation(QPrinter::Portrait);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
752
  }
Sarang Lakare's avatar
Sarang Lakare committed
753

754
  QPrintDialog *printDialog = KdePrint::createPrintDialog(m_printer, this);
John Layt's avatar
John Layt committed
755

756
  if (printDialog->exec()) {
757
    QPainter paint;
Laurent Montel's avatar
Laurent Montel committed
758

759
    if(!paint.begin(m_printer))
Laurent Montel's avatar
Laurent Montel committed
760
761
    {
      delete printDialog;
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
762
      return;
Laurent Montel's avatar
Laurent Montel committed
763
    }
764
    // draw the pixmap
765
    paint.drawImage(0, 0, pixmap);
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
766
767
    // end the painting
    paint.end();
768
769
  }

Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
770
771
772
  if(toggled) {
    slotToggleRefresh();
  }
Laurent Montel's avatar
Laurent Montel committed
773
  delete printDialog;
774
#endif // QT_NO_PRINTER
Sarang Lakare's avatar
Sarang Lakare committed
775
776
}

777
778
779
780
781
782
void KmagApp::slotFileQuit()
{
  saveOptions();
  // close the first window, the list makes the next one the first again.
  // This ensures that queryClose() is called on each window to ask for closing
  KMainWindow* w;
Laurent Montel's avatar
Laurent Montel committed
783
  if (!memberList().isEmpty())
784
  {
Laurent Montel's avatar
Laurent Montel committed
785
	for (int i = 0; i < memberList().size(); ++i)
786
    {
Laurent Montel's avatar
Laurent Montel committed
787
	  w = memberList().at(i);
788
789
790
791
      // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
      // the window and the application stay open.
      if(!w->close())
         break;
792
#ifdef __GNUC__
Laurent Montel's avatar
Laurent Montel committed
793
#warning "kde4: now memberList() is constant => we can't remove some element!"
Stephan Kulow's avatar
ported    
Stephan Kulow committed
794
#endif
Laurent Montel's avatar
Laurent Montel committed
795
	//memberList()->removeRef(w);
796
    }
Stephan Binner's avatar
Stephan Binner committed
797
  }
798
799
}

Sarang Lakare's avatar
Sarang Lakare committed
800
void KmagApp::copyToClipBoard()
Sarang Lakare's avatar
Sarang Lakare committed
801
{
Olaf Schmidt-Wischhöfer's avatar
Olaf Schmidt-Wischhöfer committed
802
  QClipboard *cb=KApplication::clipboard();
803
  cb->setPixmap(QPixmap::fromImage(m_zoomView->getImage()));
Sarang Lakare's avatar
Sarang Lakare committed
804
805
}

806
807
808
809
810
811
812
813
814
815
816
817
void KmagApp::slotShowMenu()
{
  ///////////////////////////////////////////////////////////////////
  // turn Menu on or off
  if(!m_pShowMenu->isChecked())
  {
    menuBar()->hide();
  }
  else
  {
    menuBar()->show();
  }
818
819
}

820
821
void KmagApp::slotConfKeys()
{
Laurent Montel's avatar
Laurent Montel committed
822
  KShortcutsDialog::configure( actionCollection() );
823
824
825
826
}

void KmagApp::slotEditToolbars()
{
Stephan Kulow's avatar