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
21 #include <QtCore/QDir>
22 #include <QtGui/QPrinter>
23 #include <QtGui/QPrintDialog>
24 #include <QtGui/QPainter>
25 #include <QtGui/QLayout>
26 #include <QtGui/QClipboard>
27 #include <Qt3Support/Q3DragObject>
28 #include <Qt3Support/Q3PopupMenu>
29 #include <QtGui/QContextMenuEvent>
30 #include <QtGui/QPixmap>
31 #include <QtGui/QDesktopWidget>
33 // include files for KDE
34 #include <kxmlguiclient.h>
36 #include <ktoggleaction.h>
37 #include <kactioncollection.h>
38 #include <kselectaction.h>
39 #include <kdeversion.h>
40 #include <kxmlguifactory.h>
42 #include <kapplication.h>
43 #include <kstandardshortcut.h>
44 #include <kshortcutsdialog.h>
45 #include <kiconloader.h>
46 #include <kmessagebox.h>
47 #include <kfiledialog.h>
52 #include <kstandardaction.h>
53 #include <khelpmenu.h>
56 #include <kio/netaccess.h>
57 #include <ktemporaryfile.h>
59 #include <kedittoolbar.h>
62 // application specific includes
64 #include "kmagzoomview.h"
65 #include "kmagselrect.h"
68 #define havesetCheckedState
70 KmagApp::KmagApp(QWidget
* , const char* name
)
71 : KXmlGuiWindow(0, Qt::WStyle_MinMax
| Qt::WType_TopLevel
| Qt::WDestructiveClose
| Qt::WStyle_ContextHelp
| Qt::WStyle_StaysOnTop
),
72 m_defaultMouseCursorType(2)
75 config
=KGlobal::config();
77 zoomArrayString
<< "5:1" << "2:1" << "1:1" << "1:1.5" << "1:2" << "1:3" << "1:4" << "1:5"
78 << "1:6" << "1:7" << "1:8" << "1:12" << "1:16" << "1:20";
80 // Is there a better way to initialize a vector array?
81 zoomArray
.push_back(0.2); zoomArray
.push_back(0.5); zoomArray
.push_back(1.0);
82 zoomArray
.push_back(1.5); zoomArray
.push_back(2.0); zoomArray
.push_back(3.0);
83 zoomArray
.push_back(4.0); zoomArray
.push_back(5.0); zoomArray
.push_back(6.0); zoomArray
.push_back(7.0);
84 zoomArray
.push_back(8.0); zoomArray
.push_back(12.0); zoomArray
.push_back(16.0); zoomArray
.push_back(20.0);
86 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");
88 fpsArray
.push_back(2); // very low
89 fpsArray
.push_back(6); // low
90 fpsArray
.push_back(10); // medium
91 fpsArray
.push_back(15); // high
92 fpsArray
.push_back(25); // very high
94 rotationArrayString
<< i18n("&No Rotation (0 Degrees)") << i18n("&Left (90 Degrees)") << i18n("&Upside Down (180 Degrees)") << i18n("&Right (270 Degrees)");
96 rotationArray
.push_back(0); // no rotation
97 rotationArray
.push_back(90); // left
98 rotationArray
.push_back(180); // upside down
99 rotationArray
.push_back(270); // right
101 // call inits to invoke all other construction parts
106 // read options from config file
112 * Default destructor.
116 m_zoomView
->showSelRect(false);
119 void KmagApp::initActions()
121 fileNewWindow
= actionCollection()->addAction("new_window");
122 fileNewWindow
->setIcon(KIcon("window-new"));
123 fileNewWindow
->setText(i18n("New &Window"));
124 connect(fileNewWindow
, SIGNAL(triggered(bool) ), SLOT(slotFileNewWindow()));
125 fileNewWindow
->setShortcuts(KStandardShortcut::openNew());
126 fileNewWindow
->setToolTip(i18n("Open a new KMagnifier window"));
128 refreshSwitch
= actionCollection()->addAction("start_stop_refresh");
129 refreshSwitch
->setIcon(KIcon("process-stop"));
130 refreshSwitch
->setText(i18n("&Stop"));
131 connect(refreshSwitch
, SIGNAL(triggered(bool) ), SLOT(slotToggleRefresh()));
132 refreshSwitch
->setShortcuts(KStandardShortcut::reload());
133 refreshSwitch
->setToolTip(i18n("Click to stop window refresh"));
134 refreshSwitch
->setWhatsThis(i18n("Clicking on this icon will <b>start</b> / <b>stop</b>\
135 updating of the display. Stopping the update will zero the processing power\
136 required (CPU usage)"));
138 m_pSnapshot
= actionCollection()->addAction("snapshot");
139 m_pSnapshot
->setIcon(KIcon("ksnapshot"));
140 m_pSnapshot
->setText(i18n("&Save Snapshot As..."));
141 connect(m_pSnapshot
, SIGNAL(triggered(bool) ), SLOT(saveZoomPixmap()));
142 m_pSnapshot
->setShortcuts(KStandardShortcut::save());
143 m_pSnapshot
->setWhatsThis(i18n("Saves the zoomed view to an image file."));
144 m_pSnapshot
->setToolTip(i18n("Save image to a file"));
146 m_pPrint
= actionCollection()->addAction(KStandardAction::Print
, this, SLOT(slotFilePrint()));
147 m_pPrint
->setWhatsThis(i18n("Click on this button to print the current zoomed view."));
149 m_pQuit
= actionCollection()->addAction(KStandardAction::Quit
, this, SLOT(slotFileQuit()));
150 m_pQuit
->setToolTip(i18n("Quits the application"));
151 m_pQuit
->setWhatsThis (i18n("Quits the application"));
153 m_pCopy
= actionCollection()->addAction(KStandardAction::Copy
, this, SLOT(copyToClipBoard()));
154 m_pCopy
->setWhatsThis(i18n("Click on this button to copy the current zoomed view to the clipboard which you can paste in other applications."));
155 m_pCopy
->setToolTip(i18n("Copy zoomed image to clipboard"));
157 m_pShowMenu
= new KToggleAction(KIcon("show-menu"), i18n("Show &Menu"), this);
158 actionCollection()->addAction("show_menu", m_pShowMenu
);
159 connect(m_pShowMenu
, SIGNAL(triggered(bool)), SLOT(slotShowMenu()));
160 m_pShowMenu
->setShortcut(Qt::CTRL
+Qt::Key_M
);
161 #ifdef havesetCheckedState
162 m_pShowMenu
->setCheckedState(KGuiItem(i18n("Hide &Menu")));
164 m_pShowMainToolBar
= new KToggleAction(i18n("Show Main &Toolbar"), this);
165 actionCollection()->addAction("show_mainToolBar", m_pShowMainToolBar
);
166 connect(m_pShowMainToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowMainToolBar()));
167 #ifdef havesetCheckedState
168 m_pShowMainToolBar
->setCheckedState(KGuiItem(i18n("Hide Main &Toolbar")));
170 m_pShowViewToolBar
= new KToggleAction(i18n("Show &View Toolbar"), this);
171 actionCollection()->addAction("show_viewToolBar", m_pShowViewToolBar
);
172 connect(m_pShowViewToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowViewToolBar()));
173 #ifdef havesetCheckedState
174 m_pShowViewToolBar
->setCheckedState(KGuiItem(i18n("Hide &View Toolbar")));
176 m_pShowSettingsToolBar
= new KToggleAction(i18n("Show &Settings Toolbar"), this);
177 actionCollection()->addAction("show_settingsToolBar", m_pShowSettingsToolBar
);
178 connect(m_pShowSettingsToolBar
, SIGNAL(triggered(bool)), SLOT(slotShowSettingsToolBar()));
179 #ifdef havesetCheckedState
180 m_pShowSettingsToolBar
->setCheckedState(KGuiItem(i18n("Hide &Settings Toolbar")));
183 m_modeFollowMouse
= new KToggleAction(KIcon("followmouse"), i18n("&Follow Mouse Mode"), this);
184 actionCollection()->addAction("mode_followmouse", m_modeFollowMouse
);
185 connect(m_modeFollowMouse
, SIGNAL(triggered(bool)), SLOT(slotModeFollowMouse()));
186 m_modeFollowMouse
->setShortcut(Qt::Key_F1
);
187 m_modeFollowMouse
->setToolTip(i18n("Magnify around the mouse cursor"));
188 m_modeFollowMouse
->setWhatsThis(i18n("If selected, the area around the mouse cursor is magnified"));
190 m_modeSelWin
= new KToggleAction(KIcon("window"), i18n("Se&lection Window Mode"), this);
191 actionCollection()->addAction("mode_selectionwindow", m_modeSelWin
);
192 connect(m_modeSelWin
, SIGNAL(triggered(bool)), SLOT(slotModeSelWin()));
193 m_modeSelWin
->setShortcut(Qt::Key_F2
);
194 m_modeSelWin
->setToolTip(i18n("Show a window for selecting the magnified area"));
196 m_modeWholeScreen
= new KToggleAction(KIcon("view-fullscreen"), i18n("&Whole Screen Mode"), this);
197 actionCollection()->addAction("mode_wholescreen", m_modeWholeScreen
);
198 connect(m_modeWholeScreen
, SIGNAL(triggered(bool)), SLOT(slotModeWholeScreen()));
199 m_modeWholeScreen
->setShortcut(Qt::Key_F3
);
200 m_modeWholeScreen
->setToolTip(i18n("Magnify the whole screen"));
201 m_modeWholeScreen
->setWhatsThis(i18n("Click on this button to fit the zoom view to the zoom window."));
203 m_hideCursor
= new KToggleAction(KIcon("hidemouse"), i18n("Hide Mouse &Cursor"), this);
204 actionCollection()->addAction("hidecursor", m_hideCursor
);
205 connect(m_hideCursor
, SIGNAL(triggered(bool)), SLOT(slotToggleHideCursor()));
206 m_hideCursor
->setShortcut(Qt::Key_F4
);
207 #ifdef havesetCheckedState
208 m_hideCursor
->setCheckedState(KGuiItem(i18n("Show Mouse &Cursor")));
210 m_hideCursor
->setToolTip(i18n("Hide the mouse cursor"));
212 m_pZoomIn
= actionCollection()->addAction(KStandardAction::ZoomIn
, this, SLOT(zoomIn()));
213 m_pZoomIn
->setWhatsThis(i18n("Click on this button to <b>zoom-in</b> on the selected region."));
215 m_pZoomBox
= new KSelectAction(i18n("&Zoom"), this);
216 actionCollection()->addAction("zoom", m_pZoomBox
);
217 m_pZoomBox
->setItems(zoomArrayString
);
218 m_pZoomBox
->setWhatsThis(i18n("Select the zoom factor."));
219 m_pZoomBox
->setToolTip(i18n("Zoom factor"));
221 m_pZoomOut
= actionCollection()->addAction(KStandardAction::ZoomOut
, this, SLOT(zoomOut()));
222 m_pZoomOut
->setWhatsThis(i18n("Click on this button to <b>zoom-out</b> on the selected region."));
224 m_pRotationBox
= new KSelectAction(i18n("&Rotation"),this);
225 actionCollection()->addAction("rotation", m_pRotationBox
);
226 m_pRotationBox
->setItems(rotationArrayString
);
227 m_pRotationBox
->setWhatsThis(i18n("Select the rotation degree."));
228 m_pRotationBox
->setToolTip(i18n("Rotation degree"));
230 // KHelpMenu *newHelpMenu = new KHelpMenu(this, KGlobal::mainComponent().aboutData());
232 m_keyConf
= actionCollection()->addAction(KStandardAction::KeyBindings
, this, SLOT(slotConfKeys()));
233 m_toolConf
= actionCollection()->addAction(KStandardAction::ConfigureToolbars
, this, SLOT(slotEditToolbars()));
235 m_pFPSBox
= new KSelectAction(i18n("&Refresh"),this);
236 actionCollection()->addAction("fps_selector", m_pFPSBox
);
237 m_pFPSBox
->setItems(fpsArrayString
);
238 m_pFPSBox
->setWhatsThis(i18n("Select the refresh rate. The higher the rate, the more computing power (CPU) will be needed."));
239 m_pFPSBox
->setToolTip(i18n("Refresh rate"));
244 void KmagApp::initView()
246 m_zoomView
= new KMagZoomView( this, "ZoomView" );
247 m_zoomView
->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType
)7, (QSizePolicy::SizeType
)7, m_zoomView
->sizePolicy().hasHeightForWidth() ) );
248 m_zoomView
->setFrameShape( QFrame::StyledPanel
);
249 m_zoomView
->setFrameShadow( QFrame::Raised
);
251 setCentralWidget(m_zoomView
);
255 void KmagApp::slotChangeZoomBoxIndex(int index
)
257 m_pZoomBox
->setCurrentItem(index
);
260 void KmagApp::slotChangeRotationBoxIndex(int index
)
262 m_pRotationBox
->setCurrentItem(index
);
265 void KmagApp::slotChangeFPSIndex(int index
)
267 m_pFPSBox
->setCurrentItem(index
);
272 * Initialize all connections.
274 void KmagApp::initConnections()
276 // change in zoom value -> update the view
277 connect(this, SIGNAL(updateZoomValue(float)), m_zoomView
, SLOT(setZoom(float)));
278 connect(this, SIGNAL(updateRotationValue(int)), m_zoomView
, SLOT(setRotation(int)));
279 connect(this, SIGNAL(updateFPSValue(float)), m_zoomView
, SLOT(setRefreshRate(float)));
281 // change in zoom index -> update the selector
282 connect(this, SIGNAL(updateZoomIndex(int)), this, SLOT(slotChangeZoomBoxIndex(int)));
283 connect(this, SIGNAL(updateRotationIndex(int)), this, SLOT(slotChangeRotationBoxIndex(int)));
284 connect(this, SIGNAL(updateFPSIndex(int)), this, SLOT(slotChangeFPSIndex(int)));
286 // selector selects a zoom index -> set the zoom index
287 connect(m_pZoomBox
, SIGNAL(triggered(int)), this, SLOT(setZoomIndex(int)));
288 connect(m_pRotationBox
, SIGNAL(triggered(int)), this, SLOT(setRotationIndex(int)));
289 connect(m_pFPSBox
, SIGNAL(triggered(int)), this, SLOT(setFPSIndex(int)));
293 * Save options to config file.
295 void KmagApp::saveOptions()
297 KConfigGroup
cg( config
, "General Options");
298 cg
.writeEntry("Geometry", size());
299 cg
.writeEntry("ZoomIndex", m_zoomIndex
);
300 cg
.writeEntry("RotationIndex", m_rotationIndex
);
301 cg
.writeEntry("FPSIndex", m_fpsIndex
);
302 cg
.writeEntry("SelRect", m_zoomView
->getSelRectPos());
303 cg
.writeEntry("ShowMouse", m_zoomView
->getShowMouseType());
305 if (m_modeFollowMouse
->isChecked())
306 cg
.writeEntry("Mode", "followmouse");
307 else if (m_modeWholeScreen
->isChecked())
308 cg
.writeEntry("Mode", "wholescreen");
309 else if (m_modeSelWin
->isChecked())
310 cg
.writeEntry("Mode", "selectionwindow");
312 cg
.writeEntry("ShowMenu", m_pShowMenu
->isChecked());
313 cg
.writeEntry("ShowMainToolBar", m_pShowMainToolBar
->isChecked());
314 cg
.writeEntry("ShowViewToolBar", m_pShowViewToolBar
->isChecked());
315 cg
.writeEntry("ShowSettingsToolBar", m_pShowSettingsToolBar
->isChecked());
317 KConfigGroup
mainToolBarGroup(config
,"Main ToolBar");
318 toolBar("mainToolBar")->saveSettings( mainToolBarGroup
);
319 KConfigGroup
viewToolBarGroup(config
,"View ToolBar" );
320 toolBar("viewToolBar")->saveSettings( viewToolBarGroup
);
321 KConfigGroup
settingsToolbarGroup(config
,"Settings ToolBar" );
322 toolBar("settingsToolBar")->saveSettings( settingsToolbarGroup
);
327 * Read settings from config file.
329 void KmagApp::readOptions()
331 QColor
blue (0,0,128);
332 QColor
yellow (255,255,0);
333 QColor
white (255,255,255);
335 KConfigGroup
cgWM( config
, "WM");
337 cgWM
.readEntry("inactiveBackground", blue
),
338 cgWM
.readEntry("inactiveForeground", white
),
339 cgWM
.readEntry("inactiveTitleBtnBg", yellow
));
341 KConfigGroup
cg(config
,"General Options");
343 QSize
defSize(460,390);
344 QSize size
=cg
.readEntry("Geometry", defSize
);
350 // set zoom - defaults to 2x
351 unsigned int zoomIndex
= cg
.readEntry("ZoomIndex", 4);
352 setZoomIndex(zoomIndex
);
353 emit
updateZoomIndex(m_zoomIndex
);
355 unsigned int rotationIndex
= cg
.readEntry("RotationIndex", 0);
356 setRotationIndex(rotationIndex
);
357 emit
updateRotationIndex(m_rotationIndex
);
359 unsigned int fpsIndex
= cg
.readEntry("FPSIndex", 2);
360 setFPSIndex(fpsIndex
);
361 emit
updateFPSIndex(m_fpsIndex
);
363 QString mode
= cg
.readEntry("Mode", "followmouse");
364 if (mode
== "wholescreen")
365 slotModeWholeScreen();
366 else if (mode
== "selectionwindow")
369 slotModeFollowMouse();
371 QRect
defaultRect(0,0,211,164);
372 m_zoomView
->setSelRectPos(cg
.readEntry("SelRect", defaultRect
));
374 m_mouseCursorType
= cg
.readEntry("ShowMouse", m_defaultMouseCursorType
);
375 m_zoomView
->showMouse(m_mouseCursorType
);
376 if(m_mouseCursorType
)
377 m_hideCursor
->setChecked(false);
379 m_hideCursor
->setChecked(true);
381 KConfigGroup
settingsToolbarGroup(config
,"Settings ToolBar");
382 if( settingsToolbarGroup
.exists() )
383 toolBar("settingsToolBar")->applySettings(settingsToolbarGroup
);
385 KConfigGroup
mainToolbarGroup(config
,"Main ToolBar");
386 if( mainToolbarGroup
.exists() )
387 toolBar("mainToolBar")->applySettings( mainToolbarGroup
);
389 KConfigGroup
viewToolbarGroup(config
,"View ToolBar" );
390 if( viewToolbarGroup
.exists() )
391 toolBar("viewToolBar")->applySettings( viewToolbarGroup
);
393 KConfigGroup
generalOptionGroup(config
,"General Options");
394 m_pShowMenu
->setChecked( generalOptionGroup
.readEntry("ShowMenu", true));
397 m_pShowMainToolBar
->setChecked(generalOptionGroup
.readEntry("ShowMainToolBar", false));
398 slotShowMainToolBar();
400 m_pShowViewToolBar
->setChecked(generalOptionGroup
.readEntry("ShowViewToolBar", true));
401 slotShowViewToolBar();
403 m_pShowSettingsToolBar
->setChecked(generalOptionGroup
.readEntry("ShowSettingsToolBar", true));
404 slotShowSettingsToolBar();
407 bool KmagApp::queryClose()
412 bool KmagApp::queryExit()
419 * Called when mouse is clicked inside the window
423 void KmagApp::contextMenuEvent ( QContextMenuEvent
* e
)
426 KXMLGUIFactory
*factory
= this->factory();
427 QMenu
*popup
= (QMenu
*)factory
->container("mainPopUp",this);
429 popup
->popup(e
->globalPos(), 0);
434 /////////////////////////////////////////////////////////////////////
435 // SLOT IMPLEMENTATION
436 /////////////////////////////////////////////////////////////////////
439 * Shows/hides the mouse cursor
441 void KmagApp::showMouseCursor(bool show
)
444 if(m_mouseCursorType
== 0)
445 m_mouseCursorType
= m_defaultMouseCursorType
;
446 m_zoomView
->showMouse(m_mouseCursorType
);
448 m_zoomView
->showMouse(0);
455 void KmagApp::zoomIn()
457 // set the new index .. checking will done inside setZoom
458 setZoomIndex(m_zoomIndex
+1);
459 // signal change in zoom index
460 emit
updateZoomIndex((int)m_zoomIndex
);
466 void KmagApp::zoomOut()
468 // set the new index .. checking will done inside setZoom
469 setZoomIndex(m_zoomIndex
-1);
470 // signal change in zoom index
471 emit
updateZoomIndex((int)m_zoomIndex
);
474 * Sets the zoom index to index
476 void KmagApp::setZoomIndex(int index
)
478 if(index
< 0 || index
>= (int)zoomArray
.size()) {
479 // the index is invalid
480 kWarning() << "Invalid index!" ;
482 } else if((int)m_zoomIndex
== index
) {
489 if(m_zoomIndex
== 0) {
490 // meaning that no more zooming-out is possible
491 // -> disable zoom-out icon
492 m_pZoomOut
->setEnabled(false);
493 } else { // enable the icon
494 m_pZoomOut
->setEnabled(true);
497 if(m_zoomIndex
== zoomArray
.size()-1) {
498 // meaning that no more zooming-in is possible
499 // -> disable zoom-in icon
500 m_pZoomIn
->setEnabled(false);
501 } else { // enable the icon
502 m_pZoomIn
->setEnabled(true);
505 // signal change in zoom value
506 emit
updateZoomValue(zoomArray
[m_zoomIndex
]);
510 * Sets the rotation index to index
512 void KmagApp::setRotationIndex(int index
)
514 if(index
< 0 || index
>= (int)rotationArray
.size()) {
515 // the index is invalid
516 kWarning() << "Invalid index!" ;
518 } else if((int)m_rotationIndex
== index
) {
522 m_rotationIndex
= index
;
525 // signal change in zoom value
526 emit
updateRotationValue(rotationArray
[m_rotationIndex
]);
530 * Sets the fps index to index
532 void KmagApp::setFPSIndex(int index
)
534 if(index
< 0 || index
>= (int)fpsArray
.size()) {
535 // the index is invalid
536 kWarning() << "Invalid index!" ;
538 } else if((int)m_fpsIndex
== index
) {
545 // signal change in fps value
546 emit
updateFPSValue(fpsArray
[m_fpsIndex
]);
551 * Save the zoomed image
553 void KmagApp::saveZoomPixmap()
557 // stop refresh temporarily
558 if (m_zoomView
->getRefreshStatus()) {
563 KUrl url
= KFileDialog::getSaveUrl(QString(),
564 KImageIO::pattern(KImageIO::Writing
),
565 0,i18n("Save Snapshot As"));
567 if(!url
.fileName().isEmpty()) {
568 if(!url
.isLocalFile()) {
569 // create a temp file.. save image to it.. copy over the n/w and then delete the temp file.
570 KTemporaryFile tempFile
;
572 #warning "kde4: port KImageIO::type \n";
574 if(!tempFile
.open() || !m_zoomView
->getPixmap().save(tempFile
.fileName(),"png"/*, KImageIO::type(url.fileName()).latin1()*/)) {
575 KMessageBox::error(0, i18n("Unable to save temporary file (before uploading to the network file you specified)."),
576 i18n("Error Writing File"));
578 if(!KIO::NetAccess::upload(tempFile
.fileName(), url
, this)) {
579 KMessageBox::error(0, i18n("Unable to upload file over the network."),
580 i18n("Error Writing File"));
582 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url
.prettyUrl()),
583 i18n("Information"), "save_confirm");
589 #warning "kde4 : port KImageIO::type(...) \n";
591 if(!m_zoomView
->getPixmap().save(url
.path(), "png"/*KImageIO::type(url.fileName()).latin1()*/)) {
592 KMessageBox::error(0, i18n("Unable to save file. Please check if you have permission to write to the directory."),
593 i18n("Error Writing File"));
595 KMessageBox::information(0, i18n("Current zoomed image saved to\n%1", url
.prettyUrl()),
596 i18n("Information"), "save_confirm");
606 void KmagApp::slotToggleRefresh()
608 m_zoomView
->toggleRefresh();
609 if(m_zoomView
->getRefreshStatus()) {
610 refreshSwitch
->setIcon(KIcon("stop.png"));
611 refreshSwitch
->setText(i18n("Stop"));
612 refreshSwitch
->setToolTip(i18n("Click to stop window update"));
614 refreshSwitch
->setIcon(KIcon("reload.png"));
615 refreshSwitch
->setText(i18n("Start"));
616 refreshSwitch
->setToolTip(i18n("Click to start window update"));
621 void KmagApp::slotModeWholeScreen()
623 m_zoomView
->setSelRectPos(QRect (0, 0, QApplication::desktop()->width(), QApplication::desktop()->height()));
624 m_zoomView
->followMouse(false);
625 m_zoomView
->showSelRect(false);
626 m_zoomView
->setFitToWindow (false);
627 m_modeFollowMouse
->setChecked(false);
628 m_modeWholeScreen
->setChecked(true);
629 m_modeSelWin
->setChecked(false);
633 void KmagApp::slotModeSelWin()
635 m_zoomView
->followMouse(false);
636 m_zoomView
->showSelRect(true);
637 m_zoomView
->setFitToWindow (false);
638 m_modeFollowMouse
->setChecked(false);
639 m_modeWholeScreen
->setChecked(false);
640 m_modeSelWin
->setChecked(true);
644 void KmagApp::slotModeFollowMouse()
646 m_zoomView
->followMouse(true);
647 m_zoomView
->showSelRect(false);
648 m_zoomView
->setFitToWindow (true);
649 m_modeFollowMouse
->setChecked(true);
650 m_modeWholeScreen
->setChecked(false);
651 m_modeSelWin
->setChecked(false);
655 void KmagApp::slotToggleHideCursor()
657 showMouseCursor(!m_hideCursor
->isChecked());
661 void KmagApp::slotFileNewWindow()
663 KmagApp
*new_window
= new KmagApp();
668 void KmagApp::slotFilePrint()
670 #ifndef QT_NO_PRINTER
676 // stop refresh temporarily
677 if (m_zoomView
->getRefreshStatus()) {
682 const QPixmap
pixmap(m_zoomView
->getPixmap());
684 // use some AI to get the best orientation
685 if(pixmap
.width() > pixmap
.height()) {
686 printer
.setOrientation(QPrinter::Landscape
);
688 printer
.setOrientation(QPrinter::Portrait
);
691 QPrintDialog
printDialog(&printer
, this);
693 if (printDialog
.exec()) {
696 if(!paint
.begin(&printer
))
699 paint
.drawPixmap(0, 0, pixmap
);
707 #endif // QT_NO_PRINTER
710 void KmagApp::slotFileQuit()
713 // close the first window, the list makes the next one the first again.
714 // This ensures that queryClose() is called on each window to ask for closing
716 if (!memberList().isEmpty())
718 for (int i
= 0; i
< memberList().size(); ++i
)
720 w
= memberList().at(i
);
721 // only close the window if the closeEvent is accepted. If the user presses Cancel on the saveModified() dialog,
722 // the window and the application stay open.
726 #warning "kde4: now memberList() is constant => we can't remove some element!"
728 //memberList()->removeRef(w);
733 void KmagApp::copyToClipBoard()
735 QClipboard
*cb
=KApplication::clipboard();
736 cb
->setPixmap(m_zoomView
->getPixmap());
739 void KmagApp::slotShowMenu()
741 ///////////////////////////////////////////////////////////////////
742 // turn Menu on or off
743 if(!m_pShowMenu
->isChecked())
755 void KmagApp::slotShowMainToolBar()
757 ///////////////////////////////////////////////////////////////////
758 // turn mainToolbar on or off
759 if(!m_pShowMainToolBar
->isChecked())
761 toolBar("mainToolBar")->hide();
765 toolBar("mainToolBar")->show();
769 void KmagApp::slotShowViewToolBar()
771 ///////////////////////////////////////////////////////////////////
772 // turn viewToolbar on or off
773 if(!m_pShowViewToolBar
->isChecked())
775 toolBar("viewToolBar")->hide();
779 toolBar("viewToolBar")->show();
783 void KmagApp::slotShowSettingsToolBar()
785 ///////////////////////////////////////////////////////////////////
786 // turn viewToolbar on or off
787 if(!m_pShowSettingsToolBar
->isChecked())
789 toolBar("settingsToolBar")->hide();
793 toolBar("settingsToolBar")->show();
797 void KmagApp::slotConfKeys()
799 KShortcutsDialog::configure( actionCollection() );
802 void KmagApp::slotEditToolbars()
804 KConfigGroup
cg( KGlobal::config(), "MainWindow" );
805 saveMainWindowSettings( cg
);
806 KEditToolBar
dlg( actionCollection() );
807 connect( &dlg
, SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() ) );
813 void KmagApp::slotNewToolbarConfig()
815 applyMainWindowSettings( KGlobal::config()->group( "MainWindow" ) );