Back to index

texmacs  1.0.7.15
Public Slots | Public Member Functions | Public Attributes | Private Attributes
QTMImagePreview Class Reference

#include <QTMFileDialog.hpp>

List of all members.

Public Slots

void setImage (const QString &)

Public Member Functions

 QTMImagePreview (QWidget *parent=0)

Public Attributes

QLineEdit * wid
QLineEdit * hei
QLineEdit * xps
QLineEdit * yps

Private Attributes

QLabel * image

Detailed Description

Definition at line 58 of file QTMFileDialog.hpp.


Constructor & Destructor Documentation

QTMImagePreview::QTMImagePreview ( QWidget *  parent = 0)

Definition at line 88 of file QTMFileDialog.cpp.

  : QWidget (parent) {
  QVBoxLayout* vbox= new QVBoxLayout (this);
  vbox->addStretch ();
  image= new QLabel (this);
  image->setMinimumWidth (100);
  image->setAlignment (Qt::AlignCenter);
  vbox->addWidget (image);
  vbox->addSpacing (10);
  wid= new QLineEdit (this);
  vbox->addWidget (simple_input ("Width:", wid, this));
  hei= new QLineEdit (this);
  vbox->addWidget (simple_input ("Height:", hei, this));
  xps= new QLineEdit (this);
  vbox->addWidget (simple_input ("X-position:", xps, this));
  yps= new QLineEdit (this);
  vbox->addWidget (simple_input ("Y-position:", yps, this));
  vbox->addStretch ();
  vbox->addStretch ();
  setLayout (vbox);
  setMinimumWidth (175);
  setMaximumWidth (225);
  setImage (0);
}

Here is the call graph for this function:


Member Function Documentation

void QTMImagePreview::setImage ( const QString &  file) [slot]

Definition at line 114 of file QTMFileDialog.cpp.

                                              {
  QImage img;
  wid->setText ("");
  hei->setText ("");
  xps->setText ("");
  yps->setText ("");

  if (file.endsWith (".ps") ||
      file.endsWith (".eps") ||
      file.endsWith (".pdf")) {
    url temp= url_temp (".png");
    url image_url= url_system (scm_unquote (from_qstring_utf8 (file)));
    int w_pt, h_pt;
    double w, h;
    image_size (image_url, w_pt, h_pt);
    if (w_pt > h_pt) {
      w= 98;
      h= h_pt*98/w_pt;
      if ((int)h < h) h= (int)h+1; else h= (int)h;
    }
    else {
      w= w_pt*98/h_pt;
      if ((int)w < w) w= (int)w+1; else w= (int)w;
      h= 98;
    }
    image_to_png (image_url, temp, w, h);
    img.load (utf8_to_qstring (as_string (temp)));
    remove (temp);
  }
  else {
    img.load (file);
    if (!img.isNull()) {
      wid->setText (QString::number (img.width ()) + "px");
      hei->setText (QString::number (img.height ()) + "px");
    }
  }

  if (img.isNull()) {
    QImage vide (100, 100, QImage::Format_RGB32);
    QPainter painter;
    painter.begin (&vide);
    painter.fillRect (0, 0, 100, 100, Qt::white);
    QPen ThinBlack (Qt::black);
    ThinBlack.setWidth (0);
    ThinBlack.setStyle (Qt::SolidLine);
    painter.setPen (ThinBlack);
    painter.drawLine (0, 0, 99, 99);
    painter.drawLine (0, 99, 99, 0);
    painter.drawRect (0, 0, 99, 99);
    painter.end ();
    image->setPixmap(QPixmap::fromImage(vide));
  }
  else
    image->setPixmap (QPixmap::fromImage (img.scaled (98, 98, Qt::KeepAspectRatio, Qt::FastTransformation)));
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 66 of file QTMFileDialog.hpp.

QLabel* QTMImagePreview::image [private]

Definition at line 62 of file QTMFileDialog.hpp.

Definition at line 65 of file QTMFileDialog.hpp.

Definition at line 67 of file QTMFileDialog.hpp.

Definition at line 68 of file QTMFileDialog.hpp.


The documentation for this class was generated from the following files: