summaryrefslogtreecommitdiffstats
path: root/kview/kviewviewer
diff options
context:
space:
mode:
Diffstat (limited to 'kview/kviewviewer')
-rw-r--r--kview/kviewviewer/ChangeLog68
-rw-r--r--kview/kviewviewer/Makefile.am21
-rw-r--r--kview/kviewviewer/config/Makefile.am17
-rw-r--r--kview/kviewviewer/config/kviewviewerpluginsconfig.cpp48
-rw-r--r--kview/kviewviewer/config/kviewviewerpluginsconfig.desktop118
-rw-r--r--kview/kviewviewer/config/kviewviewerpluginsconfig.h38
-rw-r--r--kview/kviewviewer/imagesettings.cpp73
-rw-r--r--kview/kviewviewer/imagesettings.h45
-rw-r--r--kview/kviewviewer/kviewkonqextension.cpp105
-rw-r--r--kview/kviewviewer/kviewkonqextension.h52
-rw-r--r--kview/kviewviewer/kviewpopup.rc7
-rw-r--r--kview/kviewviewer/kviewviewer.cpp883
-rw-r--r--kview/kviewviewer/kviewviewer.desktop118
-rw-r--r--kview/kviewviewer/kviewviewer.h145
-rw-r--r--kview/kviewviewer/kviewviewer.rc36
-rw-r--r--kview/kviewviewer/kviewviewer_ro.rc34
-rw-r--r--kview/kviewviewer/kviewvieweriface.h30
-rw-r--r--kview/kviewviewer/printimagesettings.ui190
-rw-r--r--kview/kviewviewer/test/Makefile.am9
-rw-r--r--kview/kviewviewer/test/main.cpp51
-rw-r--r--kview/kviewviewer/test/test.cpp43
-rw-r--r--kview/kviewviewer/test/test.h25
22 files changed, 2156 insertions, 0 deletions
diff --git a/kview/kviewviewer/ChangeLog b/kview/kviewviewer/ChangeLog
new file mode 100644
index 00000000..e76a70cd
--- /dev/null
+++ b/kview/kviewviewer/ChangeLog
@@ -0,0 +1,68 @@
+2003-10-06 Matthias Kretz <kretz@kde.org>
+
+ * config/kviewviewerpluginsconfig.cpp:
+ Don't show an empty config page in the pluginselector (there are no
+ KView plugins with config options, yet).
+
+2003-08-22 Matthias Kretz <kretz@kde.org>
+
+ * confmodules.*
+ moved to kviewcanvas/config
+ * generalconfigwidget.ui
+ moved to kviewcanvas/config
+
+2003-08-19 Matthias Kretz <kretz@kde.org>
+
+ * kviewvieweriface.h:
+ Everything is gone, let's see if this interface will stay
+ around...
+ * Makefile.am:
+ Added own messages target
+ * kviewviewer.{h,cpp}:
+ Remove image cache again. It's making more problems than it's
+ worth. The speedup is minimal. A real speedup would probably be
+ to preload images and/or cache the QPixmaps.
+ Problems I had: At some point no new image would be shown
+ anymore. Also the memory usage was too high and the kernel
+ does disk caching anyway, so the QImage caching is just a
+ minor optimization.
+
+2003-04-03 Matthias Kretz <kretz@kde.org>
+
+ * kviewviewer.cpp:
+ s/QUriDrag/KURLDrag/
+
+2003-03-11 Matthias Kretz <kretz@kde.org>
+
+ * kviewviewer.cpp:
+ uhm, fix a biiiig memory leak: the cache wasn't deleted on
+ part destruction
+
+2003-03-06 Matthias Kretz <kretz@kde.org>
+
+ * kviewviewer.desktop:
+ Changed MimeType field to support pbm, pnm, ppm and pgm. And
+ added the image/jp2 type.
+ Name change: Image Viewer Part -> KView Image Viewer. Somehow
+ the part needs to be identified with KView.
+
+2003-03-04 Matthias Kretz <kretz@kde.org>
+
+ * kviewvieweriface.h:
+ New interface header. This is probably going to be KView
+ specific stuff or become a DCOP interface (or both) have to
+ look into that some more...
+ It has only one method so far: setCacheSize( uint ) for
+ setting the maximum size of the QImage cache of the viewer.
+ * kviewviewer.cpp:
+ Cache QImages in a QCache.
+ This introduces a few problems: If a newer version is
+ available on file the cache will be used because the
+ modification time isn't checked.
+ Also the watching of files doesn't work anymore if the image
+ is loaded from the cache.
+ * kviewviewer.{cpp,h,rc}, kviewviewer_ro.rc:
+ added "rotate clockwise" and changed icon of CCW (patch by
+ Adriaan de Groot)
+
+# vim: sw=4 ts=4 tw=80 noet
diff --git a/kview/kviewviewer/Makefile.am b/kview/kviewviewer/Makefile.am
new file mode 100644
index 00000000..0aa490ec
--- /dev/null
+++ b/kview/kviewviewer/Makefile.am
@@ -0,0 +1,21 @@
+SUBDIRS = test config
+
+kde_module_LTLIBRARIES = libkviewviewer.la
+INCLUDES = -I$(top_srcdir)/kview $(all_includes)
+
+noinst_HEADERS = kviewkonqextension.h kviewviewer.h
+
+libkviewviewer_la_SOURCES = printimagesettings.ui imagesettings.cpp kviewkonqextension.cpp kviewviewer.cpp
+libkviewviewer_la_LDFLAGS = $(all_libraries) -avoid-version -module -no-undefined
+libkviewviewer_la_LIBADD = $(LIB_KDEPRINT) $(LIB_KUTILS) \
+ $(top_builddir)/kview/kimageviewer/libkimageviewer.la
+
+METASOURCES = AUTO
+
+kde_services_DATA = kviewviewer.desktop
+
+partdir = $(kde_datadir)/kviewviewer
+part_DATA = kviewviewer.rc kviewviewer_ro.rc kviewpopup.rc
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kviewviewer.pot
diff --git a/kview/kviewviewer/config/Makefile.am b/kview/kviewviewer/config/Makefile.am
new file mode 100644
index 00000000..fe65e613
--- /dev/null
+++ b/kview/kviewviewer/config/Makefile.am
@@ -0,0 +1,17 @@
+INCLUDES = $(all_includes)
+
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = kcm_kviewviewerpluginsconfig.la
+
+noinst_HEADERS = kviewviewerpluginsconfig.h
+
+kcm_kviewviewerpluginsconfig_la_SOURCES = kviewviewerpluginsconfig.cpp
+kcm_kviewviewerpluginsconfig_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kcm_kviewviewerpluginsconfig_la_LIBADD = $(LIB_KUTILS)
+
+kcm_kviewviewerpluginsconfig_DATA = kviewviewerpluginsconfig.desktop
+kcm_kviewviewerpluginsconfigdir = $(kde_servicesdir)/kconfiguredialog
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp *.h -o $(podir)/kcm_kviewviewerpluginsconfig.pot
diff --git a/kview/kviewviewer/config/kviewviewerpluginsconfig.cpp b/kview/kviewviewer/config/kviewviewerpluginsconfig.cpp
new file mode 100644
index 00000000..04b9e982
--- /dev/null
+++ b/kview/kviewviewer/config/kviewviewerpluginsconfig.cpp
@@ -0,0 +1,48 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include "kviewviewerpluginsconfig.h"
+
+#include <kpluginselector.h>
+#include <kgenericfactory.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <ksimpleconfig.h>
+#include <kplugininfo.h>
+
+#include <qstring.h>
+
+typedef KGenericFactory<KViewViewerPluginsConfig, QWidget> KViewViewerPluginsConfigFactory;
+K_EXPORT_COMPONENT_FACTORY( kcm_kviewviewerpluginsconfig, KViewViewerPluginsConfigFactory( "kcm_kviewviewerpluginsconfig" ) )
+
+KViewViewerPluginsConfig::KViewViewerPluginsConfig( QWidget * parent, const char *, const QStringList & args )
+ : KSettings::PluginPage( KViewViewerPluginsConfigFactory::instance(), parent, args )
+{
+ m_config = new KSimpleConfig( "kviewviewerrc" );
+ pluginSelector()->addPlugins( QString::fromAscii( "kviewviewer" ), i18n( "Viewer" ), QString::null, m_config );
+ pluginSelector()->setShowEmptyConfigPage( false );
+}
+
+KViewViewerPluginsConfig::~KViewViewerPluginsConfig()
+{
+ delete m_config;
+}
+
+// vim: sw=4 ts=4 noet
+
+#include "kviewviewerpluginsconfig.moc"
diff --git a/kview/kviewviewer/config/kviewviewerpluginsconfig.desktop b/kview/kviewviewer/config/kviewviewerpluginsconfig.desktop
new file mode 100644
index 00000000..d2faedfd
--- /dev/null
+++ b/kview/kviewviewer/config/kviewviewerpluginsconfig.desktop
@@ -0,0 +1,118 @@
+[Desktop Entry]
+Icon=plugin
+Type=Service
+ServiceTypes=KCModule
+
+X-KDE-ModuleType=Library
+X-KDE-Library=kviewviewerpluginsconfig
+X-KDE-FactoryName=KViewViewerPluginsConfigFactory
+X-KDE-ParentApp=kview
+X-KDE-ParentComponents=kviewviewer
+X-KDE-Weight=2
+X-KDE-CfgDlgHierarchy=Viewer
+
+Name=Plugins
+Name[ar]=البرامج المساعدة
+Name[bg]=Приставки
+Name[br]=Lugantoù
+Name[bs]=Dodaci
+Name[ca]=Connectors
+Name[cs]=Moduly
+Name[cy]=Ategion
+Name[da]=Plugin
+Name[de]=Module
+Name[el]=Πρόσθετα
+Name[eo]=Kromaĵoj
+Name[es]=Extensiones
+Name[et]=Pluginad
+Name[eu]=Pluginak
+Name[fa]=وصله‌ها
+Name[fi]=Liitännäiset
+Name[fr]=Modules externes
+Name[ga]=Breiseáin
+Name[he]=תוספים
+Name[hi]=प्लगइन्स
+Name[hr]=Umetci
+Name[hu]=Bővítőmodulok
+Name[is]=Íforrit
+Name[it]=Plugin
+Name[ja]=プラグイン
+Name[kk]=Плагин модулі
+Name[km]=កម្មវិធី​ជំនួយ
+Name[lt]=Priedai
+Name[ms]=Plugin
+Name[nb]=Programtillegg
+Name[nds]=Modulen
+Name[ne]=प्लगइन
+Name[nn]=Programtillegg
+Name[pa]=ਪਲੱਗਿੰਨ
+Name[pl]=Wtyczki
+Name[pt]='Plugins'
+Name[ro]=Module
+Name[ru]=Модули
+Name[rw]=Amacomeka
+Name[se]=Lassemoduvllat
+Name[sk]=Moduly
+Name[sl]=Vstavki
+Name[sr]=Прикључци
+Name[sr@Latn]=Priključci
+Name[sv]=Insticksprogram
+Name[ta]=சொருகுப்பொருள்
+Name[tg]=Модулҳо
+Name[tr]=Eklentiler
+Name[uk]=Втулки
+Name[uz]=Plaginlar
+Name[uz@cyrillic]=Плагинлар
+Name[wa]=Tchôke-divins
+Name[zh_CN]=插件
+Name[zh_HK]=插件
+Name[zh_TW]=外掛程式
+Comment=Choose and Configure Your Plugins
+Comment[bg]=Избор и настройване на приставки
+Comment[br]=Dibabit ha kefluniut ho lugentoù
+Comment[bs]=Izaberite i podesite vaše dodatke
+Comment[ca]=Escolliu i configureu els connectors
+Comment[cs]=Zvolte a nastavte si moduly
+Comment[da]=Vælg og indstil dine plugin
+Comment[de]=Auswahl und Einrichtung der Module
+Comment[el]=Επιλέξτε και ρυθμίστε τα πρόσθετα σας
+Comment[eo]=Elektu kaj agordu viajn kromprogramojn
+Comment[es]=Seleccione y configure sus extensiones
+Comment[et]=Pluginate valimine ja seadistamine
+Comment[eu]=Aukeratu eta konfigurau zure pluginak
+Comment[fa]=وصله‌های خود را انتخاب و پیکربندی کنید
+Comment[fi]=Valitse ja muokkaa liitännäisten asetuksia
+Comment[fr]=Choisissez et configurez vos modules externes
+Comment[gl]=Elexir e Configurar as súas Extensións
+Comment[he]=בחר והגדר את התוספים שלך
+Comment[hu]=Bővítőmodulok kiválasztása, beállítása
+Comment[is]=Velja og stilla íforrit
+Comment[it]=Scegli e configura i tuoi plugin
+Comment[ja]=プラグインを選択して設定します
+Comment[kk]=Плагин модулін таңдап алып баптау
+Comment[km]=ជ្រើស និង​កំណត់​រចនាសម្ព័ន្ធ​កម្មវិធី​ជំនួយ​របស់​អ្នក
+Comment[lt]=Pasirinkite ir konfigūruokite priedus
+Comment[ms]=Pilih dan Konfigur Plugin Anda
+Comment[nb]=Velg og sett opp programtilleggene
+Comment[nds]=Dien Modulen utsöken un instellen
+Comment[ne]=तपाईँको प्लगइन रोज्नुहोस् र कन्फिगर गर्नुहोस्
+Comment[nl]=Kies uw plugins en stel ze in
+Comment[nn]=Vel og set opp programtillegga
+Comment[pl]=Wybór i konfiguracja wtyczek
+Comment[pt]=Escolha e Configure os 'Plugins'
+Comment[pt_BR]=Escolha e Configure os Seus Plugins
+Comment[ro]=Alegeţi şi configuraţi modulele dumneavoastră
+Comment[ru]=Выберите и настройте модули
+Comment[sk]=Vyberte a nastavte si moduly
+Comment[sl]=Izberite in nastavite vstavke
+Comment[sr]=Изаберите и подесите ваше прикључке
+Comment[sr@Latn]=Izaberite i podesite vaše priključke
+Comment[sv]=Välj och anpassa insticksprogram
+Comment[ta]=சொருகுப்பொருள்களைத் தேர்ந்தெடுத்து வடிவமைக்கவும்
+Comment[tr]=Eklentilerinizi Seçin ve Yapılandırın:
+Comment[uk]=Виберіть та налаштуйте ваші втулки
+Comment[uz]=Plaginlarni tanlash va moslash
+Comment[uz@cyrillic]=Плагинларни танлаш ва мослаш
+Comment[zh_CN]=选择并配置您的插件
+Comment[zh_HK]=選擇及設定你的插件
+Comment[zh_TW]=選擇並設定您的外掛程式
diff --git a/kview/kviewviewer/config/kviewviewerpluginsconfig.h b/kview/kviewviewer/config/kviewviewerpluginsconfig.h
new file mode 100644
index 00000000..4f2b30ab
--- /dev/null
+++ b/kview/kviewviewer/config/kviewviewerpluginsconfig.h
@@ -0,0 +1,38 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef KVIEWVIEWERPLUGINSCONFIG_H
+#define KVIEWVIEWERPLUGINSCONFIG_H
+
+#include <ksettings/pluginpage.h>
+
+class KConfig;
+
+class KViewViewerPluginsConfig : public KSettings::PluginPage
+{
+ Q_OBJECT
+ public:
+ KViewViewerPluginsConfig( QWidget * parent, const char * name = 0, const QStringList & args = QStringList() );
+ ~KViewViewerPluginsConfig();
+ private:
+ KConfig * m_config;
+};
+
+// vim: sw=4 ts=4 noet
+
+#endif // KVIEWVIEWERPLUGINSCONFIG_H
diff --git a/kview/kviewviewer/imagesettings.cpp b/kview/kviewviewer/imagesettings.cpp
new file mode 100644
index 00000000..4f483db7
--- /dev/null
+++ b/kview/kviewviewer/imagesettings.cpp
@@ -0,0 +1,73 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include "imagesettings.h"
+
+#include <qcheckbox.h>
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kdialog.h>
+
+ImageSettings::ImageSettings( QWidget * parent, const char * name )
+ : KPrintDialogPage( parent, name )
+ , m_pFitImage( 0 )
+{
+ setTitle( i18n( "Image Settings" ) );
+
+ QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
+ m_pFitImage = new QCheckBox( i18n( "Fit image to page size" ), this );
+ m_pFitImage->setChecked( true );
+ layout->addWidget( m_pFitImage );
+ m_pCenter = new QCheckBox( i18n( "Center image on page" ), this );
+ m_pCenter->setChecked( true );
+ layout->addWidget( m_pCenter );
+ layout->insertStretch( -1, 0 );
+}
+
+ImageSettings::~ImageSettings()
+{
+}
+
+void ImageSettings::setOptions( const QMap<QString, QString> & opts )
+{
+ m_pFitImage->setChecked( opts[ "app-kviewviewer-fitimage" ] == "1" );
+ m_pCenter->setChecked( opts[ "app-kviewviewer-center" ] == "1" );
+}
+
+void ImageSettings::getOptions( QMap<QString, QString> & opts, bool include_def )
+{
+ if( m_pFitImage->isChecked() )
+ opts[ "app-kviewviewer-fitimage" ] = "1";
+ else if( include_def )
+ opts[ "app-kviewviewer-fitimage" ] = "0";
+
+ if( m_pCenter->isChecked() )
+ opts[ "app-kviewviewer-center" ] = "1";
+ else if( include_def )
+ opts[ "app-kviewviewer-center" ] = "0";
+}
+
+bool ImageSettings::isValid( QString & /*msg*/ )
+{
+ return true;
+}
+
+#include "imagesettings.moc"
+
+// vim:sw=4:ts=4
diff --git a/kview/kviewviewer/imagesettings.h b/kview/kviewviewer/imagesettings.h
new file mode 100644
index 00000000..5d7bf88e
--- /dev/null
+++ b/kview/kviewviewer/imagesettings.h
@@ -0,0 +1,45 @@
+/* This file is part of the KDE project
+ Copyright (C) 2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#ifndef IMAGESETTINGS_H
+#define IMAGESETTINGS_H
+
+#include <kdeprint/kprintdialogpage.h>
+
+class QCheckBox;
+
+class ImageSettings : public KPrintDialogPage
+{
+ Q_OBJECT
+ public:
+ ImageSettings( QWidget * parent = 0, const char * name = 0 );
+ ~ImageSettings();
+
+ void setOptions( const QMap<QString, QString> & opts );
+ void getOptions( QMap<QString, QString> & opts, bool include_def = false );
+ bool isValid( QString & msg );
+
+ private:
+ QCheckBox * m_pFitImage;
+ QCheckBox * m_pCenter;
+};
+
+// vim:sw=4:ts=4
+
+#endif // IMAGESETTINGS_H
+
diff --git a/kview/kviewviewer/kviewkonqextension.cpp b/kview/kviewviewer/kviewkonqextension.cpp
new file mode 100644
index 00000000..40876b7c
--- /dev/null
+++ b/kview/kviewviewer/kviewkonqextension.cpp
@@ -0,0 +1,105 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
+ 2001 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include "kviewkonqextension.h"
+#include "kviewviewer.h"
+#include "kimageviewer/canvas.h"
+#include "imagesettings.h"
+
+#include <qpainter.h>
+#include <qimage.h>
+#include <qpaintdevicemetrics.h>
+
+#include <kprinter.h>
+#include <kdebug.h>
+#include <kglobal.h>
+#include <klocale.h>
+
+KViewKonqExtension::KViewKonqExtension( KImageViewer::Canvas * canvas,
+ KViewViewer *parent, const char *name )
+ : KParts::BrowserExtension( parent, name ),
+ m_pViewer( parent ),
+ m_pCanvas( canvas )
+{
+ KGlobal::locale()->insertCatalogue("kview");
+}
+
+void KViewKonqExtension::setXYOffset( int x, int y )
+{
+ m_pCanvas->setXYOffset( x, y );
+}
+
+int KViewKonqExtension::xOffset()
+{
+ return m_pCanvas->xOffset();
+}
+
+int KViewKonqExtension::yOffset()
+{
+ return m_pCanvas->yOffset();
+}
+
+void KViewKonqExtension::print()
+{
+ if( ! m_pCanvas->image() )
+ {
+ kdError( 4610 ) << "No image to print" << endl;
+ return;
+ }
+
+ KPrinter printer;//( true, QPrinter::ScreenResolution );
+ printer.addDialogPage( new ImageSettings );
+ printer.setDocName( "KView: " + m_pViewer->url().fileName( false ) );
+
+ if ( !printer.setup( ((KViewViewer *)parent())->widget(), i18n("Print %1").arg(m_pViewer->url().fileName( false )) ) )
+ return;
+
+ QPainter painter;
+ painter.begin( &printer );
+
+ QPaintDeviceMetrics metrics( painter.device() );
+ kdDebug( 4610 ) << "metrics: " << metrics.width() << "x" << metrics.height() << endl;
+ QPoint pos( 0, 0 );
+
+ QImage imagetoprint;
+ if( printer.option( "app-kviewviewer-fitimage" ) == "1" )
+ imagetoprint = m_pCanvas->image()->smoothScale( metrics.width(), metrics.height(), QImage::ScaleMin );
+ else
+ imagetoprint = *m_pCanvas->image();
+
+ if( printer.option( "app-kviewviewer-center" ) == "1" )
+ {
+ pos.setX( ( metrics.width() - imagetoprint.width() ) / 2 );
+ pos.setY( ( metrics.height() - imagetoprint.height() ) / 2 );
+ }
+
+ painter.drawImage( pos, imagetoprint );
+ painter.end();
+}
+
+void KViewKonqExtension::del()
+{
+ m_pViewer->slotDel();
+}
+
+// vim:sw=4:ts=4
+
+#include "kviewkonqextension.moc"
+
diff --git a/kview/kviewviewer/kviewkonqextension.h b/kview/kviewviewer/kviewkonqextension.h
new file mode 100644
index 00000000..b7692f31
--- /dev/null
+++ b/kview/kviewviewer/kviewkonqextension.h
@@ -0,0 +1,52 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
+ 2001 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef __kviewkonqextension_h__
+#define __kviewkonqextension_h__
+
+#include <kparts/browserextension.h>
+
+namespace KImageViewer { class Canvas; }
+class KViewViewer;
+
+class KViewKonqExtension: public KParts::BrowserExtension
+{
+ friend class KViewViewer; // it can emit our signals
+ Q_OBJECT
+ public:
+ KViewKonqExtension( KImageViewer::Canvas *, KViewViewer *parent, const char *name = 0 );
+ virtual ~KViewKonqExtension() {}
+
+ virtual void setXYOffset( int x, int y );
+ virtual int xOffset();
+ virtual int yOffset();
+
+ public slots:
+ // Automatically detected by konqueror and kview
+ void print();
+ void del();
+
+ private:
+ KViewViewer * m_pViewer;
+ KImageViewer::Canvas * m_pCanvas;
+};
+
+// vim:sw=4:ts=4
+
+#endif
diff --git a/kview/kviewviewer/kviewpopup.rc b/kview/kviewviewer/kviewpopup.rc
new file mode 100644
index 00000000..ad4ece69
--- /dev/null
+++ b/kview/kviewviewer/kviewpopup.rc
@@ -0,0 +1,7 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kview_popup" version="1">
+ <Menu name="popupmenu">
+ <Separator />
+ <Action name="saveimageas" />
+ </Menu>
+</kpartgui>
diff --git a/kview/kviewviewer/kviewviewer.cpp b/kview/kviewviewer/kviewviewer.cpp
new file mode 100644
index 00000000..bab325ec
--- /dev/null
+++ b/kview/kviewviewer/kviewviewer.cpp
@@ -0,0 +1,883 @@
+/* This file is part of the KDE project
+
+ Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
+ 2001-2003 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+
+#include "kviewviewer.h"
+#include "kimageviewer/canvas.h"
+#include "version.h"
+
+#include <ksettings/dispatcher.h>
+
+#include <unistd.h>
+#include <assert.h>
+
+#include <qbuffer.h>
+#include <qlayout.h>
+#include <qvbox.h>
+#include <qlabel.h>
+#include <qregexp.h>
+
+#include <kpushbutton.h>
+#include <kpassivepopup.h>
+#include <kdebug.h>
+#include <kio/job.h>
+#include <kxmlguifactory.h>
+#include <kfiledialog.h>
+#include <kparts/genericfactory.h>
+#include <kparts/componentfactory.h>
+#include <kparts/plugin.h>
+#include <kmessagebox.h>
+#include <ktempfile.h>
+#include <kapplication.h>
+#include <kimageio.h>
+#include <kstdaccel.h>
+#include <kdirwatch.h>
+#include <kurldrag.h>
+#include <krecentdocument.h>
+
+typedef KParts::GenericFactory<KViewViewer> KViewViewerFactory;
+K_EXPORT_COMPONENT_FACTORY( libkviewviewer, KViewViewerFactory )
+
+KViewViewer::KViewViewer( QWidget *parentWidget, const char * /*widgetName*/,
+ QObject *parent, const char *name, const QStringList & )
+ : KImageViewer::Viewer( parent, name )
+ , m_pParentWidget( parentWidget )
+ , m_pJob( 0 )
+ , m_pExtension( 0 )
+ , m_pCanvas( 0 )
+ , m_pTempFile( 0 )
+ , m_pBuffer( 0 )
+ , m_pFileWatch( new KDirWatch( this ) )
+{
+ KImageIO::registerFormats();
+
+ QWidget * widget = KParts::ComponentFactory::createInstanceFromQuery<QWidget>(
+ "KImageViewer/Canvas", QString::null, m_pParentWidget );
+ m_pCanvas = static_cast<KImageViewer::Canvas *>( widget->qt_cast( "KImageViewer::Canvas" ) );
+ kdDebug( 4610 ) << "KImageViewer::Canvas at " << m_pCanvas << endl;
+ if( ! ( widget && m_pCanvas ) )
+ {
+ if( ! widget )
+ KMessageBox::error( m_pParentWidget, i18n( "Unable to find a suitable Image Canvas. This probably means that KView was not installed properly." ) );
+ else
+ KMessageBox::error( m_pParentWidget, i18n( "Accessing the KImageViewer interface of the Image Canvas failed. Something in your setup is broken (a component claims to be a KImageViewer::Canvas but it is not)." ) );
+ }
+ else
+ {
+ // create the extension before the plugins are loaded, because plugins might want to use it
+ m_pExtension = new KViewKonqExtension( m_pCanvas, this );
+
+ setPluginLoadingMode( LoadPluginsIfEnabled );
+ setInstance( KViewViewerFactory::instance() );
+
+ // m_url isn't set from ReadOnlyPart so we set it here to the CWD
+ m_url = QDir::currentDirPath() + "/";
+ m_sCaption = i18n( "Title caption when no image loaded", "no image loaded" );
+
+ setWidget( widget );
+
+ // Drag and Drop for the Canvas
+ widget->setAcceptDrops( true );
+ widget->installEventFilter( this );
+
+ setupActions();
+
+ if( isReadWrite() )
+ setXMLFile( "kviewviewer.rc" );
+ else
+ setXMLFile( "kviewviewer_ro.rc" );
+
+ connect( widget, SIGNAL( contextPress( const QPoint & ) ),
+ this, SLOT( slotPopupMenu( const QPoint & ) ) );
+ connect( widget, SIGNAL( zoomChanged( double ) ),
+ this, SLOT( zoomChanged( double ) ) );
+ connect( widget, SIGNAL( showingImageDone() ),
+ this, SLOT( switchBlendEffect() ) );
+ connect( widget, SIGNAL( hasImage( bool ) ),
+ this, SLOT( hasImage( bool ) ) );
+ connect( widget, SIGNAL( imageChanged() ),
+ this, SLOT( setModified() ) );
+
+ connect( m_pFileWatch, SIGNAL( dirty( const QString & ) ),
+ this, SLOT( slotFileDirty( const QString & ) ) );
+
+ KSettings::Dispatcher::self()->registerInstance( instance(), this, SLOT( readSettings() ) );
+
+ // by default disable progress info (so it won't open the dialog in Konqueror)
+ setProgressInfoEnabled( false );
+
+ m_popupDoc = KXMLGUIFactory::readConfigFile( "kviewpopup.rc", true, instance() );
+
+ KConfigGroup cfgGroup( instance()->config(), "Settings" );
+ bool hideBars = cfgGroup.readBoolEntry( "hideScrollbars", false );
+ m_pCanvas->hideScrollbars( hideBars );
+ m_paShowScrollbars->setChecked( ! hideBars );
+ m_vEffects.resize( m_pCanvas->numOfBlendEffects() );
+
+ readSettings();
+ }
+}
+
+KViewViewer::~KViewViewer()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+
+ writeSettings();
+ instance()->config()->sync();
+
+ /*abortLoad(); //just in case
+ if( isModified() && isReadWrite() )
+ {
+ int res = m_url.isEmpty() ?
+ KMessageBox::warningYesNo( widget(),
+ i18n( "This is a new document.\nDo you want to save it ?" ),
+ QString::null, KStdGuiItem::saveAs(), KStdGuiItem::discard() ):
+ KMessageBox::warningYesNo( widget(),
+ i18n( "The document has been modified.\nDo you want to save it ?" ),
+ QString::null, KStdGuiItem::saveAs(), KStdGuiItem::dontSave() );
+
+ if( res == KMessageBox::Yes )
+ {
+ KURL url = KFileDialog::getSaveURL();
+ if( ! url.isEmpty() )
+ saveAs( url );
+ }
+ }
+ ReadOnlyPart::closeURL();*/
+
+ abortLoad();
+ delete m_pTempFile;
+ delete m_pBuffer;
+}
+
+KAboutData * KViewViewer::createAboutData()
+{
+ KAboutData * aboutData = new KAboutData( "kviewviewer", I18N_NOOP( "KView" ),
+ KVIEW_VERSION, I18N_NOOP( "KDE Image Viewer Part" ),
+ KAboutData::License_GPL,
+ I18N_NOOP("(c) 1997-2002, The KView Developers") );
+ aboutData->addAuthor( "Matthias Kretz", I18N_NOOP( "Maintainer" ), "kretz@kde.org" );
+ aboutData->addAuthor( "Sirtaj Singh Kang", I18N_NOOP( "started it all" ), "taj@kde.org" );
+ aboutData->addAuthor( "Simon Hausmann", 0, "hausmann@kde.org" );
+ return aboutData;
+}
+
+void KViewViewer::setReadWrite( bool readwrite )
+{
+ KImageViewer::Viewer::setReadWrite( readwrite );
+ if( readwrite )
+ setXMLFile( "kviewviewer.rc" );
+ else
+ setXMLFile( "kviewviewer_ro.rc" );
+}
+
+bool KViewViewer::saveAs( const KURL & kurl )
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ if( !kurl.isValid() )
+ return KParts::ReadWritePart::saveAs( kurl ); // sets m_bClosing = false
+
+ // if the image wasn't modified and should be saved in the same format we just copy the file - no need
+ // to lose some quality or information by calling QImage::save()
+ if( ! ( isModified() && isReadWrite() ) && m_mimeType == m_newMimeType )
+ {
+ kdDebug( 4610 ) << "copy image from " << m_file << " to " << kurl.prettyURL() << endl;
+
+ KIO::Job * job = KIO::copy( KURL( m_file ), kurl, isProgressInfoEnabled() );
+ emit started( job );
+ connect( job, SIGNAL( result( KIO::Job * ) ),
+ this, SLOT( slotResultSaveAs( KIO::Job * ) ) );
+ return true;
+ }
+ kdDebug( 4610 ) << "call KParts::ReadWritePart::saveAs( " << kurl.prettyURL() << " )" << endl;
+
+ bool ret = KParts::ReadWritePart::saveAs( kurl );
+ if( ret == false )
+ KMessageBox::error( m_pParentWidget, i18n( "The image could not be saved to disk. A possible causes is that you don't have permission to write to that file." ) );
+ return ret;
+}
+
+void KViewViewer::setModified( bool modified )
+{
+ m_paSave->setEnabled( modified );
+ KImageViewer::Viewer::setModified( modified );
+}
+
+bool KViewViewer::openURL( const KURL & url )
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ if ( !url.isValid() )
+ {
+ kdWarning( 4610 ) << "malformed URL " << url.prettyURL() << endl;
+ return false;
+ }
+ if ( !closeURL() )
+ {
+ kdDebug( 4610 ) << "closeURL didn't work out" << endl;
+ return false;
+ }
+ setModified( false );
+ m_url = url;
+ m_mimeType = m_pExtension->urlArgs().serviceType; // if this fails to
+ // find the right mime type it'll be determined in openFile()
+ if ( m_url.isLocalFile() )
+ {
+ emit started( 0 );
+ m_file = m_url.path();
+ kdDebug( 4610 ) << "open local file " << m_file << endl;
+ bool ret = openFile();
+ if( ret )
+ {
+ m_sCaption = m_url.prettyURL();
+ emit setWindowCaption( m_sCaption );
+ emit completed();
+ }
+ return ret;
+ }
+ else
+ {
+ m_sCaption = m_url.prettyURL();
+ emit setWindowCaption( m_sCaption );
+ m_bTemp = true;
+ // Use same extension as remote file. This is important for mimetype-determination (e.g. koffice)
+ QString extension;
+ QString fileName = url.fileName();
+ int extensionPos = fileName.findRev( '.' );
+ if ( extensionPos != -1 )
+ extension = fileName.mid( extensionPos ); // keep the '.'
+ delete m_pTempFile;
+ m_pTempFile = new KTempFile( QString::null, extension );
+ m_file = m_pTempFile->name();
+
+ m_pJob = KIO::get( m_url, m_pExtension->urlArgs().reload, isProgressInfoEnabled() );
+ emit started( m_pJob );
+ connect( m_pJob, SIGNAL( result( KIO::Job * ) ), SLOT( slotJobFinished ( KIO::Job * ) ) );
+ connect( m_pJob, SIGNAL( data( KIO::Job *, const QByteArray & ) ), SLOT( slotData( KIO::Job *, const QByteArray & ) ) );
+ return true;
+ }
+}
+
+bool KViewViewer::closeURL()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ abortLoad();
+ QString file = m_file;
+ bool ret = KParts::ReadWritePart::closeURL();
+ if( ret )
+ if( ! file.isEmpty() )
+ {
+ kdDebug( 4610 ) << "remove " << file << " from KDirWatch\n";
+ m_pFileWatch->removeFile( file );
+ }
+ return ret;
+}
+
+void KViewViewer::newImage( const QImage & newimg )
+{
+ if( closeURL() )
+ {
+ m_url = "";
+ m_file = QString::null;
+ m_sCaption = i18n( "Title caption when new image selected", "new image" );
+ m_pCanvas->setImage( newimg );
+ if( isReadWrite() )
+ setModified( true );
+ }
+}
+
+void KViewViewer::reload()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+
+ if( isReadWrite() && isModified() )
+ if( ! queryClose() )
+ return;
+
+ //load from file
+ QImage image( m_file );
+ m_pCanvas->setImage( image );
+ setModified( false );
+}
+
+bool KViewViewer::eventFilter( QObject * o, QEvent * e )
+{
+ KImageViewer::Canvas * canvas = static_cast<KImageViewer::Canvas*>( o->qt_cast( "KImageViewer::Canvas" ) );
+ if( canvas )
+ {
+ // intercept drops onto the Canvas
+ switch( e->type() )
+ {
+ case QEvent::DragEnter:
+ {
+ QDragEnterEvent * ev = static_cast<QDragEnterEvent*>( e );
+ kdDebug( 4610 ) << "DragEnter Event in the Canvas: " << endl;
+ for( int i = 0; ev->format( i ); ++i )
+ kdDebug( 4610 ) << " - " << ev->format( i ) << endl;
+ ev->accept( KURLDrag::canDecode( ev ) || QImageDrag::canDecode( ev ) );
+ return true;
+ }
+ case QEvent::Drop:
+ {
+ QDropEvent * ev = static_cast<QDropEvent*>( e );
+ kdDebug( 4610 ) << "Drop Event in the Canvas" << endl;
+ QStringList l;
+ QImage image;
+ if( KURLDrag::decodeToUnicodeUris( ev, l ) )
+ openURL( KURL( l.first() ) );
+ else if( QImageDrag::decode( ev, image ) )
+ newImage( image );
+ return true;
+ }
+ default:
+ break;
+ }
+ }
+ return KImageViewer::Viewer::eventFilter( o, e );
+}
+
+void KViewViewer::abortLoad()
+{
+ if ( m_pJob )
+ {
+ m_pJob->kill();
+ m_pJob = 0;
+ }
+}
+
+bool KViewViewer::openFile()
+{
+ //m_pCanvas->setMaximumImageSize( QSize( widget()->width(), widget()->height() ) );
+ if( m_pBuffer )
+ {
+ kdDebug( 4610 ) << k_funcinfo << " load from buffer\n";
+ //load from buffer
+ m_pBuffer->close();
+ if( m_pTempFile )
+ {
+ m_pTempFile->dataStream()->writeRawBytes( m_pBuffer->buffer().data(), m_pBuffer->buffer().size() );
+ m_pTempFile->close();
+ }
+
+ // determine Mime Type
+ if( m_mimeType.isNull() )
+ {
+ m_mimeType = KImageIO::mimeType( m_url.fileName() );
+ kdDebug( 4610 ) << "MimeType: " << m_mimeType << endl;
+ if( m_mimeType.isNull() )
+ {
+ m_mimeType = KMimeType::findByContent( m_pBuffer->buffer() )->name();
+ kdDebug( 4610 ) << "MimeType: " << m_mimeType << endl;
+ }
+ }
+
+ QImage image( m_pBuffer->buffer() );
+ delete m_pBuffer;
+ m_pBuffer = 0;
+ if( ! image.isNull() )
+ {
+ QSize size = image.size();
+ m_pCanvas->setImage( image, size );
+ }
+ else
+ {
+ emit setStatusBarText( i18n( "Unknown image format: %1" ).arg( m_url.prettyURL() ) );
+ return false;
+ }
+ }
+ else
+ { //load from local file
+ kdDebug( 4610 ) << k_funcinfo << " load from file: " << m_file << endl;
+ if( ! QFile::exists( m_file ) )
+ {
+ emit setStatusBarText( i18n( "No such file: %1" ).arg( m_file ) );
+ return false;
+ }
+ if( QImage::imageFormat( m_file ) == 0 )
+ {
+ emit setStatusBarText( i18n( "Unknown image format: %1" ).arg( m_file ) );
+ return false;
+ }
+ // determine Mime Type
+ if( m_mimeType.isNull() )
+ {
+ m_mimeType = KImageIO::mimeType( m_file );
+ kdDebug( 4610 ) << "MimeType: " << m_mimeType << endl;
+ }
+
+ //load from file
+ QImage image( m_file );
+ QSize size = image.size();
+ m_pCanvas->setImage( image, size );
+ }
+ m_pFileWatch->addFile( m_file );
+ emit imageOpened( m_url );
+ return true;
+}
+
+bool KViewViewer::saveFile()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ // two possibilities:
+ //
+ // 1. The image should be saved as an exact copy of the loaded one (this
+ // is useful if you downloaded an image from the net and want to save it
+ // locally) - this can happen only in saveAs() so only 2. applies here:
+ //
+ // 2. The image should be saved in a different format or was modified, so
+ // that copying isn't possible anymore.
+
+ const QImage * image = m_pCanvas->image();
+ if( ! image )
+ return false;
+
+ if( ! m_newMimeType.isNull() )
+ {
+ m_mimeType = m_newMimeType;
+ m_newMimeType = QString::null;
+ }
+ QString type = KImageIO::typeForMime( m_mimeType );
+ kdDebug( 4610 ) << "save m_pCanvas->image() to " << m_file << " as " << type << endl;
+ int quality = 100; // TODO: ask user for quality. Keep it at 100 so that our
+ // users don't lose quality when working with KView.
+
+ m_pFileWatch->removeFile( m_file );
+ bool ret = image->save( m_file, type.latin1(), quality );
+ m_pFileWatch->addFile( m_file );
+ return ret;
+}
+
+void KViewViewer::setupActions()
+{
+ m_paZoomIn = new KAction( i18n( "Zoom In" ), "viewmag+", KStdAccel::shortcut( KStdAccel::ZoomIn ), this,
+ SLOT( slotZoomIn() ), actionCollection(), "zoomin" );
+ m_paZoomOut = new KAction( i18n( "Zoom Out" ), "viewmag-", KStdAccel::shortcut( KStdAccel::ZoomOut ), this,
+ SLOT( slotZoomOut() ), actionCollection(), "zoomout" );
+
+ m_paZoom = new KSelectAction( i18n( "Zoom" ), "viewmag", 0, actionCollection(), "view_zoom" );
+ connect( m_paZoom, SIGNAL( activated( const QString & ) ), this, SLOT( setZoom( const QString & ) ) );
+ m_paZoom->setEditable( true );
+ m_paZoom->clear();
+ m_paZoom->setItems( QStringList::split( '|', "20%|25%|33%|50%|75%|100%|125%|150%|200%|250%|300%|350%|400%|450%|500%" ) );
+ m_paZoom->setCurrentItem( 5 );
+
+ m_paFlipMenu = new KActionMenu( i18n( "&Flip" ), actionCollection(), "flip" );
+ m_paFlipV = new KAction( i18n( "&Vertical" ), Key_V, this, SLOT( slotFlipV() ), actionCollection(), "flip_vertical" );
+ m_paFlipH = new KAction( i18n( "&Horizontal" ), Key_H, this, SLOT( slotFlipH() ), actionCollection(), "flip_horizontal" );
+ m_paFlipMenu->insert( m_paFlipV );
+ m_paFlipMenu->insert( m_paFlipH );
+
+ m_paRotateCCW = new KAction( i18n( "Ro&tate Counter-Clockwise" ), "rotate_ccw", 0, this,
+ SLOT( slotRotateCCW() ), actionCollection(), "rotateCCW" );
+ m_paRotateCW = new KAction( i18n( "Rotate Clockwise" ), "rotate_cw", 0, this,
+ SLOT( slotRotateCW() ), actionCollection(), "rotateCW" );
+ m_paSave = KStdAction::save( this, SLOT( slotSave() ), actionCollection() );
+ m_paSave->setEnabled( false );
+ m_paSaveAs = KStdAction::saveAs( this, SLOT( slotSaveAs() ), actionCollection() );
+
+ m_paFitToWin = new KAction( i18n( "Fit Image to Window" ), 0, 0, this,
+ SLOT( slotFitToWin() ), actionCollection(), "fittowin" );
+ m_paZoomIn->setEnabled( false );
+ m_paZoomOut->setEnabled( false );
+ m_paZoom->setEnabled( false );
+ m_paRotateCCW->setEnabled( false );
+ m_paRotateCW->setEnabled( false );
+ m_paSaveAs->setEnabled( false );
+ m_paFitToWin->setEnabled( false );
+ m_paFlipMenu->setEnabled( false );
+ m_paFlipV->setEnabled( false );
+ m_paFlipH->setEnabled( false );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paZoomIn, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paZoomOut, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paZoom, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paRotateCCW, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paRotateCW, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paSaveAs, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paFitToWin, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paFlipMenu, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paFlipV, SLOT( setEnabled( bool ) ) );
+ connect( widget(), SIGNAL( hasImage( bool ) ), m_paFlipH, SLOT( setEnabled( bool ) ) );
+
+ m_paShowScrollbars = new KToggleAction( i18n( "Show Scrollbars" ), 0, this, SLOT( slotToggleScrollbars() ),
+ actionCollection(), "show_scrollbars" );
+ m_paShowScrollbars->setCheckedState(i18n("Hide Scrollbars"));
+}
+
+void KViewViewer::guiActivateEvent( KParts::GUIActivateEvent * event )
+{
+ ReadWritePart::guiActivateEvent( event );
+ bool enabled = m_pCanvas->image() ? true : false;
+ emit m_pExtension->enableAction( "del", enabled );
+ emit m_pExtension->enableAction( "print", enabled );
+ if( ! enabled )
+ {
+ m_sCaption = i18n( "Title caption when no image loaded", "no image loaded" );
+ emit setWindowCaption( m_sCaption );
+ }
+}
+
+void KViewViewer::readSettings()
+{
+ KConfigGroup cfgGroup( instance()->config(), "Settings" );
+ m_pCanvas->setFastScale( ! cfgGroup.readBoolEntry( "Smooth Scaling", ! m_pCanvas->fastScale() ) );
+ m_pCanvas->setKeepAspectRatio( cfgGroup.readBoolEntry( "Keep Aspect Ratio", m_pCanvas->keepAspectRatio() ) );
+ m_pCanvas->setCentered( cfgGroup.readBoolEntry( "Center Image", m_pCanvas->centered() ) );
+
+ m_pCanvas->setBgColor( cfgGroup.readColorEntry( "Background Color", &m_pCanvas->bgColor() ) );
+
+ m_pCanvas->setMinimumImageSize( QSize( cfgGroup.readNumEntry( "Minimum Width", m_pCanvas->minimumImageSize().width() ),
+ cfgGroup.readNumEntry( "Minimum Height", m_pCanvas->minimumImageSize().height() ) ) );
+ m_pCanvas->setMaximumImageSize( QSize( cfgGroup.readNumEntry( "Maximum Width", m_pCanvas->maximumImageSize().width() ),
+ cfgGroup.readNumEntry( "Maximum Height", m_pCanvas->maximumImageSize().height() ) ) );
+
+ KConfigGroup blendConfig( instance()->config(), "Blend Effects" );
+ m_vEffects.clear();
+ for( unsigned int i = 1; i <= m_pCanvas->numOfBlendEffects(); ++i )
+ {
+ if( blendConfig.readBoolEntry( QString::number( i ), false ) )
+ m_vEffects.push_back( i );
+ }
+ // and now tell the canvas what blend effect to use
+ switchBlendEffect();
+ loadPlugins();
+}
+
+void KViewViewer::writeSettings()
+{
+ KConfigGroup cfgGroup( instance()->config(), "Settings" );
+ cfgGroup.writeEntry( "hideScrollbars", ! m_paShowScrollbars->isChecked() );
+}
+
+void KViewViewer::zoomChanged( double zoom )
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ emit setWindowCaption( m_sCaption + QString( " (%1%)" ).arg( zoom * 100, 0, 'f', 0 ) );
+ updateZoomMenu( zoom );
+}
+
+void KViewViewer::slotJobFinished( KIO::Job * job )
+{
+ assert( job == m_pJob );
+ m_pJob = 0;
+ if (job->error())
+ emit canceled( job->errorString() );
+ else
+ {
+ openFile();
+ emit completed();
+ }
+}
+
+void KViewViewer::slotData( KIO::Job *, const QByteArray & data )
+{
+ if( ! m_pBuffer )
+ {
+ m_pBuffer = new QBuffer();
+ m_pBuffer->open( IO_ReadWrite );
+ }
+ m_pBuffer->writeBlock( data.data(), data.size() );
+
+ //show partial image XXX: is this really the way to do it?
+ //No. :) It takes forever like this.
+ //OK. So I really have to look at khtml...
+ //later...
+ //m_pCanvas->setImage( QImage( m_pBuffer->buffer() ) );
+}
+
+void KViewViewer::slotSave()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ if( ! save() )
+ KMessageBox::error( m_pParentWidget, i18n( "The image could not be saved to disk. A possible causes is that you don't have permission to write to that file." ) );
+}
+
+void KViewViewer::slotSaveAs()
+{
+ kdDebug( 4610 ) << k_funcinfo << endl;
+ KFileDialog dlg( QString::null, QString::null, widget(), "filedialog", true );
+ dlg.setMimeFilter( KImageIO::mimeTypes( KImageIO::Writing ) );
+ dlg.setSelection( m_url.fileName() );
+ dlg.setCaption( i18n( "Save As" ) );
+ dlg.setOperationMode( KFileDialog::Saving );
+ dlg.exec();
+ KURL url = dlg.selectedURL();
+ m_newMimeType = dlg.currentMimeFilter();
+ if( m_newMimeType.isEmpty() )
+ m_newMimeType = KImageIO::mimeType( url.path() );
+ kdDebug( 4610 ) << k_funcinfo << "m_newMimeType = " << m_newMimeType << endl;
+ if( url.isValid() )
+ KRecentDocument::add( url );
+ saveAs( url );
+}
+
+void KViewViewer::slotZoomIn()
+{
+ double zoom = m_pCanvas->zoom() * 1.1;
+ if (zoom < 0.01) zoom=0.01 ;
+ m_pCanvas->setZoom( zoom );
+}
+
+void KViewViewer::slotZoomOut()
+{
+ double zoom = m_pCanvas->zoom() / 1.1;
+ if (zoom < 0.01) zoom=0.01 ;
+ m_pCanvas->setZoom( zoom );
+}
+
+void KViewViewer::setZoom( const QString & newZoom )
+{
+ kdDebug( 4610 ) << k_funcinfo << newZoom << endl;
+ double zoom;
+ QString z = newZoom;
+ z.remove( z.find( '%' ), 1 );
+ if( newZoom == "33%" )
+ zoom = 1.0 / 3.0;
+ else
+ zoom = KGlobal::locale()->readNumber( z ) / 100;
+
+ m_pCanvas->setZoom( zoom );
+}
+
+void KViewViewer::updateZoomMenu( double zoom )
+{
+ QStringList lst;
+ if( zoom > 0.0 )
+ {
+ //lst << i18n( "Maxpect" );
+ QValueList<int> list;
+ QString z;
+ int val;
+ bool ok;
+ QStringList itemsList = m_paZoom->items();
+ for( QStringList::Iterator it = itemsList.begin(); it != itemsList.end(); ++it )
+ {
+ z = ( *it ).replace( QRegExp( "%" ), "" );
+ z = z.simplifyWhiteSpace();
+ val = z.toInt( &ok );
+ if( ok && val > 0 && list.contains( val ) == 0 )
+ list << val;
+ }
+ val = QString::number( zoom * 100, 'f', 0 ).toInt(); // round/lround from math.h doesn't work - dunno
+ if( list.contains( val ) == 0 )
+ list.append( val );
+
+ qHeapSort( list );
+
+ for( QValueList<int>::Iterator it = list.begin(); it != list.end(); ++it )
+ lst << QString::number( *it ) + '%';
+ m_paZoom->setItems( lst );
+ }
+
+ // first look if it's a new value (not in the list yet)
+ QString z = QString( "%1%" ).arg( zoom * 100, 0, 'f', 0 );
+ QStringList items = m_paZoom->items();
+ int idx = items.findIndex( z );
+ if( -1 == idx )
+ {
+ // not found XXX: remove when done
+ kdDebug( 4610 ) << "zoom value not in the list: " << z << endl;
+ kdDebug( 4610 ) << "here's the list:\n- " << items.join( "\n- " ) << endl;
+ }
+ else
+ {
+ // already in the list
+ kdDebug( 4610 ) << "zoom value already in the list: " << z << endl;
+ // make that one selected
+ m_paZoom->setCurrentItem( idx );
+ }
+}
+
+void KViewViewer::slotFlipH()
+{
+ m_pCanvas->flipVertical( isReadWrite() );
+}
+
+void KViewViewer::slotFlipV()
+{
+ m_pCanvas->flipHorizontal( isReadWrite() );
+}
+
+void KViewViewer::slotRotateCCW()
+{
+ m_pCanvas->rotate( -90.0, isReadWrite() );
+}
+
+void KViewViewer::slotRotateCW()
+{
+ m_pCanvas->rotate( 90.0, isReadWrite() );
+}
+
+void KViewViewer::slotFitToWin()
+{
+ m_pCanvas->boundImageTo( widget()->size() );
+}
+
+void KViewViewer::slotDel()
+{
+ //just in case m_url get's modified while closing
+ KURL urltodel = m_url;
+ if( closeURL() )
+ {
+ setModified( false );
+ KIO::file_delete( urltodel );
+ m_pCanvas->clear();
+ }
+}
+
+class PopupGUIClient : public KXMLGUIClient
+{
+ public:
+ PopupGUIClient( KInstance *inst, const QString &doc )
+ {
+ setInstance( inst );
+ setXML( doc );
+ }
+};
+
+void KViewViewer::slotPopupMenu( const QPoint &pos )
+{
+ KXMLGUIClient *popupGUIClient = new PopupGUIClient( instance(), m_popupDoc );
+
+ (void) new KAction( i18n( "Save Image As..." ), 0, this, SLOT( slotSaveAs() ),
+ popupGUIClient->actionCollection(), "saveimageas" );
+
+ // ### HACK treat the image as dir to get the back/fwd/reload buttons (Simon)
+ emit m_pExtension->popupMenu( popupGUIClient, pos, m_url, m_mimeType, S_IFDIR );
+
+ delete popupGUIClient;
+}
+
+void KViewViewer::slotResultSaveAs( KIO::Job *job )
+{
+ if ( job->error() )
+ {
+ emit canceled( job->errorString() );
+ //job->showErrorDialog( widget() );
+ }
+ else
+ {
+ emit completed();
+ KIO::CopyJob * cjob = ::qt_cast<KIO::CopyJob*>( job );
+ if( cjob )
+ {
+ m_url = cjob->destURL();
+ m_sCaption = m_url.prettyURL();
+ }
+ else
+ m_sCaption = "";
+ emit setWindowCaption( m_sCaption );
+ }
+
+ // Now we have to delete the tempfile if it exists and if the current
+ // image position is on the local HD. If it's somewhere else we keep the
+ // tempfile in case the user calls saveAs() again.
+ if( m_url.isLocalFile() )
+ {
+ if( m_bTemp )
+ {
+ unlink( QFile::encodeName( m_file ) );
+ m_bTemp = false;
+ }
+ m_file = m_url.path();
+ }
+}
+
+void KViewViewer::slotFileDirty( const QString & )
+{
+ if( isModified() && isReadWrite() )
+ {
+ KPassivePopup * pop = new KPassivePopup( m_pParentWidget );
+ QVBox * vb = pop->standardView( i18n( "Load changed image? - %1" ).arg( kapp->aboutData()->programName() ),
+ QString::null, kapp->miniIcon() );
+ ( void )new QLabel( i18n( "The image %1 which you have modified has changed on disk.\n"
+ "Do you want to reload the file and lose your changes?\n"
+ "If you don't and subsequently save the image, you will lose the\n"
+ "changes that have already been saved." ).arg( url().fileName() ), vb );
+ QWidget * hb = new QWidget( vb );
+ QHBoxLayout * layout = new QHBoxLayout( hb );
+ layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum ) );
+ KPushButton * yes = new KPushButton( i18n("Reload"), hb );
+ layout->addWidget( yes );
+ layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum ) );
+ KPushButton * no = new KPushButton( i18n("Do Not Reload"), hb );
+ layout->addWidget( no );
+ layout->addItem( new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Minimum ) );
+ connect( yes, SIGNAL( clicked() ), this, SLOT( slotReloadUnmodified() ) );
+ connect( yes, SIGNAL( clicked() ), pop, SLOT( hide() ) );
+ connect( no, SIGNAL( clicked() ), pop, SLOT( hide() ) );
+ pop->setView( vb );
+ pop->setTimeout( 0 );
+ pop->setAutoDelete( true );
+ pop->show();
+ kdDebug( 4610 ) << "popup returned\n";
+ }
+ else
+ reload();
+}
+
+void KViewViewer::slotReloadUnmodified()
+{
+ setModified( false );
+ reload();
+ kdDebug( 4610 ) << "reload done\n";
+}
+
+void KViewViewer::slotToggleScrollbars()
+{
+ m_pCanvas->hideScrollbars( ! m_paShowScrollbars->isChecked() );
+}
+
+void KViewViewer::loadPlugins()
+{
+ KImageViewer::Viewer::loadPlugins( this, this, instance() );
+ if( factory() )
+ {
+ QPtrList<KParts::Plugin> plugins = KParts::Plugin::pluginObjects( this );
+ KParts::Plugin * plugin;
+ for( plugin = plugins.first(); plugin; plugin = plugins.next() )
+ factory()->addClient( plugin );
+ }
+}
+
+void KViewViewer::switchBlendEffect()
+{
+ if( m_vEffects.empty() )
+ m_pCanvas->setBlendEffect( 0 );
+ else
+ {
+ unsigned int num = KApplication::random() % m_vEffects.size();
+ m_pCanvas->setBlendEffect( m_vEffects[ num ] );
+ }
+}
+
+void KViewViewer::hasImage( bool b )
+{
+ emit m_pExtension->enableAction( "del", b );
+ emit m_pExtension->enableAction( "print", b );
+ if( ! b )
+ {
+ m_sCaption = i18n( "Title caption when no image loaded", "No Image Loaded" );
+ emit setWindowCaption( m_sCaption );
+ }
+}
+
+// vim:sw=4:ts=4
+
+#include "kviewviewer.moc"
+
diff --git a/kview/kviewviewer/kviewviewer.desktop b/kview/kviewviewer/kviewviewer.desktop
new file mode 100644
index 00000000..2961fb65
--- /dev/null
+++ b/kview/kviewviewer/kviewviewer.desktop
@@ -0,0 +1,118 @@
+[Desktop Entry]
+Type=Service
+Icon=kview
+Comment=KDE Image Viewer Part
+Comment[af]=Kde Beeld Aansig Deel
+Comment[ar]=عارض جزء الصور ل KDE
+Comment[br]=Perzh gweler skeudennoù KDE
+Comment[bs]=KDE Part - Preglednik slika
+Comment[ca]=Peça de KDE visualitzadora d'imatges
+Comment[cs]=Komponenta prohlížeče obrázků KDE
+Comment[cy]=Rhan Gwelydd Delweddau KDE
+Comment[da]=KDE Billedviser-part
+Comment[de]=KDE Bildbetrachter-Komponente (KPart)
+Comment[el]=Part προβολέα εικόνων του KDE
+Comment[eo]=KDE-bildorigardilo parto
+Comment[es]=Parte de visor de imágenes de KDE
+Comment[et]=KDE pildifailide näitaja komponent
+Comment[eu]=KDE irudi ikustailearen zatia
+Comment[fa]=جزء مشاهده‌گر تصویر KDE
+Comment[fi]=KDE:n kuvannäyttökomponentti
+Comment[fr]=Composant d'affichage d'images de KDE
+Comment[gl]=Visor de imaxes integrado do KDE
+Comment[he]=רכיב מציג תמונות ל־KDE
+Comment[hi]=केडीई छवि प्रदर्शक पार्ट
+Comment[hr]=KDE komponenta za pregledavanje slika
+Comment[hu]=KDE képnézegető objektum
+Comment[is]=Myndbirtir KDE
+Comment[it]=Componente KDE per la visione di immagini
+Comment[ja]=KDE 画像ビューアパート
+Comment[kk]=KDE кескінді қарау құралының бөлшегі
+Comment[km]=ផ្នែក​របស់​កម្មវិធី​មើល​រូបភាព KDE
+Comment[lt]=KDE paveikslėlių žiūriklio dalis
+Comment[ms]=Bahagian Pemapar Imej KDE
+Comment[nb]=KDE-bildefremviserdel
+Comment[nds]=Bildkieker-Komponent för KDE
+Comment[ne]=KDE छवि दर्शक भाग
+Comment[nl]=KDE's weergavecomponent (Part) voor afbeeldingen
+Comment[nn]=Biletvisardel for KDE
+Comment[nso]=Seripa sa Molebeledi wa Ponagalo sa KDE
+Comment[pa]=KDE ਚਿੱਤਰ ਦਰਸ਼ਕ ਭਾਗ
+Comment[pl]=Składnik do przeglądarka obrazków KDE
+Comment[pt]=Componente de Visualização de Imagens do KDE
+Comment[pt_BR]=Parte do Visualizador de Imagens do KDE
+Comment[ro]=Componentă KDE de vizualizare imagini
+Comment[ru]=Компонент KDE просмотра изображений
+Comment[se]=KDE:a govvačájehanoassi
+Comment[sk]=Part KDE Prehliadač obrázkov
+Comment[sl]=Del pregledovalnika slik KDE
+Comment[sr]=KDE-ов део за приказивање слика
+Comment[sr@Latn]=KDE-ov deo za prikazivanje slika
+Comment[sv]=KDE:s bildvisningsdel
+Comment[ta]=கேடிஇ பகுதி பிம்பக் காட்சி
+Comment[tg]=Қисмати KDE-и намоиши тасвирот
+Comment[tr]=KDE Resim Göstericisi Kısmı
+Comment[uk]=Складова KDE переглядача зображень
+Comment[ven]=Tshipida tsha muvhoni wa tshifanyiso tsha KDE
+Comment[xh]=Iqhekeza Lombonisi Womfanekiso we KDE
+Comment[zh_CN]=KDE 图像查看器组件
+Comment[zh_HK]=KDE 圖像檢視器組件
+Comment[zh_TW]=KDE 影像檢視器組件
+Comment[zu]=Ingxenye Yombukisi Wesithombe se-KDE
+MimeType=image/gif;image/x-xpm;image/x-xbm;image/jpeg;image/x-bmp;image/png;image/x-ico;image/x-portable-bitmap;image/x-portable-pixmap;image/x-portable-greymap;image/tiff;image/jp2
+Name=KView Image Viewer
+Name[ar]=عارض KView للصور
+Name[br]=Gweler skeudennoù KView
+Name[bs]=KView predglednik slika
+Name[ca]=Visualitzador d'imatges KView
+Name[cs]=Prohlížeč obrázků KView
+Name[cy]=Celfigyn Gwelydd Delweddau KGweld
+Name[da]=KView-billedfremviser
+Name[de]=Bildbetrachter KView
+Name[el]=Προβολέας εικόνων KView
+Name[eo]=KView-Bildrigardilo
+Name[es]=Visor de imágenes de KView
+Name[et]=KView pildifailide näitaja
+Name[eu]=KView irudi ikustailea
+Name[fa]=مشاهده‌گر تصویر KView
+Name[fi]=KView-kuvannäytin
+Name[fr]=Visualisateur d'images KView
+Name[gl]=Visor de imaxes KView
+Name[he]=מציג תמונות KView
+Name[hi]=के-व्यू छवि प्रदर्शक
+Name[hu]=KView képnézegető
+Name[is]=KView myndbirtirinn
+Name[it]=Visore di immagini KView
+Name[ja]=KView 画像ビューア
+Name[kk]=KView кескінді қарау құралы
+Name[km]=កម្មវិធី​មើល​រូបភាព KView
+Name[lt]=KView paveikslėlių žiūryklė
+Name[ms]=Pemapar Imej KView
+Name[nb]=Bildeviseren KView
+Name[nds]=Bildkieker KView
+Name[ne]=केडीई दृश्य छवि दर्शक
+Name[nl]=KView afbeeldingenweergave
+Name[nn]=Biletvisaren KView
+Name[pa]=KView ਚਿੱਤਰ ਦਰਸ਼ਕ
+Name[pl]=Przeglądarka obrazków KView
+Name[pt]=Visualizador de Imagens KView
+Name[pt_BR]=Visualizador de Imagens do KVisualização
+Name[ro]=Vizualizor imagini KView
+Name[ru]=Программа просмотра изображений KView
+Name[se]=KView govvačájeheaddji
+Name[sk]=Prehliadač obrázkov KView
+Name[sl]=Pregledovalnik slik KView
+Name[sr]=KView, приказивач слика
+Name[sr@Latn]=KView, prikazivač slika
+Name[sv]=Kview bildvisning
+Name[ta]=கேகாட்சி பிம்பக் காட்சி
+Name[tg]=Барномаи намоиши тасвироти KView
+Name[tr]=KView Resim Görüntüleyici
+Name[uk]=Переглядач зображень KView
+Name[wa]=KView Håyneu d' imådjes
+Name[zh_CN]=KView 图像查看器
+Name[zh_HK]=KView 圖像檢視器
+Name[zh_TW]=KView 影像檢視器
+ServiceTypes=KImageViewer/Viewer,KParts/ReadWritePart,Browser/View
+InitialPreference=3
+X-KDE-Library=libkviewviewer
diff --git a/kview/kviewviewer/kviewviewer.h b/kview/kviewviewer/kviewviewer.h
new file mode 100644
index 00000000..4c5f13a0
--- /dev/null
+++ b/kview/kviewviewer/kviewviewer.h
@@ -0,0 +1,145 @@
+/* This file is part of the KDE project
+ Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
+ 2001-2002 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+*/
+#ifndef __kviewviewer_h__
+#define __kviewviewer_h__
+
+#include "kimageviewer/viewer.h"
+#include "kviewkonqextension.h"
+
+#include <qvaluevector.h>
+#include "kviewvieweriface.h"
+#include <kdemacros.h>
+
+namespace KImageViewer { class Canvas; }
+namespace KIO { class Job; }
+
+class KTempFile;
+class KAction;
+class KActionMenu;
+class KToggleAction;
+class KSelectAction;
+class KAboutData;
+class QBuffer;
+class QSize;
+class KDirWatch;
+template<class T>
+class QCache;
+
+class KDE_EXPORT KViewViewer : public KImageViewer::Viewer, public KViewViewerIface
+{
+ Q_OBJECT
+ friend class KViewKonqExtension;
+
+ public:
+ KViewViewer( QWidget * parentWidget, const char * widgetName,
+ QObject * parent, const char * name, const QStringList & );
+ virtual ~KViewViewer();
+
+ KImageViewer::Canvas * canvas() const { return m_pCanvas; }
+ static KAboutData * createAboutData();
+ virtual void setReadWrite( bool readwrite = true );
+ KParts::BrowserExtension * browserExtension() const { return m_pExtension; }
+
+ bool saveAs( const KURL & );
+ void setModified( bool );
+
+ public slots:
+ virtual bool openURL( const KURL & );
+ virtual bool closeURL();
+ virtual void newImage( const QImage & );
+ virtual void reload();
+
+ protected:
+ bool eventFilter( QObject *, QEvent * ); // for DnD
+ void abortLoad();
+ virtual bool openFile();
+ virtual bool saveFile();
+
+ virtual void setupActions();
+ void guiActivateEvent( KParts::GUIActivateEvent * );
+
+ void writeSettings();
+
+ protected slots:
+ void readSettings();
+ void zoomChanged( double );
+ void slotJobFinished( KIO::Job * );
+ void slotData( KIO::Job *, const QByteArray & );
+
+ void slotSave();
+ void slotSaveAs();
+ void slotZoomIn();
+ void slotZoomOut();
+ void setZoom( const QString & );
+ void updateZoomMenu( double zoom );
+ void slotFlipH();
+ void slotFlipV();
+ void slotRotateCCW();
+ void slotRotateCW();
+ void slotFitToWin();
+ void slotDel();
+
+ void slotPopupMenu( const QPoint & );
+ void slotResultSaveAs( KIO::Job * );
+
+ void slotFileDirty( const QString & );
+ void slotReloadUnmodified();
+
+ void slotToggleScrollbars();
+
+ void loadPlugins();
+
+ void switchBlendEffect();
+ void hasImage( bool );
+
+ private:
+ QWidget * m_pParentWidget;
+ KIO::Job * m_pJob;
+ KViewKonqExtension * m_pExtension;
+ KImageViewer::Canvas * m_pCanvas;
+ KTempFile * m_pTempFile;
+ QBuffer * m_pBuffer;
+ KDirWatch * m_pFileWatch;
+
+ // Actions:
+ KAction * m_paZoomIn;
+ KAction * m_paZoomOut;
+ KSelectAction * m_paZoom;
+ KActionMenu * m_paFlipMenu;
+ KAction * m_paFlipH;
+ KAction * m_paFlipV;
+ KAction * m_paRotateCCW;
+ KAction * m_paRotateCW;
+ KAction * m_paSave;
+ KAction * m_paSaveAs;
+ KAction * m_paFitToWin;
+ KToggleAction * m_paShowScrollbars;
+
+ QString m_popupDoc;
+ QString m_mimeType;
+ QString m_newMimeType;
+ QString m_sCaption;
+
+ QValueVector<unsigned int> m_vEffects;
+};
+
+// vim:sw=4:ts=4
+
+#endif
diff --git a/kview/kviewviewer/kviewviewer.rc b/kview/kviewviewer/kviewviewer.rc
new file mode 100644
index 00000000..cc36070b
--- /dev/null
+++ b/kview/kviewviewer/kviewviewer.rc
@@ -0,0 +1,36 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="KViewViewer Part" version="6">
+ <MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_save" group="save_merge_group"/>
+ <Action name="file_save_as" group="save_merge_group"/>
+ </Menu>
+ <Menu name="edit"><text>&amp;Edit</text>
+ <Action name="flip"/>
+ <Action name="rotateCCW"/>
+ <Action name="rotateCW"/>
+ </Menu>
+ <Menu name="view"><text>&amp;View</text>
+ <Action name="zoomin"/>
+ <Action name="view_zoom"/>
+ <Action name="zoomout"/>
+ <Separator/>
+ <Action name="fittowin"/>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="show_scrollbars" group="show_merge_group" />
+ </Menu>
+ </MenuBar>
+ <ToolBar name="mainToolBar"><text>Main Toolbar</text>
+ <Action name="file_save_as"/>
+ <Action name="zoomin"/>
+ <Action name="view_zoom"/>
+ <Action name="zoomout"/>
+ <Action name="rotateCCW"/>
+ <Action name="rotateCW"/>
+ </ToolBar>
+ <Menu name="popupmenu">
+ <Separator/>
+ <Action name="saveimageas" group="file_group"/>
+ </Menu>
+</kpartgui>
diff --git a/kview/kviewviewer/kviewviewer_ro.rc b/kview/kviewviewer/kviewviewer_ro.rc
new file mode 100644
index 00000000..f266217c
--- /dev/null
+++ b/kview/kviewviewer/kviewviewer_ro.rc
@@ -0,0 +1,34 @@
+<!DOCTYPE kpartgui>
+<kpartgui name="KViewViewer Part" version="7">
+ <MenuBar>
+ <Menu name="file"><text>&amp;File</text>
+ <Action name="file_save_as" group="save_merge_group"/>
+ </Menu>
+ <Menu name="view"><text>&amp;View</text>
+ <Action name="zoomin"/>
+ <Action name="view_zoom"/>
+ <Action name="zoomout"/>
+ <Separator/>
+ <Action name="fittowin"/>
+ <Separator/>
+ <Action name="flip"/>
+ <Action name="rotateCCW"/>
+ <Action name="rotateCW"/>
+ </Menu>
+ <Menu name="settings"><text>&amp;Settings</text>
+ <Action name="show_scrollbars" group="show_merge_group" />
+ </Menu>
+ </MenuBar>
+ <ToolBar name="mainToolBar"><text>Main Toolbar</text>
+ <Action name="file_save_as"/>
+ <Action name="zoomin"/>
+ <Action name="view_zoom"/>
+ <Action name="zoomout"/>
+ <Action name="rotateCCW"/>
+ <Action name="rotateCW"/>
+ </ToolBar>
+ <Menu name="popupmenu">
+ <Separator/>
+ <Action name="saveimageas" group="file_group"/>
+ </Menu>
+</kpartgui>
diff --git a/kview/kviewviewer/kviewvieweriface.h b/kview/kviewviewer/kviewvieweriface.h
new file mode 100644
index 00000000..19a56232
--- /dev/null
+++ b/kview/kviewviewer/kviewvieweriface.h
@@ -0,0 +1,30 @@
+/* This file is part of the KDE project
+ Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License version 2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+*/
+// $Id$
+
+#ifndef KVIEWVIEWERIFACE_H
+#define KVIEWVIEWERIFACE_H
+
+class KViewViewerIface
+{
+};
+
+#endif // KVIEWVIEWERIFACE_H
+
+// vim: sw=4 ts=4
diff --git a/kview/kviewviewer/printimagesettings.ui b/kview/kviewviewer/printimagesettings.ui
new file mode 100644
index 00000000..4944ef3c
--- /dev/null
+++ b/kview/kviewviewer/printimagesettings.ui
@@ -0,0 +1,190 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>PrintImageSettings</class>
+<author>Matthias Kretz &lt;kretz@kde.org&gt;</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>PrintImageSettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>167</width>
+ <height>223</height>
+ </rect>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QButtonGroup">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="title">
+ <string>Image Size</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton1</cstring>
+ </property>
+ <property name="text">
+ <string>Fit to page size</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton2</cstring>
+ </property>
+ <property name="text">
+ <string>9x13</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton3</cstring>
+ </property>
+ <property name="text">
+ <string>10x15</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton">
+ <property name="name">
+ <cstring>radioButton4</cstring>
+ </property>
+ <property name="text">
+ <string>Manual</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>kIntSpinBox1</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>4</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>x</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>kIntSpinBox2</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>checkBox1</cstring>
+ </property>
+ <property name="text">
+ <string>Center on page</string>
+ </property>
+ </widget>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+</widget>
+<includes>
+ <include location="global" impldecl="in implementation">kdialog.h</include>
+</includes>
+<layoutdefaults spacing="6" margin="11"/>
+<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/>
+<includehints>
+ <includehint>qwidget.h</includehint>
+ <includehint>knuminput.h</includehint>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/kview/kviewviewer/test/Makefile.am b/kview/kviewviewer/test/Makefile.am
new file mode 100644
index 00000000..605435cc
--- /dev/null
+++ b/kview/kviewviewer/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)
diff --git a/kview/kviewviewer/test/main.cpp b/kview/kviewviewer/test/main.cpp
new file mode 100644
index 00000000..95910126
--- /dev/null
+++ b/kview/kviewviewer/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("KView Viewer Part Test");
+
+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("kviewviewertest", I18N_NOOP("KView Viewer Test"), 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(Test)
+ else
+ {
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if ( args->count() == 0 )
+ {
+ Test *widget = new Test;
+ widget->show();
+ }
+ else
+ {
+ int i = 0;
+ for (; i < args->count(); i++ )
+ {
+ Test *widget = new Test;
+ widget->show();
+ widget->load( args->url( i ) );
+ }
+ }
+ args->clear();
+ }
+
+ return app.exec();
+}
diff --git a/kview/kviewviewer/test/test.cpp b/kview/kviewviewer/test/test.cpp
new file mode 100644
index 00000000..d4659e6c
--- /dev/null
+++ b/kview/kviewviewer/test/test.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2001 Matthias Kretz <kretz@kde.org>
+ */
+
+#include "test.h"
+#include <kimageviewer/viewer.h>
+
+#include <kurl.h>
+#include <klibloader.h>
+#include <kmessagebox.h>
+#include <kparts/componentfactory.h>
+#include <kapplication.h>
+
+#include <qimage.h>
+
+Test::Test()
+ : KParts::MainWindow( 0, "KView Viewer Test" ),
+ m_part( 0 )
+{
+ m_part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadWritePart>(
+ "image/jpeg", "Name == 'Image Viewer Part'", this, 0, this );
+ if( m_part )
+ {
+ setCentralWidget( m_part->widget() );
+ createGUI( m_part );
+ }
+ else
+ {
+ KMessageBox::error(this, "Could not find our Part!");
+ kapp->quit();
+ }
+}
+
+Test::~Test()
+{
+}
+
+void Test::load(const KURL& url)
+{
+ m_part->openURL( url );
+}
+
+#include "test.moc"
diff --git a/kview/kviewviewer/test/test.h b/kview/kviewviewer/test/test.h
new file mode 100644
index 00000000..82777090
--- /dev/null
+++ b/kview/kviewviewer/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 KParts { class ReadWritePart; }
+
+class Test : public KParts::MainWindow
+{
+ Q_OBJECT
+public:
+ Test();
+ virtual ~Test();
+ void load(const KURL& url);
+
+private:
+ KParts::ReadWritePart * m_part;
+};
+
+#endif // KIMAGEVIEWERTEST_H