TDE core libraries
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

previewtest.cpp 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #include <tqlabel.h>
  2. #include <tqlayout.h>
  3. #include <tqpushbutton.h>
  4. #include <tdeapplication.h>
  5. #include <kdebug.h>
  6. #include <klineedit.h>
  7. #include <tdeio/previewjob.h>
  8. #include "previewtest.moc"
  9. PreviewTest::PreviewTest()
  10. :TQWidget()
  11. {
  12. TQGridLayout *layout = new TQGridLayout(this, 2, 2);
  13. m_url = new KLineEdit(this);
  14. m_url->setText("/home/malte/gore_bush.jpg");
  15. layout->addWidget(m_url, 0, 0);
  16. TQPushButton *btn = new TQPushButton("Generate", this);
  17. connect(btn, TQT_SIGNAL(clicked()), TQT_SLOT(slotGenerate()));
  18. layout->addWidget(btn, 0, 1);
  19. m_preview = new TQLabel(this);
  20. m_preview->setMinimumSize(400, 300);
  21. layout->addMultiCellWidget(m_preview, 1, 1, 0, 1);
  22. }
  23. void PreviewTest::slotGenerate()
  24. {
  25. KURL::List urls;
  26. urls.append(m_url->text());
  27. TDEIO::PreviewJob *job = TDEIO::filePreview(urls, m_preview->width(), m_preview->height(), true, 48);
  28. connect(job, TQT_SIGNAL(result(TDEIO::Job*)), TQT_SLOT(slotResult(TDEIO::Job*)));
  29. connect(job, TQT_SIGNAL(gotPreview(const KFileItem *, const TQPixmap &)), TQT_SLOT(slotPreview(const KFileItem *, const TQPixmap &)));
  30. connect(job, TQT_SIGNAL(failed(const KFileItem *)), TQT_SLOT(slotFailed()));
  31. }
  32. void PreviewTest::slotResult(TDEIO::Job*)
  33. {
  34. kdDebug() << "PreviewTest::slotResult(...)" << endl;
  35. }
  36. void PreviewTest::slotPreview(const KFileItem *, const TQPixmap &pix)
  37. {
  38. kdDebug() << "PreviewTest::slotPreview()" << endl;
  39. m_preview->setPixmap(pix);
  40. }
  41. void PreviewTest::slotFailed()
  42. {
  43. kdDebug() << "PreviewTest::slotFailed()" << endl;
  44. m_preview->setText("failed");
  45. }
  46. int main(int argc, char **argv)
  47. {
  48. TDEApplication app(argc, argv, "previewtest", true, true);
  49. PreviewTest *w = new PreviewTest;
  50. w->show();
  51. app.setMainWidget(w);
  52. return app.exec();
  53. }