From 47d455dd55be855e4cc691c32f687f723d9247ee Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kview/kviewcanvas/test/Makefile.am | 9 +++++++ kview/kviewcanvas/test/main.cpp | 51 ++++++++++++++++++++++++++++++++++++++ kview/kviewcanvas/test/test.cpp | 46 ++++++++++++++++++++++++++++++++++ kview/kviewcanvas/test/test.h | 25 +++++++++++++++++++ 4 files changed, 131 insertions(+) create mode 100644 kview/kviewcanvas/test/Makefile.am create mode 100644 kview/kviewcanvas/test/main.cpp create mode 100644 kview/kviewcanvas/test/test.cpp create mode 100644 kview/kviewcanvas/test/test.h (limited to 'kview/kviewcanvas/test') 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 +#include +#include +#include + +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 + */ +#include "test.h" +#include + +#include +#include +#include +#include + +#include + +KImageViewerTest::KImageViewerTest() + : KParts::MainWindow( 0L, "KImageViewerTest" ) +{ + QWidget * widget = KParts::ComponentFactory::createInstanceFromQuery( + "KImageViewer/Canvas", QString::null, this ); + if( widget ) + { + m_part = dynamic_cast( 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 +#endif + +#include +#include + +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 -- cgit v1.2.1