diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 47d455dd55be855e4cc691c32f687f723d9247ee (patch) | |
tree | 52e236aaa2576bdb3840ebede26619692fed6d7d /kview/modules | |
download | tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.tar.gz tdegraphics-47d455dd55be855e4cc691c32f687f723d9247ee.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/kdegraphics@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kview/modules')
50 files changed, 4052 insertions, 0 deletions
diff --git a/kview/modules/Makefile.am b/kview/modules/Makefile.am new file mode 100644 index 00000000..cfd6a400 --- /dev/null +++ b/kview/modules/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = scanner presenter browser effects diff --git a/kview/modules/NAMING b/kview/modules/NAMING new file mode 100644 index 00000000..d70532ad --- /dev/null +++ b/kview/modules/NAMING @@ -0,0 +1,4 @@ +KView plugins +============= +Name: kview_<modulename>.la +LDFLAGS: -module $(KDE_PLUGIN) diff --git a/kview/modules/README b/kview/modules/README new file mode 100644 index 00000000..74c229c0 --- /dev/null +++ b/kview/modules/README @@ -0,0 +1,52 @@ +How to write a plugin for KView +=============================== + +There are two different kinds of plugins for KView that you may write: KPart +plugins for KView or the KView KPart (KViewViewer). + + +Writing the Plugin +================== + +You have to derive your plugin from KParts::Plugin and install the rc file under +the directory "data" (KDEDIR/share/apps/ usually)+"instancename/kpartplugins/" +(where instancename can be either kview or kviewviewer). If you install it under +kviewviewer the plugin will be loaded for the KPart (meaning it get's loaded in +e.g. Konqueror). If you install it under kview it only get's loaded when +starting the KView application. + +The parent that is passed on to your plugin will be a KImageViewer::Viewer +interface (which is also a KParts::ReadWritePart) if you make it a KViewViewer +plugin, else you'll be passed a pointer to KView (take a look at the template +plugin to see how to get to the KImageViewer::Viewer interface). + + +Plugin Desktop file +=================== + +Now you need to write a .desktop file for your plugin, containing the name, +a comment, author, email and plugin name. + +Here's a start: +------------------------------------------------------------------------------ +[Desktop Entry] +Name=Coolplugin +Comment=This is a very cool plugin doing foo and bar +Type=Plugin + +[X-KDE Plugin Info] +Author=Matthias Kretz +Email=kretz@kde.org +PluginName=kviewcool +Version=1.0 +------------------------------------------------------------------------------ + +The "PluginName" entry needs to be the same as the name attribut in your .rc +file (<kpartplugin name="kviewcool" library="kview_coolplugin">). + + +Examples +======== + +There are a few modules already in the original KView sources. Just take a look +at kdegraphics/kview/modules/*. diff --git a/kview/modules/browser/Makefile.am b/kview/modules/browser/Makefile.am new file mode 100644 index 00000000..001eefd0 --- /dev/null +++ b/kview/modules/browser/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_browserplugin.la + +kview_browserplugin_la_SOURCES = kmyfileitemlist.cpp kviewbrowser.cpp +kview_browserplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint +kview_browserplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kviewviewer/kpartplugins +plug_DATA = kviewbrowser.desktop kviewbrowser.rc + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kviewbrowserplugin.pot diff --git a/kview/modules/browser/kmyfileitemlist.cpp b/kview/modules/browser/kmyfileitemlist.cpp new file mode 100644 index 00000000..534e0876 --- /dev/null +++ b/kview/modules/browser/kmyfileitemlist.cpp @@ -0,0 +1,41 @@ +/* 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. + +*/ +// $Id$ + +#include "kmyfileitemlist.h" +#include <kfileitem.h> + +KMyFileItemList::KMyFileItemList() {} +KMyFileItemList::KMyFileItemList( const QPtrList<KFileItem> & l ) : QPtrList<KFileItem>( l ) {} + +KMyFileItemList & KMyFileItemList::operator=( const QPtrList<KFileItem> & l ) +{ + return (KMyFileItemList &)QPtrList<KFileItem>::operator=( l ); +} + +int KMyFileItemList::compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ) +{ + KFileItem * fileitem1 = static_cast<KFileItem *>( item1 ); + KFileItem * fileitem2 = static_cast<KFileItem *>( item2 ); + if( fileitem1->name() == fileitem2->name() ) + return 0; + else if( fileitem1->name() > fileitem2->name() ) + return 1; + else + return -1; +} diff --git a/kview/modules/browser/kmyfileitemlist.h b/kview/modules/browser/kmyfileitemlist.h new file mode 100644 index 00000000..052fce53 --- /dev/null +++ b/kview/modules/browser/kmyfileitemlist.h @@ -0,0 +1,39 @@ +/* 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. + +*/ +// $Id$ + +#ifndef __kmyfileitemlist_h__ +#define __kmyfileitemlist_h__ + +#include <qptrlist.h> +class KFileItem; + +class KMyFileItemList : public QPtrList<KFileItem> +{ + public: + KMyFileItemList(); + KMyFileItemList( const QPtrList<KFileItem> & ); + KMyFileItemList & operator=( const QPtrList<KFileItem> & ); + + protected: + virtual int compareItems( QPtrCollection::Item item1, QPtrCollection::Item item2 ); +}; + +// vim:sw=4:ts=4 + +#endif diff --git a/kview/modules/browser/kviewbrowser.cpp b/kview/modules/browser/kviewbrowser.cpp new file mode 100644 index 00000000..6da318b7 --- /dev/null +++ b/kview/modules/browser/kviewbrowser.cpp @@ -0,0 +1,179 @@ +/* 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. + +*/ +// $Id$ + +#include "kviewbrowser.h" +#include "kmyfileitemlist.h" + +#include <qcursor.h> + +#include <kdirlister.h> +#include <kaction.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kdebug.h> +#include <kimageviewer/viewer.h> +#include <kimageviewer/canvas.h> +#include <kparts/browserextension.h> +#include <kapplication.h> +#include <kimageio.h> + +typedef KGenericFactory<KViewBrowser> KViewBrowserFactory; +K_EXPORT_COMPONENT_FACTORY( kview_browserplugin, KViewBrowserFactory( "kviewbrowserplugin" ) ) + +KViewBrowser::KViewBrowser( QObject* parent, const char* name, const QStringList & ) + : Plugin( parent, name ) + , m_pDirLister( 0 ) + , m_pFileItemList( 0 ) + , m_bShowCurrent( false ) +{ + m_pViewer = static_cast<KImageViewer::Viewer *>( parent ); + if( m_pViewer ) + { + m_paBack = KStdAction::back ( this, SLOT( slotBack() ), actionCollection(), "previous_image" ); + m_paBack->setShortcut( SHIFT+Key_Left ); + m_paForward = KStdAction::forward( this, SLOT( slotForward() ), actionCollection(), "next_image" ); + m_paForward->setShortcut( SHIFT+Key_Right ); + m_pExtension = m_pViewer->browserExtension(); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the browser plugin won't work" << endl; +} + +KViewBrowser::~KViewBrowser() +{ + delete m_pDirLister; + delete m_pFileItemList; +} + +void KViewBrowser::openURL(const KURL &u) +{ + if (m_pViewer) + { + // Opening new URL resets zoom, so remember it. + double oldZoom = m_pViewer->canvas()->zoom(); + m_pViewer->openURL(u); + m_pViewer->canvas()->setZoom(oldZoom); + } + if( m_pExtension ) + { + emit m_pExtension->setLocationBarURL( u.prettyURL() ); + } +} + +void KViewBrowser::slotBack() +{ + setupDirLister(); + if( ! m_pFileItemList ) + return; + + KFileItem * item = m_pFileItemList->prev(); + if( ! item ) + item = m_pFileItemList->last(); + if( item ) + { + kdDebug( 4630 ) << item->url().prettyURL() << endl; + openURL( item->url() ); + } + else + kdDebug( 4630 ) << "no file found" << endl; + m_bShowCurrent = false; +} + +void KViewBrowser::slotForward() +{ + setupDirLister(); + if( ! m_pFileItemList ) + return; + + KFileItem * item = m_bShowCurrent ? m_pFileItemList->current() : m_pFileItemList->next(); + if( ! item ) + item = m_pFileItemList->first(); + if( item ) + { + kdDebug( 4630 ) << item->url().prettyURL() << endl; + openURL( item->url() ); + } + else + kdDebug( 4630 ) << "no file found" << endl; + m_bShowCurrent = false; +} + +void KViewBrowser::slotNewItems( const KFileItemList & items ) +{ + kdDebug( 4630 ) << k_funcinfo << endl; + delete m_pFileItemList; + m_pFileItemList = new KMyFileItemList( items ); + m_pFileItemList->sort(); + + // set the current pointer on the currently open image + KFileItem * item = m_pFileItemList->first(); + for( ; item; item = m_pFileItemList->next() ) + if( item->url() == m_pViewer->url() ) + break; +} + +void KViewBrowser::slotDeleteItem( KFileItem * item ) +{ + bool setToFirst = false; + if( m_pFileItemList->current() == item ) + { + // The current image is being removed + // we have to take care, that the next slotForward call returns the new current item + m_bShowCurrent = true; + + if( m_pFileItemList->getLast() == item ) + // The the current image is the last image - wrap around to the first + setToFirst = true; + } + + m_pFileItemList->remove( item ); + + if( setToFirst ) + ( void )m_pFileItemList->first(); +} + +void KViewBrowser::setupDirLister() +{ + if( ! m_pDirLister ) + { + kdDebug( 4630 ) << "create new KDirLister" << endl; + m_pDirLister = new KDirLister(); + m_pDirLister->setMimeFilter( KImageIO::mimeTypes( KImageIO::Reading ) ); + m_pDirLister->setShowingDotFiles( true ); + connect( m_pDirLister, SIGNAL( newItems( const KFileItemList & ) ), SLOT( slotNewItems( const KFileItemList & ) ) ); + connect( m_pDirLister, SIGNAL( deleteItem( KFileItem * ) ), SLOT( slotDeleteItem( KFileItem * ) ) ); + } + if( m_pDirLister->url() != KURL( m_pViewer->url().directory( true, false ) ) ) + { + QApplication::setOverrideCursor( WaitCursor ); + QString url = m_pViewer->url().prettyURL(); + int pos = url.findRev( "/" ); + url = url.left( (unsigned int)pos ); + kdDebug( 4630 ) << "open KDirLister for " << url << endl; + m_pDirLister->openURL( KURL( url )); + while( ! m_pDirLister->isFinished() ) + kapp->processEvents(); + //while( ! m_pFileItemList ) + //kapp->processEvents(); + QApplication::restoreOverrideCursor(); + } +} + +// vim:sw=4:ts=4:cindent +#include "kviewbrowser.moc" diff --git a/kview/modules/browser/kviewbrowser.desktop b/kview/modules/browser/kviewbrowser.desktop new file mode 100644 index 00000000..a5b66bcc --- /dev/null +++ b/kview/modules/browser/kviewbrowser.desktop @@ -0,0 +1,130 @@ +[Desktop Entry] +Icon=browser +Type=Service +ServiceTypes=KPluginInfo + +X-KDE-PluginInfo-Author=Matthias Kretz +X-KDE-PluginInfo-Email=kretz@kde.org +X-KDE-PluginInfo-Name=kviewbrowser +X-KDE-PluginInfo-Category=General +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Name=Browser +Name[af]=Blaaier +Name[ar]=المتصفح +Name[bg]=Браузър +Name[br]=Furcher +Name[bs]=Preglednik +Name[ca]=Fullejador +Name[cs]=Prohlížeč +Name[cy]=Porydd +Name[el]=Περιηγητής +Name[eo]=Trair-Rigardilo +Name[es]=Navegador +Name[et]=Sirvija +Name[eu]=Nabegatzailea +Name[fa]=مرورگر +Name[fi]=Selain +Name[fr]=Navigateur +Name[ga]=Brabhsálaí +Name[gl]=Explorador +Name[he]=דפדפן +Name[hi]=ब्राउज़र +Name[hr]=Preglednik +Name[hu]=Böngésző +Name[is]=Flakkari +Name[ja]=ブラウザ +Name[kk]=Шолғыш +Name[km]=កម្មវិធីរុករក +Name[lt]=Naršyklė +Name[ms]=Pelayar +Name[nb]=Leser +Name[nds]=Kieker +Name[ne]=ब्राउजर +Name[nl]=Bladeren +Name[nn]=Snøgglesar +Name[nso]=Seinyakisi +Name[pa]=ਝਲਕਾਰਾ +Name[pl]=Przeglądarka +Name[pt]=Navegador +Name[pt_BR]=Navegador +Name[ro]=Navigator +Name[ru]=Просмотр +Name[se]=Bláđđejeaddji +Name[sk]=Prehliadač +Name[sl]=Brskalnik +Name[sr]=Прегледач +Name[sr@Latn]=Pregledač +Name[sv]=Bläddrare +Name[ta]=உலாவி +Name[tg]=Воқеъанигор +Name[tr]=Tarayıcı +Name[uk]=Навігатор +Name[uz]=Brauzer +Name[uz@cyrillic]=Браузер +Name[ven]=Burausa +Name[wa]=Foyteuse +Name[xh]=Umkhangeli wencwadi +Name[zh_CN]=浏览器 +Name[zh_HK]=瀏覽器 +Name[zh_TW]=瀏覽器 +Name[zu]=Umcingi +Comment=Enables you to browse through all of the images in the current directory. +Comment[af]=Aktiveer jy na blaai deur alle van die beelde in die huidige gids. +Comment[ar]=يمكنك من تصفَح كل الصور في الدليل الحالي. +Comment[bg]=Преглед на изображенията в текущата директория +Comment[bs]=Omogućuje vam da pregledate sve slike u trenutnom direktoriju. +Comment[ca]=Us permet navegar entre totes les imatges del directori actual. +Comment[cs]=Umožňuje procházet všechny obrázky v aktuálním adresáři. +Comment[cy]=Alluogi i chi bori drwy pob delwedd yn y cyfeiriadur cyfredol. +Comment[da]=Lader dig gennemse alle billederne i denne mappe. +Comment[de]=Ermöglicht das Durchsehen der Bilder im aktuellen Ordner. +Comment[el]=Σας επιτρέπει να περιηγηθείτε σε όλες τις εικόνες στον τρέχον κατάλογο. +Comment[eo]=Permesas al vi povas trarigardi ĉiujn bildojn en la nuna dosierujo. +Comment[es]=Le permite navegar por todas las imágenes del directorio actual. +Comment[et]=Võimaldab sirvida aktiivse kataloogi kõiki pilte. +Comment[eu]=Uneko direktorioko irudien artean nabigatzen uzten dizu. +Comment[fa]=برای مرور تمام تصاویر موجود در فهرست راهنمای جاری شما را توانا میکند. +Comment[fi]=Mahdollistaa nykyisessä kansiossa olevien kuvien selailun +Comment[fr]=Permet de naviguer parmi les images dans le dossier courant. +Comment[gl]=Permítelle navegar a través de todas as imaxes no directorio actual. +Comment[he]=מאפשר לך לעיין בכל התמונות שבספריה הנוכחית +Comment[hi]=मौज़ूदा डिरेक्ट्री के सभी छवियों को ब्राउज़ करने में आपको सक्षम बनाता है. +Comment[hu]=Lehetővé teszi az aktuális könyvtárban található képek áttekintését, böngészését. +Comment[is]=Gerir þér kleyft að flakka í öllum myndunum í þessari möppu. +Comment[it]=Permette di navigare tra le immagini nella directory corrente. +Comment[ja]=現在のディレクトリのすべての画像をブラウズできるようになります。 +Comment[kk]=Назардағы қапшықтағы барлық кескіндерді шолу құралы. +Comment[km]=អាចឲ្យអ្នករកមើលរូបភាពទាំងអស់ នៅក្នុងថតបច្ចុប្បន្ន ។ +Comment[lt]=Leidžia jums naršyti visuose paveikslėliuose esamame aplanke. +Comment[ms]=Membolehkan anda melayar semua imej dalam direktori semasa. +Comment[nb]=Lar deg bla gjennom alle bildene i den gjeldende katalogen. +Comment[nds]=Dörkieken vun all Biller binnen den aktuellen Orner. +Comment[ne]=हालको डाइरेक्टरिमा छविको सबै तिर ब्राउज गर्न तपाईँलाई सक्षम पार्दछ । +Comment[nl]=Hiermee kunt u door alle afbeeldingen in de huidige map bladeren. +Comment[nn]=Let deg bla gjennom alle bileta i ein katalog. +Comment[nso]=Ego dumelela go inyakisa kago diponagalo kamoka kago tshupetso ya bjale. +Comment[pl]=Pozwala na przeglądanie wszystkich obrazków w bieżącym katalogu. +Comment[pt]=Permite-lhe navegar por todas as imagens na directoria actual. +Comment[pt_BR]=Habilita você a navegar por todas as imagens no diretório atual. +Comment[ro]=Vă permite să navigaţi prin toate imaginile din directorul curent. +Comment[ru]=Просмотр всех изображений в текущей папке. +Comment[se]=Diktá du bláđđet buot govaid čađa dán ozus. +Comment[sk]=Umožňuje prechádzať mezi obrázkami v aktuálnom priečinku. +Comment[sl]=Omogoča vam brskanje po vseh slikah v trenutni mapi. +Comment[sr]=Омогућава вам да прегледате све слике у текућем директоријуму +Comment[sr@Latn]=Omogućava vam da pregledate sve slike u tekućem direktorijumu +Comment[sv]=Låter dig bläddra igenom alla bilder i den aktuella katalogen. +Comment[ta]=நடப்பு அடைவில் உள்ள பிம்பங்களை எல்லாம் பார்க்க முடியும். +Comment[tg]=Намоиши тамоми тасвирот дар каталоги ҷорӣ. +Comment[tr]=Bulunduğunuz dizindeki tüm resimler arasında gezinmenizi sağlar. +Comment[uk]=Дозволяє навігацію всіх зображень в поточному каталозі. +Comment[ven]=Ini konisa u tshimbidza kha zwifanyiso zwothe kha tsumbavhulwo ya zwino. +Comment[wa]=Vos permete di foyter dins totes les imådjes do ridant do moumint. +Comment[xh]=Ikuvumela ukuba ukwazi ukukhangela yonke imifanekiso kulawulo lwangoku. +Comment[zh_CN]=使您能够浏览当前目录中的所有图像。 +Comment[zh_HK]=讓您瀏覽當前目錄的所有圖像。 +Comment[zh_TW]=讓您瀏覽目前目錄的所有影像。 +Comment[zu]=Ikuvumela ukuba ucinge ngokwedlulela izithombe ohlwini lwamafayela lwamanje. diff --git a/kview/modules/browser/kviewbrowser.h b/kview/modules/browser/kviewbrowser.h new file mode 100644 index 00000000..3ed918b6 --- /dev/null +++ b/kview/modules/browser/kviewbrowser.h @@ -0,0 +1,62 @@ +/* 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. + +*/ +// $Id$ + +#ifndef __kviewbrowser_h +#define __kviewbrowser_h + +#include <kparts/plugin.h> +#include <kfileitem.h> + +namespace KImageViewer { class Viewer; } + +namespace KParts { class BrowserExtension; } +class KAction; +class KDirLister; +class KMyFileItemList; + +class KViewBrowser : public KParts::Plugin +{ + Q_OBJECT +public: + KViewBrowser( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewBrowser(); + +private slots: + void slotBack(); + void slotForward(); + + void slotNewItems( const KFileItemList & ); + void slotDeleteItem( KFileItem * item ); + +private: + void setupDirLister(); + void openURL(const KURL &); + + KImageViewer::Viewer * m_pViewer; + KDirLister * m_pDirLister; + KMyFileItemList * m_pFileItemList; + KParts::BrowserExtension * m_pExtension; + bool m_bShowCurrent; + + KAction * m_paBack; + KAction * m_paForward; +}; + +// vim:sw=4:ts=4:cindent +#endif diff --git a/kview/modules/browser/kviewbrowser.rc b/kview/modules/browser/kviewbrowser.rc new file mode 100644 index 00000000..9a57cabb --- /dev/null +++ b/kview/modules/browser/kviewbrowser.rc @@ -0,0 +1,18 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kviewbrowser" library="kview_browserplugin"> + <MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="previous_image"/> + <Action name="next_image"/> + </Menu> + </MenuBar> + <ToolBar name="extraToolBar"> + <text>Extra Toolbar</text> + <Action name="previous_image"/> + <Action name="next_image"/> + </ToolBar> + <Menu name="popupmenu"> + <Action name="previous_image"/> + <Action name="next_image"/> + </Menu> +</kpartplugin> diff --git a/kview/modules/effects/Makefile.am b/kview/modules/effects/Makefile.am new file mode 100644 index 00000000..64205856 --- /dev/null +++ b/kview/modules/effects/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_effectsplugin.la + +kview_effectsplugin_la_SOURCES = kvieweffects.cpp +kview_effectsplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint +kview_effectsplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kview/kpartplugins +plug_DATA = kvieweffects.desktop kvieweffects.rc + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kvieweffectsplugin.pot diff --git a/kview/modules/effects/kvieweffects.cpp b/kview/modules/effects/kvieweffects.cpp new file mode 100644 index 00000000..9295c876 --- /dev/null +++ b/kview/modules/effects/kvieweffects.cpp @@ -0,0 +1,244 @@ +/* This file is in the public domain */ + +// $Id$ + +#include "kvieweffects.h" + +#include <qobjectlist.h> + +#include <kaction.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kdebug.h> +#include <kimageviewer/viewer.h> +#include <kimageviewer/canvas.h> +#include <kdialogbase.h> +#include <knuminput.h> +#include <kiconeffect.h> +#include <qvbox.h> +#include <kcolorbutton.h> +#include <kimageeffect.h> +#include <qlabel.h> +#include <assert.h> + +typedef KGenericFactory<KViewEffects> KViewEffectsFactory; +K_EXPORT_COMPONENT_FACTORY( kview_effectsplugin, KViewEffectsFactory( "kvieweffectsplugin" ) ) + +KViewEffects::KViewEffects( QObject* parent, const char* name, const QStringList & ) + : Plugin( parent, name ) + , m_gamma( 0.5 ), m_lastgamma( -1.0 ) + , m_opacity( 50 ), m_lastopacity( -1 ) + , m_intensity( 50 ), m_lastintensity( -1 ) + , m_color( white ) + , m_image( 0 ) +{ + QObjectList * viewerList = parent->queryList( 0, "KImageViewer Part", false, false ); + m_pViewer = static_cast<KImageViewer::Viewer *>( viewerList->getFirst() ); + delete viewerList; + if( m_pViewer ) + { + KAction * gammaaction = new KAction( i18n( "&Gamma Correction..." ), 0, 0, + this, SLOT( gamma() ), + actionCollection(), "plugin_effects_gamma" ); + KAction * blendaction = new KAction( i18n( "&Blend Color..." ), 0, 0, + this, SLOT( blend() ), + actionCollection(), "plugin_effects_blend" ); + KAction * intensityaction = new KAction( i18n( "Change &Intensity (Brightness)..." ), 0, 0, + this, SLOT( intensity() ), + actionCollection(), "plugin_effects_intensity" ); + gammaaction->setEnabled( m_pViewer->canvas()->image() != 0 ); + blendaction->setEnabled( m_pViewer->canvas()->image() != 0 ); + intensityaction->setEnabled( m_pViewer->canvas()->image() != 0 ); + connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), gammaaction, SLOT( setEnabled( bool ) ) ); + connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), blendaction, SLOT( setEnabled( bool ) ) ); + connect( m_pViewer->widget(), SIGNAL( hasImage( bool ) ), intensityaction, SLOT( setEnabled( bool ) ) ); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the effects plugin won't work" << endl; +} + +KViewEffects::~KViewEffects() +{ + // no need to delete m_image here since it will always be NULL at this + // point. + assert( m_image == 0 ); +} + +void KViewEffects::intensity() +{ + KDialogBase dlg( m_pViewer->widget(), "Intensity Dialog", true /*modal*/, i18n( "Change Intensity" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel ); + connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyIntensity() ) ); + + QVBox * vbox = new QVBox( &dlg ); + vbox->setSpacing( KDialog::spacingHint() ); + dlg.setMainWidget( vbox ); + KIntNumInput * percent = new KIntNumInput( vbox, "Intensity Input" ); + percent->setRange( 0, 100, 1, true ); + percent->setValue( m_intensity ); + percent->setLabel( i18n( "&Intensity:" ) ); + percent->setSuffix( QString::fromAscii( "%" ) ); + connect( percent, SIGNAL( valueChanged( int ) ), this, SLOT( setIntensity( int ) ) ); + + int result = dlg.exec(); + if( result == QDialog::Accepted ) + { + applyIntensity(); + m_pViewer->setModified( true ); + } + else + if( m_image ) + m_pViewer->canvas()->setImage( *m_image ); + m_lastintensity = -1; + delete m_image; + m_image = 0; +} + +void KViewEffects::setIntensity( int intensity ) +{ + m_intensity = intensity; +} + +void KViewEffects::applyIntensity() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( m_intensity == m_lastintensity ) + return; // nothing to do + + QImage * work = workImage(); + if( work ) + { + KImageEffect::intensity( *work, m_intensity * 0.01 ); + m_pViewer->canvas()->setImage( *work ); + delete work; + m_lastintensity = m_intensity; + } +} + +void KViewEffects::blend() +{ + KDialogBase dlg( m_pViewer->widget(), "Blend Color Dialog", true /*modal*/, i18n( "Blend Color" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel ); + connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyBlend() ) ); + + QVBox * vbox = new QVBox( &dlg ); + vbox->setSpacing( KDialog::spacingHint() ); + dlg.setMainWidget( vbox ); + KIntNumInput * opacity = new KIntNumInput( vbox, "Opacity Input" ); + opacity->setRange( 0, 100, 1, true ); + opacity->setValue( m_opacity ); + opacity->setLabel( i18n( "O&pacity:" ) ); + opacity->setSuffix( QString::fromAscii( "%" ) ); + connect( opacity, SIGNAL( valueChanged( int ) ), this, SLOT( setOpacity( int ) ) ); + QLabel * label = new QLabel( i18n( "Blend c&olor:" ), vbox ); + KColorButton * color = new KColorButton( m_color, vbox, "Color Input Button" ); + label->setBuddy( color ); + connect( color, SIGNAL( changed( const QColor & ) ), this, SLOT( setColor( const QColor & ) ) ); + + int result = dlg.exec(); + if( result == QDialog::Accepted ) + { + applyBlend(); + m_pViewer->setModified( true ); + } + else + if( m_image ) + m_pViewer->canvas()->setImage( *m_image ); + m_lastopacity = -1; + delete m_image; + m_image = 0; +} + +void KViewEffects::setOpacity( int opacity ) +{ + m_opacity = opacity; +} + +void KViewEffects::setColor( const QColor & color ) +{ + m_color = color; +} + +void KViewEffects::applyBlend() +{ + if( m_opacity == m_lastopacity ) + return; // nothing to do + + QImage * work = workImage(); + if( work ) + { + KImageEffect::blend( m_color, *work, m_opacity * 0.01 ); + m_pViewer->canvas()->setImage( *work ); + delete work; + m_lastopacity = m_opacity; + } +} + +void KViewEffects::gamma() +{ + KDialogBase dlg( m_pViewer->widget(), "Gamma Correction Dialog", true /*modal*/, i18n( "Gamma Correction" ), KDialogBase::Ok | KDialogBase::Try | KDialogBase::Cancel ); + connect( &dlg, SIGNAL( tryClicked() ), this, SLOT( applyGammaCorrection() ) ); + + // create dialog + KDoubleNumInput * gammavalue = new KDoubleNumInput( 0.0, 1.0, 0.5, 0.01, 4, &dlg, "Gamma value input" ); + gammavalue->setRange( 0.0, 1.0, 0.01, true ); + connect( gammavalue, SIGNAL( valueChanged( double ) ), this, SLOT( setGammaValue( double ) ) ); + gammavalue->setLabel( i18n( "Gamma value:" ) ); + dlg.setMainWidget( gammavalue ); + + int result = dlg.exec(); + if( result == QDialog::Accepted ) + { + // apply gamma correction + applyGammaCorrection(); + m_pViewer->setModified( true ); + } + else + { + if( m_image ) + m_pViewer->canvas()->setImage( *m_image ); + } + m_lastgamma = -1; + delete m_image; + m_image = 0; +} + +void KViewEffects::setGammaValue( double gamma ) +{ + m_gamma = gamma; + kdDebug( 4630 ) << "m_gamma = " << m_gamma << endl; + // TODO: show effect on the fly if requested +} + +void KViewEffects::applyGammaCorrection() +{ + if( m_gamma == m_lastgamma ) + return; // nothing to do + + QImage * corrected = workImage(); + if( corrected ) + { + KIconEffect::toGamma( *corrected, m_gamma ); + m_pViewer->canvas()->setImage( *corrected ); + delete corrected; + m_lastgamma = m_gamma; + } +} + +inline QImage * KViewEffects::workImage() +{ + if( ! m_image ) + { + const QImage * canvasimage = m_pViewer->canvas()->image(); + if( canvasimage ) + m_image = new QImage( *canvasimage ); + } + if( m_image ) + { + QImage * changed = new QImage( *m_image ); + changed->detach(); + return changed; + } + return 0; +} + +// vim:sw=4:ts=4:cindent +#include "kvieweffects.moc" diff --git a/kview/modules/effects/kvieweffects.desktop b/kview/modules/effects/kvieweffects.desktop new file mode 100644 index 00000000..1f13781d --- /dev/null +++ b/kview/modules/effects/kvieweffects.desktop @@ -0,0 +1,119 @@ +[Desktop Entry] +Icon=effects +Type=Service +ServiceTypes=KPluginInfo + +X-KDE-PluginInfo-Author=Matthias Kretz +X-KDE-PluginInfo-Email=kretz@kde.org +X-KDE-PluginInfo-Name=kvieweffects +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false + +Name=Effects +Name[ar]=مؤثرات +Name[bg]=Ефекти +Name[bs]=Efekti +Name[ca]=Efectes +Name[cs]=Efekty +Name[cy]=Effeithiau +Name[da]=Effekter +Name[de]=Effekte +Name[el]=Εφέ +Name[eo]=Efektoj +Name[es]=Efectos +Name[et]=Efektid +Name[eu]=Efectuak +Name[fa]=اثرها +Name[fi]=Tehosteet +Name[fr]=Effets +Name[ga]=Maisíochtaí +Name[gl]=Efectos +Name[he]=אפקטים +Name[hi]=प्रभाव +Name[hu]=Effektusok +Name[is]=Brellur +Name[it]=Effetti +Name[ja]=効果 +Name[kk]=Эффекттері +Name[km]=បែបផែន +Name[lt]=Efektai +Name[ms]=Kesan +Name[nb]=Effekter +Name[nds]=Effekten +Name[ne]=असर +Name[nl]=Effecten +Name[nn]=Effektar +Name[pa]=ਪ੍ਰਭਾਵ +Name[pl]=Efekty +Name[pt]=Efeitos +Name[pt_BR]=Efeitos +Name[ro]=Efecte +Name[ru]=Эффекты +Name[sk]=Efekty +Name[sl]=Učinki +Name[sr]=Ефекти +Name[sr@Latn]=Efekti +Name[sv]=Effekter +Name[ta]=விளைவுகள் +Name[tg]=Воситаҳо +Name[tr]=Efektler +Name[uk]=Ефекти +Name[uz]=Effektlar +Name[uz@cyrillic]=Эффектлар +Name[wa]=Efets +Name[zh_CN]=特效 +Name[zh_HK]=效果 +Name[zh_TW]=特效 +Comment=Provides some image effects +Comment[ar]=يقدم بعض مؤثرات الصور +Comment[bg]=Визуални ефекти при зареждане на изображенията +Comment[bs]=Pruža neke efekte za slike +Comment[ca]=Proporciona alguns efectes d'imatges +Comment[cs]=Poskytuje několik efektů pro obrázky +Comment[cy]=Darparu rhai effeithiau delwedd +Comment[da]=Sørger for nogle billedeffekter +Comment[de]=Stellt einige Bildverarbeitungseffekte zur Verfügung +Comment[el]=Παρέχει μερικά εφέ εικόνας +Comment[eo]=Provizas kelkajn bildefektojn +Comment[es]=Proporciona alguno efectos para imágenes +Comment[et]=Mõned pildiefektid +Comment[eu]=Irudi efektu batzuk eskuratzen ditu +Comment[fa]=برخی اثرهای تصویر را فراهم میکند +Comment[fi]=Tarjoaa joitain kuvatehosteita +Comment[fr]=Fournit des effets sur les images +Comment[gl]=Proporciona algúns efectos para as imaxes +Comment[he]=מספק מספר אפקטים עבור תמונות +Comment[hi]=छवि में प्रभाव उत्पन्न करता है +Comment[hu]=Képeffektusok használata +Comment[is]=Býður uppá ýmsar myndbrellur +Comment[it]=Fornisce alcuni effetti per le immagini +Comment[ja]=画像効果を提供します +Comment[kk]=Кескіндердің кейбір эффектерін іске асыру +Comment[km]=ផ្ដល់នូវបែបផែនរូបភាពមួយចំនួន +Comment[lt]=Prideda kai kuriuos paveikslėlių efektus +Comment[ms]=Menyediakan beberapa kesan imej +Comment[nb]=Utfører noen effekter på bilder +Comment[nds]=Stellt en poor Bildeffekten praat +Comment[ne]=केही छवि असर प्रदान गर्दछ +Comment[nl]=Biedt enkele effecten om afbeeldingen te bewerken +Comment[nn]=Utfører nokre effektar på bilete +Comment[pl]=Dodaje kilka efektów do obrazków +Comment[pt]=Fornece alguns efeitos de imagem +Comment[pt_BR]=Fornece alguns efeitos de imagem +Comment[ro]=Oferă unele efecte pentru imagini +Comment[ru]=Некоторые эффекты обработки изображений +Comment[sk]=Poskytuje niektoré efekty pre obrázky +Comment[sl]=Prinaša nekaj učinkov za slike +Comment[sr]=Пружа неке сликовне ефекте +Comment[sr@Latn]=Pruža neke slikovne efekte +Comment[sv]=Tillhandahåller vissa bildeffekter +Comment[ta]=சில பிம்ப விளைவுகளை தருகிறது +Comment[tg]=Якчанд воситаҳои коркарди тасвирот +Comment[tr]=Resim efektleri oluşturur +Comment[uk]=Надає деякі ефекти зображень +Comment[uz]=Rasm effektlari +Comment[uz@cyrillic]=Расм эффектлари +Comment[zh_CN]=提供某些图像特效 +Comment[zh_HK]=提供一些圖像效果 +Comment[zh_TW]=提供影像特效 diff --git a/kview/modules/effects/kvieweffects.h b/kview/modules/effects/kvieweffects.h new file mode 100644 index 00000000..0bf92a8e --- /dev/null +++ b/kview/modules/effects/kvieweffects.h @@ -0,0 +1,46 @@ +/* This file is in the public domain */ + +// $Id$ + +#ifndef KVIEWEFFECTS_H +#define KVIEWEFFECTS_H + +#include <kparts/plugin.h> +#include <qcolor.h> + +namespace KImageViewer { class Viewer; } + +class KViewEffects : public KParts::Plugin +{ + Q_OBJECT +public: + KViewEffects( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewEffects(); + +private slots: + void intensity(); + void setIntensity( int ); + void applyIntensity(); + + void blend(); + void setOpacity( int ); + void setColor( const QColor & ); + void applyBlend(); + + void gamma(); + void setGammaValue( double ); + void applyGammaCorrection(); + +private: + QImage * workImage(); + + KImageViewer::Viewer * m_pViewer; + double m_gamma, m_lastgamma; + int m_opacity, m_lastopacity; + int m_intensity, m_lastintensity; + QColor m_color; + QImage * m_image; +}; + +// vim:sw=4:ts=4:cindent +#endif // KVIEWEFFECTS_H diff --git a/kview/modules/effects/kvieweffects.rc b/kview/modules/effects/kvieweffects.rc new file mode 100644 index 00000000..d0c4eda6 --- /dev/null +++ b/kview/modules/effects/kvieweffects.rc @@ -0,0 +1,10 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kvieweffects" library="kview_effectsplugin" version="2"> + <MenuBar> + <Menu name="effects"><Text>Effe&cts</Text> + <Action name="plugin_effects_gamma"/> + <Action name="plugin_effects_blend"/> + <Action name="plugin_effects_intensity"/> + </Menu> + </MenuBar> +</kpartplugin> diff --git a/kview/modules/presenter/DESIGN b/kview/modules/presenter/DESIGN new file mode 100644 index 00000000..11d77121 --- /dev/null +++ b/kview/modules/presenter/DESIGN @@ -0,0 +1,42 @@ +Presenter Plugin: +- Features: + - a playlist with image infos: + - possibly get info from KFileMetaInfo + - image infos are readable for the user + - image infos for the program + - keeps track of images that were opened + - new action to load multiple files into the 'playlist' + - shuffle functions: + - shuffle the playlist + - load a random picture from the list (don't show the same image + again, though) + - order the items in the list via DnD + - order items alphabetically + - slideshow: + - configurable interval between images (in msecs) + - blending effects (put those effects in the imagecanvas) + - optionally keep image size <= canvas size + - preload next image (optionally) + +- Implementation: + - Playlist: + - KListView + - Items: + - derived from KListViewItem + - load Info in the background + - keep local copy of downloaded files + - delete local copy on destruction + - API: + QImage * image(); + KURL url(); + QString file(); //returns local filename or QString::null + - when loading an item from the playlist first ask for a + QImage, if that's not available ask for a local file, if + that's also not available take the url. + - API: + QImage * image(); + QString file(); + KURL url(); + void setRandom(bool); + void randomizeList(); + void orderAlphabetically(); diff --git a/kview/modules/presenter/Makefile.am b/kview/modules/presenter/Makefile.am new file mode 100644 index 00000000..905bd1fc --- /dev/null +++ b/kview/modules/presenter/Makefile.am @@ -0,0 +1,17 @@ +SUBDIRS = . + +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_presenterplugin.la + +kview_presenterplugin_la_SOURCES = imagelistitem.cpp imagelistdialog.ui kviewpresenter.cpp +kview_presenterplugin_la_LIBADD = $(LIB_KIO) $(LIB_KPARTS) +kview_presenterplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kview/kpartplugins +plug_DATA = kviewpresenter.desktop kviewpresenter.rc + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kviewpresenterplugin.pot diff --git a/kview/modules/presenter/config/Makefile.am b/kview/modules/presenter/config/Makefile.am new file mode 100644 index 00000000..8c212e7f --- /dev/null +++ b/kview/modules/presenter/config/Makefile.am @@ -0,0 +1,17 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = kcm_kviewpresenterconfig.la + +noinst_HEADERS = kviewpresenterconfig.h + +kcm_kviewpresenterconfig_la_SOURCES = kviewpresenterconfig.cpp +kcm_kviewpresenterconfig_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) +kcm_kviewpresenterconfig_la_LIBADD = $(LIB_KUTILS) + +kcm_kviewpresenterconfig_DATA = kviewpresenterconfig.desktop +kcm_kviewpresenterconfigdir = $(kde_servicesdir)/kconfiguredialog + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kcm_kviewpresenterconfig.pot diff --git a/kview/modules/presenter/config/kviewpresenterconfig.cpp b/kview/modules/presenter/config/kviewpresenterconfig.cpp new file mode 100644 index 00000000..92dd8627 --- /dev/null +++ b/kview/modules/presenter/config/kviewpresenterconfig.cpp @@ -0,0 +1,72 @@ +/* This file is part of the KDE project + Copyright (C) 2002-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 "kviewpresenterconfig.h" + +#include <qlayout.h> +#include <qcheckbox.h> +#include <qframe.h> + +#include <klocale.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kconfig.h> +#include <kgenericfactory.h> + +typedef KGenericFactory<KViewPresenterConfig, QWidget> KViewPresenterConfigFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_kviewpresenterconfig, KViewPresenterConfigFactory( "kcm_kviewpresenterconfig" ) ) + +KViewPresenterConfig::KViewPresenterConfig( QWidget * parent, const char *, const QStringList & args ) + : KCModule( KViewPresenterConfigFactory::instance(), parent, args ) +{ + QBoxLayout * layout = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() ); + layout->setAutoAdd( true ); + + m_pCheckBox = new QCheckBox( "This is only for testing...", this ); + connect( m_pCheckBox, SIGNAL( clicked() ), this, SLOT( checkChanged() ) ); +} + +KViewPresenterConfig::~KViewPresenterConfig() +{ +} + +void KViewPresenterConfig::checkChanged() +{ + if( m_pCheckBox->isChecked() ) + emit changed( true ); + else + emit changed( false ); +} + +void KViewPresenterConfig::load() +{ + emit changed( false ); +} + +void KViewPresenterConfig::save() +{ + emit changed( false ); +} + +void KViewPresenterConfig::defaults() +{ +} + +// vim:sw=4:ts=4 + +#include "kviewpresenterconfig.moc" diff --git a/kview/modules/presenter/config/kviewpresenterconfig.desktop b/kview/modules/presenter/config/kviewpresenterconfig.desktop new file mode 100644 index 00000000..77bb3481 --- /dev/null +++ b/kview/modules/presenter/config/kviewpresenterconfig.desktop @@ -0,0 +1,120 @@ +[Desktop Entry] +Icon=kpresenter +Type=Service +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kviewpresenterconfig +X-KDE-FactoryName=KViewPresenterConfigFactory +X-KDE-ParentComponents=kviewpresenter + +Name=Name +Name[ar]=اسم +Name[bg]=Име +Name[br]=Anv +Name[bs]=Ime +Name[ca]=Nom +Name[cy]=Enw +Name[da]=Navn +Name[el]=Όνομα +Name[eo]=Nomo +Name[es]=Nombre +Name[et]=Nimi +Name[eu]=Izena +Name[fa]=نام +Name[fi]=Nimi +Name[fr]=Nom +Name[ga]=Ainm +Name[gl]=Nome +Name[he]=שם +Name[hi]=नाम +Name[hu]=Név +Name[is]=Heiti +Name[it]=Nome +Name[ja]=名前 +Name[kk]=Атауы +Name[km]=ឈ្មោះ +Name[lt]=Pavadinimas +Name[ms]=Nama +Name[nb]=Navn +Name[nds]=Naam +Name[ne]=नाम +Name[nl]=Naam +Name[nn]=Namn +Name[pa]=ਨਾਂ +Name[pl]=Nazwa +Name[pt]=Nome +Name[pt_BR]=Nome +Name[ro]=Nume +Name[ru]=Имя +Name[se]=Namma +Name[sk]=Meno +Name[sl]=Ime +Name[sr]=Име +Name[sr@Latn]=Ime +Name[sv]=Namn +Name[ta]=பெயர் +Name[tg]=Ном +Name[uk]=Назва +Name[uz]=Nomi +Name[uz@cyrillic]=Номи +Name[wa]=No +Name[zh_CN]=名称 +Name[zh_HK]=名稱 +Name[zh_TW]=名稱 +Comment=Comment +Comment[ar]=تعليق +Comment[bg]=Коментар +Comment[br]=Askelenn +Comment[bs]=Komentar +Comment[ca]=Comentari +Comment[cy]=Sylwad +Comment[da]=Kommentar +Comment[de]=Kommentar +Comment[el]=Σχόλιο +Comment[eo]=Komento +Comment[es]=Comentario +Comment[et]=Kommentaar +Comment[eu]=Iruzkina +Comment[fa]=توضیح +Comment[fi]=Kommentti +Comment[fr]=Commentaire +Comment[ga]=Nóta +Comment[gl]=Comentario +Comment[he]=הערה +Comment[hi]=टिप्पणी +Comment[hu]=Megjegyzés +Comment[is]=Athugasemd +Comment[it]=Commento +Comment[ja]=コメント +Comment[kk]=Түсініктемесі +Comment[km]=សេចក្ដីអធិប្បាយ +Comment[lt]=Komentaras +Comment[ms]=Komen +Comment[nb]=Kommentar +Comment[nds]=Kommentar +Comment[ne]=टिप्पणी +Comment[nl]=Omschrijving +Comment[nn]=Kommentar +Comment[pa]=ਟਿੱਪਣੀ +Comment[pl]=Komentarz +Comment[pt]=Comentário +Comment[pt_BR]=Comentário +Comment[ro]=Comentariu +Comment[ru]=Комментарий +Comment[se]=Kommeanta +Comment[sk]=Komentár +Comment[sl]=Komentar +Comment[sr]=Коментар +Comment[sr@Latn]=Komentar +Comment[sv]=Kommentar +Comment[ta]=குறிப்பு +Comment[tg]=Эзоҳ +Comment[tr]=Açıklama +Comment[uk]=Коментар +Comment[uz]=Izoh +Comment[uz@cyrillic]=Изоҳ +Comment[wa]=Rawete +Comment[zh_CN]=注释 +Comment[zh_HK]=註解 +Comment[zh_TW]=註解 diff --git a/kview/modules/presenter/config/kviewpresenterconfig.h b/kview/modules/presenter/config/kviewpresenterconfig.h new file mode 100644 index 00000000..c839690a --- /dev/null +++ b/kview/modules/presenter/config/kviewpresenterconfig.h @@ -0,0 +1,46 @@ +/* This file is part of the KDE project + Copyright (C) 2002-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 KVIEWPRESENTERCONFIG_H +#define KVIEWPRESENTERCONFIG_H + +#include <kcmodule.h> + +class QCheckBox; + +class KViewPresenterConfig : public KCModule +{ + Q_OBJECT + public: + KViewPresenterConfig( QWidget * parent, const char * name = 0, const QStringList & args = QStringList() ); + ~KViewPresenterConfig(); + + virtual void load(); + virtual void save(); + virtual void defaults(); + + private slots: + void checkChanged(); + + private: + QCheckBox * m_pCheckBox; +}; + +// vim:sw=4:ts=4 + +#endif // KVIEWPRESENTERCONFIG_H diff --git a/kview/modules/presenter/imagelistdialog.ui b/kview/modules/presenter/imagelistdialog.ui new file mode 100644 index 00000000..66d9e9b5 --- /dev/null +++ b/kview/modules/presenter/imagelistdialog.ui @@ -0,0 +1,289 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>ImageListDialog</class> +<author>Matthias Kretz <kretz@kde.org></author> +<widget class="KDialog"> + <property name="name"> + <cstring>ImageListDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>724</width> + <height>409</height> + </rect> + </property> + <property name="caption"> + <string>Image List</string> + </property> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KListView"> + <column> + <property name="text"> + <string>URL</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Size</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Dimensions</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>m_pListView</cstring> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>0</height> + </size> + </property> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="showSortIndicator"> + <bool>true</bool> + </property> + <property name="fullWidth"> + <bool>true</bool> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout4</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout2</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pPrevious</cstring> + </property> + <property name="text"> + <string>&Previous</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pNext</cstring> + </property> + <property name="text"> + <string>&Next</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + </hbox> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pShuffle</cstring> + </property> + <property name="text"> + <string>Shu&ffle</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>16</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pSlideshow</cstring> + </property> + <property name="text"> + <string>Start &Slideshow</string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + <widget class="KIntNumInput"> + <property name="name"> + <cstring>m_pInterval</cstring> + </property> + <property name="label"> + <string>Slideshow interval:</string> + </property> + <property name="value"> + <number>5000</number> + </property> + <property name="suffix"> + <string> ms</string> + </property> + <property name="whatsThis" stdset="0"> + <string>This is the interval the program will wait before showing the next image in the slideshow.</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>Spacer4</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>MinimumExpanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>80</height> + </size> + </property> + </spacer> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pCloseAll</cstring> + </property> + <property name="text"> + <string>&Close All</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>Layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pSave</cstring> + </property> + <property name="text"> + <string>Sa&ve List...</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + <widget class="KPushButton"> + <property name="name"> + <cstring>m_pLoad</cstring> + </property> + <property name="text"> + <string>&Load List...</string> + </property> + <property name="autoDefault"> + <bool>false</bool> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </hbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>m_pListView</sender> + <signal>aboutToMove()</signal> + <receiver>ImageListDialog</receiver> + <slot>noSort()</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in declaration">kdialog.h</include> + <include location="global" impldecl="in implementation">kdebug.h</include> + <include location="global" impldecl="in implementation">kimageviewer/viewer.h</include> + <include location="global" impldecl="in implementation">kio/netaccess.h</include> + <include location="global" impldecl="in implementation">kurl.h</include> + <include location="global" impldecl="in implementation">kfiledialog.h</include> + <include location="global" impldecl="in implementation">qstring.h</include> + <include location="global" impldecl="in implementation">kmessagebox.h</include> + <include location="local" impldecl="in implementation">imagelistitem.h</include> + <include location="local" impldecl="in implementation">imagelistdialog.ui.h</include> +</includes> +<forwards> + <forward>class KURL</forward> +</forwards> +<slots> + <slot access="private" specifier="non virtual">init()</slot> + <slot specifier="non virtual">noSort()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>kdialog.h</includehint> + <includehint>klistview.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> +</includehints> +</UI> diff --git a/kview/modules/presenter/imagelistdialog.ui.h b/kview/modules/presenter/imagelistdialog.ui.h new file mode 100644 index 00000000..ce97754e --- /dev/null +++ b/kview/modules/presenter/imagelistdialog.ui.h @@ -0,0 +1,23 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename slots use Qt Designer which will +** update this file, preserving your code. Create an init() slot in place of +** a constructor, and a destroy() slot in place of a destructor. +*****************************************************************************/ + +void ImageListDialog::init() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + m_pInterval->setRange( 0, 60000, 1000 ); + noSort(); +} + + +void ImageListDialog::noSort() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + m_pListView->setSorting( 1000 ); +} + + diff --git a/kview/modules/presenter/imagelistitem.cpp b/kview/modules/presenter/imagelistitem.cpp new file mode 100644 index 00000000..4236dfe7 --- /dev/null +++ b/kview/modules/presenter/imagelistitem.cpp @@ -0,0 +1,82 @@ +/* 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. + +*/ + +// $Id$ + +#include "imagelistitem.h" + +#include <qimage.h> + +#include <klistview.h> + +ImageListItem::ImageListItem( KListView * parent, const KURL & url ) + : KListViewItem( parent, parent->lastItem(), url.prettyURL() ) + , m_pImage( 0 ) + , m_filename( QString::null ) + , m_url( url ) +{ + setDragEnabled( true ); + if( m_url.isLocalFile() ) + { + m_filename = m_url.path(); + } + else + { + // download file + /* + QString extension; + QString fileName = m_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_filename = m_pTempFile->name(); + + m_pJob = KIO::get( m_url, m_pExtension->urlArgs().reload, false ); + */ + } +} + +ImageListItem::~ImageListItem() +{ + if( ! m_url.isLocalFile() ) + { + // remove downloaded tempfile + //KIO::NetAccess::removeTempFile( m_filename ); + } +} + +const QImage * ImageListItem::image() const +{ + return m_pImage; +} + +const QString & ImageListItem::file() const +{ + if( m_url.isLocalFile() ) + return QString::null; + return m_filename; +} + +const KURL & ImageListItem::url() const +{ + return m_url; +} + +// vim:sw=4:ts=4 diff --git a/kview/modules/presenter/imagelistitem.h b/kview/modules/presenter/imagelistitem.h new file mode 100644 index 00000000..63761af8 --- /dev/null +++ b/kview/modules/presenter/imagelistitem.h @@ -0,0 +1,49 @@ +/* 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. + +*/ + +// $Id$ + +#ifndef IMAGELISTITEM_H +#define IMAGELISTITEM_H + +#include <klistview.h> +#include <kurl.h> +#include <qstring.h> + +class QImage; + +class ImageListItem : public KListViewItem +{ + public: + ImageListItem( KListView * parent, const KURL & url ); + ~ImageListItem(); + + const QImage * image() const; + const QString & file() const; + const KURL & url() const; + + virtual int rtti() const { return 48294; } + + private: + QImage * m_pImage; + QString m_filename; + KURL m_url; +}; + +// vim:sw=4:ts=4 +#endif // IMAGELISTITEM_H diff --git a/kview/modules/presenter/kviewpresenter.cpp b/kview/modules/presenter/kviewpresenter.cpp new file mode 100644 index 00000000..bbc5e8eb --- /dev/null +++ b/kview/modules/presenter/kviewpresenter.cpp @@ -0,0 +1,492 @@ +/* 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. + +*/ + +/* $Id$ */ + +#include "kviewpresenter.h" +#include "imagelistdialog.h" +#include "imagelistitem.h" + +#include <qvbox.h> +#include <qobjectlist.h> +#include <qsignalslotimp.h> +#include <qtimer.h> +#include <qevent.h> +#include <qdragobject.h> +#include <qstringlist.h> + +#include <kpushbutton.h> +#include <kapplication.h> +#include <kaction.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <knuminput.h> +#include <kfiledialog.h> +#include <kimageio.h> +#include <kimageviewer/viewer.h> +#include <kimageviewer/canvas.h> +#include <kio/netaccess.h> +#include <kmessagebox.h> +#include <ktempfile.h> +#include <kurldrag.h> + +typedef KGenericFactory<KViewPresenter> KViewPresenterFactory; +K_EXPORT_COMPONENT_FACTORY( kview_presenterplugin, KViewPresenterFactory( "kviewpresenterplugin" ) ) + +KViewPresenter::KViewPresenter( QObject* parent, const char* name, const QStringList & ) + : Plugin( parent, name ) + , m_pImageList( new ImageListDialog() ) + , m_paFileOpen( 0 ) + , m_bDontAdd( false ) + , m_pCurrentItem( 0 ) + , m_pSlideshowTimer( new QTimer( this ) ) +{ + kdDebug( 4630 ) << k_funcinfo << endl; + m_imagelist.setAutoDelete( true ); + + QObjectList * viewerList = parent->queryList( 0, "KImageViewer Part", false, false ); + m_pViewer = static_cast<KImageViewer::Viewer *>( viewerList->getFirst() ); + delete viewerList; + if( m_pViewer ) + { + ( void ) new KAction( i18n( "&Image List..." ), 0, 0, + this, SLOT( slotImageList() ), + actionCollection(), "plugin_presenter_imageList" ); + m_paSlideshow = new KToggleAction( i18n( "Start &Slideshow" ), Key_S, actionCollection(), "plugin_presenter_slideshow" ); + ( void ) new KAction( i18n( "&Previous Image in List" ), "previous", ALT+Key_Left, + this, SLOT( prev() ), + actionCollection(), "plugin_presenter_prev" ); + ( void ) new KAction( i18n( "&Next Image in List" ), "next", ALT+Key_Right, + this, SLOT( next() ), + actionCollection(), "plugin_presenter_next" ); + + connect( m_paSlideshow, SIGNAL( toggled( bool ) ), m_pImageList->m_pSlideshow, SLOT( setOn( bool ) ) ); + connect( m_pImageList->m_pSlideshow, SIGNAL( toggled( bool ) ), m_paSlideshow, SLOT( setChecked( bool ) ) ); + + // search for file_open action + KXMLGUIClient * parentClient = static_cast<KXMLGUIClient*>( parent->qt_cast( "KXMLGUIClient" ) ); + if( parentClient ) + { + m_paFileOpen = parentClient->actionCollection()->action( "file_open" ); + m_paFileClose = parentClient->actionCollection()->action( "file_close" ); + } + if( m_paFileClose ) + connect( m_paFileClose, SIGNAL( activated() ), this, SLOT( slotClose() ) ); + if( m_paFileOpen ) + { + disconnect( m_paFileOpen, SIGNAL( activated() ), parent, SLOT( slotOpenFile() ) ); + connect( m_paFileOpen, SIGNAL( activated() ), this, SLOT( slotOpenFiles() ) ); + } + else + { + (void) new KAction( i18n( "Open &Multiple Files..." ), "queue", CTRL+SHIFT+Key_O, + this, SLOT( slotOpenFiles() ), + actionCollection(), "plugin_presenter_openFiles" ); + } + connect( m_pViewer, SIGNAL( imageOpened( const KURL & ) ), + SLOT( slotImageOpened( const KURL & ) ) ); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the presenter plugin won't work" << endl; + + //( void )new KViewPresenterConfModule( this ); + + connect( m_pImageList->m_pListView, SIGNAL( executed( QListViewItem* ) ), + this, SLOT( changeItem( QListViewItem* ) ) ); + connect( m_pImageList->m_pPrevious, SIGNAL( clicked() ), + this, SLOT( prev() ) ); + connect( m_pImageList->m_pNext, SIGNAL( clicked() ), + this, SLOT( next() ) ); + connect( m_pImageList->m_pListView, SIGNAL( spacePressed( QListViewItem* ) ), + this, SLOT( changeItem( QListViewItem* ) ) ); + connect( m_pImageList->m_pListView, SIGNAL( returnPressed( QListViewItem* ) ), + this, SLOT( changeItem( QListViewItem* ) ) ); + connect( m_pImageList->m_pSlideshow, SIGNAL( toggled( bool ) ), + this, SLOT( slideshow( bool ) ) ); + connect( m_pImageList->m_pInterval, SIGNAL( valueChanged( int ) ), + this, SLOT( setSlideshowInterval( int ) ) ); + connect( m_pImageList->m_pShuffle, SIGNAL( clicked() ), + this, SLOT( shuffle() ) ); + connect( m_pImageList->m_pLoad, SIGNAL( clicked() ), + this, SLOT( loadList() ) ); + connect( m_pImageList->m_pSave, SIGNAL( clicked() ), + this, SLOT( saveList() ) ); + connect( m_pImageList->m_pCloseAll, SIGNAL( clicked() ), + this, SLOT( closeAll() ) ); + + // allow drop on the dialog + m_pImageList->installEventFilter( this ); + m_pImageList->m_pListView->installEventFilter( this ); + m_pImageList->m_pListView->viewport()->installEventFilter( this ); + + // grab drops on the main view + m_pViewer->widget()->installEventFilter( this ); + + connect( m_pSlideshowTimer, SIGNAL( timeout() ), + this, SLOT( next() ) ); +} + +KViewPresenter::~KViewPresenter() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( m_paFileOpen ) + { + disconnect( m_paFileOpen, SIGNAL( activated() ), this, SLOT( slotOpenFiles() ) ); + // If the parent() doesn't exist we either leave the "File Open" action + // in an unusable state or KView was just shutting down and therefor we + // can ignore this. I've only seen the second one happening and to get + // rid of the QObject::connect warning we do the parent() check. + if( parent() ) + connect( m_paFileOpen, SIGNAL( activated() ), parent(), SLOT( slotOpenFile() ) ); + } +} + +bool KViewPresenter::eventFilter( QObject *obj, QEvent *ev ) +{ + if( obj == m_pImageList || obj == m_pImageList->m_pListView || obj == m_pImageList->m_pListView->viewport() || obj == m_pViewer->widget() ) + { + switch( ev->type() ) + { + case QEvent::DragEnter: + case QEvent::DragMove: + { + // drag enter event in the image list + //kdDebug( 4630 ) << "DragEnterEvent in the image list: " << obj->className() << endl; + QDragEnterEvent * e = static_cast<QDragEnterEvent*>( ev ); + //for( int i = 0; e->format( i ); ++i ) + //kdDebug( 4630 ) << " - " << e->format( i ) << endl; + if( KURLDrag::canDecode( e ) )// || QImageDrag::canDecode( e ) ) + { + e->accept(); + return true; + } + } + case QEvent::Drop: + { + // drop event in the image list + kdDebug( 4630 ) << "DropEvent in the image list: " << obj->className() << endl; + QDropEvent * e = static_cast<QDropEvent*>( ev ); + QStringList l; + //QImage image; + if( KURLDrag::decodeToUnicodeUris( e, l ) ) + { + for( QStringList::const_iterator it = l.begin(); it != l.end(); ++it ) + { + ImageInfo * info = new ImageInfo( KURL( *it ) ); + if( ! m_imagelist.contains( info ) ) + { + m_imagelist.inSort( info ); + ( void )new ImageListItem( m_pImageList->m_pListView, KURL( *it ) ); + } + else + delete info; + } + return true; + } + //else if( QImageDrag::decode( e, image ) ) + //newImage( image ); + } + default: // do nothing + break; + } + } + return KParts::Plugin::eventFilter( obj, ev ); +} + +void KViewPresenter::slotImageOpened( const KURL & url ) +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( ! m_bDontAdd ) + { + kdDebug( 4630 ) << k_funcinfo << "imagelist:" << endl; + ImageInfo * info = new ImageInfo( url ); + if( ! m_imagelist.contains( info ) ) + { + m_imagelist.inSort( info ); + QListViewItem * item = new ImageListItem( m_pImageList->m_pListView, url ); + makeCurrent( item ); + } + else + delete info; + } +} + +void KViewPresenter::slotImageList() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + m_pImageList->show(); +} + +void KViewPresenter::slotOpenFiles() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + KURL::List urls = KFileDialog::getOpenURLs( ":load_image", KImageIO::pattern( KImageIO::Reading ), m_pViewer->widget() ); + + if( urls.isEmpty() ) + return; + + KURL::List::Iterator it = urls.begin(); + m_pViewer->openURL( *it ); + for( ++it; it != urls.end(); ++it ) + { + ImageInfo * info = new ImageInfo( *it ); + if( ! m_imagelist.contains( info ) ) + { + m_imagelist.inSort( info ); + ( void )new ImageListItem( m_pImageList->m_pListView, *it ); + } + else + delete info; + } +} + +void KViewPresenter::slotClose() +{ + QListViewItem * next = m_pCurrentItem->itemBelow() ? m_pCurrentItem->itemBelow() : m_pImageList->m_pListView->firstChild(); + if( next == m_pCurrentItem ) + next = 0; + + ImageInfo info( m_pCurrentItem->url() ); + m_imagelist.remove( &info ); + delete m_pCurrentItem; + m_pCurrentItem = 0; + + if( next ) + changeItem( next ); +} + +void KViewPresenter::changeItem( QListViewItem * qitem ) +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( qitem->rtti() == 48294 ) + { + ImageListItem * item = static_cast<ImageListItem*>( qitem ); + if( ! item->url().isEmpty() ) + { + if( item->url().isLocalFile() && ! QFile::exists( item->url().path() ) ) + { + kdDebug( 4630 ) << "file doesn't exist. removed." << endl; + ImageInfo info( item->url() ); + m_imagelist.remove( &info ); + if( m_pCurrentItem == item ) + { + QListViewItem * next = m_pCurrentItem->itemBelow() ? m_pCurrentItem->itemBelow() : m_pImageList->m_pListView->firstChild(); + if( next->rtti() != 48294 ) + kdWarning( 4630 ) << "unknown ListView item" << endl; + else + m_pCurrentItem = static_cast<ImageListItem*>( next ); + + if( m_pCurrentItem == item ) + m_pCurrentItem = 0; // don't create a dangling pointer + delete item; + if( m_pCurrentItem ) + changeItem( m_pCurrentItem ); + } + else + { + delete item; + next(); + } + return; + } + kdDebug( 4630 ) << "got url" << endl; + makeCurrent( qitem ); + + bool dontadd = m_bDontAdd; + m_bDontAdd = true; + m_pViewer->openURL( item->url() ); + m_bDontAdd = dontadd; + } + else + kdWarning( 4630 ) << "got nothing" << endl; + } + else + kdWarning( 4630 ) << "unknown ListView item" << endl; +} + +void KViewPresenter::prev() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( m_pCurrentItem ) + { + QListViewItem * prev = m_pCurrentItem->itemAbove() ? m_pCurrentItem->itemAbove() : m_pImageList->m_pListView->lastItem(); + if( prev ) + changeItem( prev ); + } +} + +void KViewPresenter::next() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + if( m_pCurrentItem ) + { + QListViewItem * next = m_pCurrentItem->itemBelow() ? m_pCurrentItem->itemBelow() : m_pImageList->m_pListView->firstChild(); + if( next ) + changeItem( next ); + } +} + +void KViewPresenter::makeCurrent( QListViewItem * item ) +{ + if( m_pCurrentItem ) + m_pCurrentItem->setPixmap( 0, QPixmap() ); + if( item->rtti() != 48294 ) + kdWarning( 4630 ) << "unknown ListView item" << endl; + else + { + m_pCurrentItem = static_cast<ImageListItem*>( item ); + m_pCurrentItem->setPixmap( 0, KGlobal::iconLoader()->loadIcon( "1rightarrow", KIcon::Small ) ); + m_pImageList->m_pListView->ensureItemVisible( m_pCurrentItem ); + } +} + +void KViewPresenter::slideshow( bool running ) +{ + if( running ) + { + m_pSlideshowTimer->start( m_pImageList->m_pInterval->value() ); + actionCollection()->action( "plugin_presenter_slideshow" )->setText( i18n( "Stop &Slideshow" ) ); + m_pImageList->m_pSlideshow->setText( i18n( "Stop &Slideshow" ) ); + } + else + { + m_pSlideshowTimer->stop(); + actionCollection()->action( "plugin_presenter_slideshow" )->setText( i18n( "Start &Slideshow" ) ); + m_pImageList->m_pSlideshow->setText( i18n( "Start &Slideshow" ) ); + } +} + +void KViewPresenter::setSlideshowInterval( int msec ) +{ + if( m_pSlideshowTimer->isActive() ) + m_pSlideshowTimer->changeInterval( msec ); +} + +void KViewPresenter::shuffle() +{ + m_pImageList->noSort(); + KListView * listview = m_pImageList->m_pListView; + QPtrList<QListViewItem> items; + for( QListViewItem * item = listview->firstChild(); item; item = listview->firstChild() ) + { + items.append( item ); + listview->takeItem( item ); + } + while( ! items.isEmpty() ) + listview->insertItem( items.take( KApplication::random() % items.count() ) ); +} + +void KViewPresenter::closeAll() +{ + m_imagelist.clear(); + m_pImageList->m_pListView->clear(); + m_pCurrentItem = 0; + if( m_pViewer->closeURL() ) + m_pViewer->canvas()->clear(); +} + +void KViewPresenter::loadList() +{ + KURL url = KFileDialog::getOpenURL( ":load_list", QString::null, m_pImageList ); + if( url.isEmpty() ) + return; + + QString tempfile; + if( ! KIO::NetAccess::download( url, tempfile, m_pViewer->widget() ) ) + { + KMessageBox::error( m_pImageList, i18n( "Could not load\n%1" ).arg( url.prettyURL() ) ); + return; + } + QFile file( tempfile ); + if( file.open( IO_ReadOnly ) ) + { + QTextStream t( &file ); + if( t.readLine() == "[KView Image List]" ) + { + //clear old image list + closeAll(); + + QStringList list; + if( ! t.eof() ) + m_pViewer->openURL( KURL( t.readLine() ) ); + while( ! t.eof() ) + { + KURL url ( t.readLine() ); + ImageInfo * info = new ImageInfo( url ); + if( ! m_imagelist.contains( info ) ) + { + m_imagelist.inSort( info ); + ( void )new ImageListItem( m_pImageList->m_pListView, url ); + } + else + delete info; + } + } + else + { + KMessageBox::error( m_pImageList, i18n( "Wrong format\n%1" ).arg( url.prettyURL() ) ); + } + file.close(); + } + KIO::NetAccess::removeTempFile( tempfile ); +} + +void KViewPresenter::saveList() +{ + KURL url = KFileDialog::getSaveURL( ":save_list", QString::null, m_pImageList ); + + if( url.isEmpty() ) + return; + + QString tempfile; + if( url.isLocalFile() ) + tempfile = url.path(); + else + { + KTempFile ktempf; + tempfile = ktempf.name(); + } + + QFile file( tempfile ); + if( file.open( IO_WriteOnly ) ) + { + QTextStream t( &file ); + // write header + t << "[KView Image List]" << endl; + QListViewItem * item = m_pImageList->m_pListView->firstChild(); + while( item ) + { + if( item->rtti() == 48294 ) + t << static_cast<ImageListItem*>( item )->url().url() << endl; + item = item->itemBelow(); + } + file.close(); + + if( ! url.isLocalFile() ) + { + KIO::NetAccess::upload( tempfile, url, m_pViewer->widget() ); + KIO::NetAccess::removeTempFile( tempfile ); + } + } +} + +// vim:sw=4:ts=4 +#include "kviewpresenter.moc" diff --git a/kview/modules/presenter/kviewpresenter.desktop b/kview/modules/presenter/kviewpresenter.desktop new file mode 100644 index 00000000..7059caba --- /dev/null +++ b/kview/modules/presenter/kviewpresenter.desktop @@ -0,0 +1,118 @@ +[Desktop Entry] +Icon=presenter +Type=Service +ServiceTypes=KPluginInfo + +X-KDE-PluginInfo-Author=Matthias Kretz +X-KDE-PluginInfo-Email=kretz@kde.org +X-KDE-PluginInfo-Name=kviewpresenter +X-KDE-PluginInfo-Version=1.1 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true + +Name=Presenter +Name[ar]=المقدّم +Name[bg]=Презентация +Name[br]=Emginniger +Name[bs]=Prezentator +Name[ca]=Presentador +Name[cs]=Prezentace +Name[cy]=Cyflwynydd +Name[de]=Präsentationsprogramm +Name[el]=Παρουσιαστής +Name[eo]=Prezentilo +Name[et]=Esitleja +Name[eu]=Aurkezlea +Name[fa]=ارائهکننده +Name[fi]=Esitysohjelma +Name[fr]=Présentateur +Name[ga]=Láithreoir +Name[gl]=Escaparate +Name[he]=מצגות +Name[hi]=प्रस्तुतकर्ता +Name[hr]=Prezentator +Name[hu]=Bemutató +Name[it]=Presentazione +Name[ja]=プレゼンタ +Name[kk]=Презентатор +Name[km]=កម្មវិធីបង្ហាញ +Name[lt]=Pristatytojas +Name[ms]=Penyampai +Name[nds]=Präsentatschoonprogramm +Name[ne]=प्रस्तोता +Name[nl]=Presentatieprogramma +Name[nso]=Mohlagisi +Name[pa]=ਪੇਸ਼ਕਾਰ +Name[pl]=Prezenter +Name[pt]=Apresentador +Name[pt_BR]=Apresentador +Name[ro]=Prezentare +Name[ru]=Презентатор +Name[sk]=Vytvorenie prezentácie +Name[sl]=Predstavitelj +Name[sr]=Презентер +Name[sr@Latn]=Prezenter +Name[sv]=Presentationer +Name[ta]=வழங்குபவர் +Name[tg]=Презентатор +Name[tr]=Sunum Aracı +Name[ven]=Mulanguli +Name[xh]=Umbonisi +Name[zh_CN]=演示板 +Name[zh_HK]=簡報器 +Name[zh_TW]=簡報 +Name[zu]=Umnikeli +Comment=Creates an imagelist and enables you to create a slideshow +Comment[ar]=ينشئ قائمة صور ويمكنك من استعراض الصور تلقائيا +Comment[bg]=Създаване на списък с изображения и слайдшоу от тях +Comment[bs]=Pravi listu slika i omogućuje vam da napravite slide show +Comment[ca]=Crea una llista d'imatges i us permet crear un passi de diapositives +Comment[cs]=Vytvoří seznam obrázků a umožní vám z nich vytvořit slideshow. +Comment[cy]=Creu rhestr delweddau ac alluogi i chi greu sioe haenluniau +Comment[da]=Laver en billedliste og giver dig muligheden for at lave et diasshow +Comment[de]=Erzeugt eine Bilderliste und ermöglicht das Erstellen von Diashows +Comment[el]=Δημιουργεί μια λίστα εικόνων και σας επιτρέπει να δημιουργήσετε μια προβολή σλάιντ +Comment[es]=Crea una lista de imágenes ofreciendole la posibilidad de crear una animación de diapositivas +Comment[et]=Loob piltide nimekirja ja laseb selle põhjal luua slaidiseansi +Comment[eu]=Irudi-zerrenda bat sortzen du eta diapositiba-aurkezpena egiten du +Comment[fa]=یک فهرست تصویر ایجاد میکند و شما را قادر به ایجاد یک نمایش اسلاید میکند +Comment[fi]=Luo kuvalistan ja mahdollistaa esityksen luomisen +Comment[fr]=Crée une liste d'images et vous permet de créer un diaporama +Comment[gl]=Crea unha lista de imaxes e permite crear unha moviola +Comment[he]=יוצר רשימת תמונות ומאפשר לך ליצור מצגת שקופיות +Comment[hi]=एक छवि-सूची बनाता है तथा आपको एक स्लाइड-शो तैयार करने में सक्षम बनाता है +Comment[hu]=Képsorozat összeállítását és bemutatását teszi lehetővé +Comment[is]=Býr til myndlista og gerir þér kleyft að búa til myndsýningu +Comment[it]=Crea una lista di immagini e permette di creare una presentazione +Comment[ja]=画像リストを作成し、スライドショーを作成します +Comment[kk]=Слайд-шоу көрсетуге кескіндер тізімін дайындау +Comment[km]=បង្កើតបញ្ជីរូបភាព ហើយអាចឲ្យអ្នកបង្កើតជាការបញ្ចាំងស្លាយ +Comment[lt]=Sukuria paveikslėlių sąrašą ir leidžia jums sukurti skaidrių peržiūrą +Comment[ms]=Cipta senarai imej dan membolehkan anda mencipta tayangan slaid +Comment[nb]=Oppretter en bildeliste og lar deg lage en lysbildeserie +Comment[nds]=Stellt en Bildlist op un lett Di en Diaschau opstellen +Comment[ne]=छवि सूची सिर्जना गर्दछ र तपाईँलाई स्लाइड प्रर्दशन सिर्जना गर्न सक्षम पार्दछ +Comment[nl]=Maakt een afbeeldingenlijst waarmee u een diashow kunt maken +Comment[nn]=Lagar ei biletliste du kan bruka til framvising +Comment[nso]=Hlagisa palo ya ponagalo gape ego dumelela go hlagisa slidesshow +Comment[pl]=Tworzy listę obrazków i umożliwia tworzenie z niej pokazu slajdów +Comment[pt]=Cria uma lista de imagens e permite-lhe criar uma apresentação +Comment[pt_BR]=Cria uma lista de imagens e habilita você a criar uma exibição de slides +Comment[ro]=Creează o listă de imagini şi vă permite să reallizaţi o succesiune de imagini +Comment[ru]=Создание галерей изображений и просмотр их в качестве слайдов +Comment[se]=Ráhkada govvalisttu ja diktá du ráhkadit govvačájeheami +Comment[sk]=Vytvorí zoznam obrázok a umožní z nich vytvoriť prezentáciu +Comment[sl]=Ustvari seznam slik in vam omogoča ustvariti predstavitev +Comment[sr]=Прави листу слика и омогућава вам да направите слајд-шоу +Comment[sr@Latn]=Pravi listu slika i omogućava vam da napravite slajd-šou +Comment[sv]=Skapar en bildlista och ger dig möjlighet att göra ett bildspel +Comment[ta]=திரைக் காட்சிக்கான பிம்ப பட்டியலை உருவாக்கலாம் +Comment[tg]=Эҷоди нигористони тасвирот ва намоиши онҳо ҳамчун слайд +Comment[tr]=Bir resim listesi oluşturur ve slayt gösterisi yapmanıza olanak tanır +Comment[uk]=Створює список зображень та дозволяє створювати презентацію слайдів +Comment[ven]=Iita mutevhe wa tshifanyiso ya dovha yani tendela uita tsumbedzo ya tshilaidi +Comment[xh]=Yenza uluhlu lwemifanekiso ekuvumela ukwazi ukwenza umboniso wotyibiliko +Comment[zh_CN]=创建图像列表,并能为您创建幻灯片 +Comment[zh_HK]=建立圖像清單並讓您能建立幻燈片式放映 +Comment[zh_TW]=建立影像清單並讓您能建立幻燈片式放映 +Comment[zu]=Idala uhlu lwesithombe futhi ikuvumela wena ukuba udale umbukiso wesithombe esishibilikayo diff --git a/kview/modules/presenter/kviewpresenter.h b/kview/modules/presenter/kviewpresenter.h new file mode 100644 index 00000000..29fc106b --- /dev/null +++ b/kview/modules/presenter/kviewpresenter.h @@ -0,0 +1,103 @@ +/* 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. + +*/ + +/* $Id$ */ + +#ifndef __kviewpresenter_h +#define __kviewpresenter_h + +#include <kparts/plugin.h> +#include <kurl.h> + +#include <qsortedlist.h> + +namespace KImageViewer { class Viewer; } + +class ImageListDialog; +class ImageListItem; +class QListViewItem; +class QTimer; +class KToggleAction; +class KAction; + +class KViewPresenter : public KParts::Plugin +{ + Q_OBJECT +public: + KViewPresenter( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewPresenter(); + +protected: + struct ImageInfo + { + KURL url; + ImageInfo( const KURL & url ) + : url( url ) + { + } + bool operator==( const ImageInfo & i1 ) + { + return url.prettyURL() == i1.url.prettyURL(); + } + bool operator!=( const ImageInfo & i1 ) + { + return url.prettyURL() == i1.url.prettyURL(); + } + bool operator>( const ImageInfo & i1 ) + { + return url.prettyURL() > i1.url.prettyURL(); + } + bool operator<( const ImageInfo & i1 ) + { + return url.prettyURL() < i1.url.prettyURL(); + } + }; + bool eventFilter( QObject *, QEvent * ); + +private slots: + void slotImageOpened( const KURL & ); + void slotImageList(); + void slotOpenFiles(); + void slotClose(); + void changeItem( QListViewItem * ); + void prev(); + void next(); + void slideshow( bool ); + void setSlideshowInterval( int ); + void shuffle(); + void closeAll(); + void loadList(); + void saveList(); + +private: + void makeCurrent( QListViewItem * ); + + KImageViewer::Viewer * m_pViewer; + ImageListDialog * m_pImageList; + KToggleAction * m_paSlideshow; + KAction * m_paFileOpen; + KAction * m_paFileClose; + + QSortedList<ImageInfo> m_imagelist; + bool m_bDontAdd; + ImageListItem * m_pCurrentItem; + QTimer * m_pSlideshowTimer; +}; + +// vim:sw=4:ts=4:cindent +#endif diff --git a/kview/modules/presenter/kviewpresenter.rc b/kview/modules/presenter/kviewpresenter.rc new file mode 100644 index 00000000..92879d02 --- /dev/null +++ b/kview/modules/presenter/kviewpresenter.rc @@ -0,0 +1,20 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kviewpresenter" library="kview_presenterplugin" version="3"> + <MenuBar> + <Menu name="file"><text>&File</text> + <Action name="plugin_presenter_openFiles" group="open_merge_group"/> + </Menu> + <Menu name="view"><text>&View</text> + </Menu> + + <Menu name="go_document"><Text>&Go</Text> + <Action name="plugin_presenter_imageList"/> + <Action name="plugin_presenter_slideshow"/> + <Action name="plugin_presenter_prev"/> + <Action name="plugin_presenter_next"/> + </Menu> + </MenuBar> + <Menu name="popupmenu"> + <Action name="plugin_presenter_slideshow"/> + </Menu> +</kpartplugin> diff --git a/kview/modules/presenter/kviewpresenterconfmodule.cpp b/kview/modules/presenter/kviewpresenterconfmodule.cpp new file mode 100644 index 00000000..a39ea378 --- /dev/null +++ b/kview/modules/presenter/kviewpresenterconfmodule.cpp @@ -0,0 +1,60 @@ +/* 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. + +*/ + +// $Id$ + +#include "kviewpresenterconfmodule.h" + +#include <qlayout.h> +#include <qcheckbox.h> +#include <qframe.h> + +#include <klocale.h> +#include <kdialog.h> +#include <kglobal.h> +#include <kconfig.h> + +KViewPresenterConfModule::KViewPresenterConfModule( QObject * parent ) + : KPreferencesModule( "kviewpresenter", parent, "KView Presenter Config Module" ) +{ +} + +KViewPresenterConfModule::~KViewPresenterConfModule() +{ +} + +void KViewPresenterConfModule::applyChanges() +{ + emit configChanged(); +} + +void KViewPresenterConfModule::reset() +{ +} + +void KViewPresenterConfModule::createPage( QFrame * page ) +{ + QBoxLayout * layout = new QVBoxLayout( page, KDialog::marginHint(), KDialog::spacingHint() ); + layout->setAutoAdd( true ); + + m_pCheckBox = new QCheckBox( "This is only for testing...", page ); +} + +// vim:sw=4:ts=4 + +#include "kviewpresenterconfmodule.moc" diff --git a/kview/modules/presenter/kviewpresenterconfmodule.h b/kview/modules/presenter/kviewpresenterconfmodule.h new file mode 100644 index 00000000..dd7e5cf2 --- /dev/null +++ b/kview/modules/presenter/kviewpresenterconfmodule.h @@ -0,0 +1,49 @@ +/* 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. + +*/ + +// $Id$ + +#ifndef KVIEWPRESENTERCONFMODULE_H +#define KVIEWPRESENTERCONFMODULE_H + +#include "kpreferencesmodule.h" + +class QCheckBox; + +class KViewPresenterConfModule : public KPreferencesModule +{ + Q_OBJECT + public: + KViewPresenterConfModule( QObject * parent ); + ~KViewPresenterConfModule(); + + signals: + void configChanged(); + + protected: + virtual void applyChanges(); + virtual void reset(); + virtual void createPage( QFrame * page ); + + private: + QCheckBox * m_pCheckBox; +}; + +// vim:sw=4:ts=4 + +#endif // KVIEWPRESENTERCONFMODULE_H diff --git a/kview/modules/scale/Makefile.am b/kview/modules/scale/Makefile.am new file mode 100644 index 00000000..39442781 --- /dev/null +++ b/kview/modules/scale/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_scale.la + +kview_scale_la_SOURCES = kfloatspinbox.cpp scaledlg.cpp kview_scale.cpp +kview_scale_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint +kview_scale_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kviewviewer/kpartplugins +plug_DATA = kview_scale.rc kview_scale.desktop + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kview_scale.pot diff --git a/kview/modules/scale/kfloatspinbox.cpp b/kview/modules/scale/kfloatspinbox.cpp new file mode 100644 index 00000000..e5ce8465 --- /dev/null +++ b/kview/modules/scale/kfloatspinbox.cpp @@ -0,0 +1,116 @@ +/* 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. + +*/ + +// $Id$ + +#include "kfloatspinbox.h" + +#if defined(QT_ACCESSIBILITY_SUPPORT) +#include <qaccessible.h> +#endif + +#include <knumvalidator.h> +#include <klocale.h> +#include <kglobal.h> +#include <kdebug.h> + +int pow( int a, int b ) +{ + int ret = 1; + for( int i = 0; i < b; ++i ) + ret *= a; + return ret; +} + +KFloatSpinBox::KFloatSpinBox( float minValue, float maxValue, float step, unsigned int precision, QWidget * parent, const char * name ) + : QSpinBox( parent, name ) + , m_doselection( true ) +{ + setRange( minValue, maxValue, step, precision ); + connect( this, SIGNAL( valueChanged( int ) ), this, SLOT( slotValueChanged( int ) ) ); +} + +KFloatSpinBox::~KFloatSpinBox() +{ +} + +void KFloatSpinBox::setRange( float minValue, float maxValue, float step, unsigned int precision ) +{ + m_factor = pow( 10, precision ); + m_min = (int)( minValue * m_factor ); + m_max = (int)( maxValue * m_factor ); + m_step = (int)( step * m_factor ); + QSpinBox::setRange( m_min, m_max ); + setSteps( m_step, m_step * 10 ); + if( precision == 0 ) + setValidator( new KIntValidator( m_min, m_max, this, 10, "KFloatValidator::KIntValidator" ) ); + else + setValidator( new KFloatValidator( minValue, maxValue, true, this, "KFloatSpinBox::KFloatValidator" ) ); +} + +float KFloatSpinBox::value() const +{ + float ret = (float)QSpinBox::value() / m_factor; + kdDebug( 4630 ) << ret << endl; + return ret; +} + +void KFloatSpinBox::setValue( float value ) +{ + QSpinBox::setValue( (int)( value * m_factor ) ); +} + +void KFloatSpinBox::setValueBlocking( float value ) +{ + m_doselection = false; + blockSignals( true ); + KFloatSpinBox::setValue( value ); + blockSignals( false ); + m_doselection = true; +} + +QString KFloatSpinBox::mapValueToText( int value ) +{ + return KGlobal::locale()->formatNumber( (float)value / (float)m_factor, 4 ); +} + +int KFloatSpinBox::mapTextToValue( bool * ok ) +{ + return (int)( m_factor * KGlobal::locale()->readNumber( text(), ok ) ); +} + +void KFloatSpinBox::valueChange() +{ + if( m_doselection ) + QSpinBox::valueChange(); + else + { + updateDisplay(); + emit valueChanged( value() ); +#if defined(QT_ACCESSIBILITY_SUPPORT) + QAccessible::updateAccessibility( this, 0, QAccessible::ValueChanged ); +#endif + } +} + +void KFloatSpinBox::slotValueChanged( int ) +{ + emit valueChanged( value() ); +} + +#include "kfloatspinbox.moc" diff --git a/kview/modules/scale/kfloatspinbox.h b/kview/modules/scale/kfloatspinbox.h new file mode 100644 index 00000000..9407a0f1 --- /dev/null +++ b/kview/modules/scale/kfloatspinbox.h @@ -0,0 +1,64 @@ +/* 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. + +*/ + +// $Id$ + +#ifndef __kfloatspinbox_h_ +#define __kfloatspinbox_h_ + +#include <qspinbox.h> + +class KFloatSpinBox : public QSpinBox +{ + Q_OBJECT + public: + KFloatSpinBox( float minValue, float maxValue, float step, unsigned int precision, QWidget * parent = 0, const char * name = 0 ); + virtual ~KFloatSpinBox(); + + void setRange( float minValue, float maxValue, float step, unsigned int precision ); + void setRangeBlocking( float minValue, float maxValue, float step, unsigned int precision ); + + float value() const; + + public slots: + virtual void setValue( float value ); + /** + * differs from the above in that it will block all signals + */ + virtual void setValueBlocking( float value ); + + protected: + virtual QString mapValueToText( int value ); + virtual int mapTextToValue( bool * ok ); + virtual void valueChange(); + + signals: + void valueChanged( float value ); + + private slots: + void slotValueChanged( int value ); + + private: + int m_factor; + int m_min; + int m_max; + int m_step; + bool m_doselection; +}; + +#endif diff --git a/kview/modules/scale/kview_scale.cpp b/kview/modules/scale/kview_scale.cpp new file mode 100644 index 00000000..aa8dec82 --- /dev/null +++ b/kview/modules/scale/kview_scale.cpp @@ -0,0 +1,180 @@ +/* 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. + +*/ + +/* $Id$ */ + +#include "kview_scale.h" +#include "scaledlg.h" + +#include <qimage.h> +#include <qvbox.h> + +#include <kaction.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kdebug.h> +#include <kimageviewer/viewer.h> +#include <kimageviewer/canvas.h> +#include <kdialogbase.h> + +typedef KGenericFactory<KViewScale> KViewScaleFactory; +K_EXPORT_COMPONENT_FACTORY( kview_scale, KViewScaleFactory( "kview_scale" ) ) + +KViewScale::KViewScale( QObject* parent, const char* name, const QStringList & ) + : Plugin( parent, name ) + , m_pViewer( 0 ) + , m_pCanvas( 0 ) +{ + m_pViewer = static_cast<KImageViewer::Viewer *>( parent ); + if( m_pViewer ) + { + kdDebug( 4630 ) << "m_pViewer->canvas() = " << m_pViewer->canvas() << endl; + m_pCanvas = m_pViewer->canvas(); + + (void) new KAction( i18n( "&Scale Image..." ), 0, 0, + this, SLOT( slotScaleDlg() ), + actionCollection(), "plugin_scale" ); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the scale plugin won't work" << endl; +} + +KViewScale::~KViewScale() +{ +} + +void KViewScale::slotScaleDlg() +{ + kdDebug( 4630 ) << k_funcinfo << endl; + KDialogBase dlg( m_pViewer->widget(), "KView scale dialog", true, i18n( "Scale Image" ), KDialogBase::Ok|KDialogBase::Cancel ); + ScaleDlg widget( m_pCanvas->imageSize(), dlg.makeVBoxMainWidget() ); +#if 0 + QVBox * layout = dlg.makeVBoxMainWidget(); + + QGroupBox * pixelgroup = new QGroupBox( i18n( "Pixel Dimensions" ), layout ); + QGridLayout * pixelgroupgrid = new QGridLayout( pixelgroup, 1, 1, 0, KDialog::spacingHint() ); + pixelgroupgrid->setSpacing( KDialog::spacingHint() ); + pixelgroupgrid->setMargin( KDialog::marginHint() ); + QLabel * label; + QSize imagesize = m_pCanvas->imageSize(); + + // show original width + label = new QLabel( i18n( "Original width:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 0, 0 ); + pixelgroupgrid->addWidget( new QLabel( QString::number( imagesize.width() ), pixelgroup ), 0, 1 ); + label = new QLabel( i18n( "Height:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 1, 0 ); + pixelgroupgrid->addWidget( new QLabel( QString::number( imagesize.height() ), pixelgroup ), 1, 1 ); + + pixelgroupgrid->addRowSpacing( 2, KDialog::spacingHint() ); + + label = new QLabel( i18n( "New width:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 3, 0 ); + label = new QLabel( i18n( "Height:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 4, 0 ); + QSpinBox * newwidth = new QSpinBox( 1, 100000, 1, pixelgroup ); + pixelgroupgrid->addWidget( newwidth, 3, 1 ); + QSpinBox * newheight = new QSpinBox( 1, 100000, 1, pixelgroup ); + pixelgroupgrid->addWidget( newheight, 4, 1 ); + KComboBox * newsizeunit = new KComboBox( pixelgroup ); + newsizeunit->insertItem( i18n( "px" ) ); + newsizeunit->insertItem( i18n( "%" ) ); + pixelgroupgrid->addMultiCellWidget( newsizeunit, 3, 4, 2, 2, Qt::AlignVCenter ); + + pixelgroupgrid->addRowSpacing( 5, KDialog::spacingHint() ); + + label = new QLabel( i18n( "Ratio X:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 6, 0 ); + label = new QLabel( i18n( "Y:" ), pixelgroup ); + label->setAlignment( QLabel::AlignRight ); + pixelgroupgrid->addWidget( label, 7, 0 ); + QSpinBox * ratiox = new QSpinBox( pixelgroup ); + ratiox->setValidator( new QDoubleValidator( 0.0001, 10000, 4, ratiox ) ); + pixelgroupgrid->addWidget( ratiox, 6, 1 ); + QSpinBox * ratioy = new QSpinBox( pixelgroup ); + ratioy->setValidator( new QDoubleValidator( 0.0001, 10000, 4, ratioy ) ); + pixelgroupgrid->addWidget( ratioy, 7, 1 ); + pixelgroupgrid->addMultiCellWidget( new QCheckBox( i18n( "Link" ), pixelgroup ), 6, 7, 2, 2, Qt::AlignVCenter ); + + QGroupBox * printgroup = new QGroupBox( i18n( "Print Size && Display Units" ), layout ); + QGridLayout * printgroupgrid = new QGridLayout( printgroup, 1, 1, 0, KDialog::spacingHint() ); + printgroupgrid->setSpacing( KDialog::spacingHint() ); + printgroupgrid->setMargin( KDialog::marginHint() ); + + label = new QLabel( i18n( "New width:" ), printgroup ); + label->setAlignment( QLabel::AlignRight ); + printgroupgrid->addWidget( label, 0, 0 ); + label = new QLabel( i18n( "Height:" ), printgroup ); + label->setAlignment( QLabel::AlignRight ); + printgroupgrid->addWidget( label, 1, 0 ); + QSpinBox * newwidth2 = new QSpinBox( printgroup ); + printgroupgrid->addWidget( newwidth2, 0, 1 ); + QSpinBox * newheight2 = new QSpinBox( printgroup ); + printgroupgrid->addWidget( newheight2, 1, 1 ); + KComboBox * newsizeunit2 = new KComboBox( printgroup ); + newsizeunit2->insertItem( i18n( "in" ) ); + newsizeunit2->insertItem( i18n( "mm" ) ); + printgroupgrid->addMultiCellWidget( newsizeunit2, 0, 1, 2, 2, Qt::AlignVCenter ); + + printgroupgrid->addRowSpacing( 2, KDialog::spacingHint() ); + + label = new QLabel( i18n( "Resolution X:" ), printgroup ); + label->setAlignment( QLabel::AlignRight ); + printgroupgrid->addWidget( label, 3, 0 ); + label = new QLabel( i18n( "Y:" ), printgroup ); + label->setAlignment( QLabel::AlignRight ); + printgroupgrid->addWidget( label, 4, 0 ); + QSpinBox * resx = new QSpinBox( printgroup ); + printgroupgrid->addWidget( resx, 3, 1 ); + QSpinBox * resy = new QSpinBox( printgroup ); + printgroupgrid->addWidget( resy, 4, 1 ); + printgroupgrid->addMultiCellWidget( new QCheckBox( i18n( "Link" ), printgroup ), 3, 4, 2, 2, Qt::AlignVCenter ); + //KComboBox * newsizeunit2 = new KComboBox( printgroup ); + //newsizeunit2->insertItem( i18n( "in" ) ); + //newsizeunit2->insertItem( i18n( "mm" ) ); + //printgroupgrid->addMultiCellWidget( newsizeunit2, 0, 1, 2, 2, Qt::AlignVCenter ); +#endif + + dlg.exec(); +} + +void KViewScale::slotScale() +{ + // retrieve current image + kdDebug( 4630 ) << "m_pCanvas = " << m_pCanvas << endl; + const QImage * image = m_pCanvas->image(); + kdDebug( 4630 ) << "image pointer retrieved" << endl; + if( image ) + { + // scale + QImage newimage = image->smoothScale( 50, 50 ); + // put back (modified) + m_pCanvas->setImage( newimage ); + m_pViewer->setModified( true ); + } + else + kdDebug( 4630 ) << "no image to scale" << endl; +} + +// vim:sw=4:ts=4:cindent +#include "kview_scale.moc" diff --git a/kview/modules/scale/kview_scale.desktop b/kview/modules/scale/kview_scale.desktop new file mode 100644 index 00000000..6dd11c40 --- /dev/null +++ b/kview/modules/scale/kview_scale.desktop @@ -0,0 +1,127 @@ +[Desktop Entry] +Name=Scale +Name[af]=Skaal +Name[ar]=تكبير أو تصغير +Name[bg]=Мащабиране +Name[br]=Skeulaet +Name[bs]=Skaliraj +Name[ca]=Escala +Name[cs]=Změna měřítka +Name[cy]=Graddfa +Name[da]=Skala +Name[de]=Skalierer +Name[el]=Κλιμάκωση +Name[eo]=Grandecŝanĝo +Name[et]=Skaleerija +Name[eu]=Eskalatu +Name[fa]=مقیاس +Name[fi]=Skaalaa +Name[fr]=Échelle +Name[ga]=Scála +Name[gl]=Redimensionar +Name[he]=קנה מידה +Name[hi]=स्केल +Name[hr]=Skala +Name[hu]=Nagyítás +Name[is]=Skala +Name[it]=Riscala +Name[ja]=スケール +Name[kk]=Масштабтау +Name[km]=ធ្វើមាត្រដ្ឋាន +Name[lt]=Mąstelis +Name[ms]=Skala +Name[nb]=Skaler +Name[nds]=Grött-Topasser +Name[ne]=स्केल +Name[nl]=Schaalprogramma +Name[nn]=Skaler +Name[nso]=Sekala +Name[pa]=ਸਕੇਲ +Name[pl]=Skala +Name[pt]=Redimensionamento +Name[pt_BR]=Escala +Name[ro]=Scalare +Name[ru]=Масштабирование +Name[se]=Skále +Name[sk]=Škálovač +Name[sl]=Raztegni +Name[sr]=Скалирање +Name[sr@Latn]=Skaliranje +Name[sv]=Skala +Name[ta]=அளவுக்கோல் +Name[tg]=Масштабонӣ +Name[tr]=Oranla +Name[uk]=Масштаб +Name[ven]=Tshikeili +Name[wa]=Al schåle +Name[xh]=Isikali +Name[zh_CN]=缩放 +Name[zh_HK]=縮放 +Name[zh_TW]=縮放 +Name[zu]=Isikali +Comment=Filter to scale the image +Comment[af]=Filter na skaal die beeld +Comment[ar]=فلتر لتكبير أو تصغير الصورة +Comment[bg]=Филтър за мащабиране на изображения +Comment[bs]=Filter za skaliranje slike +Comment[ca]=Filtre per escalar la imatge +Comment[cs]=Filtr ke změně měřítka obrázku +Comment[cy]=Hidl i raddio'r ddelwedd +Comment[da]=Filter til at skalere billedet +Comment[de]=Ein Filter zum Skalieren von Bildern +Comment[el]=Φίλτρο για την κλιμάκωση της εικόνας +Comment[eo]=por ŝanĝi la grandecon de la bildo +Comment[es]=Filtro para cambiar la escala de una imagen +Comment[et]=Filter piltide skaleerimiseks +Comment[eu]=Eskalatu irudia +Comment[fa]=پالایه برای مقیاس کردن تصویر +Comment[fi]=Suodatin kuvan skaalaamiseen +Comment[fr]=Filtre pour zoomer une image +Comment[gl]=Filtro para redimensionar a imaxe +Comment[he]=מסנן לשינוי קנה המידה של התמונה +Comment[hi]=छवि का आकार बदलने का फ़िल्टर +Comment[hr]=Filter za promjenu veličine slike +Comment[hu]=Képméretező szűrő +Comment[is]=Sía sem skalar myndina +Comment[it]=Filtro per ridimensionare l'immagine +Comment[ja]=画像をスケールするフィルタ +Comment[kk]=Кескідерді масштабтау сүзгісі +Comment[km]=តម្រងធ្វើមាត្រដ្ឋានរូបភាព +Comment[lt]=Filtras paveikslėliui didinti ar mažinti +Comment[ms]=Tapis untuk menskalakan imej +Comment[nb]=Filter for skalering av bildet +Comment[nds]=En Filter för't Topassen vun de Bildgrött +Comment[ne]=छवि मापन गर्न फिल्टर +Comment[nl]=Filter om de afbeelding te schalen +Comment[nn]=Filter for skalering av biletet +Comment[nso]=Sesekodi sago kala ponagalo +Comment[pl]=Filtr do skalowania obrazków +Comment[pt]=Um filtro para escalar a imagem +Comment[pt_BR]=Filtro para escalar a imagem +Comment[ro]=Filtru de scalat imaginea +Comment[ru]=Фильтр для масштабирования изображений +Comment[se]=Silli mii skálere govaid +Comment[sk]=Filter pre zväčšenie obrázku +Comment[sl]=Filter za raztegovanje slike +Comment[sr]=Филтер за промену величине слике +Comment[sr@Latn]=Filter za promenu veličine slike +Comment[sv]=Filter för att skala bilden +Comment[ta]=பிம்பத்தை மாற்றும் வடிகட்டி +Comment[tg]=Филтр барои масштабонии тасвирот +Comment[tr]=Resmi oranlamak için filtre +Comment[uk]=Фільтр для масштабування зображення +Comment[ven]=Faela yau kala tshifanyiso +Comment[wa]=Passete po mete l' imådje al schåle +Comment[xh]=Icebo lokucoca ulwelo lokukala umfanekiso +Comment[zh_CN]=缩放图像的滤镜 +Comment[zh_HK]=用來縮放影像的過濾器 +Comment[zh_TW]=用來縮放影像的濾鏡 +Comment[zu]=Hluza isithombe esikaleni +Type=Plugin + +[X-KDE Plugin Info] +Author=Matthias Kretz +Email=kretz@kde.org +PluginName=kview_scale +Category=Filter +Version=0.1 diff --git a/kview/modules/scale/kview_scale.h b/kview/modules/scale/kview_scale.h new file mode 100644 index 00000000..2022f0ac --- /dev/null +++ b/kview/modules/scale/kview_scale.h @@ -0,0 +1,48 @@ +/* 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. + +*/ + +/* $Id$ */ + +#ifndef __kview_scale_h +#define __kview_scale_h + +#include <kparts/plugin.h> + +namespace KImageViewer { + class Viewer; + class Canvas; +} + +class KViewScale : public KParts::Plugin +{ + Q_OBJECT +public: + KViewScale( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewScale(); + +private slots: + void slotScaleDlg(); + void slotScale(); + +private: + KImageViewer::Viewer * m_pViewer; + KImageViewer::Canvas * m_pCanvas; +}; + +// vim:sw=4:ts=4:cindent +#endif diff --git a/kview/modules/scale/kview_scale.rc b/kview/modules/scale/kview_scale.rc new file mode 100644 index 00000000..2f952be5 --- /dev/null +++ b/kview/modules/scale/kview_scale.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kview_scale" library="kview_scale"> + <MenuBar> + <Menu name="image"><Text>&Image</Text> + <Action name="plugin_scale"/> + </Menu> + </MenuBar> + <!-- + <ToolBar name="extraToolBar"> + <text>&Extra Toolbar</text> + <Action name="plugin_scale"/> + </ToolBar> + --> +</kpartplugin> diff --git a/kview/modules/scale/scaledlg.cpp b/kview/modules/scale/scaledlg.cpp new file mode 100644 index 00000000..997be86d --- /dev/null +++ b/kview/modules/scale/scaledlg.cpp @@ -0,0 +1,311 @@ +/* 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. + +*/ + +// $Id$ + +#include "scaledlg.h" + +#include <qvbox.h> +#include <qlayout.h> +#include <qlabel.h> +#include <qspinbox.h> +#include <qcheckbox.h> +#include <qgroupbox.h> +#include <qsize.h> + +#include <kdebug.h> +#include <kcombobox.h> +#include <klocale.h> +#include <kdialog.h> +#include "kfloatspinbox.h" +#include <kglobal.h> + +#define ONEINCHINMM 2.54 + +ScaleDlg::ScaleDlg( const QSize & origsize, QVBox * parent, const char * name ) + : QObject( parent, name ) + , m_origsize( origsize ) + , m_newsizeunit( 0 ) + , m_newsizeunit2( 0 ) + , m_resolutionunit( 0 ) + , m_newwidth( origsize.width() ) + , m_newheight( origsize.height() ) + , m_resx( 72 ) + , m_resy( 72 ) +{ + QGroupBox * pixelgroup = new QGroupBox( i18n( "Pixel Dimensions" ), parent ); + QGroupBox * printgroup = new QGroupBox( i18n( "Print Size && Display Units" ), parent ); + + QGridLayout * pixelgroupgrid = new QGridLayout( pixelgroup, 1, 1, + KDialog::marginHint(), KDialog::spacingHint() ); + QGridLayout * printgroupgrid = new QGridLayout( printgroup, 1, 1, + KDialog::marginHint(), KDialog::spacingHint() ); + + QLabel * label; + + pixelgroupgrid->addRowSpacing( 0, KDialog::spacingHint() ); + + label = new QLabel( i18n( "Original width:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 1, 0 ); + label = new QLabel( i18n( "Height:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 2, 0 ); + + pixelgroupgrid->addRowSpacing( 3, KDialog::spacingHint() ); + + label = new QLabel( i18n( "New width:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 4, 0 ); + label = new QLabel( i18n( "Height:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 5, 0 ); + + pixelgroupgrid->addRowSpacing( 6, KDialog::spacingHint() ); + + label = new QLabel( i18n( "Ratio X:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 7, 0 ); + label = new QLabel( i18n( "Y:" ), pixelgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( label, 8, 0 ); + + printgroupgrid->addRowSpacing( 0, KDialog::spacingHint() ); + + label = new QLabel( i18n( "New width:" ), printgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + printgroupgrid->addWidget( label, 1, 0 ); + label = new QLabel( i18n( "Height:" ), printgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + printgroupgrid->addWidget( label, 2, 0 ); + + printgroupgrid->addRowSpacing( 3, KDialog::spacingHint() ); + + label = new QLabel( i18n( "Resolution X:" ), printgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + printgroupgrid->addWidget( label, 4, 0 ); + label = new QLabel( i18n( "Y:" ), printgroup ); + label->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + printgroupgrid->addWidget( label, 5, 0 ); + + m_pOldWidth = new QLabel( QString::number( origsize.width() ), pixelgroup ); + m_pOldWidth->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( m_pOldWidth, 1, 1 ); + m_pOldHeight = new QLabel( QString::number( origsize.height() ), pixelgroup ); + m_pOldHeight->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) ); + pixelgroupgrid->addWidget( m_pOldHeight, 2, 1 ); + + m_pNewWidth = new KFloatSpinBox( 1.0, 100000.0, 10.0, 0, pixelgroup ); + pixelgroupgrid->addWidget( m_pNewWidth, 4, 1 ); + m_pNewHeight = new KFloatSpinBox( 1.0, 100000.0, 10.0, 0, pixelgroup ); + pixelgroupgrid->addWidget( m_pNewHeight, 5, 1 ); + + m_pNewSizeUnit = new KComboBox( pixelgroup ); + m_pNewSizeUnit->insertItem( i18n( "px" ) ); + m_pNewSizeUnit->insertItem( i18n( "%" ) ); + pixelgroupgrid->addMultiCellWidget( m_pNewSizeUnit, 4, 5, 2, 2, Qt::AlignVCenter ); + + m_pRatioX = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, pixelgroup ); + pixelgroupgrid->addWidget( m_pRatioX, 7, 1 ); + m_pRatioY = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, pixelgroup ); + pixelgroupgrid->addWidget( m_pRatioY, 8, 1 ); + + m_pLinkRatio = new QCheckBox( i18n( "Link" ), pixelgroup ); + pixelgroupgrid->addMultiCellWidget( m_pLinkRatio, 7, 8, 2, 2, Qt::AlignVCenter ); + + m_pNewWidth2 = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, printgroup ); + printgroupgrid->addWidget( m_pNewWidth2, 1, 1 ); + m_pNewHeight2 = new KFloatSpinBox( 0.0001, 10000.0, 0.1, 4, printgroup ); + printgroupgrid->addWidget( m_pNewHeight2, 2, 1 ); + + m_pNewSizeUnit2 = new KComboBox( printgroup ); + m_pNewSizeUnit2->insertItem( i18n( "in" ) ); + m_pNewSizeUnit2->insertItem( i18n( "mm" ) ); + printgroupgrid->addMultiCellWidget( m_pNewSizeUnit2, 1, 2, 2, 2, Qt::AlignVCenter ); + + m_pResolutionX = new KFloatSpinBox( 0.0001, 6000.0, 1.0, 4, printgroup ); + printgroupgrid->addWidget( m_pResolutionX, 4, 1 ); + m_pResolutionY = new KFloatSpinBox( 0.0001, 6000.0, 1.0, 4, printgroup ); + printgroupgrid->addWidget( m_pResolutionY, 5, 1 ); + + m_pLinkResolution = new QCheckBox( i18n( "Link" ), printgroup ); + printgroupgrid->addMultiCellWidget( m_pLinkResolution, 4, 5, 2, 2, Qt::AlignVCenter ); + m_pResolutionUnit = new KComboBox( printgroup ); + m_pResolutionUnit->insertItem( i18n( "pixels/in" ) ); + m_pResolutionUnit->insertItem( i18n( "pixels/mm" ) ); + printgroupgrid->addMultiCellWidget( m_pResolutionUnit, 6, 6, 1, 2, Qt::AlignLeft ); + + m_pNewWidth->setValue( m_origsize.width() ); + m_pNewHeight->setValue( m_origsize.height() ); + + m_newsizeunit = 0; + m_newsizeunit2 = 0; + m_resolutionunit = 0; + + connect( m_pNewWidth, SIGNAL( valueChanged( float ) ), SLOT( slotNewWidth( float ) ) ); + connect( m_pNewHeight, SIGNAL( valueChanged( float ) ), SLOT( slotNewHeight( float ) ) ); + connect( m_pNewWidth2, SIGNAL( valueChanged( float ) ), SLOT( slotNewWidth2( float ) ) ); + connect( m_pNewHeight2, SIGNAL( valueChanged( float ) ), SLOT( slotNewHeight2( float ) ) ); + connect( m_pResolutionX, SIGNAL( valueChanged( float ) ), SLOT( slotResolutionX( float ) ) ); + connect( m_pResolutionY, SIGNAL( valueChanged( float ) ), SLOT( slotResolutionY( float ) ) ); + + connect( m_pNewSizeUnit, SIGNAL( activated( int ) ), SLOT( slotChangeNewSizeUnit( int ) ) ); + connect( m_pNewSizeUnit2, SIGNAL( activated( int ) ), SLOT( slotChangeNewSizeUnit2( int ) ) ); + connect( m_pResolutionUnit, SIGNAL( activated( int ) ), SLOT( slotChangeResolutionUnit( int ) ) ); +} + +ScaleDlg::~ScaleDlg() +{ +} + +void ScaleDlg::slotNewWidth( float newval ) +{ + float newwidth; + switch( m_newsizeunit ) + { + case 0: // Pixel + newwidth = newval; + break; + case 1: // Percent + newwidth = newval / 100.0 * m_origsize.width(); + break; + default: + kdError( 4630 ) << "unknown unit\n"; + break; + } + + m_newwidth = newwidth; + m_pNewWidth2->setValueBlocking( m_newwidth / m_resx / ( m_newsizeunit2 ? ONEINCHINMM : 1 ) ); + m_pRatioX->setValueBlocking( m_newwidth / m_origsize.width() ); + if( m_pLinkRatio->isChecked() ) + { + m_newheight = m_newwidth / m_origsize.width() * m_origsize.height(); + m_pNewHeight->setValueBlocking( m_newheight * ( m_newsizeunit ? 100.0 / m_origsize.height() : 1 ) ); + m_pRatioY->setValueBlocking( m_newheight / m_origsize.height() ); + m_pNewHeight2->setValueBlocking( m_newheight / m_resy / ( m_newsizeunit2 ? ONEINCHINMM : 1 ) ); + } +} + +void ScaleDlg::slotNewHeight( float newval ) +{ +} + +void ScaleDlg::slotNewWidth2( float newval ) +{ +} + +void ScaleDlg::slotNewHeight2( float newval ) +{ +} + +void ScaleDlg::slotResolutionX( float newval ) +{ +} + +void ScaleDlg::slotResolutionY( float newval ) +{ +} + +void ScaleDlg::slotChangeNewSizeUnit( int index ) +{ + if( m_newsizeunit == index ) + return; + + m_newsizeunit = index; + + switch( m_newsizeunit ) + { + case 0: + // Pixel + m_pNewWidth->setRange( 1.0, 100000.0, 10.0, 0 ); + m_pNewHeight->setRange( 1.0, 100000.0, 10.0, 0 ); + m_pNewWidth->setValueBlocking( m_newwidth ); + m_pNewHeight->setValueBlocking( m_newheight ); + break; + case 1: + // Percent + m_pNewWidth->setRange( 0.0001, 100000.0, 0.1, 4 ); + m_pNewHeight->setRange( 0.0001, 100000.0, 0.1, 4 ); + m_pNewWidth->setValueBlocking( m_newwidth * 100.0 / m_origsize.width() ); + m_pNewHeight->setValueBlocking( m_newheight * 100.0 / m_origsize.height() ); + break; + default: + kdError( 4630 ) << "change to unknown unit\n"; + break; + } +} + +void ScaleDlg::slotChangeNewSizeUnit2( int index ) +{ + if( m_newsizeunit2 == index ) + return; + + m_newsizeunit2 = index; + + switch( m_newsizeunit2 ) + { + case 0: + // Inch + m_pNewWidth2->setRange( 0.0001, 10000.0, 0.1, 4 ); + m_pNewHeight2->setRange( 0.0001, 10000.0, 0.1, 4 ); + m_pNewWidth2->setValueBlocking( m_newwidth / m_resx ); + m_pNewHeight2->setValueBlocking( m_newheight / m_resy ); + break; + case 1: + // Millimeter + m_pNewWidth2->setRange( 0.0002, 25400.0, 0.1, 4 ); + m_pNewHeight2->setRange( 0.0002, 25400.0, 0.1, 4 ); + m_pNewWidth2->setValueBlocking( m_newwidth / m_resx / ONEINCHINMM ); + m_pNewHeight2->setValueBlocking( m_newheight / m_resy / ONEINCHINMM ); + break; + default: + kdError( 4630 ) << "change to unknown unit\n"; + break; + } +} + +void ScaleDlg::slotChangeResolutionUnit( int index ) +{ + if( m_resolutionunit == index ) + return; + + m_resolutionunit = index; + + switch( m_resolutionunit ) + { + case 0: + // Pixels per Inch + m_pResolutionX->setRange( 0.0002, 25400.0, 0.1, 4 ); + m_pResolutionY->setRange( 0.0002, 25400.0, 0.1, 4 ); + m_pResolutionX->setValueBlocking( m_resx ); + m_pResolutionY->setValueBlocking( m_resy ); + break; + case 1: + // Pixels per Millimeter + m_pResolutionX->setRange( 0.0001, 10000.0, 0.1, 4 ); + m_pResolutionY->setRange( 0.0001, 10000.0, 0.1, 4 ); + m_pResolutionX->setValueBlocking( m_resx / ONEINCHINMM ); + m_pResolutionY->setValueBlocking( m_resy / ONEINCHINMM ); + break; + default: + kdError( 4630 ) << "change to unknown unit\n"; + break; + } +} + +#include "scaledlg.moc" diff --git a/kview/modules/scale/scaledlg.h b/kview/modules/scale/scaledlg.h new file mode 100644 index 00000000..ac5a6c44 --- /dev/null +++ b/kview/modules/scale/scaledlg.h @@ -0,0 +1,78 @@ +/* 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. + +*/ + +// $Id$ + +#ifndef __scaledlg_h_ +#define __scaledlg_h_ + +#include <qobject.h> + +class QLabel; +class KFloatSpinBox; +class KComboBox; +class QCheckBox; +class QVBox; +class QSize; + +class ScaleDlg : public QObject +{ + Q_OBJECT + public: + ScaleDlg( const QSize & originalsize, QVBox * parent, const char * name = 0 ); + ~ScaleDlg(); + + private slots: + void slotNewWidth( float ); + void slotNewHeight( float ); + void slotNewWidth2( float ); + void slotNewHeight2( float ); + void slotResolutionX( float ); + void slotResolutionY( float ); + void slotChangeNewSizeUnit( int ); + void slotChangeNewSizeUnit2( int ); + void slotChangeResolutionUnit( int ); + + private: + QSize m_origsize; + int m_newsizeunit; + int m_newsizeunit2; + int m_resolutionunit; + + float m_newwidth, m_newheight; // in Pixel + float m_resx, m_resy; // in dpi + + QLabel * m_pOldWidth; + QLabel * m_pOldHeight; + KFloatSpinBox * m_pNewWidth; + KFloatSpinBox * m_pNewHeight; + KComboBox * m_pNewSizeUnit; + KFloatSpinBox * m_pRatioX; + KFloatSpinBox * m_pRatioY; + QCheckBox * m_pLinkRatio; + + KFloatSpinBox * m_pNewWidth2; + KFloatSpinBox * m_pNewHeight2; + KComboBox * m_pNewSizeUnit2; + KFloatSpinBox * m_pResolutionX; + KFloatSpinBox * m_pResolutionY; + QCheckBox * m_pLinkResolution; + KComboBox * m_pResolutionUnit; +}; + +#endif diff --git a/kview/modules/scanner/Makefile.am b/kview/modules/scanner/Makefile.am new file mode 100644 index 00000000..83a22b32 --- /dev/null +++ b/kview/modules/scanner/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_scannerplugin.la + +kview_scannerplugin_la_SOURCES = kviewscanner.cpp +kview_scannerplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint +kview_scannerplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kview/kpartplugins +plug_DATA = kviewscanner.desktop kviewscanner.rc + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kviewscannerplugin.pot diff --git a/kview/modules/scanner/kviewscanner.cpp b/kview/modules/scanner/kviewscanner.cpp new file mode 100644 index 00000000..d1f96e5f --- /dev/null +++ b/kview/modules/scanner/kviewscanner.cpp @@ -0,0 +1,96 @@ +/* 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. + +*/ + +// $Id$ + +#include "kviewscanner.h" + +#include <qimage.h> +#include <qobjectlist.h> + +#include <kaction.h> +#include <kinstance.h> +#include <klocale.h> +#include <kgenericfactory.h> +#include <kscan.h> +#include <kmessagebox.h> +#include <kdebug.h> +#include <kimageviewer/viewer.h> + +typedef KGenericFactory<KViewScanner> KViewScannerFactory; +K_EXPORT_COMPONENT_FACTORY( kview_scannerplugin, KViewScannerFactory( "kviewscannerplugin" ) ) + +KViewScanner::KViewScanner( QObject* parent, const char* name, + const QStringList & ) + : Plugin( parent, name ), + m_pScandlg( 0 ), + m_pViewer( 0 ) +{ + QObjectList * viewerList = parent->queryList( 0, "KImageViewer Part", false, false ); + m_pViewer = static_cast<KImageViewer::Viewer *>( viewerList->getFirst() ); + delete viewerList; + if( m_pViewer ) + { + (void) new KAction( i18n( "&Scan Image..." ), "scanner", 0, + this, SLOT( slotScan() ), + actionCollection(), "plugin_scan" ); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the scanner plugin won't work" << endl; +} + +KViewScanner::~KViewScanner() +{ +} + +void KViewScanner::slotScan() +{ + if( ! m_pScandlg ) + { + m_pScandlg = KScanDialog::getScanDialog(); + if( m_pScandlg ) + { + m_pScandlg->setMinimumSize( 300, 300 ); + + connect( m_pScandlg, SIGNAL( finalImage( const QImage &, int ) ), + this, SLOT( slotImgScanned( const QImage & ) ) ); + } + else + { + KMessageBox::sorry( 0L, + i18n( "You do not appear to have SANE support, or your scanner " + "is not attached properly. Please check these items before " + "scanning again." ), + i18n( "No Scan-Service Available" ) ); + kdDebug( 4630 ) << "*** No Scan-service available, aborting!" << endl; + return; + } + } + + if( m_pScandlg->setup() ) + m_pScandlg->show(); +} + +void KViewScanner::slotImgScanned( const QImage & img ) +{ + kdDebug( 4630 ) << "received an image from the scanner" << endl; + m_pViewer->newImage( img ); +} + +// vim:sw=4:ts=4:cindent +#include "kviewscanner.moc" diff --git a/kview/modules/scanner/kviewscanner.desktop b/kview/modules/scanner/kviewscanner.desktop new file mode 100644 index 00000000..99abe5ff --- /dev/null +++ b/kview/modules/scanner/kviewscanner.desktop @@ -0,0 +1,127 @@ +[Desktop Entry] +Icon=scanner +Type=Service +ServiceTypes=KPluginInfo + +X-KDE-PluginInfo-Author=Matthias Kretz +X-KDE-PluginInfo-Email=kretz@kde.org +X-KDE-PluginInfo-Name=kviewscanner +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false + +Name=Scanner +Name[af]=Skandeerder +Name[ar]=الماسح الضوئي +Name[bg]=Скенер +Name[br]=Eiltreser +Name[bs]=Skener +Name[ca]=Escàner +Name[cy]=Sganiwr +Name[da]=Skanner +Name[el]=Σαρωτής +Name[eo]=Skanilo +Name[et]=Skänner +Name[eu]=Eskanerra +Name[fa]=پویشگر +Name[fi]=Skanneri +Name[fo]=Ljóslesari +Name[ga]=Scanóir +Name[gl]=Escáner +Name[he]=סורק +Name[hi]=स्कैनर +Name[hr]=Skener +Name[hu]=Lapolvasó +Name[is]=Skanni +Name[ja]=スキャナ +Name[kk]=Сканер +Name[km]=ម៉ាស៊ីនស្កេន +Name[lt]=Skaneris +Name[ms]=Pengimbas +Name[nb]=Skanner +Name[nds]=Bildinleser +Name[ne]=स्क्यानर +Name[nl]=Scanprogramma +Name[nn]=Skannar +Name[nso]=Selebeledi +Name[pa]=ਸਕੈਨਰ +Name[pl]=Skaner +Name[pt]=Digitalizador +Name[pt_BR]=Digitalizador +Name[ro]=Scaner +Name[ru]=Сканер +Name[se]=Skánner +Name[sk]=Skener +Name[sl]=Skener +Name[sr]=Скенер +Name[sr@Latn]=Skener +Name[sv]=Bildläsare +Name[ta]=வருடி +Name[tg]=Сканер +Name[tr]=Tarayıcı +Name[uk]=Сканер +Name[uz]=Skanner +Name[uz@cyrillic]=Сканнер +Name[ven]=Tshinanguludzi +Name[wa]=Sicanrece +Name[xh]=Umvavanyi +Name[zh_CN]=扫描仪 +Name[zh_HK]=掃描器 +Name[zh_TW]=掃描器 +Name[zu]=Umhloli +Comment=Open images from your scanner into KView +Comment[af]=Open beelde van jou skandeerder binnein K-bekyk +Comment[ar]=يفتح الصور الموجودة على ماسحك الضوئي في برنامج KView +Comment[bg]=Сканиране и отваряне на изображения от скенера +Comment[bs]=Otvara slike sa skenera u KView +Comment[ca]=Obre les imatges de l'escàner a KView +Comment[cs]=Otevírá obrázky ze skeneru do KView +Comment[cy]=Agor delweddau oddiwrth eich sganiwr yn KGweld +Comment[da]=åbn billeder fra din skanner til KView +Comment[de]=Lädt Bilder vom Scanner in KView +Comment[el]=Ανοίξτε εικόνες από το σαρωτή σας στο KView +Comment[es]=Abre imágenes desde su escáner en KView +Comment[et]=Avab skaneeritud pilte rakendusega KView +Comment[eu]=Zure eskanerretik irudiak KView-en erakusten ditu +Comment[fa]=باز کردن تصاویر از پویشگرتان در KView +Comment[fi]=Avaa kuvan skannerilta KView-ohjelmaan +Comment[fr]=Ouvre des images de votre scanner dans KView +Comment[gl]=Obre as imaxes do teu escáner en KView +Comment[he]=פתיחת תמונות מהסורק שלך ב־KView +Comment[hi]=आपके स्कैनर से के-व्यू में छवि खोलता है +Comment[hu]=Kép beolvasása lapolvasóról a KView-ba +Comment[is]=Senda myndir frá skannanum í KView +Comment[it]=Apre le immagini provenienti dallo scanner in KView +Comment[ja]=スキャナから画像を開き KView に転送します +Comment[kk]=Сканерден KView-ға кескінді түсіру +Comment[km]=បើករូបភាពពីម៉ាស៊ីនស្កេនរបស់អ្នកក្នុង KView +Comment[lt]=Atveria paveikslėlius iš Jūsų skanerio į KView +Comment[ms]=Buka imej dari pengimbas anda ke dalam KView +Comment[nb]=Åpner bilder fra skanneren til KView +Comment[nds]=Haalt Biller vun Dien Inleser na KView +Comment[ne]=तपाईँको स्क्यानरबाट केडीई दृश्य भित्र छवि खोल्नुहोस् +Comment[nl]=Scan afbeeldingen rechtstreeks in KView +Comment[nn]=Opnar bilete frå skannaren i KView +Comment[nso]=Bula diponagalo gotswa go selebeledi sa gago goya kago KView +Comment[pl]=Otwiera obrazki ze skanera w przeglądarce KView +Comment[pt]=Abrir as imagens do seu 'scanner' no KView +Comment[pt_BR]=Abre imagens do seu digitalizador no KVisualização +Comment[ro]=Deschide imagini din scaner în KView +Comment[ru]=Сканирование изображений в KView +Comment[se]=Rahpá govaid skánneris KView:as +Comment[sk]=Otvorí obrázky z vášho skeneru v KView +Comment[sl]=Odpre sliko iz vašega skenerja v KView +Comment[sr]=Отвара слике из вашег скенера у KView-у +Comment[sr@Latn]=Otvara slike iz vašeg skenera u KView-u +Comment[sv]=Öppnar bilder från bildläsaren i Kview +Comment[ta]= கேகாட்சியின் வருடியில் இருந்து பிம்பங்களைத் திற +Comment[tg]=Сканеронии тасвирот дар KView +Comment[tr]=Tarayıcıdan KView'a resim gönderin +Comment[uk]=Відкриває зображення з вашого сканера в KView +Comment[ven]=Vulani zwifanyiso ubva kha tshinanguludzi uya kha mbonalelo ya K +Comment[wa]=Drovi des imådjes di vosse sicanrece avou KView +Comment[xh]=Vula imifanekiso evela kumvavanyisi wakho kwi KView +Comment[zh_CN]=从您的扫描仪中打开图像至 KView +Comment[zh_HK]=從您的掃描器開啟圖像至 KView +Comment[zh_TW]=從您的掃描器開啟影像至 KView +Comment[zu]=Vula izithombe ezisuka kumhloli wakho kwi-KView diff --git a/kview/modules/scanner/kviewscanner.h b/kview/modules/scanner/kviewscanner.h new file mode 100644 index 00000000..cdb32d67 --- /dev/null +++ b/kview/modules/scanner/kviewscanner.h @@ -0,0 +1,50 @@ +/* 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. + +*/ + +// $Id$ + +#ifndef __kviewscanner_h +#define __kviewscanner_h + +#include <kparts/plugin.h> +#include <klibloader.h> + +class KURL; +class KScanDialog; +namespace KImageViewer { class Viewer; } + +class KViewScanner : public KParts::Plugin +{ + Q_OBJECT +public: + KViewScanner( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewScanner(); + +//public slots: + +private slots: + void slotScan(); + void slotImgScanned( const QImage & ); + +private: + KScanDialog * m_pScandlg; + KImageViewer::Viewer * m_pViewer; +}; + +// vim:sw=4:ts=4:cindent +#endif diff --git a/kview/modules/scanner/kviewscanner.rc b/kview/modules/scanner/kviewscanner.rc new file mode 100644 index 00000000..43e60593 --- /dev/null +++ b/kview/modules/scanner/kviewscanner.rc @@ -0,0 +1,12 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kviewscanner" library="kview_scannerplugin"> + <MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="plugin_scan"/> + </Menu> + </MenuBar> + <ToolBar name="extraToolBar"> + <text>Extra Toolbar</text> + <Action name="plugin_scan"/> + </ToolBar> +</kpartplugin> diff --git a/kview/modules/template/Makefile.am b/kview/modules/template/Makefile.am new file mode 100644 index 00000000..29ddc94c --- /dev/null +++ b/kview/modules/template/Makefile.am @@ -0,0 +1,15 @@ +INCLUDES = -I$(top_srcdir)/kview $(all_includes) + +kde_module_LTLIBRARIES = kview_templateplugin.la + +kview_templateplugin_la_SOURCES = kviewtemplate.cpp +kview_templateplugin_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) -lkdeprint +kview_templateplugin_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) + +plugdir = $(kde_datadir)/kview/kpartplugins +plug_DATA = kviewtemplate.desktop kviewtemplate.rc + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/kviewtemplateplugin.pot diff --git a/kview/modules/template/kviewtemplate.cpp b/kview/modules/template/kviewtemplate.cpp new file mode 100644 index 00000000..c8c6dc9d --- /dev/null +++ b/kview/modules/template/kviewtemplate.cpp @@ -0,0 +1,43 @@ +/* This file is in the public domain */ + +// $Id$ + +#include "kviewtemplate.h" + +#include <qobjectlist.h> + +#include <kaction.h> +/*#include <klocale.h>*/ +#include <kgenericfactory.h> +#include <kdebug.h> +#include <kimageviewer/viewer.h> + +typedef KGenericFactory<KViewTemplate> KViewTemplateFactory; +K_EXPORT_COMPONENT_FACTORY( kview_templateplugin, KViewTemplateFactory( "kviewtemplateplugin" ) ) + +KViewTemplate::KViewTemplate( QObject* parent, const char* name, const QStringList & ) + : Plugin( parent, name ) +{ + QObjectList * viewerList = parent->queryList( 0, "KImageViewer Part", false, false ); + m_pViewer = static_cast<KImageViewer::Viewer *>( viewerList->getFirst() ); + delete viewerList; + if( m_pViewer ) + { + (void) new KAction( /*i18n(*/ "&Do Something" /*)*/, 0, 0, + this, SLOT( yourSlot() ), + actionCollection(), "plugin_template" ); + } + else + kdWarning( 4630 ) << "no KImageViewer interface found - the template plugin won't work" << endl; +} + +KViewTemplate::~KViewTemplate() +{ +} + +void KViewTemplate::yourSlot() +{ +} + +// vim:sw=4:ts=4:cindent +#include "kviewtemplate.moc" diff --git a/kview/modules/template/kviewtemplate.desktop b/kview/modules/template/kviewtemplate.desktop new file mode 100644 index 00000000..e1039d06 --- /dev/null +++ b/kview/modules/template/kviewtemplate.desktop @@ -0,0 +1,129 @@ +[Desktop Entry] +Icon=mypluginicon +Type=Service +ServiceTypes=KPluginInfo + +X-KDE-PluginInfo-Author=Your Name +X-KDE-PluginInfo-Email=Your@address +X-KDE-PluginInfo-Name=kviewtemplate +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-License=Public Domain +X-KDE-PluginInfo-EnabledByDefault=true + +Name=Template +Name[af]=Werkvoorbeeld +Name[ar]=قالب +Name[bg]=Шаблон +Name[br]=Patrom +Name[bs]=Šablon +Name[ca]=Plantilla +Name[cs]=Šablona +Name[cy]=Patrymlun +Name[da]=Skabelon +Name[de]=Vorlage +Name[el]=Πρότυπο +Name[eo]=Ŝablono +Name[es]=Plantilla +Name[et]=Mallid +Name[eu]=Txantiloia +Name[fa]=قالب +Name[fi]=Pohja +Name[fr]=Modèle +Name[ga]=Teimpléad +Name[gl]=Modelo +Name[he]=תבנית +Name[hi]=टैम्प्लेट +Name[hu]=Sablon +Name[is]=Snið +Name[it]=Modello +Name[ja]=テンプレート +Name[kk]=Үлгі +Name[km]=ពុម្ព +Name[lt]=Šablonas +Name[ms]=Templat +Name[nb]=Mal +Name[nds]=Vörlaag +Name[ne]=टेम्प्लेट +Name[nl]=Sjabloon +Name[nn]=Mal +Name[nso]=Papiso +Name[pl]=Wzorzec +Name[pt]=Modelo +Name[pt_BR]=Modelo +Name[ro]=Model +Name[ru]=Шаблон +Name[se]=Málle +Name[sk]=Šablóna +Name[sl]=Predloga +Name[sr]=Шаблон +Name[sr@Latn]=Šablon +Name[sv]=Mall +Name[ta]=வார்ப்புரு +Name[tg]=Қолиб +Name[tr]=Şablon +Name[uk]=Шаблон +Name[uz]=Namuna +Name[uz@cyrillic]=Намуна +Name[wa]=Modele +Name[zh_CN]=模板 +Name[zh_HK]=範本 +Name[zh_TW]=範本 +Name[zu]=i-template +Comment=A longer description of what the plugin does +Comment[af]='n langer beskrywing van wat die inplak doen +Comment[ar]=وصف أطول عن عمل البرنامج المساعد +Comment[bg]=Подробно описание на приставката +Comment[bs]=Duži opis onoga što dodatak radi +Comment[ca]=Una descripció més llarga del que fa l'endollat +Comment[cs]=Zde by měl být delší popis modulu +Comment[cy]=Disgrifiad hirach o beth mae'r ategyn yn ei wneud +Comment[da]=En længere beskrivelse af hvad dette plugin gør +Comment[de]=Hier sollte eine längere Beschreibung des Moduls stehen +Comment[el]=Μια μεγαλύτερη περιγραφή για το τι κάνει το πρόσθετο +Comment[eo]=Pli longa priskribo pri la kromaĵo +Comment[es]=Una descripción más completa de la función del plugin +Comment[et]=Pluginate tegevuse pikemad kirjeldused +Comment[eu]=Pluginak egiten duenaren azalpen luzeagoa +Comment[fa]=توصیفی طولانیتر از آنچه وصله انجام میدهد +Comment[fi]=Pidempi kuvaus, mitä liitännäinen tekee +Comment[fr]=Une plus longue description de ce que fait le module +Comment[gl]=Unha descrición máis longa do que pode facer a extensión +Comment[he]=תיאור מפורט יותר לגבי מה שהתוסף עושה +Comment[hi]=प्लगइन के बारे में लंबा वर्णन कि वह क्या करता है +Comment[hr]=Duži opis umetka +Comment[hu]=Ez a bővítőmodul részletesebb leírása +Comment[is]=hér ætti að vera smá lýsing á hvað þetta gerir +Comment[it]=Una descrizione più lunga di quello che fa il plugin +Comment[ja]=ここにより詳細なプラグインの記述をします +Comment[kk]=Плагин модульдің түсініктемесі +Comment[km]=សេចក្ដីពណ៌នាវែង អំពីមុខងាររបស់កម្មវិធីជំនួយ +Comment[lt]=Ilgesnis aprašymas, ką daro priedas +Comment[ms]=Huraian panjang tentang apa yang plugin lakukan +Comment[nb]=En lengre beskrivelse av hva modulen gjør +Comment[nds]=En länger Beschrieven vun't Könen vun dat Moduul +Comment[ne]=प्लगइनले गर्ने कामको बारेमा लामो वर्णन +Comment[nl]=Plaats hier een kleine omschrijving van uw plugin +Comment[nn]=Ei lengre skildring av kva modulen gjer +Comment[nso]=Thlaloso ye telele ya seo ya seo plugin ese dirago +Comment[pl]=Dłuższy opis tego, co wtyczka robi +Comment[pt]=Uma descrição mais extensa do que o 'plugin' faz +Comment[pt_BR]= Uma descrição maior do que um plugin faz +Comment[ro]=O descriere mai lungă a modulului +Comment[ru]=А здесь должно быть описание модуля +Comment[se]=Guhkkit čilgehus mii muitala maid lassemoduvla bargá +Comment[sk]=Tu by mal byť popis, čo modul robí +Comment[sl]=Daljši opis, kaj naredi ta vstavek +Comment[sr]=Дужи опис чему прикључак служи +Comment[sr@Latn]=Duži opis čemu priključak služi +Comment[sv]=En längre beskrivningen av vad insticksprogrammet gör +Comment[ta]= சொருகுப்பொருள் செய்த பணியின் நீண்ட வருணனை +Comment[tg]=Дар инҷо бояд тасвироти модул бошад +Comment[tr]=Eklentinin uzun açıklaması +Comment[uk]=Докладний опис можливостей втулку +Comment[ven]=Thalutshedzo khulwane ya ine plugin ya ita zwone +Comment[wa]=On discrijhaedje pus complet di çou k' est fwait på tchôke-divins +Comment[xh]=Inkcazelo ende echaza ukuba iplagi ezingaphakathi zenza ntoni na +Comment[zh_CN]=这里应该填写插件功能详细一点的描述 +Comment[zh_HK]=這個插件的功用的較長描述 +Comment[zh_TW]=關於這個外掛程式的所做所為的較長描述 +Comment[zu]=incazelo ende yokuthi i-plugin yenzani diff --git a/kview/modules/template/kviewtemplate.h b/kview/modules/template/kviewtemplate.h new file mode 100644 index 00000000..1d158b05 --- /dev/null +++ b/kview/modules/template/kviewtemplate.h @@ -0,0 +1,27 @@ +/* This file is in the public domain */ + +// $Id$ + +#ifndef __kviewtemplate_h +#define __kviewtemplate_h + +#include <kparts/plugin.h> + +namespace KImageViewer { class Viewer; } + +class KViewTemplate : public KParts::Plugin +{ + Q_OBJECT +public: + KViewTemplate( QObject* parent, const char* name, const QStringList & ); + virtual ~KViewTemplate(); + +private slots: + void yourSlot(); + +private: + KImageViewer::Viewer * m_pViewer; +}; + +// vim:sw=4:ts=4:cindent +#endif diff --git a/kview/modules/template/kviewtemplate.rc b/kview/modules/template/kviewtemplate.rc new file mode 100644 index 00000000..03d51f57 --- /dev/null +++ b/kview/modules/template/kviewtemplate.rc @@ -0,0 +1,11 @@ +<!DOCTYPE kpartgui> +<kpartplugin name="kviewtemplate" library="kview_templateplugin"> + <MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="plugin_template"/> + </Menu> + </MenuBar> + <ToolBar name="extraToolBar"> + <Action name="plugin_template"/> + </ToolBar> +</kpartplugin> |