45 #include <QPrintDialog> 49 #include "PrintPlugin.hh" 55 void PrintPlugin::pluginsInitialized()
58 QMenu *printMenu =
new QMenu(tr(
"&Printing"));
60 printMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"document-print.png"));
62 emit addMenubarAction(printMenu->menuAction(),
FILEMENU );
64 QAction* AC_Print =
new QAction(tr(
"&Print"),
this);;
65 AC_Print->setStatusTip(tr(
"Print the current view"));
66 AC_Print->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"document-print.png"));
68 connect(AC_Print, SIGNAL(triggered()),
this, SLOT(printView()));
69 printMenu->addAction(AC_Print);
72 void PrintPlugin::printView () {
75 QPrinter printer(QPrinter::HighResolution);
77 QPrintDialog *dialog =
new QPrintDialog(&printer);
78 dialog->setWindowTitle(tr(
"Print Current View"));
79 if (dialog->exec() != QDialog::Accepted)
88 painter.begin(&printer);
92 QRect rect = painter.viewport();
93 QSize size = image.size();
94 size.scale(rect.size(), Qt::KeepAspectRatio);
95 painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
96 painter.setWindow(image.rect());
98 painter.drawImage(0, 0, image);
105 void PrintPlugin::slotKeyEvent( QKeyEvent* _event ) {
106 if (_event->modifiers() == Qt::ControlModifier ) {
107 switch (_event->key())
void getCurrentViewImage(QImage &_image)
Returns a QImage of the current View.