summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/showimg/ImageFileSelector.cpp72
-rw-r--r--noncore/multimedia/showimg/ImageFileSelector.h65
-rw-r--r--noncore/multimedia/showimg/settingsdialog.cpp88
-rw-r--r--noncore/multimedia/showimg/settingsdialog.h49
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.cpp106
-rw-r--r--noncore/multimedia/showimg/settingsdialogbase.h45
-rw-r--r--noncore/multimedia/showimg/showimg.cpp279
-rw-r--r--noncore/multimedia/showimg/showimg.h104
-rw-r--r--noncore/multimedia/showimg/showimg.pro34
9 files changed, 658 insertions, 184 deletions
diff --git a/noncore/multimedia/showimg/ImageFileSelector.cpp b/noncore/multimedia/showimg/ImageFileSelector.cpp
index 347300f..7872c09 100644
--- a/noncore/multimedia/showimg/ImageFileSelector.cpp
+++ b/noncore/multimedia/showimg/ImageFileSelector.cpp
@@ -20,12 +20,10 @@
#include "ImageFileSelector.h"
-
-
-
-ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w) : QWidget( parent ),fl(f)
+ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,int w)
+ : QWidget( parent ),fl(f)
{
setBackgroundMode(NoBackground);
if ( w!=-1 )
setMinimumSize(w,p.height()+24);
@@ -37,9 +35,9 @@ ThumbWidget::ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent,
description->setGeometry(0,height()-24,width(),24);
pixmap=p;
}
-void ThumbWidget::resizeEvent(QResizeEvent *e)
+void ThumbWidget::resizeEvent(QResizeEvent *)
{
description->setGeometry(0,height()-24,width(),24);
}
@@ -52,17 +50,17 @@ void ThumbWidget::paintEvent( QPaintEvent *e )
painter.drawPixmap((width() - pixmap.width()) / 2,0, pixmap);
}
-void ThumbWidget::mouseReleaseEvent(QMouseEvent* event)
+void ThumbWidget::mouseReleaseEvent(QMouseEvent* )
{
emit clicked(fl);
}
-
-ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f): QListViewItem( parent ), fl( f )
+ImageFileSelectorItem::ImageFileSelectorItem( QListView *parent, const DocLnk &f)
+ : QListViewItem( parent ), fl( f )
{
setText( 0, f.name() );
QFileInfo fi(f.file());
setText( 1, (fi.extension()).upper() );
@@ -77,9 +75,10 @@ ImageFileSelectorItem::~ImageFileSelectorItem()
}
-ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char *name ):QWidgetStack(parent)
+ImageFileSelector::ImageFileSelector( CURRENT_VIEW scv,QWidget *parent,const char * )
+ : QWidgetStack(parent)
{
detailed=new QListView(this);
@@ -164,10 +163,11 @@ void ImageFileSelector::updateSizes()
background->setMinimumWidth(thumb->visibleWidth());
thumb->updateScrollBars();
}
-void ImageFileSelector::reread(bool purgeCache)
+void ImageFileSelector::reread(bool)
{
+// qDebug("reread");
ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->selectedItem();
QString oldFile;
if ( item )
oldFile = item->file().file();
@@ -176,70 +176,64 @@ void ImageFileSelector::reread(bool purgeCache)
DocLnkSet files;
Global::findDocuments(&files, "image/*");
count = files.children().count();
QListIterator<DocLnk> dit( files.children() );
- int y=0;
- int x=4;
- int totalHeight=4;
+// int y=0;
+// int x=4;
+// int totalHeight=4;
ThumbWidget *l=0;
int width=80;
gl->expand(dit.count()/2,2);
-
int i,j;
-
i=j=0;
-
detailed->setUpdatesEnabled(false);
thumb->setUpdatesEnabled(false);
- for ( ; dit.current(); ++dit )
- {
+
+ for ( ; dit.current(); ++dit ) {
item = new ImageFileSelectorItem( detailed, **dit );
if ( item->file().file() == oldFile )
detailed->setCurrentItem( item );
}
QListViewItemIterator it( detailed );
ImageFileSelectorItem *ii;
- // iterate through all items of the listview
- for ( ; it.current(); ++it )
- {
+ // iterate through all items of the listview
+ for ( ; it.current(); ++it ) {
ii=(ImageFileSelectorItem *)it.current();
- QImage img(ii->file().file());
- img=img.smoothScale(64,64);
- QPixmap pix;
- pix.convertFromImage(img);
- l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width);
- l->setBackgroundColor(colorGroup().base());
- gl->addWidget(l,j,i);
- i++;
- if ( i==2 )
- {
- i=0;
- j++;
+ QImage img( ii->file().file() );
+ if( !img.isNull()) {
+ img=img.smoothScale(64,64);
+ QPixmap pix;
+ pix.convertFromImage(img);
+ l=new ThumbWidget(pix,ii->file().name(),ii->file(),background,width);
+ l->setBackgroundColor(colorGroup().base());
+ gl->addWidget(l,j,i);
+ i++;
+ if ( i==2 ) {
+ i=0;
+ j++;
+ }
+ tList.append(l);
+ connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &)));
}
- tList.append(l);
- connect(l,SIGNAL(clicked(const DocLnk &)),this,SLOT(thumbClicked(const DocLnk &)));
-
}
-
-
if ( !detailed->selectedItem() )
detailed->setCurrentItem( detailed->firstChild() );
detailed->setUpdatesEnabled(true);
thumb->setUpdatesEnabled(true);
detailed->update();
thumb->update();
-
}
int ImageFileSelector::fileCount()
{
return count;
}
const DocLnk * ImageFileSelector::selected()
{
+ qDebug("image selected");
ImageFileSelectorItem *item = (ImageFileSelectorItem *) detailed->selectedItem();
if ( item )
return new DocLnk( item->file() );
return 0;
diff --git a/noncore/multimedia/showimg/ImageFileSelector.h b/noncore/multimedia/showimg/ImageFileSelector.h
index 2c346c4..798ebcc 100644
--- a/noncore/multimedia/showimg/ImageFileSelector.h
+++ b/noncore/multimedia/showimg/ImageFileSelector.h
@@ -11,21 +11,18 @@
#include "qpe/applnk.h"
class QScrollView;
class QLabel;
+//class QValueList;
class ThumbWidget : public QWidget
{
Q_OBJECT
- public:
+public:
ThumbWidget(QPixmap p,QString text,const DocLnk& f,QWidget *parent=0,int width=-1);
- ~ThumbWidget()
- {
-
- }
+ ~ThumbWidget() { }
- DocLnk file() const
- {
+ DocLnk file() const {
return fl;
}
@@ -44,16 +41,30 @@ private:
DocLnk fl;
};
+
+
+class ImageFileSelectorItem : public QListViewItem
+{
+public:
+ ImageFileSelectorItem( QListView *parent, const DocLnk& f );
+ ~ImageFileSelectorItem();
+
+ DocLnk file() const {
+ return fl;
+ }
+private:
+ DocLnk fl;
+};
+
class ImageFileSelector : public QWidgetStack
{
Q_OBJECT
- public:
+public:
- enum CURRENT_VIEW
- {
+ enum CURRENT_VIEW {
THUMBNAIL,
DETAILED,
UNKNOWN
};
@@ -67,13 +78,22 @@ class ImageFileSelector : public QWidgetStack
const DocLnk *selected();
void setView(CURRENT_VIEW v);
- CURRENT_VIEW view()
- {
+ CURRENT_VIEW view() {
return cView;
}
+ QValueList<DocLnk> fileList() const {
+ ((ImageFileSelector*)this)->fileCount(); // ensure all loaded when this is extended
+ QValueList<DocLnk> list;
+ ImageFileSelectorItem *item = (ImageFileSelectorItem *)detailed->firstChild();
+ while (item) {
+ list.append(item->file());
+ item = (ImageFileSelectorItem *)item->nextSibling();
+ }
+ return list;
+ }
public slots:
void switchView();
@@ -108,28 +128,7 @@ private:
QWidget *background;
QGridLayout *gl;
};
-
-
-class ImageFileSelectorItem : public QListViewItem
-{
-public:
- ImageFileSelectorItem( QListView *parent, const DocLnk& f );
- ~ImageFileSelectorItem();
-
- DocLnk file() const
- {
- return fl;
- }
-
-
-private:
- DocLnk fl;
-};
-
-
-
-
#endif // IMAGEFILE_SELECTOR_H
diff --git a/noncore/multimedia/showimg/settingsdialog.cpp b/noncore/multimedia/showimg/settingsdialog.cpp
new file mode 100644
index 0000000..55d555a
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialog.cpp
@@ -0,0 +1,88 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include "settingsdialog.h"
+#include <qslider.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <qradiobutton.h>
+#include <qbuttongroup.h>
+
+SettingsDialog::SettingsDialog( QWidget *parent, const char *name, bool modal, WFlags f )
+ : SettingsDialogBase( parent, name, modal, f )
+{
+ connect( delaySlider, SIGNAL(valueChanged(int)), this, SLOT(delayChanged(int)) );
+}
+
+void SettingsDialog::setDelay( int d )
+{
+ delaySlider->setValue( d );
+ delayChanged( d );
+}
+
+int SettingsDialog::delay() const
+{
+ return delaySlider->value();
+}
+
+void SettingsDialog::setRepeat( bool r )
+{
+ repeatCheck->setChecked( r );
+}
+
+bool SettingsDialog::repeat() const
+{
+ return repeatCheck->isChecked();
+}
+
+void SettingsDialog::delayChanged( int d )
+{
+ delayText->setText( QString::number( d ) + " s" );
+}
+
+void SettingsDialog::setReverse(bool r)
+{
+ reverseCheck->setChecked(r);
+}
+
+bool SettingsDialog::reverse() const
+{
+ return reverseCheck->isChecked();
+}
+
+void SettingsDialog::setRotate(bool r)
+{
+ rotateCheck->setChecked(r);
+}
+
+bool SettingsDialog::rotate() const
+{
+ return rotateCheck->isChecked();
+}
+
+void SettingsDialog::setFastLoad(bool f)
+{
+ fastLoadCheck->setChecked(f);
+}
+
+bool SettingsDialog::fastLoad() const
+{
+ return fastLoadCheck->isChecked();
+}
diff --git a/noncore/multimedia/showimg/settingsdialog.h b/noncore/multimedia/showimg/settingsdialog.h
new file mode 100644
index 0000000..0f47990
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialog.h
@@ -0,0 +1,49 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#ifndef SETTINGSDIALOG_H
+#define SETTINGSDIALOG_H
+
+#include "settingsdialogbase.h"
+
+class SettingsDialog : public SettingsDialogBase
+{
+ Q_OBJECT
+public:
+
+ SettingsDialog( QWidget * parent=0, const char * name=0, bool modal=FALSE, WFlags f=0 );
+
+ void setDelay( int d );
+ int delay() const;
+ void setRepeat( bool r );
+ bool repeat() const;
+ void setReverse( bool r );
+ bool reverse() const;
+ void setRotate(bool r);
+ bool rotate() const;
+ void setFastLoad(bool f);
+ bool fastLoad() const;
+
+private slots:
+ void delayChanged( int );
+};
+
+
+#endif
diff --git a/noncore/multimedia/showimg/settingsdialogbase.cpp b/noncore/multimedia/showimg/settingsdialogbase.cpp
new file mode 100644
index 0000000..e0c5bb0
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialogbase.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'settingsdialogbase.ui'
+**
+** Created: Sun Nov 3 07:29:03 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#include "settingsdialogbase.h"
+
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qpushbutton.h>
+#include <qslider.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a SettingsDialogBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+SettingsDialogBase::SettingsDialogBase( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "SettingsDialogBase" );
+ resize( 246, 201 );
+ setCaption( tr( "Preferences" ) );
+ SettingsDialogBaseLayout = new QVBoxLayout( this );
+ SettingsDialogBaseLayout->setSpacing( 6 );
+ SettingsDialogBaseLayout->setMargin( 6 );
+
+ GroupBox1 = new QGroupBox( this, "GroupBox1" );
+ GroupBox1->setTitle( tr( "Slide Show" ) );
+ GroupBox1->setColumnLayout(0, Qt::Vertical );
+ GroupBox1->layout()->setSpacing( 0 );
+ GroupBox1->layout()->setMargin( 0 );
+ GroupBox1Layout = new QVBoxLayout( GroupBox1->layout() );
+ GroupBox1Layout->setAlignment( Qt::AlignTop );
+ GroupBox1Layout->setSpacing( 6 );
+ GroupBox1Layout->setMargin( 11 );
+
+ Layout3 = new QGridLayout;
+ Layout3->setSpacing( 6 );
+ Layout3->setMargin( 0 );
+
+ TextLabel1 = new QLabel( GroupBox1, "TextLabel1" );
+ TextLabel1->setText( tr( "Delay between pictures" ) );
+
+ Layout3->addMultiCellWidget( TextLabel1, 0, 0, 0, 1 );
+
+ delaySlider = new QSlider( GroupBox1, "delaySlider" );
+ delaySlider->setMinValue( 2 );
+ delaySlider->setMaxValue( 60 );
+ delaySlider->setLineStep( 2 );
+ delaySlider->setOrientation( QSlider::Horizontal );
+ delaySlider->setTickmarks( QSlider::Right );
+ delaySlider->setTickInterval( 10);
+
+ Layout3->addWidget( delaySlider, 1, 0 );
+
+ delayText = new QLabel( GroupBox1, "delayText" );
+ delayText->setMinimumSize( QSize( 25, 0 ) );
+ delayText->setText( tr( "s" ) );
+ delayText->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+
+ Layout3->addWidget( delayText, 1, 1 );
+ GroupBox1Layout->addLayout( Layout3 );
+
+ repeatCheck = new QCheckBox( GroupBox1, "repeatCheck" );
+ repeatCheck->setText( tr( "Repeat slideshow" ) );
+ GroupBox1Layout->addWidget( repeatCheck );
+
+ reverseCheck = new QCheckBox( GroupBox1, "reverseCheck" );
+ reverseCheck->setText( tr( "Show pictures in reverse" ) );
+ GroupBox1Layout->addWidget( reverseCheck );
+ SettingsDialogBaseLayout->addWidget( GroupBox1 );
+
+ rotateCheck = new QCheckBox( this, "rotateCheck" );
+ rotateCheck->setText( tr( "Load pictures rotated 90 degrees" ) );
+ SettingsDialogBaseLayout->addWidget( rotateCheck );
+
+ fastLoadCheck = new QCheckBox( this, "fastLoadCheck" );
+ fastLoadCheck->setText( tr( "Fast load pictures" ) );
+ SettingsDialogBaseLayout->addWidget( fastLoadCheck );
+ fastLoadCheck->hide(); //FIXME
+// QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding );
+// layout->addItem( spacer, 10, 0 );
+
+
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+SettingsDialogBase::~SettingsDialogBase()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
diff --git a/noncore/multimedia/showimg/settingsdialogbase.h b/noncore/multimedia/showimg/settingsdialogbase.h
new file mode 100644
index 0000000..9594ec6
--- a/dev/null
+++ b/noncore/multimedia/showimg/settingsdialogbase.h
@@ -0,0 +1,45 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'settingsdialogbase.ui'
+**
+** Created: Sun Nov 3 07:29:03 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#ifndef SETTINGSDIALOGBASE_H
+#define SETTINGSDIALOGBASE_H
+
+#include <qvariant.h>
+#include <qdialog.h>
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QCheckBox;
+class QGroupBox;
+class QLabel;
+class QSlider;
+
+class SettingsDialogBase : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SettingsDialogBase( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~SettingsDialogBase();
+
+ QGroupBox* GroupBox1;
+ QLabel* TextLabel1;
+ QSlider* delaySlider;
+ QLabel* delayText;
+ QCheckBox* repeatCheck;
+ QCheckBox* reverseCheck;
+ QCheckBox* rotateCheck;
+ QCheckBox* fastLoadCheck;
+
+protected:
+ QVBoxLayout* SettingsDialogBaseLayout;
+ QVBoxLayout* GroupBox1Layout;
+ QGridLayout* Layout3;
+};
+
+#endif // SETTINGSDIALOGBASE_H
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index d7d53ec..0fbffe7 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -23,9 +23,14 @@
//
#include "showimg.h"
#include "ImageFileSelector.h"
+#include "settingsdialog.h"
+
+#include <opie/ofiledialog.h>
+
+#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/applnk.h>
@@ -48,14 +53,14 @@
#include <qspinbox.h>
-ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent):QDialog(parent,0,true)
+ControlsDialog::ControlsDialog(const QString &caption,QImage image,int *brightness,QWidget *parent)
+ : QDialog(parent,0,true)
{
setCaption(caption);
- if ( parent )
- {
+ if ( parent ) {
setPalette(parent->palette());
}
b=brightness;
@@ -100,11 +105,12 @@ void ControlsDialog::accept()
*b=spb->value();
done(1);
}
+//===========================================================================
-
-InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent):QDialog(parent,0,true)
+InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *parent)
+ : QDialog(parent,0,true)
{
setCaption(caption);
if ( parent )
@@ -148,8 +154,10 @@ void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWi
dlg->exec();
delete dlg;
}
+//===========================================================================
+
ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
{
vb = new QVBoxLayout( this );
@@ -228,28 +236,35 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
fileMenuFile = new QPopupMenu(this);
//menuBarmenubarFile->insertItem( tr("File"), fileMenu );
- fileMenuFile->insertItem(tr("Open"), this, SLOT(openFile()), 0);
+ fileMenuFile->insertItem(tr("Open"),
+ this, SLOT(openFile()), 0);
viewMenuFile = new QPopupMenu( this );
//menubarFile->insertItem( tr("View"), viewMenu );
- viewMenuFile->insertItem( tr("Thumbnail View"), this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS );
+ viewMenuFile->insertItem( tr("Thumbnail View"),
+ this, SLOT(switchThumbView()), 0, SHOW_THUMBNAILS );
viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
optionsMenuFile = new QPopupMenu( this);
//menubarFile->insertItem( tr("Options"),optionsMenu );
- optionsMenuFile->insertItem( tr("Slideshow") );
- optionsMenuFile->insertSeparator();
- optionsMenuFile->insertItem( tr("Preferences.."));
- optionsMenuFile->insertItem( tr("Help"));
-
+ slideAction = new QAction( tr( "Slide show" ), Resource::loadIconSet( "slideshow" ),
+ QString::null, 0, this, 0 );
+ slideAction->setToggleAction( TRUE );
+ connect( slideAction, SIGNAL( toggled(bool) ), this, SLOT( slideShow(bool) ) );
+ slideAction->addTo( optionsMenuFile);
+// slideAction->addTo( toolBar );
+// optionsMenuFile->insertItem( tr("Slideshow") );
+ optionsMenuFile->insertSeparator();
+ optionsMenuFile->insertItem( tr("Preferences.."), this, SLOT(settings()), 0);
+// optionsMenuFile->insertItem( tr("Help"), this, SLOT(help()), 0);
QStrList fmt = QImage::outputFormats();
@@ -290,9 +305,13 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
//fileSelector = new ImageFileSelector("image/*", stack, "fs");
//fileSelector->setNewVisible(FALSE);
//fileSelector->setCloseVisible(FALSE);
connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( closeFileSelector() ) );
- connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( openFile( const DocLnk & ) ) );
+ connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ),
+ this, SLOT( openFile( const DocLnk & ) ) );
+
+ imageList = fileSelector->fileList();
+ slideAction->setEnabled( imageList.count() != 0);
iconToolBar = new QPEToolBar(this);
QAction *a;
@@ -335,13 +354,33 @@ ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
sss->setOn(isSized);
viewMenuView->insertSeparator();
- a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
+ a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ),
+ QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) );
a->addTo( iconToolBar );
a->addTo( viewMenuView);
+ a = new QAction( tr( "Stop Slideshow" ), Resource::loadPixmap( "quit_icon" ),
+ QString::null, 0, this, 0 );
+ connect( a, SIGNAL( activated() ), this, SLOT( stopSlideShow() ) );
+ a->addTo( iconToolBar );
+ a->addTo( viewMenuView);
+
+
+ Config config( "ImageViewer" );
+ config.setGroup( "SlideShow" );
+ slideDelay = config.readNumEntry( "Delay", 2);
+ slideRepeat = config.readBoolEntry( "Repeat", FALSE );
+ slideReverse = config.readBoolEntry("Reverse", FALSE);
+
+ config.setGroup("Default");
+ rotateOnLoad = config.readBoolEntry("Rotate", FALSE);
+ fastLoad = config.readBoolEntry("FastLoad", TRUE);
+ slideTimer = new QTimer( this );
+ connect( slideTimer, SIGNAL(timeout()), this, SLOT(slideUpdate()) );
+
switchToFileSelector();
setMouseTracking( TRUE );
@@ -355,11 +394,54 @@ ImageViewer::~ImageViewer()
cfg.writeEntry("ShowThumbnails",(int)showThumbView);
cfg.writeEntry("SizeToScreen",(int)isSized);
+ cfg.setGroup( "SlideShow" );
+ cfg.writeEntry( "Delay", slideDelay);
+ cfg.writeEntry( "Repeat", slideRepeat );
+ cfg.writeEntry("Reverse", slideReverse);
+
+ cfg.setGroup("Default");
+ cfg.writeEntry("Rotate", rotateOnLoad);
+ cfg.writeEntry("FastLoad", fastLoad);
+
delete imagePanel; // in case it is fullscreen
}
+void ImageViewer::help() {
+
+}
+
+
+void ImageViewer::settings()
+{
+ SettingsDialog dlg( this, 0, TRUE );
+ dlg.setDelay( slideDelay );
+ dlg.setRepeat( slideRepeat );
+ dlg.setReverse( slideReverse );
+ dlg.setRotate(rotateOnLoad);
+ dlg.setFastLoad(fastLoad);
+
+ if ( QPEApplication::execDialog(&dlg) == QDialog::Accepted ) {
+ qDebug("<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>");
+ slideDelay = dlg.delay();
+ slideRepeat = dlg.repeat();
+ slideReverse = dlg.reverse();
+ rotateOnLoad = dlg.rotate();
+ fastLoad = dlg.fastLoad();
+
+ Config config( "ImageViewer" );
+ config.setGroup( "SlideShow" );
+ config.writeEntry( "Delay", slideDelay );
+ config.writeEntry( "Repeat", slideRepeat );
+ config.writeEntry("Reverse", slideReverse);
+
+ config.setGroup("Default");
+ config.writeEntry("Rotate", rotateOnLoad);
+ config.writeEntry("FastLoad", fastLoad);
+ }
+}
+
void ImageViewer::switchSizeToScreen()
{
isSized=!isSized;
sss->setOn(isSized);
@@ -367,14 +449,11 @@ void ImageViewer::switchSizeToScreen()
}
void ImageViewer::updateImage()
{
- if ( isSized )
- {
+ if ( isSized ) {
imagePanel->setPixmap(pmScaled);
- }
- else
- {
+ } else {
imagePanel->setPixmap(pm);
}
}
@@ -395,8 +474,9 @@ void ImageViewer::switchToFileSelector()
menuBar->insertItem( tr("View"), viewMenuFile );
menuBar->insertItem( tr("Options"), optionsMenuFile );
iconToolBar->hide();
imagePanel->disable();
+ slideShow(false);
}
void ImageViewer::switchToImageView()
@@ -433,29 +513,45 @@ void ImageViewer::show()
}
void ImageViewer::show(const QString& fileref)
{
+// qDebug("Show "+fileref);
bFromDocView = TRUE;
closeFileSelector();
DocLnk link(fileref);
- if ( link.isValid() )
- {
+ if ( link.isValid() ) {
openFile(link);
- }
- else
- {
+ } else {
filename = fileref;
updateCaption( fileref );
loadImage( fileref );
}
}
-void ImageViewer::openFile( const DocLnk &file )
+void ImageViewer::openFile() {
+ MimeTypes types;
+ QStringList image;
+ image << "image/*";
+ types.insert("Images", image);
+
+ QString str = OFileDialog::getOpenFileName( 1,QPEApplication::documentDir(),"", types, 0 );
+ DocLnk link(str);
+ if ( link.isValid() )
+ openFile(link);
+
+}
+
+void ImageViewer::openFile( const DocLnk &link )
{
closeFileSelector();
- DocLnk link(file);
+// DocLnk link(file);
+ qDebug("open "+link.name());
updateCaption( link.name() );
loadImage( link.file() );
+ if (slideTimer->isActive()) {
+ slideTimer->start(slideDelay * 1000, FALSE);
+ }
+
}
void ImageViewer::open()
{
@@ -481,26 +577,37 @@ void ImageViewer::updateCaption( QString name )
void ImageViewer::loadImage( const char *fileName )
{
filename = fileName;
- if ( filename )
- {
+ if ( filename ) {
QApplication::setOverrideCursor( waitCursor ); // this might take time
//imagePanel->statusLabel()->setText( tr("Loading image...") );
qApp->processEvents();
bool ok = image.load(filename, 0);
- if ( ok )
- {
+ if ( ok ) {
ok = reconvertImage();
updateImageInfo(filename);
}
- if ( !ok )
- {
+ if ( !ok ) {
pm.resize(0,0); // couldn't load image
update();
}
QApplication::restoreOverrideCursor(); // restore original cursor
}
+
+// fastLoad ? ", Fast" : "",
+// fastLoad ? QMAX(imagewidth/maxsize, imageheight/maxsize) : 1);
+
+
+// matrix.reset();
+ rotated90 = FALSE;
+
+ if (rotateOnLoad) {
+ rotated90 = TRUE;
+ rot90();
+// matrix.rotate( -90.0 );
+ }
+
switchToImageView();
updateImage();
}
@@ -618,34 +725,39 @@ void ImageViewer::resizeEvent( QResizeEvent * )
void ImageViewer::hFlip()
{
+// matrix.scale( -1.0, 1.0 );
+
setImage(image.mirror(TRUE,FALSE));
}
void ImageViewer::vFlip()
{
+// matrix.scale( 1.0, -1.0 );
setImage(image.mirror(FALSE,TRUE));
}
void ImageViewer::rot180()
{
-
+// matrix.rotate( 180.0 );
setImage(image.mirror(TRUE,TRUE));
}
void ImageViewer::rot90()
{
QImage oldimage;
oldimage = image.convertDepth(32);
+// matrix.rotate( -90.0 );
setImage(rotate(oldimage,Rotate90));
}
void ImageViewer::rot270()
{
QImage oldimage;
oldimage = image.convertDepth(32);
+// matrix.rotate(90.0);
setImage(rotate(oldimage,Rotate270));
}
@@ -653,10 +765,8 @@ void ImageViewer::blackAndWhite()
{
viewMenuView->setItemEnabled(BLACKANDWHITE,false);
setImage(toGray(image,false));
-
-
}
void ImageViewer::displayControlsDialog()
{
@@ -671,10 +781,9 @@ void ImageViewer::displayControlsDialog()
int newB=0;
ControlsDialog *dlg=new ControlsDialog("Image Viewer",small,&newB,this);
dlg->exec();
- if ( newB )
- {
+ if ( newB ) {
intensity(image,(float)newB/100);
setImage(image);
}
@@ -706,8 +815,13 @@ void ImageViewer::normalView()
}
}
+void ImageViewer::stopSlideShow() {
+ if (slideTimer->isActive())
+ slideTimer->stop();
+}
+
void ImageViewer::fullScreen()
{
// Full-screen option
// contributed by Robert Wittams <robert@wittams.com>
@@ -1033,12 +1147,103 @@ QImage ImageViewer::rotate(QImage &img, RotateDirection r)
}
}
return (dest);
+}
+
+void ImageViewer::slideShow( bool on )
+{
+ if (on) {
+ if (!imageList.isEmpty()) {
+ slideTimer->start(slideDelay * 1000, FALSE);
+ filename = ""; // force restart
+ slideReverse ? prevImage() : nextImage();
+ }
+ } else {
+ slideTimer->stop();
+ slideAction->setOn( false);
+ }
+}
+
+void ImageViewer::slideUpdate()
+{
+ bool final_image = slideReverse ? prevImage() : nextImage();
+
+ if (final_image && !slideRepeat) {
+ slideTimer->stop();
+ slideAction->setOn(FALSE);
+ }
+}
+//
+// Display the image after the current one in the image list.
+// Return TRUE if the next call to nextImage() will wrap around to the
+// first image in the list (ie. we're now viewing the last image in the list).
+//
+bool ImageViewer::nextImage(void)
+{
+ int idx = 0;
+
+ if (imageList.count() > 0) {
+ idx = imageIndex();
+ if (idx != -1) {
+ if (idx == int(imageList.count() - 1)) {
+ idx = 0;
+ } else {
+ idx++;
+ }
+ } else {
+ idx = 0;
+ }
+ openFile(imageList[idx]);
+ }
+ return idx == int(imageList.count() - 1) ? TRUE : FALSE;
}
+//
+// Display the image preceeding the current one in the image list.
+// Return TRUE if the next call to prevImage() will wrap around to the last
+// image in the list (ie. we're now viewing the first image in the list).
+//
+bool ImageViewer::prevImage(void)
+{
+ int idx = -1;
+
+ if (imageList.count() > 0) {
+ idx = imageIndex();
+ if (idx != -1) {
+ if (idx == 0) {
+ idx = imageList.count() - 1;
+ } else {
+ idx--;
+ }
+ } else {
+ idx = imageList.count() - 1;
+ }
+ openFile(imageList[idx]);
+ }
+ return idx == 0 ? TRUE : FALSE;
+}
+//
+// Return the index into the imageList of the currently viewed
+// image (ie. ImageViewer::filename in ImageViewer::imageList).
+//
+int ImageViewer::imageIndex(void)
+{
+ QValueListConstIterator<DocLnk> i;
+ int index;
+ if (imageList.count() == 0) {
+ return -1;
+ }
+ for (index = 0, i = imageList.begin(); i != imageList.end(); ++i, index++) {
+ if ((*i).file() == filename) {
+ return index;
+ }
+ }
+
+ return -1;
+}
diff --git a/noncore/multimedia/showimg/showimg.h b/noncore/multimedia/showimg/showimg.h
index 0d3bc7d..8555ff0 100644
--- a/noncore/multimedia/showimg/showimg.h
+++ b/noncore/multimedia/showimg/showimg.h
@@ -28,9 +28,13 @@
#include <qlayout.h>
#include <qscrollview.h>
#include <qdialog.h>
#include <qstringlist.h>
+#include <qvaluelist.h>
+#include <qwmatrix.h>
+
+class QAction;
class QPEToolBar;
class QPEMenuBar;
class QPopupMenu;
class QWidgetStack;
@@ -39,33 +43,27 @@ class DocLnk;
class QLabel;
class QAction;
class QSpinBox;
class ImageFileSelector;
-
+class QTimer;
class ImageWidget : public QWidget
{
Q_OBJECT
- public:
- ImageWidget(
- QWidget *parent=0
- ) : QWidget( parent )
- {
+ public:
+ ImageWidget( QWidget *parent=0 )
+ : QWidget( parent ) {
setBackgroundMode(NoBackground);
}
- ~ImageWidget()
- {
-
- }
+ ~ImageWidget() { }
- void setPixmap( const QPixmap &pm )
- {
+ void setPixmap( const QPixmap &pm ) {
pixmap = pm;
show();
}
- signals:
+signals:
void clicked();
protected:
void paintEvent( QPaintEvent * );
@@ -78,9 +76,9 @@ private:
class InfoDialog:public QDialog
{
Q_OBJECT
- public:
+public:
static void displayInfo(const QString &caption, const QStringList text, QWidget *parent);
private:
@@ -92,9 +90,9 @@ private:
class ControlsDialog:public QDialog
{
Q_OBJECT
- public:
+public:
ControlsDialog(const QString &caption,const QImage image,int *brightness, QWidget *parent);
private slots:
@@ -113,14 +111,11 @@ private:
class ImagePane : public QWidget
{
Q_OBJECT
- public:
+public:
ImagePane( QWidget *parent=0 );
- ~ImagePane()
- {
-
- }
+ ~ImagePane() { }
//void showStatus();
//void hideStatus();
//QLabel *statusLabel()
@@ -129,29 +124,25 @@ class ImagePane : public QWidget
//}
void setPixmap( const QPixmap &pm );
- int paneWidth() const
- {
+ int paneWidth() const {
return image->visibleWidth();
}
- int paneHeight() const
- {
+ int paneHeight() const {
return image->visibleHeight();
}
- void setPosition(int x, int y)
- {
+ void setPosition(int x, int y) {
image->setContentsPos (x,y );
}
- void disable()
- {
+ void disable() {
pic->hide();
}
- signals:
+signals:
void clicked();
private:
QScrollView *image;
@@ -165,19 +156,18 @@ private slots:
class ImageViewer : public QMainWindow
{
Q_OBJECT
- public:
+public:
ImageViewer( QWidget *parent=0, const char *name=0, int wFlags=0 );
~ImageViewer();
void loadImage( const char *fileName );
void show(const QString& fileref);
void show();
- enum INFO_STRINGS
- {
+ enum INFO_STRINGS {
PATH,
FORMAT,
FILE_SIZE,
SIZE,
@@ -185,23 +175,25 @@ class ImageViewer : public QMainWindow
ALPHA,
LAST
};
- enum RotateDirection
- {
+ enum RotateDirection {
Rotate90, Rotate180, Rotate270
};
static QImage rotate(QImage &img, RotateDirection r);
static QImage& intensity(QImage &image, float percent);
static QImage& toGray(QImage &image, bool fast = false);
+ bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view
protected:
void resizeEvent( QResizeEvent * );
void closeEvent( QCloseEvent * );
private:
+ int imageIndex(void);
+
void updateCaption( QString name );
bool loadSelected();
void scale();
bool reconvertImage();
@@ -212,19 +204,23 @@ private:
void switchToImageView();
void updateImage();
-
-
-
private slots:
+ void slideShow( bool on );
+ void help();
+ void slideUpdate();
+ bool nextImage();
+ bool prevImage();
+ void settings();
+
void switchThumbView();
void switchSizeToScreen();
void setDocument(const QString& fileref);
void doDelayedLoad();
void openFile( const DocLnk &file );
- //void openFile();
+ void openFile();
void open();
void closeFileSelector();
void hFlip();
void vFlip();
@@ -232,35 +228,21 @@ private slots:
void rot90();
void rot270();
void normalView();
void fullScreen();
+ void stopSlideShow();
void blackAndWhite();
void displayInfoDialog();
void displayControlsDialog();
-
-
-
-
-
-
-
-
-
-
private:
-
-
-
-
- enum MENU_ITEMS
- {
+ QWMatrix matrix;
+ bool rotated90;
+ enum MENU_ITEMS {
SHOW_THUMBNAILS,
SIZE_TO_SCREEN,
BLACKANDWHITE
};
-
-
QString filename;
QString delayLoad;
QImage image; // the loaded image
QPixmap pm; // the converted pixmap
@@ -288,9 +270,17 @@ private:
bool isSized; // true if image is to be resized to fit the window size
bool bFromDocView; // a flag to indicate whether or not we were
// launched from the document view...
- bool showThumbView; // a flag to indicate if FileSelector should be initialized with thumbnail view
+ int slideDelay;
+ bool slideRepeat;
+ bool slideReverse; // show slideshow in reverse order
+ bool rotateOnLoad; // rotate by 90 degrees on loading
+ bool fastLoad;
+ QTimer *slideTimer;
+ QValueList<DocLnk> imageList;
+ QAction *slideAction;
+
QString imageInfo[LAST];
};
diff --git a/noncore/multimedia/showimg/showimg.pro b/noncore/multimedia/showimg/showimg.pro
index 2b6241f..4ff4746 100644
--- a/noncore/multimedia/showimg/showimg.pro
+++ b/noncore/multimedia/showimg/showimg.pro
@@ -1,27 +1,25 @@
TEMPLATE = app
CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
-HEADERS = showimg.h ImageFileSelector.h
-SOURCES = main.cpp \
- showimg.cpp\
- ImageFileSelector.cpp
+HEADERS = showimg.h ImageFileSelector.h settingsdialog.h settingsdialogbase.h
+SOURCES = main.cpp showimg.cpp ImageFileSelector.cpp settingsdialog.cpp settingsdialogbase.cpp
TARGET = showimg
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopie
REQUIRES = showimg
TRANSLATIONS = ../../../i18n/de/showimg.ts \
- ../../../i18n/en/showimg.ts \
- ../../../i18n/es/showimg.ts \
- ../../../i18n/fr/showimg.ts \
- ../../../i18n/hu/showimg.ts \
- ../../../i18n/ja/showimg.ts \
- ../../../i18n/ko/showimg.ts \
- ../../../i18n/no/showimg.ts \
- ../../../i18n/pl/showimg.ts \
- ../../../i18n/pt/showimg.ts \
- ../../../i18n/pt_BR/showimg.ts \
- ../../../i18n/sl/showimg.ts \
- ../../../i18n/zh_CN/showimg.ts \
- ../../../i18n/zh_TW/showimg.ts
+ ../../../i18n/en/showimg.ts \
+ ../../../i18n/es/showimg.ts \
+ ../../../i18n/fr/showimg.ts \
+ ../../../i18n/hu/showimg.ts \
+ ../../../i18n/ja/showimg.ts \
+ ../../../i18n/ko/showimg.ts \
+ ../../../i18n/no/showimg.ts \
+ ../../../i18n/pl/showimg.ts \
+ ../../../i18n/pt/showimg.ts \
+ ../../../i18n/pt_BR/showimg.ts \
+ ../../../i18n/sl/showimg.ts \
+ ../../../i18n/zh_CN/showimg.ts \
+ ../../../i18n/zh_TW/showimg.ts