summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/iconview.cpp11
-rw-r--r--noncore/graphics/opie-eye/gui/imageview.cpp2
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp43
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h4
4 files changed, 45 insertions, 15 deletions
diff --git a/noncore/graphics/opie-eye/gui/iconview.cpp b/noncore/graphics/opie-eye/gui/iconview.cpp
index f6e1816..7231bfb 100644
--- a/noncore/graphics/opie-eye/gui/iconview.cpp
+++ b/noncore/graphics/opie-eye/gui/iconview.cpp
@@ -234,111 +234,109 @@ void PIconView::slotChangeDir(const QString& path) {
*/
lister->setStartPath( path );
m_path = lister->currentPath();
m_view->viewport()->setUpdatesEnabled( false );
m_view->clear();
/*
* add files and folders
*/
addFolders( lister->folders() );
addFiles( lister->files() );
m_view->viewport()->setUpdatesEnabled( true );
// Also invalidate the cache. We can't cancel the operations anyway
g_stringPix.clear();
g_stringInf.clear();
// looks ugly
static_cast<QMainWindow*>(parent())->setCaption( QObject::tr("%1 - O View", "Name of the dir").arg( m_path ) );
}
/**
* get the current file name
* @param isDir see if this is a dir or real file
*/
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();
}
QString PIconView::nextFileName(bool &isDir)const
{
isDir = false;
QIconViewItem* _it1 = m_view->currentItem();
if ( !_it1 )
return QString::null;
QIconViewItem* _it = _it1->nextItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
- m_view->setCurrentItem(_it);
return it->path();
}
QString PIconView::prevFileName(bool &isDir)const{
isDir = false;
QIconViewItem* _it = m_view->currentItem();
if ( !_it )
return QString::null;
_it = _it->prevItem();
if ( !_it )
return QString::null;
IconViewItem* it = static_cast<IconViewItem*>( _it );
isDir = it->isDir();
- m_view->setCurrentItem(_it);
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();
}
/*
* see what views are available
*/
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());
}
/*
*swicth view reloadDir and connect signals
*/
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 );
@@ -434,108 +432,111 @@ void PIconView::slotThumbNail(const QString& _path, const QPixmap &pix) {
}
/*
* FIXME rename
*/
void PIconView::slotRename() {
}
/*
* BEAM the current file
*/
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" ) );
}
/*
* BEAM done clean up
*/
void PIconView::slotBeamDone( Ir* ir) {
delete ir;
}
void PIconView::slotStart() {
m_view->viewport()->setUpdatesEnabled( false );
}
void PIconView::slotEnd() {
if ( m_updatet )
m_view->arrangeItemsInGrid( );
m_view->viewport()->setUpdatesEnabled( true );
m_updatet = false;
}
void PIconView::slotShowNext()
{
bool isDir = false;
QString name = nextFileName(isDir);
- if (isDir) return;
if (name.isEmpty()) return;
- odebug << "Show next: " << name << oendl;
+ if (isDir) return;
+ /* if we got a name we have a next item */
+ m_view->setCurrentItem(m_view->currentItem()->nextItem());
slotShowImage(name);
}
void PIconView::slotShowPrev()
{
bool isDir = false;
QString name = prevFileName(isDir);
- if (isDir) return;
if (name.isEmpty()) return;
+ if (isDir) return;
+ /* if we got a name we have a prev item */
+ m_view->setCurrentItem(m_view->currentItem()->prevItem());
slotShowImage(name);
}
void PIconView::slotShowImage()
{
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) return;
slotShowImage( name );
}
void PIconView::slotShowImage( const QString& name) {
emit sig_display( name );
}
void PIconView::slotImageInfo() {
bool isDir = false;
QString name = currentFileName(isDir);
if (isDir) return;
slotImageInfo( name );
}
void PIconView::slotImageInfo( const QString& name) {
emit sig_showInfo( name );
}
void PIconView::slotChangeMode( int mode ) {
if ( mode >= 1 && mode <= 3 )
m_mode = mode;
QIconView::ItemTextPos pos;
switch( m_mode ) {
case 2:
pos = QIconView::Bottom;
break;
case 3:
case 1:
default:
pos = QIconView::Right;
break;
}
m_view->setItemTextPos( pos );
calculateGrid();
slotReloadDir();
}
diff --git a/noncore/graphics/opie-eye/gui/imageview.cpp b/noncore/graphics/opie-eye/gui/imageview.cpp
index aa2b9bc..fbc4494 100644
--- a/noncore/graphics/opie-eye/gui/imageview.cpp
+++ b/noncore/graphics/opie-eye/gui/imageview.cpp
@@ -1,85 +1,87 @@
#include "imageview.h"
#include <opie2/odebug.h>
#include <opie2/oconfig.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
using namespace Opie::Core;
ImageView::ImageView(Opie::Core::OConfig *cfg, QWidget* parent, const char* name, WFlags fl )
: Opie::MM::OImageScrollView(parent,name,fl)
{
m_viewManager = 0;
m_cfg = cfg;
initKeys();
}
ImageView::~ImageView()
{
if (m_viewManager) {
delete m_viewManager;
}
}
Opie::Core::OKeyConfigManager* ImageView::manager()
{
if (!m_viewManager) {
initKeys();
}
return m_viewManager;
}
void ImageView::initKeys()
{
odebug << "init imageview keys" << oendl;
if (!m_cfg) {
m_cfg = new Opie::Core::OConfig("phunkview");
m_cfg->setGroup("image_view_keys" );
}
Opie::Core::OKeyPair::List lst;
lst.append( Opie::Core::OKeyPair::upArrowKey() );
lst.append( Opie::Core::OKeyPair::downArrowKey() );
lst.append( Opie::Core::OKeyPair::leftArrowKey() );
lst.append( Opie::Core::OKeyPair::rightArrowKey() );
+ lst.append( Opie::Core::OKeyPair(Qt::Key_N,0));
+ lst.append( Opie::Core::OKeyPair(Qt::Key_P,0));
m_viewManager = new Opie::Core::OKeyConfigManager(m_cfg, "image_view_keys",
lst, false,this, "image_view_keys" );
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("View Image Info"), "imageviewinfo",
Resource::loadPixmap("1to1"), ViewInfo,
Opie::Core::OKeyPair(Qt::Key_I,Qt::ShiftButton),
this, SLOT(slotShowImageInfo())));
#if 0
m_viewManager->addKeyConfig( Opie::Core::OKeyConfigItem(tr("Next image"), "nextimage",
Resource::loadPixmap("next"), ViewInfo,
Opie::Core::OKeyPair(Qt::Key_N,0),
this, SLOT(slotDispNext())));
#endif
m_viewManager->handleWidget( this );
m_viewManager->load();
}
void ImageView::keyReleaseEvent(QKeyEvent * e)
{
if (!e || e->state()!=0) {
return;
}
if (e->key()==Qt::Key_N) slotDispNext();
if (e->key()==Qt::Key_P) slotDispPrev();
}
void ImageView::slotDispNext()
{
emit dispNext();
}
void ImageView::slotDispPrev()
{
emit dispPrev();
}
void ImageView::slotShowImageInfo()
{
emit dispImageInfo(m_lastName);
}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 57be247..6f3f255 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -19,132 +19,144 @@
#include <opie2/otabwidget.h>
#include <opie2/okeyconfigwidget.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/ir.h>
#include <qpe/applnk.h>
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qlayout.h>
#include <qdialog.h>
#include <qmap.h>
#include <qtimer.h>
OPIE_EXPORT_APP_V2( Opie::Core::OApplicationFactory<PMainWindow>,"Opie Eye" )
PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
: QMainWindow( wid, name, style ), m_info( 0 ), m_disp( 0 )
{
setCaption( QObject::tr("Opie Eye Caramba" ) );
m_cfg = new Opie::Core::OConfig("phunkview");
m_cfg->setGroup("Zecke_view" );
// qDebug( "Process-wide OApplication object @ %0x", oApp );
/*
* Initialize ToolBar and IconView
* And Connect Them
*/
QToolBar *bar = new QToolBar( this );
bar->setHorizontalStretchable( true );
setToolBarsMovable( false );
m_stack = new Opie::Ui::OWidgetStack( this );
setCentralWidget( m_stack );
m_view = new PIconView( m_stack, m_cfg );
m_stack->addWidget( m_view, IconView );
m_stack->raiseWidget( IconView );
connect(m_view, SIGNAL(sig_display(const QString&)),
this, SLOT(slotDisplay(const QString&)));
connect(m_view, SIGNAL(sig_showInfo(const QString&)),
this, SLOT(slotShowInfo(const QString&)) );
m_stack->forceMode(Opie::Ui::OWidgetStack::NoForce);
- QToolButton *btn = new QToolButton( bar );
- btn->setIconSet( Resource::loadIconSet( "up" ) );
- connect( btn, SIGNAL(clicked()),
+ upButton = new QToolButton( bar );
+ upButton->setIconSet( Resource::loadIconSet( "up" ) );
+ connect( upButton, SIGNAL(clicked()),
m_view, SLOT(slotDirUp()) );
- btn = new PFileSystem( bar );
- connect( btn, SIGNAL( changeDir( const QString& ) ),
+ fsButton = new PFileSystem( bar );
+ connect( fsButton, SIGNAL( changeDir( const QString& ) ),
m_view, SLOT(slotChangeDir( const QString& ) ) );
- btn = new QToolButton( bar );
+ QToolButton*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 ViewModeButton( bar );
- connect( btn, SIGNAL(changeMode(int)),
+ viewModeButton = new ViewModeButton( bar );
+ connect( viewModeButton, SIGNAL(changeMode(int)),
m_view, SLOT(slotChangeMode(int)));
btn = new QToolButton( bar );
btn->setIconSet( Resource::loadIconSet( "SettingsIcon" ) );
connect( btn, SIGNAL(clicked() ),
this, SLOT(slotConfig() ) );
+
+
+ prevButton = new QToolButton(bar);
+ prevButton->setIconSet( Resource::loadIconSet( "back" ) );
+ connect(prevButton,SIGNAL(clicked()),m_view,SLOT(slotShowPrev()));
+ prevButton->hide();
+
+ nextButton = new QToolButton(bar);
+ nextButton->setIconSet( Resource::loadIconSet( "forward" ) );
+ connect(nextButton,SIGNAL(clicked()),m_view,SLOT(slotShowNext()));
+ nextButton->hide();
+
rotateButton = new QToolButton(bar);
rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
rotateButton->setToggleButton(true);
odebug << "Mode = " << m_stack->mode() << oendl;
if (m_stack->mode() == Opie::Ui::OWidgetStack::SmallScreen) {
rotateButton->setOn(true);
autoRotate = true;
} else {
rotateButton->setOn(false);
autoRotate = false;
}
connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
btn = new QToolButton(bar);
btn->setIconSet( Resource::loadIconSet( "1to1" ) );
btn->setToggleButton(true);
btn->setOn(false);
connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
autoScale = true;
btn = new QToolButton(bar);
btn->setIconSet( Resource::loadIconSet( "mag" ) );
btn->setToggleButton(true);
btn->setOn(true);
connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotZoomerToggled(bool)));
zoomerOn = true;
}
PMainWindow::~PMainWindow() {
odebug << "Shutting down" << oendl;
}
void PMainWindow::slotZoomerToggled(bool how)
{
zoomerOn = how;
if (m_disp) {
m_disp->setShowZoomer(zoomerOn);
}
}
void PMainWindow::slotRotateToggled(bool how)
{
autoRotate = how;
if (m_disp) {
m_disp->setAutoRotate(how);
}
@@ -239,91 +251,106 @@ void PMainWindow::slotConfig() {
* we will make the other delete on exit
*/
template<class T>
void PMainWindow::initT( const char* name, T** ptr, int id) {
if ( *ptr ) {
(*ptr)->disconnect(this, SLOT(slotReturn()));
(*ptr)->setDestructiveClose();
m_stack->removeWidget( *ptr );
}
*ptr = new T(m_cfg, m_stack, name );
m_stack->addWidget( *ptr, id );
connect(*ptr, SIGNAL(sig_return()),
this,SLOT(slotReturn()));
}
void PMainWindow::initInfo() {
initT<imageinfo>( "Image Info", &m_info, ImageInfo );
connect(m_info,SIGNAL(dispImage(const QString&)),this,SLOT(slotDisplay(const QString&)));
}
void PMainWindow::initDisp() {
initT<ImageView>( "Image ScrollView", &m_disp, ImageDisplay );
if (m_disp) {
if (m_stack->mode() != Opie::Ui::OWidgetStack::SmallScreen) {
m_disp->setMinimumSize(QApplication::desktop()->size()/2);
}
m_disp->setAutoScale(autoScale);
m_disp->setAutoRotate(autoRotate);
m_disp->setShowZoomer(zoomerOn);
connect(m_disp,SIGNAL(dispImageInfo(const QString&)),this,SLOT(slotShowInfo(const QString&)));
connect(m_disp,SIGNAL(dispNext()),m_view,SLOT(slotShowNext()));
connect(m_disp,SIGNAL(dispPrev()),m_view,SLOT(slotShowPrev()));
}
}
/**
* With big Screen the plan could be to 'detach' the image
* window if visible and to create a ne wone
* init* already supports it but I make no use of it for
* now. We set filename and raise
*
* ### FIXME and talk to alwin
*/
void PMainWindow::slotShowInfo( const QString& inf ) {
if ( !m_info ) {
initInfo();
}
m_info->setPath( inf );
+ prevButton->hide();
+ nextButton->hide();
+ upButton->hide();
+ fsButton->hide();
+ viewModeButton->hide();
m_stack->raiseWidget( ImageInfo );
}
void PMainWindow::slotDisplay( const QString& inf ) {
if ( !m_disp ) {
initDisp();
}
m_disp->setImage( inf );
+ prevButton->show();
+ nextButton->show();
+ upButton->hide();
+ fsButton->hide();
+ viewModeButton->hide();
m_stack->raiseWidget( ImageDisplay );
}
void PMainWindow::slotReturn() {
raiseIconView();
}
void PMainWindow::closeEvent( QCloseEvent* ev ) {
/*
* return from view
* or properly quit
*/
if ( m_stack->visibleWidget() == m_info ||
m_stack->visibleWidget() == m_disp ) {
raiseIconView();
ev->ignore();
return;
}
ev->accept();
QTimer::singleShot(0, qApp, SLOT(closeAllWindows()));
}
void PMainWindow::raiseIconView() {
+ prevButton->hide();
+ nextButton->hide();
+ upButton->show();
+ fsButton->show();
+ viewModeButton->show();
m_stack->raiseWidget( IconView );
}
void PMainWindow::setDocument( const QString& showImg ) {
QString file = showImg;
DocLnk lnk(showImg);
if (lnk.isValid() )
file = lnk.file();
slotDisplay( file );
}
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index adb5dc2..1967ef7 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -18,56 +18,56 @@ namespace Ui{
}
namespace Core{
class OKeyConfigManager;
}
}
class ImageView;
class PIconView;
class imageinfo;
class PMainWindow : public QMainWindow {
Q_OBJECT
enum Views { IconView, ImageInfo, ImageDisplay };
public:
static QString appName() { return QString::fromLatin1("opie-eye" ); }
PMainWindow(QWidget*, const char*, WFlags );
~PMainWindow();
signals:
void configChanged();
public slots:
void slotShowInfo( const QString& inf );
void slotDisplay( const QString& inf );
void slotReturn();
void slotRotateToggled(bool);
void slotScaleToggled(bool);
void slotZoomerToggled(bool);
void setDocument( const QString& );
protected:
void raiseIconView();
void closeEvent( QCloseEvent* );
private:
template<class T> void initT( const char* name, T**, int );
void initInfo();
void initDisp();
private:
Opie::Core::OConfig *m_cfg;
Opie::Ui::OWidgetStack *m_stack;
PIconView* m_view;
imageinfo *m_info;
ImageView *m_disp;
bool autoRotate;
bool autoScale;
bool zoomerOn;
- QToolButton*rotateButton;
-
+ QToolButton*rotateButton,*upButton,*fsButton,*viewModeButton;
+ QToolButton*nextButton,*prevButton;
private slots:
void slotConfig();
};
#endif