summaryrefslogtreecommitdiffstats
path: root/kio/tests/previewtest.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kio/tests/previewtest.cpp
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/tests/previewtest.cpp')
-rw-r--r--kio/tests/previewtest.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/kio/tests/previewtest.cpp b/kio/tests/previewtest.cpp
new file mode 100644
index 000000000..66fa9398e
--- /dev/null
+++ b/kio/tests/previewtest.cpp
@@ -0,0 +1,64 @@
+
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+
+#include <kapplication.h>
+#include <kdebug.h>
+#include <klineedit.h>
+
+#include <kio/previewjob.h>
+
+#include "previewtest.moc"
+
+PreviewTest::PreviewTest()
+ :QWidget()
+{
+ QGridLayout *layout = new QGridLayout(this, 2, 2);
+ m_url = new KLineEdit(this);
+ m_url->setText("/home/malte/gore_bush.jpg");
+ layout->addWidget(m_url, 0, 0);
+ QPushButton *btn = new QPushButton("Generate", this);
+ connect(btn, SIGNAL(clicked()), SLOT(slotGenerate()));
+ layout->addWidget(btn, 0, 1);
+ m_preview = new QLabel(this);
+ m_preview->setMinimumSize(400, 300);
+ layout->addMultiCellWidget(m_preview, 1, 1, 0, 1);
+}
+
+void PreviewTest::slotGenerate()
+{
+ KURL::List urls;
+ urls.append(m_url->text());
+ KIO::PreviewJob *job = KIO::filePreview(urls, m_preview->width(), m_preview->height(), true, 48);
+ connect(job, SIGNAL(result(KIO::Job*)), SLOT(slotResult(KIO::Job*)));
+ connect(job, SIGNAL(gotPreview(const KFileItem *, const QPixmap &)), SLOT(slotPreview(const KFileItem *, const QPixmap &)));
+ connect(job, SIGNAL(failed(const KFileItem *)), SLOT(slotFailed()));
+}
+
+void PreviewTest::slotResult(KIO::Job*)
+{
+ kdDebug() << "PreviewTest::slotResult(...)" << endl;
+}
+
+void PreviewTest::slotPreview(const KFileItem *, const QPixmap &pix)
+{
+ kdDebug() << "PreviewTest::slotPreview()" << endl;
+ m_preview->setPixmap(pix);
+}
+
+void PreviewTest::slotFailed()
+{
+ kdDebug() << "PreviewTest::slotFailed()" << endl;
+ m_preview->setText("failed");
+}
+
+int main(int argc, char **argv)
+{
+ KApplication app(argc, argv, "previewtest");
+ PreviewTest *w = new PreviewTest;
+ w->show();
+ app.setMainWidget(w);
+ return app.exec();
+}
+