summaryrefslogtreecommitdiffstats
path: root/kview/kviewcanvas/test
diff options
context:
space:
mode:
Diffstat (limited to 'kview/kviewcanvas/test')
-rw-r--r--kview/kviewcanvas/test/Makefile.am9
-rw-r--r--kview/kviewcanvas/test/main.cpp51
-rw-r--r--kview/kviewcanvas/test/test.cpp46
-rw-r--r--kview/kviewcanvas/test/test.h25
4 files changed, 131 insertions, 0 deletions
diff --git a/kview/kviewcanvas/test/Makefile.am b/kview/kviewcanvas/test/Makefile.am
new file mode 100644
index 00000000..1fc3e92c
--- /dev/null
+++ b/kview/kviewcanvas/test/Makefile.am
@@ -0,0 +1,9 @@
+INCLUDES = -I$(top_srcdir)/kview $(all_includes)
+
+METASOURCES = AUTO
+
+check_PROGRAMS = test
+
+test_SOURCES = main.cpp test.cpp
+test_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+test_LDADD = $(LIB_KPARTS) $(top_builddir)/kview/kimageviewer/libkimageviewer.la
diff --git a/kview/kviewcanvas/test/main.cpp b/kview/kviewcanvas/test/main.cpp
new file mode 100644
index 00000000..360fdefd
--- /dev/null
+++ b/kview/kviewcanvas/test/main.cpp
@@ -0,0 +1,51 @@
+#include "test.h"
+#include <kapplication.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+static const char description[] =
+ I18N_NOOP("A KDE KPart Application");
+
+static const char version[] = "v0.1";
+
+static KCmdLineOptions options[] =
+{
+ { "+[URL]", I18N_NOOP( "Image to open" ), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KAboutData about("kimageviewertest", I18N_NOOP("KImageViewerTest"), version, description, KAboutData::License_GPL, "(C) 2001 Matthias Kretz", 0, 0, "kretz@kde.org");
+ about.addAuthor( "Matthias Kretz", 0, "kretz@kde.org" );
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions( options );
+ KApplication app;
+
+ if (app.isRestored())
+ RESTORE(KImageViewerTest)
+ else
+ {
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if ( args->count() == 0 )
+ {
+ KImageViewerTest *widget = new KImageViewerTest;
+ widget->show();
+ }
+ else
+ {
+ int i = 0;
+ for (; i < args->count(); i++ )
+ {
+ KImageViewerTest *widget = new KImageViewerTest;
+ widget->show();
+ widget->load( args->url( i ) );
+ }
+ }
+ args->clear();
+ }
+
+ return app.exec();
+}
diff --git a/kview/kviewcanvas/test/test.cpp b/kview/kviewcanvas/test/test.cpp
new file mode 100644
index 00000000..8422f944
--- /dev/null
+++ b/kview/kviewcanvas/test/test.cpp
@@ -0,0 +1,46 @@
+/*
+ * kimageviewertest.cpp
+ *
+ * Copyright (c) 2001 Matthias Kretz <kretz@kde.org>
+ */
+#include "test.h"
+#include <kimageviewer/canvas.h>
+
+#include <kurl.h>
+#include <klibloader.h>
+#include <kmessagebox.h>
+#include <kparts/componentfactory.h>
+
+#include <qimage.h>
+
+KImageViewerTest::KImageViewerTest()
+ : KParts::MainWindow( 0L, "KImageViewerTest" )
+{
+ QWidget * widget = KParts::ComponentFactory::createInstanceFromQuery<QWidget>(
+ "KImageViewer/Canvas", QString::null, this );
+ if( widget )
+ {
+ m_part = dynamic_cast<KImageViewer::Canvas *>( widget );
+ setCentralWidget( widget );
+ }
+ else
+ {
+ KMessageBox::error(this, "Could not find our Part!");
+ kapp->quit();
+ }
+}
+
+KImageViewerTest::~KImageViewerTest()
+{
+}
+
+void KImageViewerTest::load(const KURL& url)
+{
+ QImage image( url.fileName() );
+ if( m_part )
+ m_part->setImage( image );
+ else
+ KMessageBox::error(this, "can't load the file");
+}
+
+#include "test.moc"
diff --git a/kview/kviewcanvas/test/test.h b/kview/kviewcanvas/test/test.h
new file mode 100644
index 00000000..b6a85188
--- /dev/null
+++ b/kview/kviewcanvas/test/test.h
@@ -0,0 +1,25 @@
+#ifndef KIMAGEVIEWERTEST_H
+#define KIMAGEVIEWERTEST_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <kapplication.h>
+#include <kparts/mainwindow.h>
+
+namespace KImageViewer { class Canvas; };
+
+class KImageViewerTest : public KParts::MainWindow
+{
+ Q_OBJECT
+public:
+ KImageViewerTest();
+ virtual ~KImageViewerTest();
+ void load(const KURL& url);
+
+private:
+ KImageViewer::Canvas *m_part;
+};
+
+#endif // KIMAGEVIEWERTEST_H