summaryrefslogtreecommitdiff
path: root/noncore/multimedia/showimg/showimg.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/showimg/showimg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/showimg/showimg.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/multimedia/showimg/showimg.cpp b/noncore/multimedia/showimg/showimg.cpp
index ba76e57..02a1d91 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -119,386 +119,386 @@ InfoDialog::InfoDialog(const QString &caption, const QStringList text,QWidget *p
}
QString labels[]={ tr("File Name"),tr("Format"),tr("File Size"),tr("Size"),tr("Colors"),tr("Alpha") };
setMinimumSize(180,80);
int num=ImageViewer::LAST+1;
if ( text[ImageViewer::ALPHA].isEmpty() )
num--;
QGridLayout *gl= new QGridLayout(this,num,2,4,2);
QLabel *l;
int count=0;
for ( int i=0;i<num;i++ )
{
if ( i==1 )
{
QFrame *frm=new QFrame(this);
frm->setFrameStyle(QFrame::HLine|QFrame::Sunken);
gl->addMultiCellWidget(frm,i,i,0,1);
}
else
{
l=new QLabel( tr( labels[count] )+":",this);
gl->addWidget(l,i,0,AlignLeft);
l=new QLabel(text[count],this);
gl->addWidget(l,i,1,AlignRight);
count++;
}
}
}
void InfoDialog::displayInfo(const QString &caption, const QStringList text, QWidget *parent)
{
InfoDialog *dlg=new InfoDialog(caption,text,parent);
dlg->exec();
delete dlg;
}
//===========================================================================
ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
{
vb = new QVBoxLayout( this );
image = new QScrollView(this,0,WResizeNoErase|WNorthWestGravity);
pic=new ImageWidget(image);
image->addChild(pic);
connect(pic, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
vb->addWidget( image );
}
void ImagePane::setPixmap( const QPixmap &pm )
{
pic->setPixmap( pm );
pic->resize(pm.width(),pm.height());
image->updateScrollBars ();
pic->repaint(false);
}
void ImagePane::imageClicked()
{
emit clicked();
}
//===========================================================================
/*
Draws the portion of the scaled pixmap that needs to be updated
*/
void ImageWidget::paintEvent( QPaintEvent *e )
{
QPainter painter(this);
painter.setClipRect(e->rect());
painter.fillRect(0,0,width(),height(),QColor(0,0,0));
if ( pixmap.size() != QSize( 0, 0 ) )
{ // is an image loaded?
painter.drawPixmap((width() - pixmap.width()) / 2, (height() - pixmap.height()) / 2, pixmap);
}
}
void ImageWidget::mouseReleaseEvent(QMouseEvent *)
{
emit clicked();
}
//===========================================================================
ImageViewer::ImageViewer( QWidget *parent, const char *name, int wFlags )
: QMainWindow( parent, name, WResizeNoErase ), filename( 0 ), bFromDocView( FALSE )
{
setCaption( tr("Image Viewer") );
setIcon( Resource::loadPixmap( "ImageViewer" ) );
Config cfg("Image Viewer");
cfg.setGroup("Image Viewer");
showThumbView=cfg.readBoolEntry("ShowThumbnails",false);
isSized=cfg.readBoolEntry("SizeToScreen",true);
isFullScreen = FALSE;
setToolBarsMovable( FALSE );
toolBar = new QToolBar( this );
toolBar->setHorizontalStretchable( TRUE );
menuBar = new QMenuBar( toolBar );
current=menuBar;
fileMenuFile = new QPopupMenu(this);
//menuBarmenubarFile->insertItem( tr("File"), fileMenu );
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->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
optionsMenuFile = new QPopupMenu( this);
//menubarFile->insertItem( tr("Options"),optionsMenu );
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();
fileMenuView = new QPopupMenu( this );
//menubarView->insertItem( tr("File"),fileMenu );
fileMenuView->insertItem( tr("Image Info ..."),this, SLOT(displayInfoDialog()),0 );
fileMenuView->insertSeparator();
viewMenuView = new QPopupMenu(this );
viewMenuView->setCheckable ( true );
//menubarView->insertItem( tr("View"),viewMenu );
viewMenuView->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0);
viewMenuView->insertItem(tr("Vertical flip"), this, SLOT(vFlip()), 0);
stack = new QWidgetStack( this );
stack->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) );
setCentralWidget( stack );
imagePanel = new ImagePane( stack );
connect(imagePanel, SIGNAL(clicked()), this, SLOT(normalView()));
ImageFileSelector::CURRENT_VIEW cv;
if(showThumbView)
cv=ImageFileSelector::THUMBNAIL;
else
cv=ImageFileSelector::DETAILED;
qDebug("cv = %d",cv);
fileSelector = new ImageFileSelector( cv,stack, "fs");
//switchThumbView();
//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 QToolBar(this);
QAction *a;
a = new QAction( tr( "Open ..." ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( open() ) );
a->addTo( fileMenuView);
a->addTo( iconToolBar );
a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0);
connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) );
a->addTo( iconToolBar );
a->addTo( viewMenuView );
a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) );
a->addTo( iconToolBar );
a->addTo( viewMenuView );
a = new QAction( tr( "Rotate 270"), Resource::loadPixmap( "rotate270" ), QString::null, 0, this, 0);
connect( a, SIGNAL( activated() ), this, SLOT( rot270() ) );
//a->addTo( iconToolBar );
a->addTo( viewMenuView );
viewMenuView->insertSeparator();
viewMenuView->insertItem(tr("Brightness ..."), this, SLOT(displayControlsDialog()), 0);
viewMenuView->insertItem(tr("Black And White"), this, SLOT(blackAndWhite()), 0,BLACKANDWHITE);
viewMenuView->insertSeparator();
sss = new QAction( tr( "Scale to Screen"), Resource::loadPixmap( "scale" ), QString::null, 0, this, 0,true);
connect( sss, SIGNAL( activated() ), this, SLOT( switchSizeToScreen() ) );
sss->addTo( iconToolBar );
sss->addTo( viewMenuView );
sss->setOn(isSized);
viewMenuView->insertSeparator();
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 );
}
ImageViewer::~ImageViewer()
{
Config cfg("Image Viewer");
cfg.setGroup("Image Viewer");
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);
updateImage();
}
void ImageViewer::updateImage()
{
if ( isSized ) {
imagePanel->setPixmap(pmScaled);
} else {
imagePanel->setPixmap(pm);
}
}
void ImageViewer::switchThumbView()
{
showThumbView=!showThumbView;
viewMenuFile->setItemChecked ( SHOW_THUMBNAILS, showThumbView );
fileSelector->switchView();
}
void ImageViewer::switchToFileSelector()
{
stack->raiseWidget(fileSelector);
menuBar->clear();
menuBar->insertItem( tr("File"), fileMenuFile );
menuBar->insertItem( tr("View"), viewMenuFile );
menuBar->insertItem( tr("Options"), optionsMenuFile );
iconToolBar->hide();
imagePanel->disable();
slideShow(false);
}
void ImageViewer::switchToImageView()
{
stack->raiseWidget(imagePanel);
menuBar->clear();
menuBar->insertItem( tr("File"), fileMenuView );
menuBar->insertItem( tr("View"), viewMenuView );
viewMenuView->setItemEnabled(BLACKANDWHITE,true);
iconToolBar->show();
imagePanel->setPosition(0,0);
}
void ImageViewer::setDocument(const QString& fileref)
{
delayLoad = fileref;
switchToImageView();
QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
}