1 /***************************************************************************
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 /***************************************************************************
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. *
18 ***************************************************************************/
20 // include files for QT
26 #include <q3dragobject.h>
27 #include <q3whatsthis.h>
29 #include <q3popupmenu.h>
30 #include <kxmlguiclient.h>
32 #include <kstdaccel.h>
33 #include <ktoggleaction.h>
34 #include <kselectaction.h>
36 #include <QContextMenuEvent>
38 #include <QDesktopWidget>
39 #include <kdeversion.h>
40 #include <kxmlguifactory.h>
42 // include files for KDE
43 #include <kapplication.h>
45 #include <kkeydialog.h>
46 #include <kiconloader.h>
47 #include <kmessagebox.h>
48 #include <kfiledialog.h>
53 #include <kstdaction.h>
54 #include <khelpmenu.h>
57 #include <kio/netaccess.h>
58 #include <ktemporaryfile.h>
60 #include <kedittoolbar.h>
65 // application specific includes
67 #include "kmagzoomview.h"
68 #include "kmagselrect.h"
71 #define havesetCheckedState
73 KmagApp::KmagApp(QWidget
* , const char* name
)
74 : KMainWindow(0, name
, Qt::WStyle_MinMax
| Qt::WType_TopLevel
| Qt::WDestructiveClose
| Qt::WStyle_ContextHelp
| Qt::WStyle_StaysOnTop
),
75 m_defaultMouseCursorType(2)
77 config
=KGlobal::config();
79 zoomArrayString
<< "5:1" << "2:1" << "1:1" << "1:1.5" << "1:2" << "1:3" << "1:4" << "1:5"
80 << "1:6" << "1:7" << "1:8" << "1:12" << "1:16" << "1:20";
82 // Is there a better way to initialize a vector array?
83 zoomArray
.push_back(0.2); zoomArray
.push_back(0.5); zoomArray
.push_back(1.0);
84 zoomArray
.push_back(1.5); zoomArray
.push_back(2.0); zoomArray
.push_back(3.0);
85 zoomArray
.push_back(4.0); zoomArray
.push_back(5.0); zoomArray
.push_back(6.0); zoomArray
.push_back(7.0);
86 zoomArray
.push_back(8.0); zoomArray
.push_back(12.0); zoomArray
.push_back(16.0); zoomArray
.push_back(20.0);
88 fpsArrayString
<< i18n("&Very Low") << i18n("&Low") << i18n("&Medium") << i18n("&High") << i18n("V&ery High");
90 fpsArray
.push_back(2); // very low
91 fpsArray
.push_back(6); // low
92 fpsArray
.push_back(10); // medium
93 fpsArray
.push_back(15); // high
94 fpsArray
.push_back(25); // very high
96 rotationArrayString
<< i18n("&No Rotation (0 Degrees)") << i18n("&Left (90 Degrees)") << i18n("&Upside Down (180 Degrees)") << i18n("&Right (270 Degrees)");
98 rotationArray
.push_back(0); // no rotation
99 rotationArray
.push_back(90); // left
100 rotationArray
.push_back(180); // upside down
101 rotationArray
.push_back(270); // right
103 // call inits to invoke all other construction parts
108 // read options from config file
114 * Default destructor.
118 m_zoomView
->showSelRect(false);
121 void KmagApp::initActions()
123 fileNewWindow
= new KAction(KIcon("window_new"), i18n("New &Window"), actionCollection(), "new_window");
124 connect(fileNewWindow
, SIGNAL(triggered(bool) ), SLOT(slotFileNewWindow()));
125 fileNewWindow
->setShortcut(KStdAccel::openNew());
126 fileNewWindow
->setToolTip(i18n("Open a new KMagnifier window"));
128 refreshSwitch
= new KAction(KIcon("stop"), i18n("&Stop"), actionCollection(), "start_stop_refresh");
129 connect(refreshSwitch
, SIGNAL(triggered(bool) ), SLOT(slotToggleRefresh()));
130 refreshSwitch
->setShortcut(KStdAccel::reload());
131 refreshSwitch
->setToolTip(i18n("Click to stop window refresh"));
132 refreshSwitch
->setWhatsThis(i18n("Clicking on this icon will <b>start</b> / <b>stop</b>\
133 updating of the display. Stopping the update will zero the processing power\
134 required (CPU usage)"));
136 m_pSnapshot
= new KAction(KIcon("ksnapshot"), i18n("&Save Snapshot As..."), actionCollection(), "snapshot");
137 connect(m_pSnapshot
, SIGNAL(triggered(bool) ), SLOT(saveZoomPixmap()));
138 m_pSnapshot
->setShortcut(KStdAccel::save());
139 m_pSnapshot
->setWhatsThis(i18n("Saves the zoomed view to an image file."));
140 m_pSnapshot
->setToolTip(i18n("Save image to a file"));
142 m_pPrint
= KStdAction::print(this, SLOT(slotFilePrint()), actionCollection(), "print");
143 m_pPrint
->setWhatsThis(i18n("Click on this button to print the current zoomed view."));
145 m_pQuit
= KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection(), "quit");
146 m_pQuit
->setToolTip(i18n("Quits the application"));
147 m_pQuit
->setWhatsThis (i18n("Quits the application"));
149 m_pCopy
= KStdAction::copy(this, SLOT(copyToClipBoard()), actionCollection(), "copy");
150 m_pCopy
->setWhatsThis(i18n("Click on this button to copy the current zoomed view to the clipboard which you can paste in other applications."));
151 m_pCopy
->setToolTip(i18n("Copy zoomed image to clipboard"));
153 m_pShowMenu
= new KToggleAction(KIcon("showmenu"), i18n("Show &Menu"), actionCollection(), "show_menu");
154 connect(m_pShowMenu
, SIGNAL(triggered(bool)), SLOT(slotShowMenu()));
155 m_pShowMenu
->setShortcut(Qt::CTRL
+Qt::Key_M
);
156 #ifdef havesetCheckedState
157 m_pShowMenu
->setCheckedState(KGuiItem(i18n("Hide &Menu")));
159 m_pShowMainToolBar
= new KToggleAction(i18n("Show Main &Toolbar"), actionCollection(), "show_mainToolBar");
160 connect(m_pShowMainToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowMainToolBar()));
161 #ifdef havesetCheckedState
162 m_pShowMainToolBar
->setCheckedState(KGuiItem(i18n("Hide Main &Toolbar")));
164 m_pShowViewToolBar
= new KToggleAction(i18n("Show &View Toolbar"), actionCollection(), "show_viewToolBar");
165 connect(m_pShowViewToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowViewToolBar()));
166 #ifdef havesetCheckedState
167 m_pShowViewToolBar
->setCheckedState(KGuiItem(i18n("Hide &View Toolbar")));
169 m_pShowSettingsToolBar
= new KToggleAction(i18n("Show &Settings Toolbar"), actionCollection(), "show_settingsToolBar");
170 connect(m_pShowSettingsToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowSettingsToolBar()));
171 #ifdef havesetCheckedState
172 m_pShowSettingsToolBar
->setCheckedState(KGuiItem(i18n("Hide &Settings Toolbar")));
175 m_modeFollowMouse
= new KToggleAction(KIcon("followmouse"), i18n("&Follow Mouse Mode"), actionCollection(), "mode_followmouse");
176 connect(m_modeFollowMouse
, SIGNAL(triggered(bool)), SLOT(slotModeFollowMouse()));
177 m_modeFollowMouse
->setShortcut(Qt::Key_F1
);
178 m_modeFollowMouse
->setToolTip(i18n("Magnify around the mouse cursor"));
179 m_modeFollowMouse
->setWhatsThis(i18n("If selected, the area around the mouse cursor is magnified"));
181 m_modeSelWin
= new KToggleAction(KIcon("window"), i18n("Se&lection Window Mode"), actionCollection(), "mode_selectionwindow");
182 connect(m_modeSelWin
, SIGNAL(triggered(bool)), SLOT(slotModeSelWin()));
183 m_modeSelWin
->setShortcut(Qt::Key_F2
);
184 m_modeSelWin
->setToolTip(i18n("Show a window for selecting the magnified area"));
186 m_modeWholeScreen
= new KToggleAction(KIcon("window_fullscreen"), i18n("&Whole Screen Mode"), actionCollection(), "mode_wholescreen");
187 connect(m_modeWholeScreen
, SIGNAL(triggered(bool)), SLOT(slotModeWholeScreen()));
188 m_modeWholeScreen
->setShortcut(Qt::Key_F3
);
189 m_modeWholeScreen
->setToolTip(i18n("Magnify the whole screen"));
190 m_modeWholeScreen
->setWhatsThis(i18n("Click on this button to fit the zoom view to the zoom window."));
192 m_hideCursor
= new KToggleAction(KIcon("hidemouse"), i18n("Hide Mouse &Cursor"), actionCollection(), "hidecursor");
193 connect(m_hideCursor
, SIGNAL(triggered(bool)), SLOT(slotToggleHideCursor()));
194 m_hideCursor
->setShortcut(Qt::Key_F4
);
195 #ifdef havesetCheckedState
196 m_hideCursor
->setCheckedState(KGuiItem(i18n("Show Mouse &Cursor")));
198 m_hideCursor
->setToolTip(i18n("Hide the mouse cursor"));
200 m_pZoomIn
= KStdAction::zoomIn(this, SLOT(zoomIn()), actionCollection(), "zoom_in");
201 m_pZoomIn
->setWhatsThis(i18n("Click on this button to <b>zoom-in</b> on the selected region."));
203 m_pZoomBox
= new KSelectAction(i18n("&Zoom"),actionCollection(),"zoom");
204 m_pZoomBox
->setItems(zoomArrayString
);
205 m_pZoomBox
->setWhatsThis(i18n("Select the zoom factor."));
206 m_pZoomBox
->setToolTip(i18n("Zoom factor"));
208 m_pZoomOut
= KStdAction::zoomOut(this, SLOT(zoomOut()), actionCollection(), "zoom_out");
209 m_pZoomOut
->setWhatsThis(i18n("Click on this button to <b>zoom-out</b> on the selected region."));
211 m_pRotationBox
= new KSelectAction(i18n("&Rotation"),actionCollection(),"rotation");
212 m_pRotationBox
->setItems(rotationArrayString
);
213 m_pRotationBox
->setWhatsThis(i18n("Select the rotation degree."));
214 m_pRotationBox
->setToolTip(i18n("Rotation degree"));
216 // KHelpMenu *newHelpMenu = new KHelpMenu(this, KGlobal::instance()->aboutData());
218 m_keyConf
= KStdAction::keyBindings( this, SLOT( slotConfKeys() ), actionCollection(), "key_conf");
219 m_toolConf
= KStdAction::configureToolbars( this, SLOT( slotEditToolbars() ),
220 actionCollection(), "toolbar_conf");
222 m_pFPSBox
= new KSelectAction(i18n("&Refresh"),actionCollection(),"fps_selector");
223 m_pFPSBox
->setItems(fpsArrayString
);
224 m_pFPSBox
->setWhatsThis(i18n("Select the refresh rate. The higher the rate, the more computing power (CPU) will be needed."));
225 m_pFPSBox
->setToolTip(i18n("Refresh rate"));
230 void KmagApp::initView()
232 m_zoomView
= new KMagZoomView( this, "ZoomView" );
233 m_zoomView
->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType
)7, (QSizePolicy::SizeType
)7, m_zoomView
->sizePolicy().hasHeightForWidth() ) );
234 m_zoomView
->setFrameShape( QFrame::StyledPanel
);
235 m_zoomView
->setFrameShadow( QFrame::Raised
);
237 setCentralWidget(m_zoomView
);
241 * Initialize all connections.
243 void KmagApp::initConnections()
245 // change in zoom value -> update the view
246 connect(this, SIGNAL(updateZoomValue(float)), m_zoomView
, SLOT(setZoom(float)));
247 connect(this, SIGNAL(updateRotationValue(int)), m_zoomView
, SLOT(setRotation(int)));
248 connect(this, SIGNAL(updateFPSValue(float)), m_zoomView
, SLOT(setRefreshRate(float)));
250 // change in zoom index -> update the selector
251 connect(this, SIGNAL(updateZoomIndex(int)), m_pZoomBox
, SLOT(setCurrentItem(int)));
252 connect(this, SIGNAL(updateRotationIndex(int)), m_pRotationBox
, SLOT(setCurrentItem(int)));
253 connect(this, SIGNAL(updateFPSIndex(int)), m_pFPSBox
, SLOT(setCurrentItem(int)));
255 // selector selects a zoom index -> set the zoom index
256 connect(m_pZoomBox
, SIGNAL(activated(int)), this, SLOT(setZoomIndex(int)));
257 connect(m_pRotationBox
, SIGNAL(activated(int)), this, SLOT(setRotationIndex(int)));
258 connect(m_pFPSBox
, SIGNAL(activated(int)), this, SLOT(setFPSIndex(int)));
262 * Save options to config file.
264 void KmagApp::saveOptions()
266 config
->setGroup("General Options");
267 config
->writeEntry("Geometry", size());
268 config
->writeEntry("ZoomIndex", m_zoomIndex
);
269 config
->writeEntry("RotationIndex", m_rotationIndex
);
270 config
->writeEntry("FPSIndex", m_fpsIndex
);
271 config
->writeEntry("SelRect", m_zoomView
->getSelRectPos());
272 config
->writeEntry("ShowMouse", m_zoomView
->getShowMouseType());
274 if (m_modeFollowMouse
->isChecked())
275 config
->writeEntry("Mode", "followmouse");
276 else if (m_modeWholeScreen
->isChecked())
277 config
->writeEntry("Mode", "wholescreen");
278 else if (m_modeSelWin
->isChecked())
279 config
->writeEntry("Mode", "selectionwindow");
281 config
->writeEntry("ShowMenu", m_pShowMenu
->isChecked());
282 config
->writeEntry("ShowMainToolBar", m_pShowMainToolBar
->isChecked());
283 config
->writeEntry("ShowViewToolBar", m_pShowViewToolBar
->isChecked());
284 config
->writeEntry("ShowSettingsToolBar", m_pShowSettingsToolBar
->isChecked());
286 toolBar("mainToolBar")->saveSettings(config
,"Main ToolBar");
287 toolBar("viewToolBar")->saveSettings(config
,"View ToolBar");
288 toolBar("settingsToolBar")->saveSettings(config
,"Settings ToolBar");
293 * Read settings from config file.
295 void KmagApp::readOptions()
297 QColor
blue (0,0,128);
298 QColor
yellow (255,255,0);
299 QColor
white (255,255,255);
301 config
->setGroup ("WM");
303 config
->readEntry("inactiveBackground", blue
),
304 config
->readEntry("inactiveForeground", white
),
305 config
->readEntry("inactiveTitleBtnBg", yellow
));
307 config
->setGroup("General Options");
309 QSize
defSize(460,390);
310 QSize size
=config
->readEntry("Geometry", defSize
);
316 // set zoom - defaults to 2x
317 unsigned int zoomIndex
= config
->readEntry("ZoomIndex", 4);
318 setZoomIndex(zoomIndex
);
319 emit
updateZoomIndex(m_zoomIndex
);
321 unsigned int rotationIndex
= config
->readEntry("RotationIndex", 0);
322 setRotationIndex(rotationIndex
);
323 emit
updateRotationIndex(m_rotationIndex
);
325 unsigned int fpsIndex
= config
->readEntry("FPSIndex", 2);
326 setFPSIndex(fpsIndex
);
327 emit
updateFPSIndex(m_fpsIndex
);
329 QString mode
= config
->readEntry("Mode", "followmouse");
330 if (mode
== "wholescreen")
331 slotModeWholeScreen();
332 else if (mode
== "selectionwindow")
335 slotModeFollowMouse();
337 QRect
defaultRect(0,0,211,164);
338 m_zoomView
->setSelRectPos(config
->readEntry("SelRect", defaultRect
));
340 m_mouseCursorType
= config
->readEntry("ShowMouse", m_defaultMouseCursorType
);
341 m_zoomView
->showMouse(m_mouseCursorType
);
342 if(m_mouseCursorType
)
343 m_hideCursor
->setChecked(false);
345 m_hideCursor
->setChecked(true);
347 if(config
->hasGroup("Settings ToolBar"))
348 toolBar("settingsToolBar")->applySettings(config
,"Settings ToolBar");
350 if(config
->hasGroup("Main ToolBar"))
351 toolBar("mainToolBar")->applySettings(config
,"Main ToolBar");
353 if(config
->hasGroup("View ToolBar"))
354 toolBar("viewToolBar")->applySettings(config
,"View ToolBar");
356 m_pShowMenu
->setChecked(config
->readEntry("ShowMenu", QVariant(true)).toBool());
359 m_pShowMainToolBar
->setChecked(config
->readEntry("ShowMainToolBar", QVariant(false)).toBool());
360 slotShowMainToolBar();
362 m_pShowViewToolBar
->setChecked(config
->readEntry("ShowViewToolBar", QVariant(true)).toBool());
363 slotShowViewToolBar();
365 m_pShowSettingsToolBar
->setChecked(config
->readEntry("ShowSettingsToolBar", QVariant(true)).toBool());
366 slotShowSettingsToolBar();
369 bool KmagApp::queryClose()
374 bool KmagApp::queryExit()
381 * Called when mouse is clicked inside the window
385 void KmagApp::contextMenuEvent ( QContextMenuEvent
* e
)
388 KXMLGUIFactory
*factory
= this->factory();
389 QMenu
*popup
= (QMenu
*)factory
->container("mainPopUp",this);
391 popup
->popup(e
->globalPos(), 0);
396 /////////////////////////////////////////////////////////////////////
397 // SLOT IMPLEMENTATION
398 /////////////////////////////////////////////////////////////////////
401 * Shows/hides the mouse cursor
403 void KmagApp::showMouseCursor(bool show
)
406 if(m_mouseCursorType
== 0)
407 m_mouseCursorType
= m_defaultMouseCursorType
;
408 m_zoomView
->showMouse(m_mouseCursorType
);
410 m_zoomView
->showMouse(0);
417 void KmagApp::zoomIn()
419 // set the new index .. checking will done inside setZoom
420 setZoomIndex(m_zoomIndex
+1);
421 // signal change in zoom index
422 emit
updateZoomIndex((int)m_zoomIndex
);
428 void KmagApp::zoomOut()
430 // set the new index .. checking will done inside setZoom
431 setZoomIndex(m_zoomIndex
-1);
432 // signal change in zoom index
433 emit
updateZoomIndex((int)m_zoomIndex
);
436 * Sets the zoom index to index
438 void KmagApp::setZoomIndex(int index
)
440 if(index
< 0 || index
>= (int)zoomArray
.size()) {
441 // the index is invalid
442 kWarning() << "Invalid index!" << endl
;
444 } else if((int)m_zoomIndex
== index
) {
451 if(m_zoomIndex
== 0) {
452 // meaning that no more zooming-out is possible
453 // -> disable zoom-out icon
454 m_pZoomOut
->setEnabled(false);
455 } else { // enable the icon
456 m_pZoomOut
->setEnabled(true);
459 if(m_zoomIndex
== zoomArray
.size()-1) {
460 // meaning that no more zooming-in is possible
461 // -> disable zoom-in icon
462 m_pZoomIn
->setEnabled(false);
463 } else { // enable the icon
464 m_pZoomIn
->setEnabled(true);
467 // signal change in zoom value
468 emit
updateZoomValue(zoomArray
[m_zoomIndex
]);
472 * Sets the rotation index to index
474 void KmagApp::setRotationIndex(int index
)
476 if(index
< 0 || index
>= (int)rotationArray
.size()) {
477 // the index is invalid
478 kWarning() << "Invalid index!" << endl
;
480 } else if((int)m_rotationIndex
== index
) {
484 m_rotationIndex
= index
;
487 // signal change in zoom value
488 emit
updateRotationValue(rotationArray
[m_rotationIndex
]);
492 * Sets the fps index to index
494 void KmagApp::setFPSIndex(int index
)
496 if(index
< 0 || index
>= (int)fpsArray
.size()) {
497 // the index is invalid
498 kWarning() << "Invalid index!" << endl
;
500 } else if((int)m_fpsIndex
== index
) {
507 // signal change in fps value
508 emit
updateFPSValue(fpsArray
[m_fpsIndex
]);
513 * Save the zoomed image
515 void KmagApp::saveZoomPixmap()
519 // stop refresh temporarily
520 if (m_zoomView
->getRefreshStatus()) {
525 KUrl url
= KFileDialog::getSaveUrl(QString(),
526 KImageIO::pattern(KImageIO::Writing
),
527 0,i18n("Save Snapshot As"));
529 if(!url
.fileName().isEmpty()) {
530 if(!url
.isLocalFile()) {
531 // create a temp file.. save image to it.. copy over the n/w and then delete the temp file.
532 KTemporaryFile tempFile
;
534 #warning "kde4: port KImageIO::type \n";
536 if(!tempFile
.open() || !m_zoomView
->getPixmap().save(tempFile
.fileName(),"png"/*, KImageIO::type(url.fileName()).latin1()*/)) {
537 KMessageBox::error(0, i18n("Unable to save temporary file (before uploading to the network file you specified)."),
538 i18n("Error Writing File"));
540 if(!KIO::NetAccess::upload(tempFile
.fileName(), url
, this)) {
541 KMessageBox::error(0, i18n("Unable to upload file over the network."),
542 i18n("Error Writing File"));
544 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url
.prettyUrl()),
545 i18n("Information"), "save_confirm");
551 #warning "kde4 : port KImageIO::type(...) \n";
553 if(!m_zoomView
->getPixmap().save(url
.path(), "png"/*KImageIO::type(url.fileName()).latin1()*/)) {
554 KMessageBox::error(0, i18n("Unable to save file. Please check if you have permission to write to the directory."),
555 i18n("Error Writing File"));
557 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url
.prettyUrl()),
558 i18n("Information"), "save_confirm");
568 void KmagApp::slotToggleRefresh()
570 m_zoomView
->toggleRefresh();
571 if(m_zoomView
->getRefreshStatus()) {
572 refreshSwitch
->setIcon(KIcon("stop.png"));
573 refreshSwitch
->setText(i18n("Stop"));
574 refreshSwitch
->setToolTip(i18n("Click to stop window update"));
576 refreshSwitch
->setIcon(KIcon("reload.png"));
577 refreshSwitch
->setText(i18n("Start"));
578 refreshSwitch
->setToolTip(i18n("Click to start window update"));
583 void KmagApp::slotModeWholeScreen()
585 m_zoomView
->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
586 m_zoomView
->followMouse(false);
587 m_zoomView
->showSelRect(false);
588 m_zoomView
->setFitToWindow (false);
589 m_modeFollowMouse
->setChecked(false);
590 m_modeWholeScreen
->setChecked(true);
591 m_modeSelWin
->setChecked(false);
595 void KmagApp::slotModeSelWin()
597 m_zoomView
->followMouse(false);
598 m_zoomView
->showSelRect(true);
599 m_zoomView
->setFitToWindow (false);
600 m_modeFollowMouse
->setChecked(false);
601 m_modeWholeScreen
->setChecked(false);
602 m_modeSelWin
->setChecked(true);
606 void KmagApp::slotModeFollowMouse()
608 m_zoomView
->followMouse(true);
609 m_zoomView
->showSelRect(false);
610 m_zoomView
->setFitToWindow (true);
611 m_modeFollowMouse
->setChecked(true);
612 m_modeWholeScreen
->setChecked(false);
613 m_modeSelWin
->setChecked(false);
617 void KmagApp::slotToggleHideCursor()
619 showMouseCursor(!m_hideCursor
->isChecked());
623 void KmagApp::slotFileNewWindow()
625 KmagApp
*new_window
= new KmagApp();
630 void KmagApp::slotFilePrint()
632 #ifndef QT_NO_PRINTER
638 // stop refresh temporarily
639 if (m_zoomView
->getRefreshStatus()) {
644 const QPixmap
pixmap(m_zoomView
->getPixmap());
646 // use some AI to get the best orientation
647 if(pixmap
.width() > pixmap
.height()) {
648 printer
.setOrientation(KPrinter::Landscape
);
650 printer
.setOrientation(KPrinter::Portrait
);
653 if (printer
.setup(this)) {
656 if(!paint
.begin(&printer
))
659 paint
.drawPixmap(0, 0, pixmap
);
667 #endif // QT_NO_PRINTER
670 void KmagApp::slotFileQuit()
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
676 if (!memberList().isEmpty())
678 for (int i
= 0; i
< memberList().size(); ++i
)
680 w
= memberList().at(i
);
681 // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
682 // the window and the application stay open.
686 #warning "kde4: now memberList() is constant => we can't remove some element!"
688 //memberList()->removeRef(w);
693 void KmagApp::copyToClipBoard()
695 QClipboard
*cb
=KApplication::clipboard();
696 cb
->setPixmap(m_zoomView
->getPixmap());
699 void KmagApp::slotShowMenu()
701 ///////////////////////////////////////////////////////////////////
702 // turn Menu on or off
703 if(!m_pShowMenu
->isChecked())
715 void KmagApp::slotShowMainToolBar()
717 ///////////////////////////////////////////////////////////////////
718 // turn mainToolbar on or off
719 if(!m_pShowMainToolBar
->isChecked())
721 toolBar("mainToolBar")->hide();
725 toolBar("mainToolBar")->show();
729 void KmagApp::slotShowViewToolBar()
731 ///////////////////////////////////////////////////////////////////
732 // turn viewToolbar on or off
733 if(!m_pShowViewToolBar
->isChecked())
735 toolBar("viewToolBar")->hide();
739 toolBar("viewToolBar")->show();
743 void KmagApp::slotShowSettingsToolBar()
745 ///////////////////////////////////////////////////////////////////
746 // turn viewToolbar on or off
747 if(!m_pShowSettingsToolBar
->isChecked())
749 toolBar("settingsToolBar")->hide();
753 toolBar("settingsToolBar")->show();
757 void KmagApp::slotConfKeys()
759 KKeyDialog::configure( actionCollection() );
762 void KmagApp::slotEditToolbars()
764 saveMainWindowSettings( KGlobal::config(), "MainWindow" );
765 KEditToolbar
dlg( actionCollection() );
766 connect( &dlg
, SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() ) );
772 void KmagApp::slotNewToolbarConfig()
774 applyMainWindowSettings( KGlobal::config(), "MainWindow" );