Fix compile/link
[kdeaccessibility.git] / kmag / kmag.cpp
blob109653be6778a5a3b653e223ed4d1126ab54c71c
1 /***************************************************************************
2 kmag.cpp - description
3 -------------------
4 begin : Mon Feb 12 23:45:41 EST 2001
5 copyright : (C) 2001-2003 by Sarang Lakare
6 email : sarang#users.sourceforge.net
7 copyright : (C) 2003-2004 by Olaf Schmidt
8 email : ojschmidt@kde.org
9 ***************************************************************************/
11 /***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
20 // include files for QT
21 #include <qdir.h>
22 #include <qprinter.h>
23 #include <qpainter.h>
24 #include <qlayout.h>
25 #include <qclipboard.h>
26 #include <q3dragobject.h>
27 #include <q3whatsthis.h>
28 #include <qtooltip.h>
29 #include <q3popupmenu.h>
30 #include <kxmlguiclient.h>
31 //Added by qt3to4:
32 #include <QContextMenuEvent>
33 #include <QPixmap>
34 #include <Q3Frame>
35 #include <QDesktopWidget>
36 #include <kdeversion.h>
37 #include <kxmlguifactory.h>
39 // include files for KDE
40 #if KDE_VERSION > 300
41 #include <kapplication.h>
42 #else
43 #include <kapplication.h>
44 #endif // KDE 3.x
46 #include <kkeydialog.h>
47 #include <kiconloader.h>
48 #include <kmessagebox.h>
49 #include <kfiledialog.h>
50 #include <kmenubar.h>
51 #include <klocale.h>
52 #include <kconfig.h>
53 #include <kdebug.h>
54 #include <kstdaction.h>
55 #include <khelpmenu.h>
56 #include <kimageio.h>
57 #include <kio/job.h>
58 #include <kio/netaccess.h>
59 #include <ktempfile.h>
60 #include <kmenu.h>
61 #include <kedittoolbar.h>
63 #if KDE_VERSION < 220
64 #include <qprinter.h>
65 #else
66 #include <kprinter.h>
67 #endif
69 // application specific includes
70 #include "kmag.moc"
71 #include "kmagzoomview.h"
72 #include "kmagselrect.h"
75 #define havesetCheckedState
77 KmagApp::KmagApp(QWidget* , const char* name)
78 : KMainWindow(0, name, Qt::WStyle_MinMax | Qt::WType_TopLevel | Qt::WDestructiveClose | Qt::WStyle_ContextHelp | Qt::WStyle_StaysOnTop),
79 m_defaultMouseCursorType(2)
81 config=kapp->config();
83 zoomArrayString << "5:1" << "2:1" << "1:1" << "1:1.5" << "1:2" << "1:3" << "1:4" << "1:5"
84 << "1:6" << "1:7" << "1:8" << "1:12" << "1:16" << "1:20";
86 // Is there a better way to initialize a vector array?
87 zoomArray.push_back(0.2); zoomArray.push_back(0.5); zoomArray.push_back(1.0);
88 zoomArray.push_back(1.5); zoomArray.push_back(2.0); zoomArray.push_back(3.0);
89 zoomArray.push_back(4.0); zoomArray.push_back(5.0); zoomArray.push_back(6.0); zoomArray.push_back(7.0);
90 zoomArray.push_back(8.0); zoomArray.push_back(12.0); zoomArray.push_back(16.0); zoomArray.push_back(20.0);
92 fpsArrayString << i18n("&Very Low") << i18n("&Low") << i18n("&Medium") << i18n("&High") << i18n("V&ery High");
94 fpsArray.push_back(2); // very low
95 fpsArray.push_back(6); // low
96 fpsArray.push_back(10); // medium
97 fpsArray.push_back(15); // high
98 fpsArray.push_back(25); // very high
100 rotationArrayString << i18n("&No Rotation (0°)") << i18n("&Left (90°)") << i18n("&Upside Down (180°)") << i18n("&Right (270°)");
102 rotationArray.push_back(0); // no rotation
103 rotationArray.push_back(90); // left
104 rotationArray.push_back(180); // upside down
105 rotationArray.push_back(270); // right
107 // call inits to invoke all other construction parts
108 initView();
109 initActions();
110 initConnections();
112 // read options from config file
113 readOptions();
115 // Register all KIO image formats - to be used when saving image.
116 KImageIO::registerFormats();
120 * Default destructor.
122 KmagApp::~KmagApp()
124 m_zoomView->showSelRect(false);
127 void KmagApp::initActions()
129 fileNewWindow = new KAction(i18n("New &Window"), "window_new", KStdAccel::openNew(), this,
130 SLOT(slotFileNewWindow()), actionCollection(),"new_window");
131 fileNewWindow->setToolTip(i18n("Open a new KMagnifier window"));
133 refreshSwitch = new KAction(i18n("&Stop"), "stop", KStdAccel::reload(), this,
134 SLOT(slotToggleRefresh()), actionCollection(), "start_stop_refresh");
135 refreshSwitch->setToolTip(i18n("Click to stop window refresh"));
136 refreshSwitch->setWhatsThis(i18n("Clicking on this icon will <b>start</b> / <b>stop</b>\
137 updating of the display. Stopping the update will zero the processing power\
138 required (CPU usage)"));
140 m_pSnapshot = new KAction(i18n("&Save Snapshot As..."), "ksnapshot", KStdAccel::save(), this,
141 SLOT(saveZoomPixmap()), actionCollection(),"snapshot");
142 m_pSnapshot->setWhatsThis(i18n("Saves the zoomed view to an image file."));
143 m_pSnapshot->setToolTip(i18n("Save image to a file"));
145 m_pPrint = KStdAction::print(this, SLOT(slotFilePrint()), actionCollection(), "print");
146 m_pPrint->setWhatsThis(i18n("Click on this button to print the current zoomed view."));
148 m_pQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection(), "quit");
149 m_pQuit->setToolTip(i18n("Quits the application"));
150 m_pQuit->setWhatsThis (i18n("Quits the application"));
152 m_pCopy = KStdAction::copy(this, SLOT(copyToClipBoard()), actionCollection(), "copy");
153 m_pCopy->setWhatsThis(i18n("Click on this button to copy the current zoomed view to the clipboard which you can paste in other applications."));
154 m_pCopy->setToolTip(i18n("Copy zoomed image to clipboard"));
156 m_pShowMenu = new KToggleAction(i18n("Show &Menu"), "showmenu", Qt::CTRL+Qt::Key_M, this,
157 SLOT(slotShowMenu()), actionCollection(),"show_menu");
158 #ifdef havesetCheckedState
159 m_pShowMenu->setCheckedState(i18n("Hide &Menu"));
160 #endif
161 m_pShowMainToolBar = new KToggleAction(i18n("Show Main &Toolbar"), 0, 0, this,
162 SLOT(slotShowMainToolBar()), actionCollection(),"show_mainToolBar");
163 #ifdef havesetCheckedState
164 m_pShowMainToolBar->setCheckedState(i18n("Hide Main &Toolbar"));
165 #endif
166 m_pShowViewToolBar = new KToggleAction(i18n("Show &View Toolbar"), 0, 0, this,
167 SLOT(slotShowViewToolBar()), actionCollection(),"show_viewToolBar");
168 #ifdef havesetCheckedState
169 m_pShowViewToolBar->setCheckedState(i18n("Hide &View Toolbar"));
170 #endif
171 m_pShowSettingsToolBar = new KToggleAction(i18n("Show &Settings Toolbar"), 0, 0, this,
172 SLOT(slotShowSettingsToolBar()), actionCollection(),"show_settingsToolBar");
173 #ifdef havesetCheckedState
174 m_pShowSettingsToolBar->setCheckedState(i18n("Hide &Settings Toolbar"));
175 #endif
177 m_modeFollowMouse = new KRadioAction(i18n("&Follow Mouse Mode"), "followmouse", Qt::Key_F1, this,
178 SLOT(slotModeFollowMouse()), actionCollection(), "mode_followmouse");
179 m_modeFollowMouse->setToolTip(i18n("Magnify around the mouse cursor"));
180 m_modeFollowMouse->setWhatsThis(i18n("If selected, the area around the mouse cursor is magnified"));
182 m_modeSelWin = new KRadioAction(i18n("Se&lection Window Mode"), "window", Qt::Key_F2, this,
183 SLOT(slotModeSelWin()), actionCollection(), "mode_selectionwindow");
184 m_modeSelWin->setToolTip(i18n("Show a window for selecting the magnified area"));
186 m_modeWholeScreen = new KRadioAction(i18n("&Whole Screen Mode"), "window_fullscreen", Qt::Key_F3, this,
187 SLOT(slotModeWholeScreen()), actionCollection(),"mode_wholescreen");
188 m_modeWholeScreen->setToolTip(i18n("Magnify the whole screen"));
189 m_modeWholeScreen->setWhatsThis(i18n("Click on this button to fit the zoom view to the zoom window."));
191 m_hideCursor = new KToggleAction(i18n("Hide Mouse &Cursor"), "hidemouse", Qt::Key_F4, this,
192 SLOT(slotToggleHideCursor()), actionCollection(), "hidecursor");
193 #ifdef havesetCheckedState
194 m_hideCursor->setCheckedState(i18n("Show Mouse &Cursor"));
195 #endif
196 m_hideCursor->setToolTip(i18n("Hide the mouse cursor"));
198 m_pZoomIn = KStdAction::zoomIn(this, SLOT(zoomIn()), actionCollection(), "zoom_in");
199 m_pZoomIn->setWhatsThis(i18n("Click on this button to <b>zoom-in</b> on the selected region."));
201 m_pZoomBox = new KSelectAction(i18n("&Zoom"),0,actionCollection(),"zoom");
202 m_pZoomBox->setItems(zoomArrayString);
203 m_pZoomBox->setWhatsThis(i18n("Select the zoom factor."));
204 m_pZoomBox->setToolTip(i18n("Zoom factor"));
206 m_pZoomOut = KStdAction::zoomOut(this, SLOT(zoomOut()), actionCollection(), "zoom_out");
207 m_pZoomOut->setWhatsThis(i18n("Click on this button to <b>zoom-out</b> on the selected region."));
209 m_pRotationBox = new KSelectAction(i18n("&Rotation"),0,actionCollection(),"rotation");
210 m_pRotationBox->setItems(rotationArrayString);
211 m_pRotationBox->setWhatsThis(i18n("Select the rotation degree."));
212 m_pRotationBox->setToolTip(i18n("Rotation degree"));
214 // KHelpMenu *newHelpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData());
216 m_keyConf = KStdAction::keyBindings( this, SLOT( slotConfKeys() ), actionCollection(), "key_conf");
217 m_toolConf = KStdAction::configureToolbars( this, SLOT( slotEditToolbars() ),
218 actionCollection(), "toolbar_conf");
220 m_pFPSBox = new KSelectAction(i18n("&Refresh"),0,actionCollection(),"fps_selector");
221 m_pFPSBox->setItems(fpsArrayString);
222 m_pFPSBox->setWhatsThis(i18n("Select the refresh rate. The higher the rate, the more computing power (CPU) will be needed."));
223 m_pFPSBox->setToolTip(i18n("Refresh rate"));
225 createGUI();
228 void KmagApp::initView()
230 m_zoomView = new KMagZoomView( this, "ZoomView" );
231 m_zoomView->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, m_zoomView->sizePolicy().hasHeightForWidth() ) );
232 m_zoomView->setFrameShape( Q3Frame::StyledPanel );
233 m_zoomView->setFrameShadow( Q3Frame::Raised );
235 setCentralWidget(m_zoomView);
239 * Initialize all connections.
241 void KmagApp::initConnections()
243 // change in zoom value -> update the view
244 connect(this, SIGNAL(updateZoomValue(float)), m_zoomView, SLOT(setZoom(float)));
245 connect(this, SIGNAL(updateRotationValue(int)), m_zoomView, SLOT(setRotation(int)));
246 connect(this, SIGNAL(updateFPSValue(float)), m_zoomView, SLOT(setRefreshRate(float)));
248 // change in zoom index -> update the selector
249 connect(this, SIGNAL(updateZoomIndex(int)), m_pZoomBox, SLOT(setCurrentItem(int)));
250 connect(this, SIGNAL(updateRotationIndex(int)), m_pRotationBox, SLOT(setCurrentItem(int)));
251 connect(this, SIGNAL(updateFPSIndex(int)), m_pFPSBox, SLOT(setCurrentItem(int)));
253 // selector selects a zoom index -> set the zoom index
254 connect(m_pZoomBox, SIGNAL(activated(int)), this, SLOT(setZoomIndex(int)));
255 connect(m_pRotationBox, SIGNAL(activated(int)), this, SLOT(setRotationIndex(int)));
256 connect(m_pFPSBox, SIGNAL(activated(int)), this, SLOT(setFPSIndex(int)));
260 * Save options to config file.
262 void KmagApp::saveOptions()
264 config->setGroup("General Options");
265 config->writeEntry("Geometry", size());
266 config->writeEntry("ZoomIndex", m_zoomIndex);
267 config->writeEntry("RotationIndex", m_rotationIndex);
268 config->writeEntry("FPSIndex", m_fpsIndex);
269 config->writeEntry("SelRect", m_zoomView->getSelRectPos());
270 config->writeEntry("ShowMouse", m_zoomView->getShowMouseType());
272 if (m_modeFollowMouse->isChecked())
273 config->writeEntry("Mode", "followmouse");
274 else if (m_modeWholeScreen->isChecked())
275 config->writeEntry("Mode", "wholescreen");
276 else if (m_modeSelWin->isChecked())
277 config->writeEntry("Mode", "selectionwindow");
279 config->writeEntry("ShowMenu", m_pShowMenu->isChecked());
280 config->writeEntry("ShowMainToolBar", m_pShowMainToolBar->isChecked());
281 config->writeEntry("ShowViewToolBar", m_pShowViewToolBar->isChecked());
282 config->writeEntry("ShowSettingsToolBar", m_pShowSettingsToolBar->isChecked());
284 toolBar("mainToolBar")->saveSettings(config,"Main ToolBar");
285 toolBar("viewToolBar")->saveSettings(config,"View ToolBar");
286 toolBar("settingsToolBar")->saveSettings(config,"Settings ToolBar");
291 * Read settings from config file.
293 void KmagApp::readOptions()
295 QColor blue (0,0,128);
296 QColor yellow (255,255,0);
297 QColor white (255,255,255);
299 config->setGroup ("WM");
300 setTitleColors (
301 config->readColorEntry("inactiveBackground", &blue),
302 config->readColorEntry("inactiveForeground", &white),
303 config->readColorEntry("inactiveTitleBtnBg", &yellow));
305 config->setGroup("General Options");
307 QSize defSize(460,390);
308 QSize size=config->readSizeEntry("Geometry", &defSize);
309 if(!size.isEmpty())
311 resize(size);
314 // set zoom - defaults to 2x
315 unsigned int zoomIndex = config->readUnsignedNumEntry("ZoomIndex", 4);
316 setZoomIndex(zoomIndex);
317 emit updateZoomIndex(m_zoomIndex);
319 unsigned int rotationIndex = config->readUnsignedNumEntry("RotationIndex", 0);
320 setRotationIndex(rotationIndex);
321 emit updateRotationIndex(m_rotationIndex);
323 unsigned int fpsIndex = config->readUnsignedNumEntry("FPSIndex", 2);
324 setFPSIndex(fpsIndex);
325 emit updateFPSIndex(m_fpsIndex);
327 QString mode = config->readEntry("Mode", "followmouse");
328 if (mode == "wholescreen")
329 slotModeWholeScreen();
330 else if (mode == "selectionwindow")
331 slotModeSelWin();
332 else
333 slotModeFollowMouse();
335 QRect defaultRect(0,0,211,164);
336 m_zoomView->setSelRectPos(config->readRectEntry("SelRect", &defaultRect));
338 m_mouseCursorType = config->readUnsignedNumEntry("ShowMouse", m_defaultMouseCursorType);
339 m_zoomView->showMouse(m_mouseCursorType);
340 if(m_mouseCursorType)
341 m_hideCursor->setChecked(false);
342 else
343 m_hideCursor->setChecked(true);
345 if(config->hasGroup("Settings ToolBar"))
346 toolBar("settingsToolBar")->applySettings(config,"Settings ToolBar");
348 if(config->hasGroup("Main ToolBar"))
349 toolBar("mainToolBar")->applySettings(config,"Main ToolBar");
351 if(config->hasGroup("View ToolBar"))
352 toolBar("viewToolBar")->applySettings(config,"View ToolBar");
354 m_pShowMenu->setChecked(config->readBoolEntry("ShowMenu", true));
355 slotShowMenu();
357 m_pShowMainToolBar->setChecked(config->readBoolEntry("ShowMainToolBar", false));
358 slotShowMainToolBar();
360 m_pShowViewToolBar->setChecked(config->readBoolEntry("ShowViewToolBar", true));
361 slotShowViewToolBar();
363 m_pShowSettingsToolBar->setChecked(config->readBoolEntry("ShowSettingsToolBar", true));
364 slotShowSettingsToolBar();
367 bool KmagApp::queryClose()
369 return (true);
372 bool KmagApp::queryExit()
374 saveOptions();
375 return true;
379 * Called when mouse is clicked inside the window
381 * @param e
383 void KmagApp::contextMenuEvent ( QContextMenuEvent * e )
385 // show popup
386 KXMLGUIFactory *factory = this->factory();
387 Q3PopupMenu *popup = (Q3PopupMenu *)factory->container("mainPopUp",this);
388 if (popup != 0)
389 popup->popup(e->globalPos(), 0);
390 e->accept();
394 /////////////////////////////////////////////////////////////////////
395 // SLOT IMPLEMENTATION
396 /////////////////////////////////////////////////////////////////////
399 * Shows/hides the mouse cursor
401 void KmagApp::showMouseCursor(bool show)
403 if(show) {
404 if(m_mouseCursorType == 0)
405 m_mouseCursorType = m_defaultMouseCursorType;
406 m_zoomView->showMouse(m_mouseCursorType);
407 } else {
408 m_zoomView->showMouse(0);
413 * Zoom in.
415 void KmagApp::zoomIn()
417 // set the new index .. checking will done inside setZoom
418 setZoomIndex(m_zoomIndex+1);
419 // signal change in zoom index
420 emit updateZoomIndex((int)m_zoomIndex);
424 * Zoom out.
426 void KmagApp::zoomOut()
428 // set the new index .. checking will done inside setZoom
429 setZoomIndex(m_zoomIndex-1);
430 // signal change in zoom index
431 emit updateZoomIndex((int)m_zoomIndex);
434 * Sets the zoom index to index
436 void KmagApp::setZoomIndex(int index)
438 if(index < 0 || index >= (int)zoomArray.size()) {
439 // the index is invalid
440 kdWarning() << "Invalid index!" << endl;
441 return;
442 } else if((int)m_zoomIndex == index) {
443 // do nothing!
444 return;
445 } else {
446 m_zoomIndex = index;
449 if(m_zoomIndex == 0) {
450 // meaning that no more zooming-out is possible
451 // -> disable zoom-out icon
452 m_pZoomOut->setEnabled(false);
453 } else { // enable the icon
454 m_pZoomOut->setEnabled(true);
457 if(m_zoomIndex == zoomArray.size()-1) {
458 // meaning that no more zooming-in is possible
459 // -> disable zoom-in icon
460 m_pZoomIn->setEnabled(false);
461 } else { // enable the icon
462 m_pZoomIn->setEnabled(true);
465 // signal change in zoom value
466 emit updateZoomValue(zoomArray[m_zoomIndex]);
470 * Sets the rotation index to index
472 void KmagApp::setRotationIndex(int index)
474 if(index < 0 || index >= (int)rotationArray.size()) {
475 // the index is invalid
476 kdWarning() << "Invalid index!" << endl;
477 return;
478 } else if((int)m_rotationIndex == index) {
479 // do nothing!
480 return;
481 } else {
482 m_rotationIndex = index;
485 // signal change in zoom value
486 emit updateRotationValue(rotationArray[m_rotationIndex]);
490 * Sets the fps index to index
492 void KmagApp::setFPSIndex(int index)
494 if(index < 0 || index >= (int)fpsArray.size()) {
495 // the index is invalid
496 kdWarning() << "Invalid index!" << endl;
497 return;
498 } else if((int)m_fpsIndex == index) {
499 // do nothing!
500 return;
501 } else {
502 m_fpsIndex = index;
505 // signal change in fps value
506 emit updateFPSValue(fpsArray[m_fpsIndex]);
511 * Save the zoomed image
513 void KmagApp::saveZoomPixmap()
515 bool toggled(false);
517 // stop refresh temporarily
518 if (m_zoomView->getRefreshStatus()) {
519 slotToggleRefresh();
520 toggled = true;
523 KURL url = KFileDialog::getSaveURL(QString::null,
524 KImageIO::pattern(KImageIO::Writing),
525 0,i18n("Save Snapshot As"));
527 if(!url.fileName().isEmpty()) {
528 if(!url.isLocalFile()) {
529 // create a temp file.. save image to it.. copy over the n/w and then delete the temp file.
530 KTempFile tempFile;
531 if(!m_zoomView->getPixmap().save(tempFile.name(), KImageIO::type(url.fileName()).latin1())) {
532 KMessageBox::error(0, i18n("Unable to save temporary file (before uploading to the network file you specified)."),
533 i18n("Error Writing File"));
534 } else {
535 if(!KIO::NetAccess::upload(tempFile.name(), url, this)) {
536 KMessageBox::error(0, i18n("Unable to upload file over the network."),
537 i18n("Error Writing File"));
538 } else {
539 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1").arg(url.prettyURL()),
540 i18n("Information"), "save_confirm");
543 // remove the temporary file
544 tempFile.unlink();
546 } else {
547 if(!m_zoomView->getPixmap().save(url.path(), KImageIO::type(url.fileName()).latin1())) {
548 KMessageBox::error(0, i18n("Unable to save file. Please check if you have permission to write to the directory."),
549 i18n("Error Writing File"));
550 } else {
551 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1").arg(url.prettyURL()),
552 i18n("Information"), "save_confirm");
556 if(toggled) {
557 slotToggleRefresh();
562 void KmagApp::slotToggleRefresh()
564 m_zoomView->toggleRefresh();
565 if(m_zoomView->getRefreshStatus()) {
566 refreshSwitch->setIcon("stop.png");
567 refreshSwitch->setText(i18n("Stop"));
568 refreshSwitch->setToolTip(i18n("Click to stop window update"));
569 } else {
570 refreshSwitch->setIcon("reload.png");
571 refreshSwitch->setText(i18n("Start"));
572 refreshSwitch->setToolTip(i18n("Click to start window update"));
577 void KmagApp::slotModeWholeScreen()
579 m_zoomView->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
580 m_zoomView->followMouse(false);
581 m_zoomView->showSelRect(false);
582 m_zoomView->setFitToWindow (false);
583 m_modeFollowMouse->setChecked(false);
584 m_modeWholeScreen->setChecked(true);
585 m_modeSelWin->setChecked(false);
589 void KmagApp::slotModeSelWin()
591 m_zoomView->followMouse(false);
592 m_zoomView->showSelRect(true);
593 m_zoomView->setFitToWindow (false);
594 m_modeFollowMouse->setChecked(false);
595 m_modeWholeScreen->setChecked(false);
596 m_modeSelWin->setChecked(true);
600 void KmagApp::slotModeFollowMouse()
602 m_zoomView->followMouse(true);
603 m_zoomView->showSelRect(false);
604 m_zoomView->setFitToWindow (true);
605 m_modeFollowMouse->setChecked(true);
606 m_modeWholeScreen->setChecked(false);
607 m_modeSelWin->setChecked(false);
611 void KmagApp::slotToggleHideCursor()
613 showMouseCursor(!m_hideCursor->isChecked());
617 void KmagApp::slotFileNewWindow()
619 KmagApp *new_window= new KmagApp();
620 new_window->show();
624 void KmagApp::slotFilePrint()
626 #ifndef QT_NO_PRINTER
628 bool toggled(false);
630 #if KDE_VERSION < 220
631 QPrinter printer;
632 #else
633 KPrinter printer;
634 #endif
636 // stop refresh temporarily
637 if (m_zoomView->getRefreshStatus()) {
638 slotToggleRefresh();
639 toggled = true;
642 const QPixmap pixmap(m_zoomView->getPixmap());
644 #if KDE_VERSION >= 220
645 // use some AI to get the best orientation
646 if(pixmap.width() > pixmap.height()) {
647 printer.setOrientation(KPrinter::Landscape);
648 } else {
649 printer.setOrientation(KPrinter::Portrait);
651 #endif
653 if (printer.setup(this)) {
654 QPainter paint;
656 if(!paint.begin(&printer))
657 return;
658 // draw the pixmap
659 paint.drawPixmap(0, 0, pixmap);
660 // end the painting
661 paint.end();
664 if(toggled) {
665 slotToggleRefresh();
667 #endif // QT_NO_PRINTER
670 void KmagApp::slotFileQuit()
672 saveOptions();
673 // close the first window, the list makes the next one the first again.
674 // This ensures that queryClose() is called on each window to ask for closing
675 KMainWindow* w;
676 if (memberList())
678 for(w=memberList()->first(); w!=0; w=memberList()->first())
680 // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
681 // the window and the application stay open.
682 if(!w->close())
683 break;
684 memberList()->removeRef(w);
689 void KmagApp::copyToClipBoard()
691 QClipboard *cb=KApplication::clipboard();
692 cb->setPixmap(m_zoomView->getPixmap());
695 void KmagApp::slotShowMenu()
697 ///////////////////////////////////////////////////////////////////
698 // turn Menu on or off
699 if(!m_pShowMenu->isChecked())
701 menuBar()->hide();
703 else
705 menuBar()->show();
711 void KmagApp::slotShowMainToolBar()
713 ///////////////////////////////////////////////////////////////////
714 // turn mainToolbar on or off
715 if(!m_pShowMainToolBar->isChecked())
717 toolBar("mainToolBar")->hide();
719 else
721 toolBar("mainToolBar")->show();
725 void KmagApp::slotShowViewToolBar()
727 ///////////////////////////////////////////////////////////////////
728 // turn viewToolbar on or off
729 if(!m_pShowViewToolBar->isChecked())
731 toolBar("viewToolBar")->hide();
733 else
735 toolBar("viewToolBar")->show();
739 void KmagApp::slotShowSettingsToolBar()
741 ///////////////////////////////////////////////////////////////////
742 // turn viewToolbar on or off
743 if(!m_pShowSettingsToolBar->isChecked())
745 toolBar("settingsToolBar")->hide();
747 else
749 toolBar("settingsToolBar")->show();
753 void KmagApp::slotConfKeys()
755 KKeyDialog::configure( actionCollection() );
758 void KmagApp::slotEditToolbars()
760 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
761 KEditToolbar dlg( actionCollection() );
762 connect( &dlg, SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() ) );
763 if ( dlg.exec() )
764 createGUI();
768 void KmagApp::slotNewToolbarConfig()
770 applyMainWindowSettings( KGlobal::config(), "MainWindow" );
771 createGUI();