51 #include <QPrintDialog>
54 #include "PrintPlugin.hh"
59 #if QT_VERSION >= 0x050000
64 void PrintPlugin::pluginsInitialized()
67 QMenu *printMenu =
new QMenu(tr(
"&Printing"));
69 printMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"document-print.png"));
71 emit addMenubarAction(printMenu->menuAction(),
FILEMENU );
73 QAction* AC_Print =
new QAction(tr(
"&Print"),
this);;
74 AC_Print->setStatusTip(tr(
"Print the current view"));
75 AC_Print->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"document-print.png"));
77 connect(AC_Print, SIGNAL(triggered()),
this, SLOT(printView()));
78 printMenu->addAction(AC_Print);
81 void PrintPlugin::printView () {
84 QPrinter printer(QPrinter::HighResolution);
86 QPrintDialog *dialog =
new QPrintDialog(&printer);
87 dialog->setWindowTitle(tr(
"Print Current View"));
88 if (dialog->exec() != QDialog::Accepted)
97 painter.begin(&printer);
101 QRect rect = painter.viewport();
102 QSize size = image.size();
103 size.scale(rect.size(), Qt::KeepAspectRatio);
104 painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
105 painter.setWindow(image.rect());
107 painter.drawImage(0, 0, image);
114 void PrintPlugin::slotKeyEvent( QKeyEvent* _event ) {
115 if (_event->modifiers() == Qt::ControlModifier ) {
116 switch (_event->key())
126 #if QT_VERSION < 0x050000
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.
#define FILEMENU
The Menu will be added inside the File Menu.