summaryrefslogtreecommitdiff
authorfbarros <fbarros>2002-07-17 18:11:28 (UTC)
committer fbarros <fbarros>2002-07-17 18:11:28 (UTC)
commitb498618d255732f8620055439bf25eab8feefdc0 (patch) (side-by-side diff)
tree41020f7fb72d6816910b86d4373df727c6b6476d
parentf9a3edf09f28811d57ee834833dd6fb49cb4178f (diff)
downloadopie-b498618d255732f8620055439bf25eab8feefdc0.zip
opie-b498618d255732f8620055439bf25eab8feefdc0.tar.gz
opie-b498618d255732f8620055439bf25eab8feefdc0.tar.bz2
just 2 tr()
Diffstat (more/less context) (show 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 7c43e11..24218e6 100644
--- a/noncore/multimedia/showimg/showimg.cpp
+++ b/noncore/multimedia/showimg/showimg.cpp
@@ -1,329 +1,329 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of 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.
**
**********************************************************************/
//
// Full-screen and rotation options contributed by Robert Wittams <robert@wittams.com>
//
#include "showimg.h"
#include <qpe/resource.h>
#include <qpe/fileselector.h>
#include <qpe/applnk.h>
#include <qpe/qpemenubar.h>
#include <qwidgetstack.h>
#include <qpe/qpetoolbar.h>
#include <qaction.h>
#include <qfiledialog.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qlabel.h>
#include <qpainter.h>
#include <qkeycode.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <qtimer.h>
ImagePane::ImagePane( QWidget *parent ) : QWidget( parent )
{
vb = new QVBoxLayout( this );
image = new ImageWidget( this );
connect(image, SIGNAL( clicked() ), this, SLOT( imageClicked() ));
vb->addWidget( image );
status = new QLabel( this );
status->setFixedHeight( fontMetrics().height() + 4 );
vb->addWidget( status );
}
void ImagePane::setPixmap( const QPixmap &pm )
{
image->setPixmap( pm );
image->repaint( false );
}
void ImagePane::imageClicked()
{
emit clicked();
}
void ImagePane::showStatus()
{
delete vb;
vb = new QVBoxLayout( this );
vb->addWidget( image );
status->show();
vb->addWidget( status );
}
void ImagePane::hideStatus()
{
delete vb;
vb = new QVBoxLayout( this );
vb->addWidget( image );
status->hide();
}
//===========================================================================
/*
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.setBrush( black );
painter.drawRect( 0, 0, width(), height() );
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, wFlags ), filename( 0 ),
pickx( -1 ), picky( -1 ), clickx( -1 ), clicky( -1 ), bFromDocView( FALSE )
{
setCaption( tr("Image Viewer") );
setIcon( Resource::loadPixmap( "ImageViewer" ) );
isFullScreen = FALSE;
setToolBarsMovable( FALSE );
toolBar = new QPEToolBar( this );
toolBar->setHorizontalStretchable( TRUE );
menubar = new QPEMenuBar( toolBar );
QStrList fmt = QImage::outputFormats();
QPopupMenu *edit = new QPopupMenu( menubar );
QPopupMenu *view = new QPopupMenu( menubar );
- menubar->insertItem( "Edit", edit );
- menubar->insertItem( "View", view );
+ menubar->insertItem(tr("Edit"), edit );
+ menubar->insertItem(tr("View"), view );
edit->insertItem(tr("Horizontal flip"), this, SLOT(hFlip()), 0);
edit->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()));
fileSelector = new FileSelector("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 & ) ) );
toolBar = new QPEToolBar( 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( toolBar );
a = new QAction( tr( "Rotate 180" ), Resource::loadPixmap( "repeat" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( rot180() ) );
a->addTo( toolBar );
a->addTo( edit );
a = new QAction( tr( "Rotate 90"), Resource::loadPixmap( "rotate90" ), QString::null, 0, this, 0);
connect( a, SIGNAL( activated() ), this, SLOT( rot90() ) );
a->addTo( toolBar );
a->addTo( edit );
a = new QAction( tr( "Fullscreen" ), Resource::loadPixmap( "fullscreen" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( fullScreen() ) );
a->addTo( toolBar );
a->addTo( view);
stack->raiseWidget( fileSelector );
setMouseTracking( TRUE );
}
ImageViewer::~ImageViewer()
{
delete imagePanel; // in case it is fullscreen
}
void ImageViewer::setDocument(const QString& fileref)
{
delayLoad = fileref;
stack->raiseWidget(imagePanel);
QTimer::singleShot( 0, this, SLOT(doDelayedLoad()) );
}
void ImageViewer::doDelayedLoad()
{
show(delayLoad);
}
void ImageViewer::show()
{
normalView();
QMainWindow::show();
}
void ImageViewer::show(const QString& fileref)
{
bFromDocView = TRUE;
closeFileSelector();
DocLnk link(fileref);
if ( link.isValid() ) {
openFile(link);
} else {
filename = fileref;
updateCaption( fileref );
loadImage( fileref );
}
}
void ImageViewer::openFile( const DocLnk &file )
{
closeFileSelector();
DocLnk link(file);
updateCaption( link.name() );
loadImage( link.file() );
}
void ImageViewer::open()
{
stack->raiseWidget(fileSelector);
}
void ImageViewer::closeFileSelector()
{
stack->raiseWidget(imagePanel);
}
void ImageViewer::updateCaption( QString name )
{
int sep = name.findRev( '/' );
if ( sep >= 0 )
name = name.mid( sep+1 );
setCaption( name + tr(" - Image Viewer") );
}
/*
This function loads an image from a file.
*/
void ImageViewer::loadImage( const char *fileName )
{
filename = fileName;
if ( filename ) {
QApplication::setOverrideCursor( waitCursor ); // this might take time
imagePanel->statusLabel()->setText( tr("Loading image...") );
qApp->processEvents();
bool ok = image.load(filename, 0);
pickx = -1;
clickx = -1;
if ( ok )
ok = reconvertImage();
if ( !ok ) {
pm.resize(0,0); // couldn't load image
update();
}
QApplication::restoreOverrideCursor(); // restore original cursor
}
updateStatus();
imagePanel->setPixmap( pmScaled );
stack->raiseWidget(imagePanel);
}
bool ImageViewer::loadSelected()
{
bool ok = false;
if ( stack->visibleWidget() == fileSelector ) {
const DocLnk *link = fileSelector->selected();
if ( link ) {
if ( link->file() != filename ) {
updateCaption( link->name() );
filename = link->file();
imagePanel->statusLabel()->setText( tr("Loading image...") );
qApp->processEvents();
ok = image.load(filename, 0);
if ( ok )
ok = reconvertImage();
if ( !ok )
pm.resize(0,0);
}
}
}
if ( !image.isNull() ) {
ok = true;
closeFileSelector();
}
return ok;
}
bool ImageViewer::reconvertImage()
{
bool success = FALSE;
if ( image.isNull() ) return FALSE;
QApplication::setOverrideCursor( waitCursor ); // this might take time
if ( pm.convertFromImage(image /*, conversion_flags */ ) )
{
pmScaled = QPixmap();
scale();
success = TRUE; // load successful
} else {
pm.resize(0,0); // couldn't load image
}
QApplication::restoreOverrideCursor(); // restore original cursor
return success; // TRUE if loaded OK
}
int ImageViewer::calcHeight()
{
if ( !isFullScreen)
return height() - menubar->heightForWidth( width() )
- imagePanel->statusLabel()->height();
else
return qApp->desktop()->height();
}
/*