Commit 24642a74 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@5250 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 96200724
#include <QtGui>
#include "PrintPlugin.hh"
#include <iostream>
#include <ACG/GL/GLState.hh>
#include <ACG/GL/GLState.hh>
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
......@@ -13,60 +13,57 @@ void PrintPlugin::pluginsInitialized()
{
// color menu
QMenu *printMenu = new QMenu(tr("&Printing"));
QIcon icon;
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png");
printMenu->setIcon(icon);
emit addMenu( printMenu, FILEMENU );
printMenu->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png"));
emit addMenubarAction(printMenu->menuAction(), FILEMENU );
QAction* AC_Print = new QAction(tr("&Print"), this);;
AC_Print->setStatusTip(tr("Print the current view"));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png");
AC_Print->setIcon(icon);
AC_Print->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"document-print.png"));
connect(AC_Print, SIGNAL(triggered()), this, SLOT(printView()));
printMenu->addAction(AC_Print);
}
void PrintPlugin::printView () {
QPrinter printer(QPrinter::HighResolution);
QPrintDialog *dialog = new QPrintDialog(&printer);
dialog->setWindowTitle("Print Current View");
if (dialog->exec() != QDialog::Accepted)
return;
QImage image;
// create the snapshot
PluginFunctions::getCurrentViewImage(image);
QPainter painter;
painter.begin(&printer);
painter.save();
QRect rect = painter.viewport();
QSize size = image.size();
size.scale(rect.size(), Qt::KeepAspectRatio);
painter.setViewport(rect.x(), rect.y(), size.width(), size.height());
painter.setWindow(image.rect());
painter.drawImage(0, 0, image);
painter.restore();
painter.end();
}
}
void PrintPlugin::slotKeyEvent( QKeyEvent* _event ) {
if (_event->modifiers() == Qt::ControlModifier ) {
switch (_event->key())
switch (_event->key())
{
case Qt::Key_P :
case Qt::Key_P :
printView();
return;
}
......
......@@ -18,7 +18,7 @@ class PrintPlugin : public QObject, BaseInterface, MenuInterface, KeyInterface
Q_INTERFACES(KeyInterface)
signals:
void addMenu(QMenu* _menu, MenuType _type);
void addMenubarAction(QAction* _action, MenuActionType _type );
private slots:
void pluginsInitialized();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment