diff --git a/CMakeLists.txt b/CMakeLists.txt index 960be83..de4bb02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,30 +1,31 @@ cmake_minimum_required (VERSION 3.0) project (kdegraphics) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) find_package(KDE1 REQUIRED) find_package(GIF REQUIRED) add_definitions(-DHAVE_CONFIG_H) include(CMakePackageConfigHelpers) include(Qt1Macros) include(KDE1Macros) include(KDE1InstallDirs) if (CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive -std=c++98") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") endif() configure_file(common/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) include_directories(${CMAKE_CURRENT_BINARY_DIR}) #add_subdirectory(bsd-port) add_subdirectory(kpaint) +add_subdirectory(kview) #add_subdirectory(po) diff --git a/kview/CMakeLists.txt b/kview/CMakeLists.txt new file mode 100644 index 0000000..0750de0 --- /dev/null +++ b/kview/CMakeLists.txt @@ -0,0 +1,60 @@ +#add_subdirectory(doc) + +include_directories ( + ${KDE1_INCLUDE_DIR} + layout/ +) + +set(KVIEW_SRCS + canvas.cpp + colour.cpp + filter.cpp + filtlist.cpp + filtmenu.cpp + ilistdlg.cpp + kaccelmenuwatch.cpp + kcproc.cpp + khelpidx.cpp + kview.cpp + main.cpp + numdlg.cpp + prefdlg.cpp + viewer.cpp + + bagconst.cpp + baglayout.cpp + typolayout.cpp +) + +set(KVIEW_MOC + baglayout.moc + canvas.moc + colour.moc + filter.moc + filtmenu.moc + ilistdlg.moc + kaccelmenuwatch.moc + kview.moc + prefdlg.moc + typolayout.moc + viewer.moc + ) + +QT1_WRAP_MOC(MOC_FILES ${KVIEW_MOC}) + +add_executable(kview ${KVIEW_SRCS} ${MOC_FILES}) +target_link_libraries(kview + Qt::Qt1 + ${X11_LIBRARIES} + ${KDE1_KDECORE} + ${KDE1_KDEUI} + ${KDE1_KFM} + ${KDE1_KFILE} + ${KDE1_KIMGIO} +) + +install(TARGETS kview RUNTIME DESTINATION ${KDE1_BINDIR}) +install(FILES kview.kdelnk DESTINATION ${KDE1_APPSDIR}/Graphics) +install_icon(kview.xpm) + +#add_subdirectory(doc) TODO diff --git a/kview/layout/bagconst.cpp b/kview/bagconst.cpp similarity index 100% rename from kview/layout/bagconst.cpp rename to kview/bagconst.cpp diff --git a/kview/layout/bagconst.h b/kview/bagconst.h similarity index 100% rename from kview/layout/bagconst.h rename to kview/bagconst.h diff --git a/kview/layout/baglayout.cpp b/kview/baglayout.cpp similarity index 99% rename from kview/layout/baglayout.cpp rename to kview/baglayout.cpp index bfb8678..3adde7e 100644 --- a/kview/layout/baglayout.cpp +++ b/kview/baglayout.cpp @@ -1,312 +1,314 @@ /* * gridbagl.cpp -- Implementation of class KGridBagLayout. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Mon May 4 15:57:51 EST 1998 */ #include #include #include"baglayout.h" KBagLayout::KBagLayout( QWidget *parent, int x, int y ) : QObject( parent ), _sizeSet ( false ), _grid( x, y ), _min( 0, 0 ), _topSpace( 2 ), _bottomSpace( 2 ), _leftSpace( 2 ), _rightSpace( 2 ) { assert( parent ); _parent = parent; _cstr = new QPtrDict; _cstr->setAutoDelete( true ); _widgets = new QList; _widgets->setAutoDelete( false ); if( x != 0 || y != 0 ) { _sizeSet = true; } _parent->installEventFilter( this ); updateContentRect(); } KBagLayout::~KBagLayout() { delete _cstr; delete _widgets; } KBagConstraints *KBagLayout::addWidget( QWidget *widget ) { KBagConstraints * c = new KBagConstraints; _widgets->append( widget ); _cstr->insert( widget, c ); QSize hint = widget->sizeHint(); if( hint.isValid() ) { widget->setMinimumSize( hint ); } updateMinSize(); return c; } KBagConstraints *KBagLayout::addWidget( QWidget *widget, int x, int y, int xspan, int yspan ) { KBagConstraints * c = addWidget( widget ); c->setGridX( x ); c->setGridY( y ); c->setXSpan( xspan ); c->setYSpan( yspan ); return c; } KBagConstraints *KBagLayout::addWidget( QWidget *widget, KBagConstraints& constr ) { KBagConstraints * c = new KBagConstraints( constr ); _widgets->append( widget ); _cstr->insert( widget, c ); return c; } void KBagLayout::activate() { if ( _sizeSet == false ) { calcGridExtent(); } if( !_grid.isValid() ) { warning( "KBagLayout: illegal layout constraints." ); return; } // arrange each widget QListIterator list( *_widgets ); for( ; list.current(); ++list ) { arrangeWidget( list.current(), (KBagConstraints *) _cstr->find ( list.current() ) ); } #if 0 QRect c = _parent->childrenRect(); if( c.isValid() ) { _parent->setMinimumSize( c.width(), c.height() ); } #endif } void KBagLayout::calcGridExtent() { QListIterator list( *_widgets ); _grid.setWidth( 0 ); _grid.setHeight( 0 ); for( ; list.current(); ++list ) { KBagConstraints *c = constraints( list.current() ); int cx = c->gridX() + c->xSpan(); int cy = c->gridY() + c->ySpan(); if( cx > _grid.width() ) { _grid.setWidth( cx ); } if( cy > _grid.height() ) { _grid.setHeight( cy ); } } } void KBagLayout::arrangeWidget( QWidget *w, KBagConstraints *c ) { assert ( w ); assert ( c ); if( _grid.width() == 0 || _grid.height() == 0 ) { warning( "KBagLayout::arrangeWidget called with " "invalid grid size (%d,%d)", _grid.width(), _grid.height() ); } int x=0, y=0, width=0, height=0; int cellx = _contents.width()/_grid.width(); int celly = _contents.height()/_grid.height(); _min.setWidth ( 0 ); _min.setHeight( 0 ); // // X layout // if( c->resizePolicy() & KBagConstraints::Horizontal ) { // offset from left by X x = c->xSpace(); width = (cellx*c->xSpan()) - (2 * c->xSpace()) + 1; } else { // centre in X if ( c->align() & KBagConstraints::HCenter ) { x = (cellx - w->width())/ 2; _min.rwidth() += w->width() + 2 * c->xSpace(); } // align left else if ( c->align() & KBagConstraints::Left ) { x = c->xSpace()/2; } // align right else if ( c->align() & KBagConstraints::Right ) { x = cellx - w->width() - (c->xSpace()/2) - 1; } width = w->width(); _min.rwidth() += w->width() + 2 * c->xSpace() + 1; } // // Y layout // if( c->resizePolicy() & KBagConstraints::Vertical ) { // offset from top by Y y = c->ySpace(); height = (celly*c->ySpan()) - (2 * c->ySpace()); } else { // centre in Y if ( c->align() & KBagConstraints::VCenter ) { y = (celly - w->height()) /2; } // align top else if ( c->align() & KBagConstraints::Top ) { y = c->ySpace()/2; } // align bottom else if ( c->align() & KBagConstraints::Bottom ) { y = celly - w->height() - (c->ySpace()/2) - 1; } height = w->height(); _min.rheight() += w->height() + 2 * c->ySpace() + 1; } // move/resize widget. w->setGeometry( _contents.left() + cellx * c->gridX() + x, _contents.top() + celly * c->gridY() + y, width, height ); } bool KBagLayout::eventFilter( QObject *receiver, QEvent *event ) { if( receiver == _parent && event->type() == Event_Resize ) { updateContentRect(); activate(); } return false; } void KBagLayout::setSpaceContents( QFrame *frame ) { assert( frame ); QRect r = frame->contentsRect(); _leftSpace = r.left() + 5; _topSpace = r.top() + 20; // to skip title _rightSpace = frame->width() - (r.width() + r.left()) + 5; _bottomSpace = frame->height() - (r.height() + r.top() ) + 5; updateContentRect(); } void KBagLayout::updateContentRect() { _contents.setCoords( _leftSpace, _topSpace, _parent->rect().right() - _leftSpace, _parent->rect().bottom() - _bottomSpace ); // updateMinSize(); } void KBagLayout::updateMinSize() { int width = 0; int height = 0; int *rowwidth = new int [ _grid.height() ]; int *colheight = new int [ _grid.width() ]; for( width = 0; width < _grid.height(); width++ ) { rowwidth[ width ] = 0; } for( width = 0; width < _grid.width(); width++ ) { colheight[ width ] = 0; } width = 0; QListIterator list( *_widgets ); for( ; list.current(); ++list ) { QWidget *w = list.current(); QSize s = w->minimumSize(); KBagConstraints *c = _cstr->find( w ); // increment size of every covered row/col for( int x = 0; x < c->xSpan(); x++ ) { colheight[ x + c->gridX() ] += s.height() + 2 * c->ySpace(); } for( int y = 0; y < c->ySpan(); y++ ) { rowwidth[ y + c->gridY() ] += s.width() + 2 * c->xSpace(); } } for( int x = 0; x < _grid.width(); x++ ) { if( colheight[x] > height ) height = colheight[ x ]; } for( int y = 0; y < _grid.height(); y++ ) { if( rowwidth[y] > width ) width = rowwidth[ y ]; } // debug( "min width: %d height: %d", width, height ); _parent->setMinimumSize( width + _leftSpace + _rightSpace, height + _topSpace + _bottomSpace ); delete [] rowwidth; delete [] colheight; } + +#include "baglayout.moc" diff --git a/kview/layout/baglayout.h b/kview/baglayout.h similarity index 100% rename from kview/layout/baglayout.h rename to kview/baglayout.h diff --git a/kview/canvas.cpp b/kview/canvas.cpp index ca6bf19..84f0e39 100644 --- a/kview/canvas.cpp +++ b/kview/canvas.cpp @@ -1,496 +1,496 @@ /* * canvas.cpp -- Implementation of class KImageCanvas. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Thu Oct 9 09:03:54 EST 1997 */ #include #include #include #include #include #include #include #include #include #include #include #include"canvas.h" static QString loadStdin(); static void maxpect( QWidget *dest, QPixmap *image ); KImageCanvas::KImageCanvas( QWidget *parent ) : QScrollView( parent ), _status( OK ), _file( "" ), _client( 0 ), _orig( 0 ) { _client = new KVImageHolder( this ); connect(_client, SIGNAL( contextPress(const QPoint&) ), this, SIGNAL ( contextPress(const QPoint&) )); addChild( _client ); _client->setAutoResize( TRUE ); _client->hide(); } KImageCanvas::~KImageCanvas() { delete _orig; } KImageCanvas::Error KImageCanvas::status() const { return _status; } int KImageCanvas::load( const char *file, const char *URL, bool max ) { if( file == 0 ) { setStatus( BadPath ); return 0; } QString realfile = file; bool std = false; if( realfile == "-") { // stdin std = true; realfile = loadStdin(); if( realfile.isEmpty() ) { setStatus( BadPath ); return 0; } } static int allocContext = 0; if( allocContext ) { QColor::destroyAllocContext( allocContext ); } allocContext = QColor::enterAllocContext(); QApplication::setOverrideCursor( WaitCursor ); QPixmap newImage; bool loadOK = newImage.load( realfile ); if( !loadOK && realfile.contains( ".tga", false ) ) { loadOK = newImage.load( realfile, "TGA" ); } QColor::leaveAllocContext(); if( std ) { unlink( realfile ); } if( loadOK ) { delete _orig; // delete old buffered image _orig = 0; _client->move( 0, 0 ); _originalSize = size(); if ( max ) { maxpect( this, &newImage ); } _client->setImagePix( newImage ); _client->show(); updateScrollBars(); _file = ( URL ? URL : realfile.data() ); setStatus( OK ); setCaption( _file ); QApplication::restoreOverrideCursor(); return -1; } else { warning( "Couldn't open %s", realfile.data() ); setStatus( BadPath ); } QApplication::restoreOverrideCursor(); return 0; } bool KImageCanvas::save( const char *urls, const char *format ) { if( urls == 0 ) { warning( "KImageCanvas::save called with null url" ); } if( format == 0 ) { format = "BMP"; } return _client->pixmap()->save( urls, format ); } void KImageCanvas::reset() { if( _orig == 0 ) { return; } _client->setImagePix( *_orig ); emit imageSizeChanged(); } void KImageCanvas::clear() { _client->setBackgroundColor( QColor(0,0,0) ); _client->resize( 0, 0 ); } void KImageCanvas::transformImage( const QWMatrix& mat ) { const QPixmap *image = transPixmap(); if( image == 0 ) { return; } QApplication::setOverrideCursor( waitCursor ); QPixmap newimage = _orig->xForm( mat ); _client->clearSelection(); _client->setImagePix( newimage ); QApplication::restoreOverrideCursor(); } void KImageCanvas::tileToDesktop() const { const QPixmap *image = _client->pixmap(); if( image == 0 ) { return; } qApp->desktop()->setBackgroundPixmap( *image ); } void KImageCanvas::maxToDesktop() const { if( _client->pixmap() == 0 ) return; QPixmap image = *(_client->pixmap()); int h = qApp->desktop()->height(); int w = qApp->desktop()->width(); image.convertFromImage(image.convertToImage().smoothScale(w,h)); qApp->desktop()->setBackgroundPixmap( image ); } void KImageCanvas::maxpectToDesktop() const { if( _client->pixmap() == 0 ) return; QPixmap image = *(_client->pixmap()); double dh = (double)qApp->desktop()->height()/(double)image.height(); double dw = (double)qApp->desktop()->width()/(double)image.width(); double d = ( dh < dw ? dh : dw ); image.convertFromImage(image.convertToImage().smoothScale( int(d*image.width()), int (d*image.height()))); qApp->desktop()->setBackgroundPixmap( image ); } static void maxpect( QWidget *dest, QPixmap *image ) { double dh = (double)dest->height()/(double)image->height(); double dw = (double)dest->width()/(double)image->width(); double d = ( dh < dw ? dh : dw ); image->convertFromImage(image->convertToImage().smoothScale( int(d*image->width()), int (d*image->height()))); } void KImageCanvas::resizeEvent( QResizeEvent *ev ) { QScrollView::resizeEvent( ev ); emit imageSizeChanged(); } QImage KImageCanvas::getImage() const { return _client->pixmap()->convertToImage(); } void KImageCanvas::setImage( const QImage& image ) { transPixmap(); QPixmap pixmap; pixmap.convertFromImage( image ); _client->setImagePix( pixmap ); emit imageSizeChanged(); } QPixmap *KImageCanvas::transPixmap() { QPixmap *client = _client->pixmap(); if( client == 0 ) { return 0; } if( _orig == 0 ) { _orig = new QPixmap( *client ); } return client; } void KImageCanvas::cropImage() { QRect select = _client->selected(); if ( select.isNull() ) { return; } transPixmap(); QPixmap *oldpix = _client->pixmap(); QPixmap newpix( select.width(), select.height() ); bitBlt( &newpix, 0, 0, oldpix, select.left(), select.top(), select.width(), select.height(), CopyROP ); _client->setImagePix( newpix ); emit imageSizeChanged(); } #define BUF_SIZE 1024 /** * Read standard input into a file. * @return filename */ static QString loadStdin() { if( feof( stdin ) ) { return ""; } QString name( 100 ); if( tmpnam( name.data() ) == 0 ) { return ""; } char buffer[ BUF_SIZE ]; FILE *o; o = fopen( name, "w" ); if( o == 0 ) { return ""; } while( !feof( stdin ) ) { size_t bytes = fread( buffer, sizeof(char), BUF_SIZE, stdin ); fwrite( buffer, sizeof( char ), bytes, o ); } fclose( o ); return name; } void KImageCanvas::maxToWin() { transPixmap(); if( _client->pixmap() == 0 ) return; QPixmap image = *(_client->pixmap()); image.convertFromImage(image.convertToImage().smoothScale( width(),height())); _client->setImagePix( image ); emit imageSizeChanged(); } void KImageCanvas::maxpectToWin() { transPixmap(); if( _client->pixmap() == 0 ) return; QPixmap image = *(_client->pixmap()); double dh = (double)height()/(double)image.height(); double dw = (double)width()/(double)image.width(); double d = ( dh < dw ? dh : dw ); image.convertFromImage(image.convertToImage().smoothScale(int(d*image.width()), int (d*image.height()))); _client->setImagePix( image ); emit imageSizeChanged(); } void KImageCanvas::copyImage( QPaintDevice *dest ) const { QPainter painter( dest ); painter.drawPixmap( 0, 0, *(_client->pixmap()) ); } void KImageCanvas::mouseReleaseEvent( QMouseEvent *ev ) { // wheel support // maybe one day this will work... #if 0 switch ( ev->button() ) { case 4: lineUp(); break; case 5: lineDown(); break; default: QScrollView::mouseReleaseEvent( ev ); } #else QScrollView::mouseReleaseEvent( ev ); #endif } /* ****************************** * KVImageHolder implementation */ KVImageHolder::KVImageHolder( QWidget *parent ) : QLabel( parent ), _selected( false ), _painter( new QPainter ), _pen( new QPen( QColor( 255, 255, 255 ), 0, DashLine ) ) { assert( _painter != 0 ); } KVImageHolder::~KVImageHolder() { delete _painter; delete _pen; } void KVImageHolder::mousePressEvent( QMouseEvent *ev ) { if ( ev->button() == RightButton ) { emit contextPress( mapToGlobal( ev->pos() ) ); return; } if( pixmap() == 0 ) { return; } if( _selected ) { // remove old rubberband eraseSelect(); _selected = false; } _selection.setLeft( ev->x() ); _selection.setTop( ev->y() ); } void KVImageHolder::mouseMoveEvent( QMouseEvent *ev ) { // currently called only on drag, // so assume a selection has been started bool erase = _selected; if( !_selected ) { _selected = true; } int r = (ev->x() < width()) ? ev->x() : width() - 1; int b = (ev->y() < height()) ? ev->y() : height() - 1; if( r != _selection.right() || b != _selection.bottom() ) { if ( erase ) eraseSelect(); _selection.setRight( r ); _selection.setBottom( b ); drawSelect(); } } void KVImageHolder::drawSelect() { _painter->begin( this ); _painter->setRasterOp( XorROP ); _painter->setPen( *_pen ); _painter->drawRect( _selection ); _painter->end(); } void KVImageHolder::eraseSelect() { QRect r = _selection.normalize(); bitBlt( this, r.left(), r.top(), pixmap(), r.left(), r.top(), r.width(), r.height(), CopyROP ); } void KVImageHolder::paintEvent( QPaintEvent *ev ) { QLabel::paintEvent( ev ); if( _selected ) { drawSelect(); } } QRect KVImageHolder::selected() const { if( !_selected ) { return QRect(); } return _selection.normalize(); } void KVImageHolder::setImagePix( const QPixmap& pix ) { clearSelection(); setPixmap( pix ); resize( pix.size() ); } - +#include "canvas.moc" diff --git a/kview/colour.cpp b/kview/colour.cpp index 94c6763..2fe1242 100644 --- a/kview/colour.cpp +++ b/kview/colour.cpp @@ -1,321 +1,323 @@ /* * colour.cpp -- Implementation of class ColourFilter. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Tue Sep 22 02:26:05 EST 1998 */ #include #include"numdlg.h" #include"colour.h" #include"kapp.h" #include"kcproc.h" static void modifyIntensity( QImage& image, double factor ); // Brightness Filter void BriteFilter::invoke( QImage before ) { if ( before.depth() < 32 ) { warning( "cannot use rgb for image of depth %d", before.depth() ); return; } KNumDialog dlg; double pct = _pct; if( !dlg.getNum( pct, i18n( "Enter brightness factor (%):" ) )) { return; } if( !(pct > 0 ) ) { emit message( i18n( "Brightness factor must be positive") ); return; } _pct = pct; pct /= 100; emit status( i18n( "Changing brightness..." ) ); QApplication::setOverrideCursor( waitCursor ); QImage newimage = before; modifyIntensity( newimage, pct ); QApplication::restoreOverrideCursor(); emit changed( newimage ); emit status( 0 ); } const char *BriteFilter::name() const { return i18n( "Intensity:Brightness" ); } KImageFilter *BriteFilter::clone() const { return new BriteFilter; } static void modifyIntensity( QImage& image, double delta ) { for( int y = 0; y < image.height(); y++ ) { QRgb *clr = (QRgb *) image.scanLine( y ); for( int x = image.width(); x != 0; x--, clr++ ) { double red = qRed(*clr); double green = qGreen(*clr); double blue = qBlue(*clr); if( !KColourProc::toHSV( red, green, blue ) ) continue; // blue is intensity, so modify blue *= delta; if( blue > 1 || blue < 0 ) { continue; } KColourProc::toRGB( red, green, blue ); *clr = qRgb( (int)red, (int)green, (int)blue ); } } } // // Greyscale filter // void GreyFilter::invoke( QImage before ) { int olddepth = 0; emit status( i18n( "Converting to Greyscale..." ) ); QApplication::setOverrideCursor( waitCursor ); if ( before.depth() < 32 ) { olddepth = before.depth(); before.convertDepth( 32 ); } int cells = before.height() * before.width(); QRgb *c = (QRgb *)before.bits(); for( int y = cells; y ; y--, c++ ) { int g = qGray( *c ); *c = qRgb( g, g, g ); } if ( olddepth != 0 ) { before.convertDepth( olddepth ); } QApplication::restoreOverrideCursor(); emit changed( before ); emit status( 0 ); } const char *GreyFilter::name() const { return i18n( "Greyscale" ); } KImageFilter *GreyFilter::clone() const { return new GreyFilter; } // // Smoothen filter // void SmoothFilter::invoke( QImage before ) { int olddepth = 0; int delta[ 8 ]; int i; emit status( i18n( "Smoothing..." ) ); QApplication::setOverrideCursor( waitCursor ); QImage after = before; if ( after.depth() < 32 ) { olddepth = after.depth(); after.convertDepth( 32 ); } // init delta table delta[ 0 ] = - (after.width() - 1); delta[ 1 ] = - after.width(); delta[ 2 ] = - ( after.width() + 1); delta[ 3 ] = - 1; for( i = 0; i < 4; i ++ ) delta[ i + 4 ] = - delta[ i ]; int cells = after.height() * after.width(); QRgb *c = (QRgb *)after.bits(); setMaxProgress( cells ); for( int y = 0; y < cells ; y++, c++ ) { int r = qRed( *c ); int g = qGreen( *c ); int b = qBlue( *c ); int cnt = 1; for ( i = 0; i < 8; i ++ ) { int v = y + delta[ i ]; if ( v >= 0 && v < cells ) { r += qRed( *( c + delta[ i ]) ); g += qGreen( *( c + delta[ i ]) ); b += qBlue( *( c + delta[ i ]) ); cnt++; } } if ( cnt > 1 ) { *c = qRgb( r / cnt, g / cnt, b / cnt ); } if ( y % 50000 == 0 ) { setProgress( y ); qApp->processEvents( 100 ); } } if ( olddepth != 0 ) { after.convertDepth( olddepth ); } QApplication::restoreOverrideCursor(); setProgress( 0 ); emit changed( after ); emit status( 0 ); } const char *SmoothFilter::name() const { return i18n( "Smooth" ); } KImageFilter *SmoothFilter::clone() const { return new SmoothFilter; } // // Gamma filter // void GammaFilter::invoke( QImage before ) { // get gamma value KNumDialog dlg; KColourProc color; double gamma = 1.0; if( !dlg.getNum( gamma, i18n( "Enter gamma value ( >0 ):" ) ) || gamma < 0 ) { emit message( i18n( "Bad Gamma value" ) ); return; } // new image emit status( i18n( "Gamma-correcting..." ) ); QApplication::setOverrideCursor( waitCursor ); QImage after = before; int olddepth = 0; if ( after.depth() < 32 ) { olddepth = after.depth(); after.convertDepth( 32 ); } int cells = after.height() * after.width(); QRgb *c = (QRgb *)after.bits(); setMaxProgress( cells ); color.setGamma( gamma ); // calc gamma for each image for( int y = 0; y < cells ; y++, c++ ) { int r = qRed( *c ); int g = qGreen( *c ); int b = qBlue( *c ); // debug( "before: ( %d, %d, %d )", r, g, b ); color.gammaCorrect( r, g, b ); // debug( "after: ( %d, %d, %d )", r, g, b ); *c = qRgb( r, g, b ); if ( y % 50000 == 0 ) { setProgress( y ); qApp->processEvents( 100 ); } } if ( olddepth != 0 ) { after.convertDepth( olddepth ); } // reset viewer QApplication::restoreOverrideCursor(); setProgress( 0 ); emit changed( after ); emit status( 0 ); } const char *GammaFilter::name() const { return i18n( "Intensity:Gamma Correct..." ); } KImageFilter *GammaFilter::clone() const { return new GammaFilter; } // // Shell filter // const char *ShellFilter::name() const { return i18n( "External.." ); } KImageFilter *ShellFilter::clone() const { return new ShellFilter; } void ShellFilter::invoke( QImage ) { // TODO: stub } + +#include "colour.moc" diff --git a/kview/filter.cpp b/kview/filter.cpp index fe501a8..fe53de1 100644 --- a/kview/filter.cpp +++ b/kview/filter.cpp @@ -1,23 +1,25 @@ /* * filter.cpp -- Implementation of class KImageFilter. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Tue Apr 7 18:21:41 EST 1998 */ #include"filter.h" void KImageFilter::setMaxProgress( int max ) { _max = max; } void KImageFilter::setProgress( int val ) { if( _max == 0 ) return; long pct = ((long)val * 100) / (long)_max; emit progress( (int)pct ); } + +#include "filter.moc" diff --git a/kview/filtmenu.cpp b/kview/filtmenu.cpp index 2b560f1..a54e4b2 100644 --- a/kview/filtmenu.cpp +++ b/kview/filtmenu.cpp @@ -1,165 +1,167 @@ /* * filtmenu.cpp -- Implementation of class KFiltMenuFactory. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Fri Sep 25 05:13:29 EST 1998 */ #include"filtmenu.h" #include"filtlist.h" #include"filter.h" #include #include static int tokenize( QStrList& tokens, const QString& str, const char *separators ); KFiltMenuFactory::KFiltMenuFactory( KFilterList *filters, QObject *parent ) : QObject( parent ), _filters ( filters ), _menu ( 0 ), _lastMenuID( 1000 ), _menuList( new QList ), _menuDict( new QDict ) { assert( _menuList ); _menuList->setAutoDelete( true ); assert( _menuDict ); _menuDict->setAutoDelete( false ); } KFiltMenuFactory::~KFiltMenuFactory() { delete _menu; delete _menuList; delete _menuDict; } QPopupMenu *KFiltMenuFactory::filterMenu() { if( _menu == 0 ) { updateMenu(); } return _menu; } void KFiltMenuFactory::updateMenu() { // remove old menus _menuDict->clear(); _menuList->clear(); // create new ones if( _menu == 0 ) { _menu = new QPopupMenu( 0, "Filters" ); connect( _menu, SIGNAL(activated(int)), this, SLOT(raiseFilter(int)) ); } else { _menu->clear(); } // find or create path to dest menu, starting at _menu for( int i = 0; i < _filters->count(); i++ ) { KImageFilter *filter = _filters->filter( i ); QString token, name; QPopupMenu *menu = getItemMenu( name, _menu, filter->name() ); if( menu == 0 ) { warning( "couldn't get menu for %s", filter->name() ); continue; } menu->insertItem( name, i ); } } void KFiltMenuFactory::raiseFilter( int index ) { KImageFilter *filter = _filters->filter( index ); if( filter == 0 ) { warning( "KFiltMenuFactory:: raiseFilter: " "invalid index %d", index ); return; } emit selected( filter ); } static int tokenize( QStrList& tokens, const QString& str, const char *separators ) { tokens.clear(); if( str.length() == 0 ) { return 0; } unsigned start = 0, i = 0; for( ; i < str.length(); i++ ) { if ( strchr( separators, str[ i ] ) != 0 ) { // found separator tokens.append( str.mid( start, i - start ) ); start = i + 1; } } if ( start < i ) { tokens.append( str.mid( start, i - start) ); } return tokens.count(); } QPopupMenu *KFiltMenuFactory::getItemMenu( QString& name, QPopupMenu *parent, const QString& fullname ) { QPopupMenu *menu = 0; QStrList tokens; int count = tokenize( tokens, fullname, ":" ); if( count <= 1 ) { name = count ? fullname.data() : ""; return parent; } QString accum; int i = 0; for( ; i < count - 1; i++ ) { accum += tokens.at( i ); accum += ':'; menu = _menuDict->find( accum ); if( menu == 0 ) { menu = new QPopupMenu; _menuList->append( menu ); _menuDict->insert( accum, menu ); connect( menu, SIGNAL(activated(int)), this, SLOT(raiseFilter(int)) ); parent->insertItem( tokens.current(), menu, _lastMenuID++ ); parent = menu; } } name = tokens.at( i ); return menu; } + +#include "filtmenu.moc" diff --git a/kview/ilistdlg.cpp b/kview/ilistdlg.cpp index 16319b4..ae72db8 100644 --- a/kview/ilistdlg.cpp +++ b/kview/ilistdlg.cpp @@ -1,398 +1,400 @@ /* * ilistdlg.cpp -- Implementation of class ImgListDlg. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Wed Sep 23 16:04:52 EST 1998 */ #include #include #include #include #include #include #include #include #include #include #include #include"numdlg.h" #include"typolayout.h" #include"ilistdlg.h" ImgListDlg::ImgListDlg( QWidget *parent ) : QWidget( parent ), _slideTimer( 0 ), // allocated by slide start _slideInterval( 5 ), _loop ( false ), _paused( false ), _list( new QStrList( true ) ), // deep copies _listBox( 0 ) { // drop events KDNDDropZone *dropZone = new KDNDDropZone( this, DndURL ); connect( dropZone, SIGNAL(dropAction(KDNDDropZone *)), this, SLOT(dropEvent(KDNDDropZone*)) ); // layout KTypoLayout *layout = new KTypoLayout( this ); layout->setHSpace( 5, 0 ); layout->setVSpace( 5, 5 ); layout->setGridSize( 4, 1 ); _listBox = layout->newListBox( 0, 0, 3, 1 ); // list connect( _listBox, SIGNAL(selected(int)), this, SLOT(select(int)) ); layout = layout->newSubLayout( 3, 0, 1, 1 ); layout->setGridSize( 1, 8 ); // up btn QPushButton *up = layout->newButton( i18n("Prev"), 0, 1, 1, 1 ); connect( up, SIGNAL(clicked()), this, SLOT(prev()) ); // shuffle QPushButton *shuffle = layout->newButton( i18n("Shu&ffle"), 0, 2, 1, 1 ); connect( shuffle, SIGNAL(clicked()), this, SLOT(shuffle()) ); // down btn QPushButton *down = layout->newButton( i18n("Next"), 0, 3, 1, 1 ); connect( down, SIGNAL(clicked()), this, SLOT(next()) ); // slide start btn _slideButton = layout->newButton( i18n("Start slide"), 0, 5, 1, 1 ); connect( _slideButton, SIGNAL(clicked()), this, SLOT(toggleSlideShow()) ); // accelerators QAccel *accel = new QAccel( this ); accel->connectItem( accel->insertItem( Key_Escape ), this, SLOT(hide()) ); // caption QString cap = kapp->appName(); cap.detach(); cap += ": "; cap += i18n( "Image List" ); setCaption( cap ); srand( time(0) ); } ImgListDlg::~ImgListDlg() { delete _slideTimer; _slideTimer = 0; delete _list; _list = 0; } void ImgListDlg::addURL( const char *url, bool show ) { if ( url == 0 ) { return; } if ( !show ) { // append only, don't display int current = _list->at(); _list->append( url ); _listBox->insertItem( url ); _list->at( current ); _listBox->setCurrentItem( current ); } else { // append and display _list->append( url ); _listBox->insertItem( url ); emit selected( _list->current() ); } } void ImgListDlg::first() { if( _list->current() == 0 ) { return; } const char *str = _list->first(); if( str ) { _listBox->setCurrentItem( _list->at() ); emit selected( str ); } } void ImgListDlg::last() { if( _list->current() == 0 ) { return; } const char *str = _list->last(); if( str ) { _listBox->setCurrentItem( _list->count() - 1 ); emit selected( str ); } else { _list->first(); } } void ImgListDlg::prev() { if( _list->current() == 0 ) { return; } const char *str = _list->prev(); if( str ) { _listBox->setCurrentItem( _list->at() ); emit selected( str ); } else { _list->first(); } } void ImgListDlg::next() { if( _list->current() == 0 ) { return; } const char *str = _list->next(); if( str ) { _listBox->setCurrentItem( _list->at() ); emit selected( str ); } else { _list->last(); } } void ImgListDlg::dropEvent( KDNDDropZone *drop ) { addURLList( drop->getURLList() ); } void ImgListDlg::addURLList( const QStrList& list ) { QStrListIterator iter( list ); if ( iter.current() ) { // queue net load addURL( iter.current() ); _listBox->setAutoUpdate( false ); while( ++iter ) { addURL( iter.current(), false ); } _listBox->setAutoUpdate( true ); _listBox->repaint(); } } void ImgListDlg::select( int idx ) { if( idx < 0 || (unsigned)idx > _list->count() ) { return; } emit selected( _list->at( idx ) ); } void ImgListDlg::shuffle() { QStrList newlist; int c = _list->count(); // fill list with randomized items for( int i = c; i > 0; --i ) { int idx = (int) ( ((double)i * (double)rand()) / (RAND_MAX+1.0) ); newlist.append( _list->at( idx ) ); _list->remove( idx ); } // refill listbox _listBox->clear(); addURLList( newlist ); } void ImgListDlg::startSlideShow() { if( _list->count() == 0 ) { // no images to show return; } if( _slideTimer == 0 ) { _slideTimer = new QTimer( this, "Slideshow Timer" ); connect( _slideTimer, SIGNAL(timeout()), this, SLOT(nextSlide()) ); } if( !_slideTimer->isActive() ) { nextSlide(); _slideTimer->start( _slideInterval * 1000 ); _slideButton->setText( i18n( "Stop &slide" ) ); } } void ImgListDlg::stopSlideShow() { if( _slideTimer->isActive() ) { _slideTimer->stop(); _slideButton->setText( i18n( "Start &slide" ) ); } } void ImgListDlg::setSlideInterval( int seconds ) { if( seconds == _slideInterval ) return; _slideInterval = seconds; if( _slideTimer !=0 && _slideTimer->isActive() ) { _slideTimer->changeInterval( seconds * 1000 ); } } void ImgListDlg::nextSlide() { if( _list->current() == _list->getLast() ) { if ( _loop ) { first(); } else { stopSlideShow(); } } else { next(); } } void ImgListDlg::toggleSlideShow() { if( _slideTimer && _slideTimer->isActive() ) { stopSlideShow(); } else { startSlideShow(); } } void ImgListDlg::pauseSlideShow() { if ( slideShowRunning() ) { _slideTimer->stop(); _paused = true; } } void ImgListDlg::continueSlideShow() { if ( _paused ) { _slideTimer->start( _slideInterval * 1000 ); _paused = false; } } void ImgListDlg::saveProperties( KConfig *cfg ) { // slideshow settings cfg->writeEntry( "SlideInterval", _slideInterval ); cfg->writeEntry( "SlideLoop", _loop ); // url list cfg->writeEntry( "ListNumUrls", _list->count() ); QString tag, num; int i = 0; for( _list->first(); _list->current(); _list->next(), i++ ) { tag = "ListUrl"; num.setNum( i ); tag += num; cfg->writeEntry( tag, _list->current() ); } // geometry cfg->writeEntry( "ListWinSize" , size() ); cfg->writeEntry( "ListWinPos" , pos() ); cfg->writeEntry( "ListVisible", isVisible() ); } void ImgListDlg::restoreProperties( KConfig *cfg ) { _slideInterval = cfg->readNumEntry( "SlideInterval", 5 ); _loop = cfg->readBoolEntry( "SlideLoop", false ); int urlCount = cfg->readNumEntry( "ListNumUrls", 0 ); QString tag, num; for( int i = 0; i < urlCount; i++ ) { // load each image tag = "ListUrl"; num.setNum( i ); tag += num; if( !cfg->hasKey( tag ) ) { continue; } QString url = cfg->readEntry( tag ); addURL( url, (i == 0) ); } // geometry if( cfg->hasKey( "ListWinSize" ) ) { resize( cfg->readSizeEntry( "ListWinSize") ); } if( cfg->hasKey( "ListWinPos" ) ) { move( cfg->readPointEntry( "ListWinPos" ) ); } if ( cfg->readBoolEntry( "ListVisible", false ) ) { show(); } } void ImgListDlg::saveOptions( KConfig *cfg ) const { cfg->writeEntry( "SlideInterval", _slideInterval ); cfg->writeEntry( "SlideLoop", _loop ); } void ImgListDlg::restoreOptions( const KConfig *cfg ) { _slideInterval = cfg->readNumEntry( "SlideInterval", 5 ); _loop = cfg->readBoolEntry( "SlideLoop", false ); } + +#include "ilistdlg.moc" diff --git a/kview/kaccelmenuwatch.cpp b/kview/kaccelmenuwatch.cpp index b61e1b7..456446a 100644 --- a/kview/kaccelmenuwatch.cpp +++ b/kview/kaccelmenuwatch.cpp @@ -1,115 +1,117 @@ /* * kaccelmenuwatch.cpp -- Implementation of class KAccelMenuWatch. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Thu Jan 7 15:05:26 EST 1999 */ #include #include"kaccelmenuwatch.h" KAccelMenuWatch::KAccelMenuWatch( KAccel *accel, QObject *parent ) : QObject( parent ), _accel( accel ), _menu ( 0 ) { _accList.setAutoDelete( true ); _menuList.setAutoDelete( false ); } void KAccelMenuWatch::setMenu( QPopupMenu *menu ) { assert( menu ); // we use _menuList to ensure that the signal is // connected only once per menu. if ( !_menuList.findRef( menu ) ) { _menuList.append( menu ); connect( menu, SIGNAL(destroyed()), this, SLOT(removeDeadMenu()) ); } _menu = menu; } void KAccelMenuWatch::connectAccel( int itemId, const char *action ) { AccelItem *item = newAccelItem( _menu, itemId, StringAccel ) ; item->action = action; } void KAccelMenuWatch::connectAccel( int itemId, KAccel::StdAccel accel ) { AccelItem *item = newAccelItem( _menu, itemId, StdAccel ) ; item->stdAction = accel; } void KAccelMenuWatch::updateMenus() { assert( _accel != 0 ); QListIterator iter( _accList ); AccelItem *item; for( ; item = iter.current(); ++iter ) { switch( item->type ) { case StringAccel: _accel->changeMenuAccel( item->menu, item->itemId, item->action ); break; case StdAccel: _accel->changeMenuAccel( item->menu, item->itemId, item->stdAction ); break; default: break; } } } void KAccelMenuWatch::removeDeadMenu() { QPopupMenu *sdr = (QPopupMenu *) sender(); assert( sdr ); if ( !_menuList.findRef( sdr ) ) { return; } // remove all accels AccelItem *accel; for ( accel = _accList.first(); accel; accel = _accList.next() ) { loop: if( accel && accel->menu == sdr ) { _accList.remove(); accel = _accList.current(); goto loop; } } // remove from menu list _menuList.remove( sdr ); return; } KAccelMenuWatch::AccelItem *KAccelMenuWatch::newAccelItem( QPopupMenu *menu, int itemId, AccelType type ) { AccelItem *item = new AccelItem; item->menu = _menu; item->itemId = itemId; item->type = type; _accList.append( item ); return item; } + +#include "kaccelmenuwatch.moc" diff --git a/kview/kview.cpp b/kview/kview.cpp index d767d12..48a7c9b 100644 --- a/kview/kview.cpp +++ b/kview/kview.cpp @@ -1,154 +1,156 @@ /* * kview.cpp -- Implementation of class KView. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Wed Oct 15 01:26:27 EST 1997 */ #ifdef CORBA #include"kmicoapp.h" #else #include #endif #include #include"kview.h" #include"viewer.h" #include #include #include"filter.h" #include"filtlist.h" #include"filtmenu.h" #include"colour.h" #include"khelpidx.h" KView::KView(int argc, char **argv) : QObject( 0 ), _app( argc, argv, "kview" ), _filters( new KFilterList ), _helper( new KHelpIndex( "kview/kview.index" ) ), _viewers( new QList ), _filtMenus( new QPtrDict ), _cutBuffer( 0 ) { assert( _filters ); _viewers->setAutoDelete( true ); _filtMenus->setAutoDelete( true ); kimgioRegister(); registerBuiltinFilters(); } KView::~KView() { delete _viewers; _viewers = 0; delete _helper; _helper = 0; delete _filters; _filters = 0; delete _filtMenus; _filtMenus = 0; } int KView::exec() { if( _app.isRestored() ) { // restore saved viewers for ( int i = 1; KTopLevelWidget::canBeRestored( i ); i++ ) { makeViewer()->restore( i ); } } else { KImageViewer *viewer = makeViewer(); viewer->show(); // process arguments only if not restored for( int i = 1; i <= _app.argc(); i++ ) { viewer->appendURL( _app.argv()[ i ], (i == 1) ); } } return _app.exec(); } void KView::registerBuiltinFilters() { _filters->registerFilter( new BriteFilter, KFilterList::AutoDelete ); _filters->registerFilter( new GreyFilter, KFilterList::AutoDelete ); _filters->registerFilter( new SmoothFilter, KFilterList::AutoDelete ); _filters->registerFilter( new GammaFilter, KFilterList::AutoDelete ); } void KView::help( const char *tag ) { assert( _helper ); _helper->invoke( tag ); } void KView::newViewer() { KImageViewer *viewer = makeViewer(); viewer->show(); } KImageViewer *KView::makeViewer() { KImageViewer *viewer = new KImageViewer; if( viewer == 0 ) return 0; KFiltMenuFactory *menu = new KFiltMenuFactory( _filters ); viewer->setFilterMenu( menu ); _viewers->append( viewer ); _filtMenus->insert( viewer, menu ); connect( viewer, SIGNAL(wantHelp( const char *)), this, SLOT(help(const char *)) ); connect( viewer, SIGNAL(wantNewViewer()), this, SLOT(newViewer()) ); connect( viewer, SIGNAL(wantToDie(KImageViewer *)), this, SLOT(closeViewer(KImageViewer *)) ); connect( viewer, SIGNAL(accelChanged()), this, SLOT( updateAllAccels()) ); return viewer; } void KView::closeViewer( KImageViewer *viewer ) { assert( viewer != 0 ); _filtMenus->remove( viewer ); _viewers->remove( viewer ); if( _viewers->count() == 0 ) { kapp->quit(); } } void KView::setCutBuffer( QPixmap *image ) { if( _cutBuffer ) { delete _cutBuffer; _cutBuffer = 0; } } void KView::updateAllAccels() { QListIterator iter( *_viewers ); for( ; iter.current(); ++iter ) { iter.current()->updateAccel(); } } + +#include "kview.moc" diff --git a/kview/prefdlg.cpp b/kview/prefdlg.cpp index 9b12780..7c78225 100644 --- a/kview/prefdlg.cpp +++ b/kview/prefdlg.cpp @@ -1,112 +1,114 @@ /* * prefdlg.cpp -- Implementation of class KViewPrefDlg. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Fri Jan 1 16:15:08 EST 1999 */ #include #include #include #include #include #include #include #include #include"typolayout.h" #include"prefdlg.h" KViewPrefDlg::KViewPrefDlg( KConfig *cfg, KAccel *accel, QWidget *parent ) : QTabDialog( parent, "PrefDlg", true ), _cfg( cfg ), _accel( accel ), _dict( _accel->keyDict() ), _keysDirty( false ) { assert( cfg ); // tabdlg settings setCaption( i18n( "kView Preferences" ) ); setCancelButton( i18n( "&Cancel" ) ); setOkButton( i18n( "&OK" ) ); setApplyButton( i18n( "&Apply" ) ); connect( this, SIGNAL(applyButtonPressed()), this, SLOT(applySettings()) ); // General options QWidget *optw = new QWidget( this ); assert( optw ); KTypoLayout *l = new KTypoLayout( optw ); l->setGridSize( 1, 2 ); // load prefs KTypoLayout *sl = l->newSubGroup( i18n( "On Load" ), 0, 0 ); sl->setGridSize( 1, 3 ); KConfigGroupSaver saver( _cfg, "kview" ); QString lmode = cfg->readEntry( "LoadMode", "ResizeWindow" ); sl->startGroup(); _rw = sl->newRadioButton( i18n("Resize Window"), 0, 0 ); _rw->setChecked( !stricmp( lmode, "ResizeWindow") ); _ri = sl->newRadioButton( i18n("Resize Image"), 0, 1 ); _ri->setChecked( !stricmp( lmode, "ResizeImage") ); _rn = sl->newRadioButton( i18n("No Resize"), 0, 2 ); _rn->setChecked( !stricmp( lmode, "ResizeNone") ); // slideshow prefs sl = l->newSubGroup( i18n( "Slideshow" ), 0, 1 ); sl->setGridSize( 3, 2 ); _loop = sl->newCheckBox( i18n( "Loop" ), 0, 0, 3, 1 ); _interval = sl->newLineEdit( cfg->readEntry( "SlideInterval", "5" ), 0, 1 ); sl->newLabel( i18n( "Slide interval (sec)" ), 1, 1, 2, 1 ); addTab( optw, i18n( "&Options" ) ); // Key bindings KKeyChooser *chooser = new KKeyChooser( &_dict, this, false ); connect( chooser, SIGNAL(keyChange()), this, SLOT(setKeysDirty()) ); addTab( chooser, i18n( "&Keys" ) ); } void KViewPrefDlg::applySettings() { KConfigGroupSaver saver( _cfg, "kview" ); _cfg->writeEntry( "SlideLoop", _loop->isChecked() ); _cfg->writeEntry( "SlideInterval", _interval->text() ); const char *lmode = 0; if( _rw->isChecked() ) { lmode = "ResizeWindow"; } else if ( _ri->isChecked() ) { lmode = "ResizeImage"; } else if ( _rn->isChecked() ) { lmode = "ResizeNone"; } assert( lmode ); _cfg->writeEntry( "LoadMode", lmode ); if ( _keysDirty ) { _accel->setKeyDict( _dict ); _accel->writeSettings( _cfg ); } } + +#include "prefdlg.moc" diff --git a/kview/layout/typolayout.cpp b/kview/typolayout.cpp similarity index 99% rename from kview/layout/typolayout.cpp rename to kview/typolayout.cpp index 5b60ba8..546d2db 100644 --- a/kview/layout/typolayout.cpp +++ b/kview/typolayout.cpp @@ -1,156 +1,158 @@ /* * typolayout.cpp -- Implementation of class KTypoLayout. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Tue May 5 01:12:37 EST 1998 */ #include"baglayout.h" #include"typolayout.h" #include #include #include #include #include #include #include #include #include #include KTypoLayout::KTypoLayout( QWidget *parent ) : KBagLayout( parent ) { assert( parent ); _parent = parent; _group = 0; } QLabel *KTypoLayout::newLabel( const char *text, int x, int y, int xspan, int yspan ) { QLabel *w = new QLabel( text, _parent ); addWidget( w, x, y, xspan, yspan ); return w; } QPushButton *KTypoLayout::newButton( const char *text, int x, int y, int xspan, int yspan ) { QPushButton *w = new QPushButton( text, _parent ); addWidget( w, x, y, xspan, yspan ); if( _group ) { _group->insert( w ); } return w; } QRadioButton *KTypoLayout::newRadioButton( const char *text, int x, int y, int xspan, int yspan ) { QRadioButton *w = new QRadioButton ( text, _parent ); addWidget( w, x, y, xspan, yspan ); if( _group ) { _group->insert( w ); } return w; } QLineEdit *KTypoLayout::newLineEdit( const char *text, int x, int y, int xspan, int yspan ) { QLineEdit * w = new QLineEdit( _parent ); w->setText( text ); KBagConstraints *c = addWidget( w, x, y, xspan, yspan ); // line edits should only be resize horizontally by default c->setResizePolicy( KBagConstraints::Horizontal ); return w; } QMultiLineEdit *KTypoLayout::newMultiLineEdit( const char *text, int x, int y, int xspan, int yspan ) { QMultiLineEdit * w = new QMultiLineEdit( _parent ); w->setText( text ); addWidget( w, x, y, xspan, yspan ); return w; } QCheckBox *KTypoLayout::newCheckBox( const char *text, int x, int y, int xspan, int yspan ) { QCheckBox *w = new QCheckBox ( text, _parent ); addWidget( w, x, y, xspan, yspan ); if( _group ) { _group->insert( w ); } return w; } QListBox *KTypoLayout::newListBox( int x, int y, int xspan, int yspan) { QListBox *w = new QListBox( _parent ); addWidget( w, x, y, xspan, yspan ); return w; } KTypoLayout *KTypoLayout::newSubLayout( int x, int y, int xspan, int yspan ) { QWidget *holder = new QWidget( _parent ); addWidget( holder, x, y, xspan, yspan ); KTypoLayout *sublayout = new KTypoLayout( holder ); return sublayout; } KTypoLayout *KTypoLayout::newSubGroup( const char *title, int x, int y, int xspan, int yspan ) { QGroupBox *holder = new QGroupBox( title, _parent ); holder->setLineWidth( 1 ); holder->setFrameStyle( QFrame::Box | QFrame::Raised ); addWidget( holder, x, y, xspan, yspan ); KTypoLayout *sublayout = new KTypoLayout( holder ); sublayout->setSpaceContents( holder ); return sublayout; } QButtonGroup *KTypoLayout::startGroup() { _group = new QButtonGroup( _parent ); _group->hide(); return _group; } void KTypoLayout::endGroup() { _group = 0; } + +#include "typolayout.moc" diff --git a/kview/layout/typolayout.h b/kview/typolayout.h similarity index 100% rename from kview/layout/typolayout.h rename to kview/typolayout.h diff --git a/kview/viewer.cpp b/kview/viewer.cpp index 6c19ad3..24f7571 100644 --- a/kview/viewer.cpp +++ b/kview/viewer.cpp @@ -1,1016 +1,1018 @@ /* * viewer.cpp -- Implementation of class KImageViewer. * Author: Sirtaj Singh Kang * Version: $Id$ * Generated: Wed Oct 15 11:37:16 EST 1997 */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include"viewer.h" #include"canvas.h" #include"version.h" #include"numdlg.h" #include"prefdlg.h" #include"filter.h" #include"filtmenu.h" #include"filtlist.h" #include"ilistdlg.h" enum { StatProgress, StatStatus }; const int MessageDelay = 3000; KImageViewer::KImageViewer() : KTopLevelWidget(), _imageLoaded( false ), _kaccel( new KAccel( this ) ), _paccel( new QAccel( this ) ), _watcher( new KAccelMenuWatch( _kaccel, this ) ), _file( 0 ), _edit( 0 ), _zoom( 0 ), _transform( 0 ), _desktop( 0 ), _aggreg( 0 ), _help( 0 ), _barFilterID( 0 ), _popFilterID( 0 ), _kfm( 0 ), _transSrc( 0 ), _transDest( 0 ), _menuFact( 0 ), _pctBuffer( new QString ), _lastPct( - 1 ), _msgTimer( 0 ), _imageList( new ImgListDlg ), _zoomFactor( 100 ), _loadMode ( ResizeWindow ) { // Image canvas _canvas = new KImageCanvas( this ); connect(_canvas, SIGNAL( contextPress(const QPoint&) ), this, SLOT ( contextPress(const QPoint&) )); assert( _canvas ); setView( _canvas, FALSE ); // Caption QString cap; cap = kapp->appName().data(); cap += " - "; cap += i18n( "no image loaded" ); setCaption( cap ); // status bar _statusbar = new KStatusBar( this ); setStatusBar( _statusbar ); _statusbar->insertItem( " ", StatProgress ); _statusbar->insertItem( i18n( "Ready" ), StatStatus ); // list dialog connect( _imageList, SIGNAL(selected(const char *)), this, SLOT(loadURL(const char *)) ); // accelerators makeAccel(); // Drop events forwarded to image list object KDNDDropZone *dropObserver = new KDNDDropZone( this, DndURL ); QObject::connect( dropObserver, SIGNAL(dropAction(KDNDDropZone *)), _imageList, SLOT(dropEvent(KDNDDropZone *)) ); restoreOptions( kapp->getConfig() ); } KImageViewer::~KImageViewer() { delete _canvas; _canvas = 0; delete _file; delete _edit; delete _zoom; delete _transform; delete _desktop; delete _aggreg; delete _help; delete _contextMenu; delete _pctBuffer; delete _imageList; delete _kfm; _kfm = 0; delete _transSrc; _transSrc = 0; delete _transDest; _transDest = 0; } void KImageViewer::load() { KFileDialog dlg( "", 0, 0, 0, true, true ); QString URL = dlg.getOpenFileURL(); if( URL.length() <= 0 ) { return; } _imageList->addURL( URL ); } void KImageViewer::saveAs() { KFileDialog dlg( "", 0, 0, 0, true, false ); QString urls = dlg.getSaveFileURL(); if ( urls.length() <= 0 ) { return; } KURL url( urls ); bool stat = false; if( url.isMalformed() ) { stat = _canvas->save( urls ); } else if( url.isLocalFile() ) { stat = _canvas->save( url.path() ); } else { message( i18n("Net saving not yet implemented") ); } if( stat == false ) { return; } QString msg = urls; ksprintf( &msg, i18n( "%s: written" ), urls.data() ); message( msg ); } void KImageViewer::zoomIn10() { _mat.scale( 1.1, 1.1 ); _canvas->transformImage( _mat ); } void KImageViewer::zoomOut10() { _mat.scale( 0.9, 0.9 ); _canvas->transformImage( _mat ); } void KImageViewer::zoomIn200() { _mat.scale( 2.0, 2.0 ); _canvas->transformImage( _mat ); } void KImageViewer::zoomOut50() { _mat.scale( 0.5, 0.5 ); _canvas->transformImage( _mat ); } void KImageViewer::zoomCustom() { KNumDialog num; _zoomFactor = (int)(_mat.m11() * 100); if( !num.getNum( _zoomFactor, i18n( "Enter Zoom factor (100 = 1x):" ) ) ) return; if( _zoomFactor <= 0 ) { message( i18n( "Illegal zoom factor" ) ); return; } double val = (double)_zoomFactor/100; _mat.reset(); _mat.scale( val, val ); _canvas->transformImage( _mat ); } void KImageViewer::rotateClock() { _mat.rotate( 90 ); _canvas->transformImage( _mat ); } void KImageViewer::rotateAntiClock() { _mat.rotate( -90 ); _canvas->transformImage( _mat ); } void KImageViewer::flipVertical() { QWMatrix m( 1.0F, 0.0F, 0.0F, -1.0F, 0.0F, 0.0F ); _mat *= m; _canvas->transformImage( _mat ); } void KImageViewer::flipHorizontal() { QWMatrix m( -1.0F, 0.0F, 0.0F, 1.0F, 0.0F, 0.0F ); _mat *= m; _canvas->transformImage( _mat ); } void KImageViewer::help() { kapp->invokeHTMLHelp( "kview/kview.html", "" ); } void KImageViewer::about() { QString aboutText; aboutText.sprintf( i18n( "KView -- Graphics viewer. %s\n" "\nSirtaj S. Kang (taj@kde.org)\n" ), KVIEW_VERSION ); QMessageBox::about( this, i18n("About KView"), aboutText ); } void KImageViewer::makeRootMenu(QPopupMenu *menu) { /* menu->insertItem( i18n( "&File" ), _file ); menu->insertItem( i18n( "&Edit" ), _edit ); menu->insertItem( i18n( "&Zoom" ), _zoom ); menu->insertItem( i18n( "&Transform" ), _transform ); menu->insertItem( i18n( "To &Desktop"), _desktop ); _popFilterID = menu->insertItem( i18n( "Fi<er"), _menuFact->filterMenu() ); menu->setItemEnabled( _popFilterID, false ); menu->insertItem( i18n( "&Options" ), _aggreg ); menu->insertSeparator(); menu->insertItem( i18n( "&Help" ), _help ); */ _watcher->setMenu( menu ); conn( i18n("&List..."), "ImageList", this, SLOT(toggleImageList()) ); menu->insertSeparator(); conn( i18n("&Previous"), "Prev", _imageList, SLOT(prev()), Key_Backspace ); conn( i18n("&Next"), "Next", _imageList, SLOT(next()), Key_Tab ); menu->insertSeparator(); conn( i18n("&Slideshow On/Off"), "Slideshow", _imageList, SLOT(toggleSlideShow()), Key_S ); } void KImageViewer::makeRootMenu(KMenuBar *menu) { menu->insertItem( i18n( "&File" ), _file ); menu->insertItem( i18n( "&Edit" ), _edit ); menu->insertItem( i18n( "&Zoom" ), _zoom ); menu->insertItem( i18n( "&Transform" ), _transform ); menu->insertItem( i18n( "To &Desktop"), _desktop ); _barFilterID = menu->insertItem( i18n( "F&ilter"), _menuFact->filterMenu() ); menu->setItemEnabled( _barFilterID, false ); menu->insertItem( i18n( "&Images" ), _aggreg ); menu->insertSeparator(); menu->insertItem( i18n( "&Help" ), _help ); } void KImageViewer::makePopupMenus() { _file = new QPopupMenu; _edit = new QPopupMenu; _zoom = new QPopupMenu; _transform = new QPopupMenu; _desktop = new QPopupMenu; _aggreg = new QPopupMenu; _help = new QPopupMenu; // file pulldown _watcher->setMenu( _file ); conn( i18n( "&Open..." ), KAccel::Open, this, SLOT(load()) ); conn( i18n( "&Save As..." ), KAccel::Save, this, SLOT(saveAs()) ); conn( i18n( "&Print..." ), KAccel::Print, this, SLOT(printImage())); _file->insertSeparator(); conn( i18n( "&New Window" ), KAccel::New, this, SLOT(newViewer())); conn( i18n( "&Close Window" ),KAccel::Close, this, SLOT(closeViewer())); _file->insertSeparator(); conn( i18n( "E&xit" ), KAccel::Quit, this, SLOT(quitApp()) ); // edit pulldown _watcher->setMenu( _edit ); conn( i18n( "&Full Screen" ), "FullScreen", this, SLOT(fullScreen()), Key_F ); _edit->insertSeparator(); conn( i18n( "&Crop" ), "Crop", _canvas, SLOT(cropImage()), Key_C ); _edit->insertSeparator(); conn( i18n( "&Reset"), "Reset", this, SLOT(reset()), CTRL + Key_R ); _edit->insertSeparator(); conn( i18n( "&Preferences..."), "Prefs", this, SLOT(prefs()), CTRL + Key_E ); // zoom pulldown _watcher->setMenu( _zoom ); conn( i18n( "&Zoom..." ), "Zoom", this, SLOT(zoomCustom()), Key_Z ); conn( i18n( "Zoom &in 10%" ), "ZoomIn10", this, SLOT(zoomIn10()), Key_Period ); conn( i18n( "Zoom &out 10%"), "ZoomOut10", this,SLOT(zoomOut10()), Key_Backspace ); conn( i18n( "&Double size" ), "ZoomIn200", this, SLOT(zoomIn200()), Key_BracketRight ); conn( i18n( "&Half size"), "ZoomOut50", this, SLOT(zoomOut50()), Key_BracketLeft ); conn( i18n( "&Max size"), "Max", _canvas, SLOT(maxToWin()), Key_M ); conn( i18n( "Max/&aspect"), "Maxpect", _canvas, SLOT(maxpectToWin()), Key_A ); // transform pulldown _watcher->setMenu( _transform ); conn( i18n( "Rotate &clockwise" ), "RotateC", this, SLOT(rotateClock()), Key_Semicolon ); conn( i18n( "Rotate &anti-clockwise" ), "RotateAC", this, SLOT(rotateAntiClock()), Key_Comma ); conn( i18n( "Flip &vertical" ), "FlipV", this, SLOT(flipVertical()), Key_V ); conn( i18n( "Flip &horizontal" ),"FlipH",this,SLOT(flipHorizontal()), Key_H ); // desktop pulldown _watcher->setMenu( _desktop ); conn( i18n( "Desktop &Tile" ), "TileToDesktop", this, SLOT(tile()) ); conn( i18n( "Desktop &Max" ), "MaxpectToDesktop", this, SLOT(max()) ); conn( i18n("Desktop Max&pect"), "MaxpToDesktop", this, SLOT(maxpect()) ); _watcher->setMenu( _aggreg ); int id = conn( i18n("&List..."), "ImageList", this, SLOT(toggleImageList()), Key_I ); _aggreg->setItemChecked( id, false ); _aggreg->insertSeparator(); conn( i18n("&Previous"), "Prev", _imageList, SLOT(prev()), Key_Backspace ); conn( i18n("&Next"), "Next", _imageList, SLOT(next()), Key_Tab ); _aggreg->insertSeparator(); _aggreg->insertItem( i18n("&Slideshow On/Off"), "Slideshow", _imageList, SLOT(toggleSlideShow()), Key_S ); _watcher->setMenu( _help ); conn( i18n( "&Contents" ), KAccel::Help, this, SLOT(help())); conn( i18n( "&How do I..." ), "HelpHow", this, SLOT(helpHow())); conn( i18n( "&What is a..." ), "HelpWhat", this, SLOT(helpWhat())); _help->insertSeparator(); conn( i18n( "&About KView..." ), "About", this, SLOT(about())); } void KImageViewer::quitApp() { KApplication::getKApplication()->quit(); } void KImageViewer::tile() { _canvas->tileToDesktop(); } void KImageViewer::max() { _canvas->maxToDesktop(); } void KImageViewer::maxpect() { _canvas->maxpectToDesktop(); } void KImageViewer::loadURL( const char *url ) { if( url == 0 ) { warning( "loadURL: called with null url" ); return; } KURL kurl( url ); if( kurl.isMalformed() ) { loadFile( url ); } else if( kurl.isLocalFile() ) { // local file - open with loadFile loadFile( kurl.path(), url ); } else { // connect to kfm if( _kfm != 0 ) { message( i18n( "Existing transfer not yet complete.")); return; } _kfm = new KFM; if( !_kfm || !_kfm->isKFMRunning() || !_kfm->isOK() ) { message( i18n( "Existing transfer not yet complete.")); return; } // save transfer files if( _transSrc == 0 ) _transSrc = new QString; if( _transDest == 0 ) _transDest = new QString; _transSrc->setStr( url ); _transDest->setStr( tempnam( 0, "kview_") ); if( _transSrc->isEmpty() || _transDest->isEmpty() ) { message( i18n( "Couldn't get temporary transfer name." ) ); return; } // start transfer connect( _kfm, SIGNAL( finished() ), this, SLOT( urlFetchDone() ) ); connect( _kfm, SIGNAL( error(int, const char *) ), this, SLOT( urlFetchError(int, const char *) ) ); _kfm->copy( _transSrc->data(), _transDest->data() ); _transDir = Get; } } void KImageViewer::urlFetchDone() { if( _kfm == 0 ) { warning( "KImageViewer: urlFetchDone() called but no transfer in progress." ); return; } switch ( _transDir ) { case Get: loadFile( _transDest->data(), _transSrc->data() ); unlink( _transDest->data() ); break; case Put: break; } delete _kfm; _kfm = 0; } void KImageViewer::urlFetchError( int, const char *text ) { delete _kfm; _kfm = 0; QString msg( i18n("Transfer error: ") ); msg += text; message( msg ); } void KImageViewer::appendURL( const char *url, bool show ) { _imageList->addURL( url, show ); } void KImageViewer::invokeFilter( KImageFilter *f ) { assert( f != 0 ); QObject::disconnect( f, SIGNAL(changed(const QImage&)), 0, 0 ); connect( f, SIGNAL(changed(const QImage&)), _canvas, SLOT(setImage(const QImage&)) ); f->invoke( _canvas->getImage() ); } void KImageViewer::setFilterMenu( KFiltMenuFactory *filtmenu ) { connect( filtmenu, SIGNAL(selected(KImageFilter *)), this, SLOT(invokeFilter(KImageFilter *)) ); // connect all filters KFilterList *filters = filtmenu->filterList(); for( int i = 0; i < filters->count(); i++ ) { KImageFilter *filter = filters->filter( i ); connect( filter, SIGNAL(changed(const QImage&)), _canvas, SLOT(setImage(const QImage&)) ); connect( filter, SIGNAL(progress(int)), this, SLOT(setProgress(int)) ); connect( filter, SIGNAL(status(const char *)), this, SLOT(setStatus(const char *)) ); connect( filter, SIGNAL(message(const char *)), this, SLOT(message(const char *)) ); } _menuFact = filtmenu; makePopupMenus(); _menubar = new KMenuBar(this); makeRootMenu( _menubar ); makePopupMenus(); _contextMenu = new QPopupMenu; makeRootMenu( _contextMenu ); setMenu( _menubar ); _menubar->show(); _canvas->show(); _kaccel->readSettings(); _kaccel->setEnabled( true ); _watcher->updateMenus(); } void KImageViewer::setStatus( const char *status ) { if ( status == 0 ) { status = i18n( "Ready" ); } _statusbar->changeItem( status, StatStatus ); } void KImageViewer::loadFile( const char *file, const char *url ) { if( url == 0 ) { url = file; } // We need to do this, in case the image takes too long to load. bool slide = _imageList->slideShowRunning(); if( slide ) { _imageList->pauseSlideShow(); } setStatus( i18n( "Loading..." ) ); // load the image _canvas->load( file, 0, _loadMode == ResizeImage ); // update state setStatus( 0 ); if( _canvas->status() != KImageCanvas::OK ) { QString msg; msg.sprintf(i18n("Couldn't load %s"), url); message( msg ); } else { // resize window to screen if( _loadMode == ResizeWindow && _statusbar->isVisible() ) { rzWinToImg(); } // set caption QString cap = url; cap += " ("; cap += kapp->appName().data(); cap += ")"; setCaption( cap ); // enable filters if( !_imageLoaded ) { _menubar->setItemEnabled( _barFilterID, true ); _contextMenu->setItemEnabled( _popFilterID, true ); _imageLoaded = true; } // reset matrix _mat.reset(); } if ( slide ) { _imageList->continueSlideShow(); } } void KImageViewer::setSize() { // size QWidget *desk = kapp->desktop(); if( _canvas->height() < desk->height() && _canvas->width() < desk->width() && _canvas->height() ) { resize( _canvas->size() ); } } void KImageViewer::setProgress( int pct ) { if( pct == _lastPct ) return; const char *buf = ""; if( pct > 0 ) { _pctBuffer->setNum( pct ); *_pctBuffer += '%'; buf = _pctBuffer->data(); } _lastPct = pct; _statusbar->changeItem( buf, StatProgress ); } void KImageViewer::message( const char *message ) { _statusbar->message( message, MessageDelay ); if( _msgTimer == 0 ) { _msgTimer = new QTimer( this ); connect( _msgTimer, SIGNAL(timeout()), _statusbar, SLOT(clear()) ); } _msgTimer->start( MessageDelay, true ); } void KImageViewer::toggleImageList() { if ( _imageList->isVisible() ) { _imageList->hide(); } else { _imageList->show(); } } void KImageViewer::contextPress(const QPoint& p) { _contextMenu->popup(p); } void KImageViewer::fullScreen() { if( _statusbar->isVisible() ) { // change to full _menubar->hide(); _statusbar->hide(); _posSave = pos(); _sizeSave = size(); move( frameGeometry().x() - geometry().x(), frameGeometry().y() - geometry().y() ); resize( qApp->desktop()->size() ); _canvas->resize( size() ); _canvas->move( 0, 0 ); // Grab WM focus. We need to do this for some // reason, atleast with KWM. Otherwise the // window loses focus and keyboard accelerators // don't work unless the mouse is clicked once. setActiveWindow(); } else { // change to normal move( _posSave ); resize( _sizeSave ); _menubar->show(); _statusbar->show(); updateRects(); } } void KImageViewer::reset() { _canvas->reset(); _mat.reset(); } void KImageViewer::saveProperties( KConfig *cfg ) const { if( _statusbar->isVisible() ) { cfg->writeEntry( "ViewerFullScreen", false ); cfg->writeEntry( "ViewerPos", _posSave ); cfg->writeEntry( "ViewerSize", _sizeSave ); } else { cfg->writeEntry( "ViewerFullScreen", true ); cfg->writeEntry( "ViewerPos", pos() ); cfg->writeEntry( "ViewerPos", size() ); } _imageList->saveProperties( cfg ); } void KImageViewer::restoreProperties( KConfig *cfg ) { bool full = cfg->readBoolEntry( "ViewerFullScreen" ); if( full ) { fullScreen(); _posSave = cfg->readPointEntry( "ViewerPos" ); _sizeSave = cfg->readSizeEntry( "ViewerSize" ); } else { move( cfg->readPointEntry( "ViewerPos" ) ); resize( cfg->readSizeEntry( "ViewerSize" ) ); } _imageList->restoreProperties( cfg ); } void KImageViewer::saveOptions( KConfig *cfg ) const { KConfigGroupSaver save( cfg, "kview" ); QString lmode; switch ( _loadMode ) { case ResizeNone: lmode = "ResizeNone"; break; case ResizeImage: lmode = "ResizeImage"; break; case ResizeWindow: default: lmode = "ResizeWindow"; break; } cfg->writeEntry( "LoadMode", lmode ); _imageList->saveOptions( cfg ); _kaccel->writeSettings( cfg ); } void KImageViewer::restoreOptions( KConfig *cfg ) { KConfigGroupSaver save( cfg, "kview" ); QString lmode = cfg->readEntry( "LoadMode", "ResizeWindow" ); if ( !stricmp( lmode, "ResizeWindow" ) ) { _loadMode = ResizeWindow; } else if ( !stricmp( lmode, "ResizeImage" ) ) { _loadMode = ResizeImage; } else if ( !stricmp( lmode, "ResizeNone" ) ) { _loadMode = ResizeNone; } else { warning( "kview: warning: Unknown resize mode '%s'", (const char *)lmode ); _loadMode = ResizeWindow; } _imageList->restoreOptions( cfg ); _kaccel->readSettings( cfg ); } void KImageViewer::printImage() { QPrinter printer; // get settings if( QPrintDialog::getPrinterSetup( &printer ) == false ) return; // print setStatus( i18n( "Printing..." ) ); QApplication::setOverrideCursor( WaitCursor ); _canvas->copyImage( &printer ); printer.newPage(); QApplication::restoreOverrideCursor(); setStatus( 0 ); } void KImageViewer::newViewer() { emit wantNewViewer(); } void KImageViewer::closeViewer() { emit wantToDie( this ); } void KImageViewer::closeEvent( QCloseEvent * ) { closeViewer(); } void KImageViewer::cut() { // TODO: stub } void KImageViewer::copy() { // TODO: stub } void KImageViewer::paste() { // TODO: stub } void KImageViewer::prefs() { KConfig *cfg = kapp->getConfig(); KViewPrefDlg dlg( cfg, _kaccel ); saveOptions( cfg ); if( dlg.exec() ) { restoreOptions( cfg ); if ( dlg.keysDirty() ) { emit accelChanged(); } } } void KImageViewer::helpHow() { emit wantHelp( "how" ); } void KImageViewer::helpWhat() { emit wantHelp( "what" ); } void KImageViewer::makeAccel() { // keyboard scrolling _paccel->connectItem( _paccel->insertItem( Key_Down ), _canvas, SLOT(lineDown()) ); _paccel->connectItem( _paccel->insertItem( Key_Up ), _canvas, SLOT(lineUp()) ); _paccel->connectItem( _paccel->insertItem( Key_PageDown ), _canvas, SLOT(pageDown()) ); _paccel->connectItem( _paccel->insertItem( Key_PageUp ), _canvas, SLOT(pageUp()) ); _paccel->connectItem( _paccel->insertItem( Key_Right ), _canvas, SLOT(lineRight()) ); _paccel->connectItem( _paccel->insertItem( Key_Left ), _canvas, SLOT(lineLeft()) ); // Quit on Q. Not configurable. I don't care. _paccel->connectItem( _paccel->insertItem( Key_Q ), this, SLOT(quitApp()) ); } void KImageViewer::updateAccel() { _kaccel->readSettings(); _watcher->updateMenus(); } int KImageViewer::conn( const char *text, const char *action, QObject *receiver, const char *method, uint key ) { QPopupMenu *menu = _watcher->currentMenu(); assert( menu ); QString desc; for( const char *t = text; *t; t++ ) { if( *t == '&' ) continue; desc += *t; } _kaccel->insertItem( desc, action, key ); _kaccel->connectItem( action, receiver, method ); int id = menu->insertItem( text, receiver, method ); _watcher->connectAccel( id, action ); return id; } int KImageViewer::conn( const char *text, KAccel::StdAccel action, QObject *receiver, const char *method ) { QPopupMenu *menu = _watcher->currentMenu(); assert( menu ); QString desc; for( const char *t = text; *t; t++ ) { if( *t == '&' ) continue; desc += *t; } _kaccel->insertStdItem( action, desc ); _kaccel->connectItem( action, receiver, method ); int id = menu->insertItem( text, receiver, method ); _watcher->connectAccel( id, action ); return id; } void KImageViewer::rzWinToImg() { /* plan: to make the client area of the KTW == area of canvas contents. pending: image will fit on screen size + extra move allowed (TODO) */ int iw = _canvas->contentsWidth(); int ih = _canvas->contentsHeight(); QRect geom = frameGeometry(); QRect desk = kapp->desktop()->geometry(); int xextra = width() - _canvas->width(); int yextra = height() - _canvas->height(); int xmax = desk.width() - ( xextra + geom.x() ); int ymax = desk.height() - ( yextra + geom.y() ); setGeometry( geom.x(), geom.y(), QMIN( iw, xmax ) + xextra, QMIN( ih, ymax ) + yextra ); } + +#include "viewer.moc"