summaryrefslogtreecommitdiff
path: root/noncore/graphics/opie-eye/gui
authorzecke <zecke>2004-03-22 23:32:41 (UTC)
committer zecke <zecke>2004-03-22 23:32:41 (UTC)
commit428b687982966dc2efabaf6dbcc55ad0ea30aa10 (patch) (side-by-side diff)
tree86da20abd2e4b97a59dc32e17996bde5ee74cc91 /noncore/graphics/opie-eye/gui
parent7ce623c6351646ce738a81e103632d73c5454ecc (diff)
downloadopie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.zip
opie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.tar.gz
opie-428b687982966dc2efabaf6dbcc55ad0ea30aa10.tar.bz2
Initial Check in of the Eye Of Zilla. This ImageViewer features
Image Infos, EXIF, Jpeg,Png,Gif support. It supports scaled loading of Jpegs. an smart image cache.... GUI needs some work and we need to find a bug in QCOP as well. TODO: Add Image Service for example Mailer Add ImageCanvas/Zoomer/Display
Diffstat (limited to 'noncore/graphics/opie-eye/gui') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/filesystem.cpp52
-rw-r--r--noncore/graphics/opie-eye/gui/filesystem.h34
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp296
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.h59
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp114
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h29
-rw-r--r--noncore/graphics/opie-eye/gui/viewmap.cpp9
7 files changed, 593 insertions, 0 deletions
diff --git a/noncore/graphics/opie-eye/gui/filesystem.cpp b/noncore/graphics/opie-eye/gui/filesystem.cpp
new file mode 100644
index 0000000..91bcf67
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/filesystem.cpp
@@ -0,0 +1,52 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#include <qpopupmenu.h>
+#include <qtoolbar.h>
+
+#include <qpe/resource.h>
+#include <qpe/storage.h>
+
+
+#include "filesystem.h"
+
+PFileSystem::PFileSystem( QToolBar* bar)
+ : QToolButton( bar )
+{
+ setIconSet( Resource::loadIconSet( "cardmon/pcmcia" ) );
+
+ m_pop = new QPopupMenu( this );
+ connect( m_pop, SIGNAL( activated( int ) ),
+ this, SLOT(slotSelectDir( int ) ) );
+
+ m_storage = new StorageInfo();
+ connect(m_storage, SIGNAL(disksChanged() ),
+ this, SLOT( changed() ) );
+ changed();
+
+ setPopup( m_pop );
+}
+
+PFileSystem::~PFileSystem() {
+ delete m_storage;
+}
+
+
+void PFileSystem::changed() {
+ m_pop->clear();
+ m_dev.clear();
+ const QList<FileSystem> &fs = m_storage->fileSystems();
+ QListIterator<FileSystem> it(fs );
+ for ( ; it.current(); ++it ) {
+ const QString disk = (*it)->name();
+ const QString path = (*it)->path();
+ m_dev.insert( disk, path );
+ m_pop->insertItem( disk );
+ }
+}
+
+void PFileSystem::slotSelectDir( int id ) {
+ emit changeDir( m_dev[m_pop->text(id )] );
+}
diff --git a/noncore/graphics/opie-eye/gui/filesystem.h b/noncore/graphics/opie-eye/gui/filesystem.h
new file mode 100644
index 0000000..a29ad87
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/filesystem.h
@@ -0,0 +1,34 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#ifndef PHUNK_FILE_SYSTEM_H
+#define PHUNK_FILE_SYSTEM_H
+
+#include <qtoolbutton.h>
+#include <qmap.h>
+
+class QPopupMenu;
+class StorageInfo;
+class PFileSystem : public QToolButton {
+ Q_OBJECT
+public:
+ PFileSystem( QToolBar* );
+ ~PFileSystem();
+
+signals:
+ void changeDir( const QString& );
+
+private slots:
+ void slotSelectDir( int );
+ void changed();
+
+private:
+ QPopupMenu* m_pop;
+ StorageInfo *m_storage;
+ QMap<QString, QString> m_dev;
+};
+
+
+#endif
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
new file mode 100644
index 0000000..0b80012
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -0,0 +1,296 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#include "iconview.h"
+
+#include <lib/imagecache.h>
+
+#include <iface/dirview.h>
+#include <iface/dirlister.h>
+
+#include <qpe/config.h>
+#include <qpe/resource.h>
+#include <qpe/qpemessagebox.h>
+#include <qpe/ir.h>
+#include <qpe/qcopenvelope_qws.h>
+
+#include <qiconview.h>
+#include <qlabel.h>
+#include <qhbox.h>
+#include <qcombobox.h>
+#include <qdir.h>
+#include <qapplication.h>
+#include <qmainwindow.h>
+#include <qtimer.h>
+#include <qstyle.h>
+
+
+
+namespace {
+ QPixmap* _dirPix = 0;
+ QPixmap* _unkPix = 0;
+ class IconViewItem : public QIconViewItem {
+ public:
+ IconViewItem( QIconView*, const QString& path, const QString& name, bool isDir = false);
+ QPixmap* pixmap()const;
+ QString path()const { return m_path; }
+ bool isDir()const { return m_isDir; }
+ void setText( const QString& );
+ private:
+ mutable QPixmap* m_pix;
+ QString m_path;
+ bool m_isDir : 1;
+ bool m_noInfo :1;
+ };
+
+
+/*
+ * If we request an Image or String
+ * we add it to the map
+ */
+ QMap<QString, IconViewItem*> g_stringInf;
+ QMap<QString, IconViewItem*> g_stringPix;
+
+ IconViewItem::IconViewItem( QIconView* view,const QString& path,
+ const QString& name, bool isDir )
+ : QIconViewItem( view ), m_path( path ), m_isDir( isDir ),
+ m_noInfo( false )
+ {
+ QIconViewItem::setText( name );
+ if ( isDir && !_dirPix )
+ _dirPix = new QPixmap( Resource::loadPixmap("advancedfm/FileBrowser"));
+ else if ( !isDir && !_unkPix )
+ _unkPix = new QPixmap( Resource::loadPixmap( "UnknownDocument" ) );
+ }
+ inline QPixmap* IconViewItem::pixmap()const {
+ if ( m_isDir )
+ return _dirPix;
+ else{
+ if (!m_noInfo && !g_stringInf.contains( m_path ) ) {
+ currentView()->dirLister()->imageInfo( m_path );
+ g_stringInf.insert( m_path, const_cast<IconViewItem*>(this));
+ }
+
+ m_pix = PPixmapCache::self()->cachedImage( m_path, 64, 64 );
+ if ( !m_pix && !g_stringPix.contains( m_path )) {
+ currentView()->dirLister()->thumbNail( m_path, 64, 64 );
+ g_stringPix.insert( m_path, const_cast<IconViewItem*>(this));
+ }
+ return m_pix ? m_pix : _unkPix;
+ }
+ }
+ inline void IconViewItem::setText( const QString& str ) {
+ QString text = QIconViewItem::text()+"\n"+str;
+ m_noInfo = true;
+ QIconViewItem::setText( text );
+ }
+}
+
+
+PIconView::PIconView( QWidget* wid, Config* cfg )
+ : QVBox( wid ), m_cfg( cfg )
+{
+ {
+ QCopEnvelope( "QPE/Application/opie-eye_slave", "foo()" );
+ }
+ m_path = QDir::homeDirPath();
+
+ QHBox *hbox = new QHBox( this );
+ QLabel* lbl = new QLabel( hbox );
+ lbl->setText( tr("View as" ) );
+
+ m_views = new QComboBox( hbox, "View As" );
+ connect( m_views, SIGNAL(activated(int)),
+ this, SLOT(slotViewChanged(int)) );
+
+ m_view= new QIconView( this );
+ connect(m_view, SIGNAL(clicked(QIconViewItem*) ),
+ this, SLOT(slotClicked(QIconViewItem*)) );
+
+ m_view->setArrangement( QIconView::LeftToRight );
+ m_view->setItemTextPos( QIconView::Right );
+
+
+ int dw = QApplication::desktop()->width();
+ int viewerWidth = dw-style().scrollBarExtent().width();
+ m_view->setGridX( viewerWidth-2*m_view->spacing() );
+ m_view->setGridY( fontMetrics().height()*2+40 );
+ loadViews();
+ slotViewChanged( m_views->currentItem() );
+}
+
+PIconView::~PIconView() {
+}
+
+void PIconView::slotDirUp() {
+ QDir dir( m_path );
+ dir.cdUp();
+ slotChangeDir( dir.absPath() );
+
+}
+
+void PIconView::slotChangeDir(const QString& path) {
+ if ( !currentView() )
+ return;
+
+ PDirLister *lister = currentView()->dirLister();
+ if (!lister )
+ return;
+
+ lister->setStartPath( path );
+ m_path = lister->currentPath();
+
+ m_view->clear();
+ addFolders( lister->folders() );
+ addFiles( lister->files() );
+
+ // looks ugly
+ static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
+}
+
+QString PIconView::currentFileName(bool &isDir)const {
+ isDir = false;
+ QIconViewItem* _it = m_view->currentItem();
+ if ( !_it )
+ return QString::null;
+
+ IconViewItem* it = static_cast<IconViewItem*>( _it );
+ isDir = it->isDir();
+ return it->path();
+}
+
+void PIconView::slotTrash() {
+ bool isDir;
+ QString pa = currentFileName( isDir );
+ if ( isDir && pa.isEmpty() )
+ return;
+
+ if (!QPEMessageBox::confirmDelete( this,
+ tr("Delete Image" ),
+ tr("the Image %1" ).arg(pa)))
+ return
+
+
+ currentView()->dirLister()->deleteImage( pa );
+ delete m_view->currentItem();
+}
+void PIconView::loadViews() {
+ ViewMap::Iterator it;
+ ViewMap* map = viewMap();
+ for ( it = map->begin(); it != map->end(); ++it )
+ m_views->insertItem( QObject::tr(it.key() ) );
+}
+
+void PIconView::resetView() {
+ slotViewChanged(m_views->currentItem());
+}
+
+void PIconView::slotViewChanged( int i) {
+ if (!m_views->count() ) {
+ setCurrentView( 0l);
+ return;
+ }
+
+ PDirView* cur = currentView();
+ delete cur;
+ QString str = m_views->text(i);
+ cur = (*(*viewMap())[str])(*m_cfg);
+ setCurrentView( cur );
+
+ /* connect to the signals of the lister */
+ PDirLister* lis = cur->dirLister();
+ connect(lis, SIGNAL(sig_thumbInfo(const QString&, const QString& )),
+ this, SLOT( slotThumbInfo(const QString&, const QString&)));
+ connect(lis, SIGNAL( sig_thumbNail(const QString&, const QPixmap&)),
+ this, SLOT(slotThumbNail(const QString&, const QPixmap&)));
+ connect(lis, SIGNAL(sig_start()),
+ this, SLOT(slotStart()));
+ connect(lis, SIGNAL(sig_end()) ,
+ this, SLOT(slotEnd()) );
+
+
+ /* reload now */
+ QTimer::singleShot( 0, this, SLOT(slotReloadDir()));
+}
+
+
+void PIconView::slotReloadDir() {
+ slotChangeDir( m_path );
+}
+
+
+void PIconView::addFolders( const QStringList& lst) {
+ QStringList::ConstIterator it;
+
+ for(it=lst.begin(); it != lst.end(); ++it ) {
+ (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it), true );
+ }
+
+}
+
+void PIconView::addFiles( const QStringList& lst) {
+ QStringList::ConstIterator it;
+ for (it=lst.begin(); it!= lst.end(); ++it )
+ (void)new IconViewItem( m_view, m_path+"/"+(*it), (*it) );
+
+}
+
+void PIconView::slotClicked(QIconViewItem* _it) {
+ if(!_it )
+ return;
+
+ IconViewItem* it = static_cast<IconViewItem*>(_it);
+ if( it->isDir() )
+ slotChangeDir( it->path() );
+ else // view image
+ ;
+}
+
+void PIconView::slotThumbInfo( const QString& _path, const QString& str ) {
+ if ( g_stringInf.contains( _path ) ) {
+ IconViewItem* item = g_stringInf[_path];
+ item->setText( str );
+ item->repaint();
+ g_stringInf.remove( _path );
+ }
+}
+void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
+ if ( g_stringPix.contains( _path ) ) {
+ IconViewItem* item = g_stringPix[_path];
+ PPixmapCache::self()->insertImage( _path, pix, 64, 64 );
+ item->repaint();
+ g_stringPix.remove( _path );
+ }
+}
+
+
+void PIconView::slotRename() {
+
+}
+
+void PIconView::slotBeam() {
+ bool isDir;
+ QString pa = currentFileName( isDir );
+ if ( isDir && pa.isEmpty() )
+ return;
+
+ Ir* ir = new Ir( this );
+ connect( ir, SIGNAL(done(Ir*)),
+ this, SLOT(slotBeamDone(Ir*)));
+ ir->send(pa, tr( "Image" ) );
+
+}
+
+void PIconView::slotBeamDone( Ir* ir) {
+ delete ir;
+}
+
+void PIconView::slotStart() {
+ m_view->setUpdatesEnabled( false );
+}
+
+void PIconView::slotEnd() {
+ m_view->setUpdatesEnabled( true );
+}
diff --git a/noncore/graphics/opie-eye/gui/iconview.h b/noncore/graphics/opie-eye/gui/iconview.h
new file mode 100644
index 0000000..439833a
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/iconview.h
@@ -0,0 +1,59 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#ifndef PHUNK_ICON_VIEW_H
+#define PHUNK_ICON_VIEW_H
+
+#include <qvbox.h>
+
+#include <qpe/config.h>
+
+class QIconView;
+class QIconViewItem;
+class QComboBox;
+class PIconViewItem;
+class PDirLister;
+class Ir;
+class PIconView : public QVBox {
+ Q_OBJECT
+ friend class PIconViewItem;
+public:
+ PIconView( QWidget* wid, Config *cfg );
+ ~PIconView();
+ void resetView();
+
+private:
+ QString currentFileName(bool &isDir)const;
+ void loadViews();
+
+private slots:
+ void slotDirUp();
+ void slotChangeDir(const QString&);
+ void slotTrash();
+ void slotViewChanged( int );
+ void slotReloadDir();
+ void slotRename();
+ void slotBeam();
+ void slotBeamDone( Ir* );
+
+ void slotStart();
+ void slotEnd();
+
+/* for performance reasons make it inline in the future */
+ void addFolders( const QStringList& );
+ void addFiles( const QStringList& );
+ void slotClicked(QIconViewItem* );
+
+/**/
+ void slotThumbInfo(const QString&, const QString&);
+ void slotThumbNail(const QString&, const QPixmap&);
+private:
+ Config *m_cfg;
+ QComboBox* m_views;
+ QIconView* m_view;
+ QString m_path;
+};
+
+#endif
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
new file mode 100644
index 0000000..0a2fcab
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -0,0 +1,114 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qlayout.h>
+#include <qdialog.h>
+#include <qmap.h>
+
+#include <qpe/resource.h>
+#include <qpe/config.h>
+#include <qpe/ir.h>
+
+#include <opie/oapplicationfactory.h>
+#include <opie/otabwidget.h>
+
+#include <iface/ifaceinfo.h>
+#include <iface/dirview.h>
+
+#include "iconview.h"
+#include "filesystem.h"
+
+#include "mainwindow.h"
+
+OPIE_EXPORT_APP( OApplicationFactory<PMainWindow> )
+
+PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
+ : QMainWindow( wid, name, style ), m_cfg("phunkview")
+{
+ setCaption( QObject::tr("Opie Eye Caramba" ) );
+ m_cfg.setGroup("Zecke_view" );
+ /*
+ * Initialize ToolBar and IconView
+ * And Connect Them
+ */
+ QToolBar *bar = new QToolBar( this );
+ bar->setHorizontalStretchable( true );
+ setToolBarsMovable( false );
+
+ m_view = new PIconView( this, &m_cfg );
+ setCentralWidget( m_view );
+
+ QToolButton *btn = new QToolButton( bar );
+ btn->setIconSet( Resource::loadIconSet( "up" ) );
+ connect( btn, SIGNAL(clicked()),
+ m_view, SLOT(slotDirUp()) );
+
+ btn = new PFileSystem( bar );
+ connect( btn, SIGNAL( changeDir( const QString& ) ),
+ m_view, SLOT(slotChangeDir( const QString& ) ) );
+
+ btn = new QToolButton( bar );
+ btn->setIconSet( Resource::loadIconSet( "edit" ) );
+ connect( btn, SIGNAL(clicked()),
+ m_view, SLOT(slotRename()) );
+
+ if ( Ir::supported() ) {
+ btn = new QToolButton( bar );
+ btn->setIconSet( Resource::loadIconSet( "beam" ) );
+ connect( btn, SIGNAL(clicked()),
+ m_view, SLOT(slotBeam()) );
+ }
+
+ btn = new QToolButton( bar );
+ btn->setIconSet( Resource::loadIconSet( "trash" ) );
+ connect( btn, SIGNAL(clicked() ),
+ m_view, SLOT(slotTrash() ) );
+
+ btn = new QToolButton( bar );
+ btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
+ connect( btn, SIGNAL(clicked() ),
+ this, SLOT(slotConfig() ) );
+
+}
+
+PMainWindow::~PMainWindow() {
+}
+
+
+void PMainWindow::slotConfig() {
+ QDialog dlg(this, 0, true);
+ dlg.setCaption( tr("Phunk View - Config" ) );
+
+ QHBoxLayout *lay = new QHBoxLayout(&dlg);
+ OTabWidget *wid = new OTabWidget(&dlg );
+ lay->addWidget( wid );
+ ViewMap *vM = viewMap();
+ ViewMap::Iterator _it = vM->begin();
+ QMap<PDirView*, QWidget*> lst;
+
+ for( ; _it != vM->end(); ++_it ) {
+ PDirView *view = (_it.data())(m_cfg);
+ PInterfaceInfo *inf = view->interfaceInfo();
+ QWidget *_wid = inf->configWidget( m_cfg );
+ _wid->reparent(wid, QPoint() );
+ lst.insert( view, _wid );
+ wid->addTab( _wid, QString::null, inf->name() );
+ }
+
+ dlg.showMaximized();
+ bool act = ( dlg.exec() == QDialog::Accepted );
+
+ QMap<PDirView*, QWidget*>::Iterator it;
+ for ( it = lst.begin(); it != lst.end(); ++it ) {
+ if ( act )
+ it.key()->interfaceInfo()->writeConfig(it.data(), m_cfg);
+ delete it.key();
+ }
+
+ if ( act )
+ m_view->resetView();
+}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
new file mode 100644
index 0000000..408fe32
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -0,0 +1,29 @@
+/*
+ * GPLv2 zecke@handhelds.org
+ * No WArranty...
+ */
+
+#ifndef PHUNK_MAIN_WINDOW_H
+#define PHUNK_MAIN_WINDOW_H
+
+#include <qmainwindow.h>
+
+#include <qpe/config.h>
+
+class PIconView;
+class PMainWindow : public QMainWindow {
+ Q_OBJECT
+public:
+ static QString appName() { return QString::fromLatin1("opie-eye" ); }
+ PMainWindow(QWidget*, const char*, WFlags );
+ ~PMainWindow();
+
+private:
+ Config m_cfg;
+ PIconView* m_view;
+
+private slots:
+ void slotConfig();
+};
+
+#endif
diff --git a/noncore/graphics/opie-eye/gui/viewmap.cpp b/noncore/graphics/opie-eye/gui/viewmap.cpp
new file mode 100644
index 0000000..2dffb38
--- a/dev/null
+++ b/noncore/graphics/opie-eye/gui/viewmap.cpp
@@ -0,0 +1,9 @@
+#include <iface/dirview.h>
+
+namespace {
+ ViewMap m_view;
+}
+
+ViewMap* viewMap() {
+ return m_view;
+}