From c66249b79aa9bfa0924494adcd5345b5b1244b0c Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 10 Feb 2010 01:02:50 +0000 Subject: Added old abandoned KDE3 version of gwenview git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/gwenview@1088034 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/gvdirpart/Makefile.am | 23 ++ src/gvdirpart/cr16-app-gvdirpart.png | Bin 0 -> 768 bytes src/gvdirpart/cr22-app-gvdirpart.png | Bin 0 -> 1111 bytes src/gvdirpart/cr32-app-gvdirpart.png | Bin 0 -> 1823 bytes src/gvdirpart/crsc-app-gvdirpart.svg | 587 +++++++++++++++++++++++++++++++++++ src/gvdirpart/gvdirpart.cpp | 288 +++++++++++++++++ src/gvdirpart/gvdirpart.desktop | 44 +++ src/gvdirpart/gvdirpart.h | 174 +++++++++++ src/gvdirpart/gvdirpart.rc | 46 +++ src/gvdirpart/gvdirpartconfig.kcfg | 10 + src/gvdirpart/gvdirpartconfig.kcfgc | 4 + src/gvdirpart/hi16-app-gvdirpart.png | Bin 0 -> 828 bytes src/gvdirpart/hi22-app-gvdirpart.png | Bin 0 -> 1259 bytes src/gvdirpart/hi32-app-gvdirpart.png | Bin 0 -> 1839 bytes src/gvdirpart/hisc-app-gvdirpart.svg | 226 ++++++++++++++ 15 files changed, 1402 insertions(+) create mode 100644 src/gvdirpart/Makefile.am create mode 100644 src/gvdirpart/cr16-app-gvdirpart.png create mode 100644 src/gvdirpart/cr22-app-gvdirpart.png create mode 100644 src/gvdirpart/cr32-app-gvdirpart.png create mode 100644 src/gvdirpart/crsc-app-gvdirpart.svg create mode 100644 src/gvdirpart/gvdirpart.cpp create mode 100644 src/gvdirpart/gvdirpart.desktop create mode 100644 src/gvdirpart/gvdirpart.h create mode 100644 src/gvdirpart/gvdirpart.rc create mode 100644 src/gvdirpart/gvdirpartconfig.kcfg create mode 100644 src/gvdirpart/gvdirpartconfig.kcfgc create mode 100644 src/gvdirpart/hi16-app-gvdirpart.png create mode 100644 src/gvdirpart/hi22-app-gvdirpart.png create mode 100644 src/gvdirpart/hi32-app-gvdirpart.png create mode 100644 src/gvdirpart/hisc-app-gvdirpart.svg (limited to 'src/gvdirpart') diff --git a/src/gvdirpart/Makefile.am b/src/gvdirpart/Makefile.am new file mode 100644 index 0000000..039267d --- /dev/null +++ b/src/gvdirpart/Makefile.am @@ -0,0 +1,23 @@ +INCLUDES = -I$(srcdir)/.. $(all_includes) + +# These are not really libraries, but modules dynamically opened. +# So they should be installed in kde_module_dir, which is usually $kde_prefix/lib/kde3 +kde_module_LTLIBRARIES = libgvdirpart.la + +libgvdirpart_la_SOURCES = gvdirpart.cpp gvdirpartconfig.kcfgc +libgvdirpart_la_LIBADD = $(LIB_KPARTS) ../gvcore/libgwenviewcore.la +libgvdirpart_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) + +# Automatically generate moc files +METASOURCES = AUTO + +# Install the XML-GUI file to its correct location +gvdir = $(kde_datadir)/gvdirpart +gv_DATA = gvdirpart.rc + +# Install the .desktop file into the kde_services directory +kde_services_DATA = gvdirpart.desktop + +KDE_ICON = AUTO + +kde_kcfg_DATA = gvdirpartconfig.kcfg diff --git a/src/gvdirpart/cr16-app-gvdirpart.png b/src/gvdirpart/cr16-app-gvdirpart.png new file mode 100644 index 0000000..d49bc5b Binary files /dev/null and b/src/gvdirpart/cr16-app-gvdirpart.png differ diff --git a/src/gvdirpart/cr22-app-gvdirpart.png b/src/gvdirpart/cr22-app-gvdirpart.png new file mode 100644 index 0000000..00eaab2 Binary files /dev/null and b/src/gvdirpart/cr22-app-gvdirpart.png differ diff --git a/src/gvdirpart/cr32-app-gvdirpart.png b/src/gvdirpart/cr32-app-gvdirpart.png new file mode 100644 index 0000000..1a68bf4 Binary files /dev/null and b/src/gvdirpart/cr32-app-gvdirpart.png differ diff --git a/src/gvdirpart/crsc-app-gvdirpart.svg b/src/gvdirpart/crsc-app-gvdirpart.svg new file mode 100644 index 0000000..c470051 --- /dev/null +++ b/src/gvdirpart/crsc-app-gvdirpart.svg @@ -0,0 +1,587 @@ + + + + diff --git a/src/gvdirpart/gvdirpart.cpp b/src/gvdirpart/gvdirpart.cpp new file mode 100644 index 0000000..f85f06d --- /dev/null +++ b/src/gvdirpart/gvdirpart.cpp @@ -0,0 +1,288 @@ +/* +Copyright 2004 Jonathan Riddell + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. + +*/ +#include "gvdirpart.moc" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "gvdirpartconfig.h" + +namespace Gwenview { + +// For now let's duplicate +const char CONFIG_CACHE_GROUP[]="cache"; + + +//Factory Code +typedef KParts::GenericFactory GVDirFactory; +K_EXPORT_COMPONENT_FACTORY( libgvdirpart /*library name*/, GVDirFactory ) + +GVDirPart::GVDirPart(QWidget* parentWidget, const char* /*widgetName*/, QObject* parent, const char* name, + const QStringList &) : KParts::ReadOnlyPart( parent, name ) { + GVDirFactory::instance()->iconLoader()->addAppDir( "gwenview"); + setInstance( GVDirFactory::instance() ); + KGlobal::locale()->insertCatalogue("gwenview"); + KGlobal::locale()->setActiveCatalogue("gwenview"); + + mBrowserExtension = new GVDirPartBrowserExtension(this); + + mSplitter = new QSplitter(Qt::Horizontal, parentWidget, "gwenview-kpart-splitter"); + mSplitter->setFocusPolicy(QWidget::ClickFocus); + mSplitter->setOpaqueResize(true); + + // Create the widgets + mDocument = new Document(this); + mFileViewController = new FileViewController(mSplitter, actionCollection()); + int width=GVDirPartConfig::fileViewWidth(); + if (width!=-1) { + mFileViewController->resize(width, 10); + } + mImageView = new ImageView(mSplitter, mDocument, actionCollection()); + mSplitter->setResizeMode(mFileViewController, QSplitter::KeepSize); + + mSlideShow = new SlideShow(mDocument); + + setWidget(mSplitter); + + KStdAction::saveAs( mDocument, SLOT(saveAs()), actionCollection(), "saveAs" ); + new KAction(i18n("Rotate &Left"), "rotate_ccw", CTRL + Key_L, this, SLOT(rotateLeft()), actionCollection(), "rotate_left"); + new KAction(i18n("Rotate &Right"), "rotate_cw", CTRL + Key_R, this, SLOT(rotateRight()), actionCollection(), "rotate_right"); + + connect(mFileViewController, SIGNAL(requestContextMenu(const QPoint&, bool)), + mBrowserExtension, SLOT(openFileViewContextMenu(const QPoint&, bool)) ); + + connect(mFileViewController, SIGNAL(urlChanged(const KURL&)), + mDocument, SLOT(setURL(const KURL&)) ); + + connect(mFileViewController, SIGNAL(directoryChanged(const KURL&)), + this, SLOT(directoryChanged(const KURL&)) ); + + connect(mFileViewController, SIGNAL(selectionChanged()), + mBrowserExtension, SLOT(updateActions()) ); + + connect(mImageView, SIGNAL(requestContextMenu(const QPoint&)), + mBrowserExtension, SLOT(openImageViewContextMenu(const QPoint&)) ); + + connect(mSlideShow, SIGNAL(nextURL(const KURL&)), + this, SLOT(slotSlideShowChanged(const KURL&)) ); + + connect(mDocument, SIGNAL(loaded(const KURL&)), + this, SLOT(loaded(const KURL&)) ); + + // For wheel browsing + connect(mImageView, SIGNAL(selectPrevious()), + mFileViewController, SLOT(slotSelectPrevious()) ); + connect(mImageView, SIGNAL(selectNext()), + mFileViewController, SLOT(slotSelectNext()) ); + + mToggleSlideShow = new KToggleAction(i18n("Slide Show..."), "slideshow", 0, this, SLOT(toggleSlideShow()), actionCollection(), "slideshow"); + mToggleSlideShow->setCheckedState( i18n("Stop Slide Show" )); + + setXMLFile( "gvdirpart/gvdirpart.rc" ); + mBrowserExtension->updateActions(); +} + +GVDirPart::~GVDirPart() { + GVDirPartConfig::setFileViewWidth(mFileViewController->width()); + GVDirPartConfig::writeConfig(); + delete mSlideShow; +} + + +void GVDirPart::partActivateEvent(KParts::PartActivateEvent* event) { + if (event->activated()) { + KConfig* config=new KConfig("gwenviewrc"); + Cache::instance()->readConfig(config,CONFIG_CACHE_GROUP); + delete config; + } +} + + +KAboutData* GVDirPart::createAboutData() { + KAboutData* aboutData = new KAboutData( "gvdirpart", I18N_NOOP("GVDirPart"), + "0.1", I18N_NOOP("Image Browser"), + KAboutData::License_GPL, + "(c) 2004, Jonathan Riddell "); + return aboutData; +} + +bool GVDirPart::openFile() { + //unused because openURL implemented + + //mDocument->setFilename(mFile); + return true; +} + +bool GVDirPart::openURL(const KURL& url) { + if (!url.isValid()) { + return false; + } + + emit started( 0 ); + m_url = url; + m_url.adjustPath(1); + + emit setWindowCaption( m_url.prettyURL() ); + mFileViewController->setDirURL(m_url); + + return true; +} + +void GVDirPart::loaded(const KURL& url) { + QString caption = url.filename(); + if( !mDocument->image().isNull()) + caption += QString(" %1 x %2").arg(mDocument->width()).arg(mDocument->height()); + emit setWindowCaption(caption); + emit completed(); +} + +KURL GVDirPart::pixmapURL() { + return mDocument->url(); +} + +void GVDirPart::toggleSlideShow() { + if (mToggleSlideShow->isChecked()) { + KURL::List list; + KFileItemListIterator it( *mFileViewController->currentFileView()->items() ); + for ( ; it.current(); ++it ) { + KFileItem* item=it.current(); + if (!item->isDir() && !Archive::fileItemIsArchive(item)) { + list.append(item->url()); + } + } + if (list.count()==0) { + mToggleSlideShow->setChecked(false); + return; + } + //FIXME turn on full screen here (anyone know how?) + mSlideShow->start(list); + } else { + //FIXME turn off full screen here + mSlideShow->stop(); + } +} + +void GVDirPart::print() { + KPrinter printer; + if ( !mDocument->filename().isEmpty() ) { + printer.setDocName( m_url.filename() ); + KPrinter::addDialogPage( new PrintDialogPage( mDocument, mImageView, "GV page")); + + if (printer.setup(mImageView, QString::null, true)) { + mDocument->print(&printer); + } + } +} + +void GVDirPart::rotateLeft() { + mDocument->transform(ImageUtils::ROT_270); +} + +void GVDirPart::rotateRight() { + mDocument->transform(ImageUtils::ROT_90); +} + +void GVDirPart::directoryChanged(const KURL& dirURL) { + if( dirURL == m_url ) return; + emit mBrowserExtension->openURLRequest(dirURL); +} + +void GVDirPart::slotSlideShowChanged(const KURL& url) { + mDocument->setURL( url ); + mFileViewController->setFileNameToSelect( url.filename()); +} + + +/***** GVDirPartBrowserExtension *****/ + +GVDirPartBrowserExtension::GVDirPartBrowserExtension(GVDirPart* viewPart, const char* name) + :KParts::BrowserExtension(viewPart, name) { + mGVDirPart = viewPart; + emit enableAction("print", true ); +} + +GVDirPartBrowserExtension::~GVDirPartBrowserExtension() { +} + +void GVDirPartBrowserExtension::updateActions() { + bool somethingSelected = mGVDirPart->fileViewController()->selectionSize() != 0; + emit enableAction("trash", somethingSelected); + emit enableAction("del", somethingSelected); +} + +void GVDirPartBrowserExtension::del() { + FileViewController* fv = mGVDirPart->fileViewController(); + FileOperation::realDelete(fv->selectedURLs(), fv); + +} + +void GVDirPartBrowserExtension::trash() { + FileViewController* fv = mGVDirPart->fileViewController(); + FileOperation::trash(fv->selectedURLs(), fv); +} + + +void GVDirPartBrowserExtension::openFileViewContextMenu(const QPoint& pos, bool onItem) { + if (onItem) { + const KFileItemList* items = mGVDirPart->fileViewController()->currentFileView()->selectedItems(); + emit popupMenu(pos, *items); + } else { + emit popupMenu(pos, mGVDirPart->fileViewController()->dirURL(), 0); + } +} + + +void GVDirPartBrowserExtension::openImageViewContextMenu(const QPoint& pos) { + KURL url=mGVDirPart->url(); + QString mimeType=KMimeType::findByURL(url)->name(); + emit popupMenu(pos, url, mimeType); +} + + +void GVDirPartBrowserExtension::print() { + mGVDirPart->print(); +} + +} // namespace diff --git a/src/gvdirpart/gvdirpart.desktop b/src/gvdirpart/gvdirpart.desktop new file mode 100644 index 0000000..f2632c6 --- /dev/null +++ b/src/gvdirpart/gvdirpart.desktop @@ -0,0 +1,44 @@ +[Desktop Entry] +Type=Service +Name=Image View +Name[bg]=Преглед на изображения +Name[br]=Gwell ar skeudennoù +Name[ca]=Vista d'imatge +Name[cs]=Prohlížeč obrázků +Name[da]=Billedvisning +Name[de]=Bildbetrachter +Name[el]=Προβολή εικόνων +Name[es]=Visor de imágenes +Name[et]=Pildinäitaja +Name[fa]=نمای تصویر +Name[fr]=Aperçu d'images +Name[gl]=Visor de Imaxes +Name[hr]=Pregled slike +Name[hu]=Képnézegető +Name[is]=Myndskoðun +Name[it]=Vista immagini +Name[ja]=画像表示 +Name[ka]=სურათების ნახვა +Name[ms]=Lihat Imej +Name[nds]=Bildansicht +Name[nl]=Afbeeldingweergave +Name[pa]=ਚਿੱਤਰ ਝਲਕ +Name[pt]=Visualizador de Imagens +Name[pt_BR]=Visualizador de Imagens +Name[ru]=Просмотр изображений +Name[sk]=Zobrazenie obrázku +Name[sr]=Приказ слика +Name[sr@Latn]=Prikaz slika +Name[sv]=Bildvisare +Name[ta]=பிம்பக் காட்சி +Name[tg]=Намоишгари тасвир +Name[tr]=Resim Görünümü +Name[uk]=Перегляд зображень +Name[vi]=Xem ảnh +Name[xx]=xxImage Viewxx +Name[zh_CN]=图像查看 +MimeType=inode/directory +ServiceTypes=KParts/ReadOnlyPart +X-KDE-Library=libgvdirpart +InitialPreference=5 +Icon=gvdirpart diff --git a/src/gvdirpart/gvdirpart.h b/src/gvdirpart/gvdirpart.h new file mode 100644 index 0000000..08b5626 --- /dev/null +++ b/src/gvdirpart/gvdirpart.h @@ -0,0 +1,174 @@ +/* +Copyright 2004 Jonathan Riddell + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307, USA. + +*/ +#ifndef __gvdirpart_h__ +#define __gvdirpart_h__ + +#include +#include + +// Forward declarations +class QPoint; +class QSplitter; +class KAboutData; +class KAction; +class KToggleAction; + +namespace Gwenview { + +class ImageView; +class FileViewController; +class Document; +class SlideShow; + +class GVDirPart; + +/** + * The browser extension is an attribute of GVImagePart and provides + * some services to Konqueror. All Konqueror KParts have one. + */ +class GVDirPartBrowserExtension: public KParts::BrowserExtension { + Q_OBJECT + +public: + GVDirPartBrowserExtension(GVDirPart* viewPart, const char* name=0L); + ~GVDirPartBrowserExtension(); + +public slots: + void updateActions(); + + void trash(); + void del(); + + void print(); + +private slots: + void openFileViewContextMenu(const QPoint&, bool onItem); + void openImageViewContextMenu(const QPoint&); + +private: + GVDirPart* mGVDirPart; +}; + +/** + * A Read Only KPart to browse directories and their images using Gwenview + */ +class GVDirPart : public KParts::ReadOnlyPart { + Q_OBJECT +public: + GVDirPart(QWidget*, const char*, QObject*, const char*, const QStringList &); + virtual ~GVDirPart(); + + /** + * Return information about the part + */ + static KAboutData* createAboutData(); + + /** + * Returns the name of the current file in the pixmap + */ + KURL pixmapURL(); + + /** + * Print the image being viewed if there is one + */ + void print(); + + FileViewController* fileViewController() const { return mFileViewController; } + + +protected: + void partActivateEvent(KParts::PartActivateEvent* event); + + /** + * Unused because openURL() is implemented but required to be + * implemented. + */ + virtual bool openFile(); + + /** + * Tell the widgets the URL to browse. Sets the window + * caption and saves URL to m_url (important for history and + * others). + */ + virtual bool openURL(const KURL& url); + +protected slots: + /** + * Turns the slide show on or off + */ + void toggleSlideShow(); + + /** + * Sets Konqueror's caption, statusbar and emits completed(). + * Called by loaded() signal in GVDocument + */ + void loaded(const KURL& url); + + /** + * Rotates the current image 90 degrees counter clockwise + */ + void rotateLeft(); + + /** + * Rotates the current image 90 degrees clockwise + */ + void rotateRight(); + + void directoryChanged(const KURL& dirURL); + + void slotSlideShowChanged( const KURL& ); + +protected: + /** + * The component's widget, contains the files view on the left + * and scroll view on the right. + */ + QSplitter* mSplitter; + + /** + * Scroll widget + */ + ImageView* mImageView; + + /** + * Holds the image + */ + Document* mDocument; + + /** + * Shows the directory's files and folders + */ + + FileViewController* mFileViewController; + + /** + * This inherits from KParts::BrowserExtention and supplies + * some extra functionality to Konqueror. + */ + GVDirPartBrowserExtension* mBrowserExtension; + + /** + * Action turns on slide show + */ + KToggleAction* mToggleSlideShow; + SlideShow* mSlideShow; +}; + +} // namespace +#endif diff --git a/src/gvdirpart/gvdirpart.rc b/src/gvdirpart/gvdirpart.rc new file mode 100644 index 0000000..61717b9 --- /dev/null +++ b/src/gvdirpart/gvdirpart.rc @@ -0,0 +1,46 @@ + + + + &File + + + + + + + &View + + + + + &Colors + + + + + + + + + + + + + + + + + + +Main Toolbar + + + + + + + + + + + diff --git a/src/gvdirpart/gvdirpartconfig.kcfg b/src/gvdirpart/gvdirpartconfig.kcfg new file mode 100644 index 0000000..5296e51 --- /dev/null +++ b/src/gvdirpart/gvdirpartconfig.kcfg @@ -0,0 +1,10 @@ + + + + + + + -1 + + + diff --git a/src/gvdirpart/gvdirpartconfig.kcfgc b/src/gvdirpart/gvdirpartconfig.kcfgc new file mode 100644 index 0000000..e89b1be --- /dev/null +++ b/src/gvdirpart/gvdirpartconfig.kcfgc @@ -0,0 +1,4 @@ +File=gvdirpartconfig.kcfg +ClassName=GVDirPartConfig +Singleton=true +Mutators=true diff --git a/src/gvdirpart/hi16-app-gvdirpart.png b/src/gvdirpart/hi16-app-gvdirpart.png new file mode 100644 index 0000000..175c0df Binary files /dev/null and b/src/gvdirpart/hi16-app-gvdirpart.png differ diff --git a/src/gvdirpart/hi22-app-gvdirpart.png b/src/gvdirpart/hi22-app-gvdirpart.png new file mode 100644 index 0000000..d590c70 Binary files /dev/null and b/src/gvdirpart/hi22-app-gvdirpart.png differ diff --git a/src/gvdirpart/hi32-app-gvdirpart.png b/src/gvdirpart/hi32-app-gvdirpart.png new file mode 100644 index 0000000..9f3b269 Binary files /dev/null and b/src/gvdirpart/hi32-app-gvdirpart.png differ diff --git a/src/gvdirpart/hisc-app-gvdirpart.svg b/src/gvdirpart/hisc-app-gvdirpart.svg new file mode 100644 index 0000000..8846fb5 --- /dev/null +++ b/src/gvdirpart/hisc-app-gvdirpart.svg @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + -- cgit v1.2.1