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/photobook | |
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/photobook')
-rw-r--r-- | kview/photobook/Makefile.am | 19 | ||||
-rw-r--r-- | kview/photobook/cr16-app-photobook.png | bin | 0 -> 720 bytes | |||
-rw-r--r-- | kview/photobook/cr22-app-photobook.png | bin | 0 -> 922 bytes | |||
-rw-r--r-- | kview/photobook/photobook.cpp | 292 | ||||
-rw-r--r-- | kview/photobook/photobook.desktop | 131 | ||||
-rw-r--r-- | kview/photobook/photobook.h | 140 | ||||
-rw-r--r-- | kview/photobook/photobookui.rc | 14 |
7 files changed, 596 insertions, 0 deletions
diff --git a/kview/photobook/Makefile.am b/kview/photobook/Makefile.am new file mode 100644 index 00000000..967a2def --- /dev/null +++ b/kview/photobook/Makefile.am @@ -0,0 +1,19 @@ + +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = libphotobook.la + +libphotobook_la_SOURCES = photobook.cpp + +libphotobook_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) +libphotobook_la_LIBADD = $(LIB_KFILE) $(LIB_KPARTS) + +partrcdir = $(kde_servicesdir) +partrc_DATA = photobook.desktop + +METASOURCES = AUTO + +KDE_ICON = photobook + +partdir = $(kde_datadir)/photobook +part_DATA = photobookui.rc diff --git a/kview/photobook/cr16-app-photobook.png b/kview/photobook/cr16-app-photobook.png Binary files differnew file mode 100644 index 00000000..bfc9b9cc --- /dev/null +++ b/kview/photobook/cr16-app-photobook.png diff --git a/kview/photobook/cr22-app-photobook.png b/kview/photobook/cr22-app-photobook.png Binary files differnew file mode 100644 index 00000000..915f3dba --- /dev/null +++ b/kview/photobook/cr22-app-photobook.png diff --git a/kview/photobook/photobook.cpp b/kview/photobook/photobook.cpp new file mode 100644 index 00000000..082bfd49 --- /dev/null +++ b/kview/photobook/photobook.cpp @@ -0,0 +1,292 @@ +/* +Copyright (c) 2004,2005 Charles Samuels <[email protected]> + + This file is hereby licensed under the GNU General Public License version + 2 or later at your option. + + This file is licensed under the Qt Public License version 1 with the + condition that the licensed will be governed under the Laws of California + (USA) instead of Norway. Disputes will be settled in Santa Clara county + courts. + + This file is licensed under the following additional license. Be aware + that it is identical to the BSD license, except for the added clause 3: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. By integrating this software into any other software codebase, you waive + all rights to any patents associated with the stated codebase. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + + +#include "photobook.h" + +#include <kparts/componentfactory.h> +#include <kaction.h> +#include <kstdaccel.h> +#include <kstandarddirs.h> + +Previews::Previews(PhotoBook *parent, const QStringList &mimetypes) + : KFileIconView(parent, 0) +{ + mPhotoBook = parent; + mMimeTypes = mimetypes; + + connect(&mDirLister, SIGNAL(clear()), SLOT(slotClearView())); + connect(&mDirLister, SIGNAL(completed()), SLOT(doneListing())); + connect( + &mDirLister, SIGNAL(newItems(const KFileItemList &)), + SLOT(insertNewFiles(const KFileItemList &)) + ); + connect( + signaler(), SIGNAL(fileSelected(const KFileItem*)), + SLOT(open(const KFileItem*)) + ); + connect( + &mDirLister, SIGNAL(deleteItem(KFileItem *)), + SLOT(removeItem(KFileItem *)) + ); + + connect( + &mDirLister, SIGNAL( refreshItems( const KFileItemList& ) ), + SLOT( slotRefreshItems( const KFileItemList& ) ) + ); + + setFixedWidth(128); +} + +Previews::~Previews() +{ + +} + + +void Previews::slotRefreshItems( const KFileItemList& items ) +{ + KFileItemListIterator it( items ); + for ( ; it.current(); ++it ) + updateView( it.current() ); +} + +void Previews::slotClearView() +{ + clearView(); +} + + +void Previews::insertNewFiles(const KFileItemList &items) +{ + addItemList(items); +} + +void Previews::removeItem(KFileItem *item) +{ + KFileIconView::removeItem(item); +} + + +void Previews::go(const KFileItem *k) +{ + setSelected(k, true); + setCurrentItem(k); + ensureItemVisible(k); + open(k); + updateButton(); +} + +void Previews::updateButton() +{ + mPhotoBook->updateButton( ( nextItem(currentFileItem())!=0L ), ( prevItem(currentFileItem())!=0L )); +} + +void Previews::openURL(const KURL &url) +{ + mDirLister.setMimeFilter(mMimeTypes); + mDirLister.openURL(url); +} + +void Previews::open(const KFileItem *item) +{ + if (!item->isDir()) + { + const KURL &u = item->url(); + emit open(u); + updateButton(); + } +} + +void Previews::doneListing() +{ + // eep! -- this should not be necessary + QTimer::singleShot(0, this, SLOT(goToFirst())); +} + +void Previews::goToFirst() +{ + if (firstFileItem()) + go(firstFileItem()); + else + updateButton(); +} + + + +PhotoBook::PhotoBook(QWidget *parent, PhotoBookPart *part, const char *name) + : QSplitter(parent, name) +{ + + QStringList mimetypes; + + KTrader::OfferList offers = KTrader::self()->query( + "KImageViewer/Viewer", "KParts/ReadOnlyPart", + "DesktopEntryName == 'kviewviewer'", QString::null + ); + + for ( + KTrader::OfferList::Iterator i(offers.begin()); + i != offers.end(); ++i + ) + { + KService::Ptr service = *i; + mViewer = KParts::ComponentFactory:: + createPartInstanceFromService<KParts::ReadOnlyPart>( service, this, 0, this ); + + // is this the correct way to get the supported mimetypes? + if (mViewer) + { + KSimpleConfig e(locate("services", service->desktopEntryPath())); + e.setGroup("Desktop Entry"); + mimetypes = QStringList::split(';', e.readEntry("MimeType")); + break; + } + } + + + mList = new Previews(this, mimetypes); + + mFit = mViewer->action("fittowin"); + + connect(mList, SIGNAL(open(const KURL&)), mViewer, SLOT(openURL(const KURL&))); + connect(mViewer, SIGNAL(completed()), mFit, SLOT(activate())); + + part->insertChildClient(mViewer); +} + +void PhotoBook::openURL(const KURL &url) +{ + mList->openURL(url); + mList->setIgnoreMaximumSize(); + mList->showPreviews(); +} + +void PhotoBook::next() +{ + KFileItem *k = mList->nextItem(mList->currentFileItem()); + if (k) + mList->go(k); +} + +void PhotoBook::previous() +{ + KFileItem *k = mList->prevItem(mList->currentFileItem()); + if (k) + mList->go(k); +} + + +void PhotoBook::updateButton( bool nextExist, bool previousExit) +{ + emit emitUpdateButton( nextExist, previousExit ); +} + +K_EXPORT_COMPONENT_FACTORY(libphotobook, PhotoBookFactory ) + +PhotoBookPart::PhotoBookPart( + QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const QStringList& + ) + : KParts::ReadOnlyPart(parent, name) +{ + setInstance(PhotoBookFactory::instance()); + + new PhotoBookBrowserExtension(this); + bv = new PhotoBook(parentWidget, this, widgetName); + setWidget(bv); + + connect( + bv, SIGNAL(emitUpdateButton(bool, bool)), + this, SLOT(slotUpdateButton(bool, bool)) + ); + m_pNextAction = KStdAction::next(bv, SLOT(next()), actionCollection(), "next"); + m_pPreviousAction = KStdAction::prior(bv, SLOT(previous()), actionCollection(), "previous"); + + setXMLFile( "photobookui.rc" ); + +} + +PhotoBookPart::~PhotoBookPart() +{ + +} + + +void PhotoBookPart::slotUpdateButton( bool nextExit, bool previousExit) +{ + m_pPreviousAction->setEnabled( previousExit ); + m_pNextAction->setEnabled( nextExit ); +} + +bool PhotoBookPart::openURL(const KURL &url) +{ + bv->openURL(url); + return true; +} + + +KAboutData* PhotoBookPart::createAboutData() +{ + return new KAboutData( + "photobook", I18N_NOOP("Photo Book"), + "1.0", I18N_NOOP("Easily browse a folder of photographs"), + KAboutData::License_GPL, + I18N_NOOP("Copyright (c) 2004,2005 Charles Samuels <[email protected]>") + ); +} + +bool PhotoBookPart::openFile() +{ + return true; +} + + + +PhotoBookBrowserExtension::PhotoBookBrowserExtension(PhotoBookPart *p) + : KParts::BrowserExtension(p, "PhotoBookBrowserExtension") +{ + +} + + + + +#include "photobook.moc" + diff --git a/kview/photobook/photobook.desktop b/kview/photobook/photobook.desktop new file mode 100644 index 00000000..cb218a80 --- /dev/null +++ b/kview/photobook/photobook.desktop @@ -0,0 +1,131 @@ +[Desktop Entry] +GenericName=Photobook +GenericName[bg]=Фотоалбум +GenericName[br]=Levr foto +GenericName[ca]=Llibre de fotografies +GenericName[da]=Fotoalbum +GenericName[de]=Photobuch +GenericName[es]=Libro de fotografías +GenericName[et]=Fotoalbum +GenericName[fa]=کتاب عکس +GenericName[fi]=Valokuvakirja +GenericName[fr]=Album photo +GenericName[gl]=Libro de Fotografías +GenericName[he]=ספר תמונות +GenericName[hu]=Fényképalbum +GenericName[is]=Myndabók +GenericName[it]=Album fotografico +GenericName[ja]=フォトブック +GenericName[kk]=Фотоальбом +GenericName[km]=សៀវភៅរូបថត +GenericName[lt]=Fotoalbumas +GenericName[ms]=Bukufoto +GenericName[nb]=Fotoalbum +GenericName[nds]=Fotoalbum +GenericName[ne]=फोटो पुस्तक +GenericName[nl]=Fotoboek +GenericName[nn]=Fotoalbum +GenericName[pa]=ਫੋਟੋ ਬੁੱਕ +GenericName[pl]=Album ze zdjęciami +GenericName[pt]=Álbum Fotográfico +GenericName[pt_BR]=Álbum de Fotos +GenericName[ro]=Colecţie de fotografii +GenericName[sk]=Album fotiek +GenericName[sl]=Album slik +GenericName[sr]=Фотокњига +GenericName[sr@Latn]=Fotoknjiga +GenericName[sv]=Fotoalbum +GenericName[ta]=புகைப்படப் புத்தகம் +GenericName[tr]=Albüm +GenericName[uz]=Rasmlar toʻplami +GenericName[uz@cyrillic]=Расмлар тўплами +GenericName[zh_HK]=照相簿 + +MimeType=inode/directory +Icon=photobook +Name=Photobook +Name[br]=Levr foto +Name[ca]=Llibre de fotografies +Name[da]=Fotoalbum +Name[es]=Libro de fotografías +Name[et]=Fotoalbum +Name[fa]=کتاب عکس +Name[fi]=Valokuvakirja +Name[fr]=Album photo +Name[gl]=Libro de Fotografías +Name[he]=ספר תמונות +Name[hu]=Fényképalbum +Name[is]=Myndabók +Name[it]=Album fotografico +Name[kk]=Фотоальбом +Name[km]=សៀវភៅរូបថត +Name[lt]=Fotoalbumas +Name[ms]=Bukufoto +Name[nb]=Fotoalbum +Name[ne]=फोटो पुस्तक +Name[nl]=Fotoboek +Name[nn]=Fotoalbum +Name[pa]=ਫੋਟੋ ਬੁੱਕ +Name[pl]=Album zdjęciowy +Name[pt]=Álbum Fotográfico +Name[pt_BR]=Álbum de Fotos +Name[ro]=Colecţia de fotografii +Name[sk]=Album fotiek +Name[sr]=Фотокњига +Name[sr@Latn]=Fotoknjiga +Name[sv]=Fotoalbum +Name[ta]=புகைப்படப் புத்தகம் +Name[tr]=Albüm +Name[uz]=Rasmlar toʻplami +Name[uz@cyrillic]=Расмлар тўплами +Name[zh_HK]=照相簿 +Comment=Easily browse a folder of photographs +Comment[bg]=Колекциониране на снимки като във фотоалбум +Comment[bs]=Jednostavno pregledajte direktorij sa fotografijama +Comment[ca]=Mirar fàcilment una carpeta de fotografies +Comment[cs]=Jednoduché prohlížení složek s fotkami +Comment[da]=Mappe med fotografier, nem at gennemse +Comment[de]=Auf einfache Weise einen Ordner nach Photos durchsuchen +Comment[el]=Εύκολη περιήγηση σε ένα φάκελο φωτογραφιών +Comment[es]=Vistazo rápido de una carpeta con fotografías +Comment[et]=Fotode kausta mugav lehitsemine +Comment[eu]=Arakatu argazki karpetak modu errazan +Comment[fa]=مرور آسان پوشهای از عکسها +Comment[fi]=Selaile helpolla valokuvakansioita +Comment[fr]=Naviguer facilement dans un dossier contenant des photos +Comment[gl]=Explorar doadamente un cartafol de fotografías +Comment[he]=דפדף בקלות בתיקייה המכילה תמונות +Comment[hu]=Könyvtárba helyezett fényképek nézegetéséhez +Comment[is]=Flettu á auðveldan hátt gegnum möppu með myndum +Comment[it]=Sfoglia facilmente una cartella di fotografie +Comment[ja]=写真を含むフォルダをブラウズ +Comment[kk]=Қапшықтағы фотоларды шолу +Comment[km]=រកមើលថតរូបថតយ៉ាងងាយស្រួល +Comment[lt]=Lengvai naršykite fotografijų aplankus +Comment[ms]=Layar folder fotograf dengan mudah +Comment[nb]=Enkel lesing av mapper med bilder +Comment[nds]=Op eenfache Oort en Foto-Orner dörkieken +Comment[ne]=फोटोग्राफको फोल्डर सजिलै ब्राउज गर्नुहोस् +Comment[nl]=Blader eenvoudig door een map met foto's +Comment[nn]=Enkel vising av mapper med bilete +Comment[pl]=Łatwe przeglądanie folderów ze zdjęciami +Comment[pt]=Navegue facilmente numa pasta de fotografias +Comment[pt_BR]=Navegue facilmente por uma pasta cheia de fotos +Comment[ro]=Răsfoiţi cu uşurinţă un folder de fotografii +Comment[ru]=Просмотр папок с фотографиями +Comment[sk]=Jednoducho prehliada priečinky s fotografiami +Comment[sl]=Zlahka brskajte po mapi s fotografijami +Comment[sr]=Лако прегледајте фасциклу са сликама +Comment[sr@Latn]=Lako pregledajte fasciklu sa slikama +Comment[sv]=Bläddra enkelt i en katalog med fotografier +Comment[ta]=புகைப்படங்களின் அடைவை சுலபமாக உலாவ +Comment[tr]=Fotoğraflarla dolu bir dizini kolayca gez +Comment[uk]=Простий перегляд тек з фотографіями +Comment[zh_CN]=轻松浏览照片文件夹 +Comment[zh_HK]=容易地瀏覽資料夾的照片 +Comment[zh_TW]=輕易地瀏覽相片的資料夾 +ServiceTypes=KParts/ReadOnlyPart,Browser/View +X-KDE-Library=libphotobook +X-KDE-BrowserView-Args=DetailedList +X-DCOP-ServiceType=Multi +Type=Service diff --git a/kview/photobook/photobook.h b/kview/photobook/photobook.h new file mode 100644 index 00000000..3da5cf78 --- /dev/null +++ b/kview/photobook/photobook.h @@ -0,0 +1,140 @@ +/* +Copyright (c) 2004 Charles Samuels <[email protected]> + + This file is hereby licensed under the GNU General Public License version + 2 or later at your option. + + This file is licensed under the Qt Public License version 1 with the + condition that the licensed will be governed under the Laws of California + (USA) instead of Norway. Disputes will be settled in Santa Clara county + courts. + + This file is licensed under the following additional license. Be aware + that it is identical to the BSD license, except for the added clause 3: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. By integrating this software into any other software codebase, you waive + all rights to any patents associated with the stated codebase. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#ifndef PHOTOBOOK_H +#define PHOTOBOOK_H + +#include <qsplitter.h> +#include <kfileiconview.h> +#include <kdirlister.h> + +#include <kparts/part.h> +#include <kparts/browserextension.h> +#include <kparts/genericfactory.h> + +class Previews; +class PhotoBookPart; + +class PhotoBook : public QSplitter +{ +Q_OBJECT + Previews *mList; + KAction *mFit; + KParts::ReadOnlyPart *mViewer; + +public: + PhotoBook(QWidget *parent, PhotoBookPart *part, const char *name=0); + void openURL(const KURL &url); + void updateButton(bool, bool ); + +public slots: + void next(); + void previous(); + +signals: + void emitUpdateButton( bool, bool ); +}; + +class Previews : public KFileIconView +{ +Q_OBJECT + + KDirLister mDirLister; + PhotoBook *mPhotoBook; + QStringList mMimeTypes; + +public: + Previews(PhotoBook *parent, const QStringList &mimetypes); + ~Previews(); + void openURL(const KURL &url); + + PhotoBook *bv() { return mPhotoBook; } + void updateButton( ); + +public slots: + void go(const KFileItem*); + +signals: + void open(const KURL & ki); + +private slots: + void insertNewFiles(const KFileItemList &); + void removeItem(KFileItem *item); + void open(const KFileItem*); + void doneListing(); + void goToFirst(); + void slotRefreshItems( const KFileItemList& items ); + void slotClearView(); +}; + + +class PhotoBookPart : public KParts::ReadOnlyPart +{ +Q_OBJECT + PhotoBook *bv; + KAction *m_pPreviousAction; + KAction *m_pNextAction; + +public: + PhotoBookPart( + QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name=0, + const QStringList& args = QStringList() + ); + ~PhotoBookPart(); + + virtual bool openURL(const KURL &url); + static KAboutData* createAboutData(); + virtual bool openFile(); + +public slots: + void slotUpdateButton( bool nextExit, bool previousExit); +}; + +typedef KParts::GenericFactory<PhotoBookPart> PhotoBookFactory; + +class PhotoBookBrowserExtension : public KParts::BrowserExtension +{ +Q_OBJECT +public: + PhotoBookBrowserExtension(PhotoBookPart *p); +}; + + +#endif + diff --git a/kview/photobook/photobookui.rc b/kview/photobook/photobookui.rc new file mode 100644 index 00000000..fbc89f62 --- /dev/null +++ b/kview/photobook/photobookui.rc @@ -0,0 +1,14 @@ +<!DOCTYPE kpartplugin> +<kpartplugin name="PhotoBook Part" library="libphotobook" version="2"> +<MenuBar> + <Menu name="view"><text>&View</text> + <Action name="previous"/> + <Action name="next"/> + </Menu> +</MenuBar> + +<Toolbar name="go"><text>Go</text> + <Action name="previous"/> + <Action name="next"/> +</Toolbar> +</kpartplugin> |