+++ /dev/null
-/***************************************************************************
-* Copyright (C) 2004 by Kita Developers *
-* ikemo@users.sourceforge.jp *
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-***************************************************************************/
-
-/* Image Manager class */
-
-#include "imgmanager.h"
-#include "cache.h"
-#include "kitaconfig.h"
-#include "downloadmanager.h"
-#include "config_xt.h"
-
-#include <kdeversion.h>
-#include <kio/netaccess.h>
-#include <klocale.h>
-#include <kfiledialog.h>
-#include <kconfig.h>
-
-#include <qregexp.h>
-#include <qfile.h>
-#include <qdatastream.h>
-#include <qmessagebox.h>
-#include <qapplication.h>
-#include <qimage.h>
-
-using namespace Kita;
-
-ImgManager* ImgManager::instance = NULL;
-QMutex ImgManager::m_mutex;
-
-/*-----------------------------------------------------------*/
-
-
-ImgManager::ImgManager( QWidget* mainwidget )
-{
- m_imgDatDict.clear();
- m_mainwidget = mainwidget;
- m_urlList.clear();
-}
-
-
-ImgManager::~ImgManager()
-{}
-
-
-/* call this first */ /* public */ /* static */
-void ImgManager::setup( QWidget* mainwidget )
-{
- instance = new ImgManager( mainwidget );
-}
-
-
-/* public */ /* static */
-void ImgManager::deleteInstance()
-{
- if ( instance ) delete instance;
-}
-
-
-/* public */ /* static */
-ImgManager* ImgManager::getInstance()
-{
- return instance;
-}
-
-
-/* public */ /* static */
-bool ImgManager::isImgFile( const KURL& url, bool use_mimetype )
-{
- return instance->isImgFilePrivate( url, use_mimetype );
-}
-
-
-/* public */ /* static */
-bool ImgManager::isAnimationGIF( const KURL& url )
-{
- QRegExp reg_ext( ".*\\.gif$" );
- if ( reg_ext.search( url.fileName().lower() ) != -1 ) return TRUE;
-
- return FALSE;
-}
-
-
-/* public */ /* static */
-bool ImgManager::isBMP( const KURL& url )
-{
- QRegExp reg_ext( ".*\\.bmp$" );
- if ( reg_ext.search( url.fileName().lower() ) != -1 ) return TRUE;
-
- return FALSE;
-}
-
-
-/* public */ /* static */
-bool ImgManager::load( const KURL& url, const KURL& datURL )
-{
- QMutexLocker locker( &m_mutex );
-
- return instance->loadPrivate( url, datURL );
-}
-
-
-/* public */ /* static */
-void ImgManager::stop( const KURL& url )
-{
- QMutexLocker locker( &m_mutex );
-
- DownloadManager::stopLoading( url );
-}
-
-
-/* public */ /* static */
-QString ImgManager::getPath( const KURL& url )
-{
- return Cache::getImgPath( url );
-}
-
-
-/* public */ /* static */
-bool ImgManager::isLoadingNow( const KURL& url )
-{
-
- return DownloadManager::isLoadingNow( url );
-}
-
-
-/* public */ /* static */
-bool ImgManager::deleteCache( const KURL& url, QWidget* parent )
-{
- QMutexLocker locker( &m_mutex );
-
- return instance->deleteCachePrivate( url, parent );
-}
-
-
-/* public */ /* static */
-bool ImgManager::copyCache( const KURL& url, QWidget* parent )
-{
- QMutexLocker locker( &m_mutex );
-
- return instance->copyCachePrivate( url, parent );
-}
-
-
-/* public */ /* static */
-bool ImgManager::mosaic( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return TRUE;
-
- return imgdat->mosaic;
-}
-
-
-/* public */ /* static */
-void ImgManager::setMosaic( const KURL& url, bool status )
-{
- instance->setMosaicPrivate( url, status );
-}
-
-
-/* return -1 if IMGDAT doesn't exist. */ /* public */ /* static */
-int ImgManager::code( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return -1;
-
- return imgdat->code;
-}
-
-
-/* public */ /* static */
-unsigned int ImgManager::size( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return 0;
-
- return imgdat->size;
-}
-
-
-/* public */ /* static */
-int ImgManager::width( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return 0;
- if ( imgdat->width == 0 ) instance->getSize( url );
-
- return imgdat->width;
-}
-
-
-/* public */ /* static */
-int ImgManager::height( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return 0;
- if ( imgdat->height == 0 ) instance->getSize( url );
-
- return imgdat->height;
-}
-
-
-/* get icon pixmap */ /* public */ /* static */
-QPixmap ImgManager::icon( const KURL& url )
-{
- const int iconsize = 32;
-
- /*---------------------------*/
-
- QPixmap pixmap;
- QString path = Cache::getImgPath( url );
- QImage img = QImage( path );
- if ( img.isNull() ) return QPixmap();
-
- pixmap.convertFromImage( img.scale( iconsize, iconsize, QImage::ScaleMin ) );
- return pixmap;
-}
-
-
-/* public */ /* static */
-KURL ImgManager::datURL( const KURL& url )
-{
- instance->cacheExists( url ); /* to create IMGDAT if cache exists */
-
- IMGDAT* imgdat = instance->getImgDat( url );
- if ( !imgdat ) return KURL();
-
- return imgdat->datURL;
-}
-
-
-/*---------------------------------*/
-/* internal functions */
-
-
-/* private */
-bool ImgManager::isImgFilePrivate( const KURL& url, bool use_mimetype )
-{
- /* don't use mimetype */
- if ( !use_mimetype ) {
-
- QStringList extlist; // = KitaConfig::imgExtList();
- extlist = "jpg";
- extlist += "jpeg";
- extlist += "gif";
- extlist += "png";
- extlist += "bmp";
-
- for ( QStringList::iterator it = extlist.begin(); it != extlist.end(); ++it ) {
- QRegExp reg_ext = ".*\\." + ( *it ) + "$";
- if ( reg_ext.search( url.fileName().lower() ) != -1 ) return TRUE;
-
- }
-
- return FALSE;
- }
-
- /*-----------------------------------*/
-
- /* use mimetype ( very slow! ) */
- if ( cacheExists( url ) ) return TRUE;
-
- QString mimetype = KIO::NetAccess::mimetype( url, m_mainwidget );
- if ( mimetype.left( 6 ) == "image/" ) return TRUE;
-
- return FALSE;
-}
-
-
-/* create new loader and start loading the image */
-/* when done, ImgManager emits finishImgLoad SIGNAL. */ /* private */
-bool ImgManager::loadPrivate( const KURL& url, const KURL& datURL )
-{
- const unsigned int maxload = 5; // = KitaConfig::maxLoader();
-
- /*------------------------------*/
-
- if ( DownloadManager::isLoadingNow( url ) ) return FALSE;
-
- /* cache exists? */
- if ( cacheExists( url ) ) {
-
- /* create EmitFinishEvent to emit finishImgLoad SIGNAL later. */
- /* See also customEvent(). */
- EmitFinishEvent * e = new EmitFinishEvent( url );
- QApplication::postEvent( this, e ); // Qt will delete it when done
-
- return TRUE;
- }
-
- if ( m_urlList.count() > maxload ) return FALSE;
-
- QString path = Cache::getImgPath( url );
- deleteImgDat( url );
-
- /* create new loader, and start loading the file */
- /* slotResult is called when done. */
- LoaderOption option;
- option.usrurl = datURL;
- FileLoader* loader = DownloadManager::download( url, path, option );
- if ( loader == NULL ) return FALSE;
-
- connect( loader, SIGNAL( data( const Kita::LoaderData&, const QByteArray& ) ),
- SLOT( slotData( const Kita::LoaderData&, const QByteArray& ) ) );
-
- connect( loader, SIGNAL( result( const Kita::LoaderData& ) ),
- SLOT( slotResult( const Kita::LoaderData& ) ) );
-
- m_urlList += url.prettyURL();
-
- return TRUE;
-}
-
-
-/* delete cache */
-/* when done, cacheDeleted SIGNAL emitted */ /* private */
-bool ImgManager::deleteCachePrivate( const KURL& url, QWidget* parent )
-{
- if ( !cacheExists( url ) ) return FALSE;
-
- if ( QMessageBox::warning( parent,
- "Kita",
- i18n( "Do you want to delete the image ?" ),
- QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
- == QMessageBox::Ok ) {
-
- bool ret;;
-
- QString path = Cache::getImgPath( url );
- QString idxpath = Cache::getImgIdxPath( url );
-
- KIO::NetAccess::del( idxpath, m_mainwidget );
- ret = KIO::NetAccess::del( path, m_mainwidget );
-
- if ( ret ) {
- deleteImgDat( url );
- emit cacheDeleted( url );
- }
-
- return ret;
- }
-
- return FALSE;
-}
-
-
-/* copy cache */ /* public */
-bool ImgManager::copyCachePrivate( const KURL& url, QWidget* parent )
-{
- if ( !cacheExists( url ) ) return FALSE;
-
- /* make filter */
- QString filter;
- QString file = url.fileName().lower();
- int i = file.findRev( '.' );
- if ( i == -1 ) filter = "*|All files";
- else {
- QString ext = file.mid( i );
- filter = "*" + ext + "|*" + ext;
- }
-
- /* get filename */
- QString savefile = KFileDialog::getSaveFileName( url.fileName(), filter, parent );
- if ( savefile.isEmpty() ) return FALSE;
-
- /* file exists */
- if (
- KIO::NetAccess::exists( savefile, TRUE, m_mainwidget )
- ) {
-
- if ( QMessageBox::warning( parent,
- "Kita",
- i18n( "Do you want to replace the file?" ),
- QMessageBox::Ok, QMessageBox::Cancel | QMessageBox::Default )
- != QMessageBox::Ok ) return FALSE;
-
- KIO::NetAccess::del( savefile, m_mainwidget );
-
- }
-
- /* copy */
- QString src = Cache::getImgPath( url );
-
- KIO::NetAccess::copy( src, savefile, m_mainwidget );
-
- return TRUE;
-}
-
-
-/* private */
-void ImgManager::setMosaicPrivate( const KURL& url, bool status )
-{
- IMGDAT * imgdat = getImgDat( url );
- if ( !imgdat ) return ;
- if ( imgdat->code != 200 ) return ;
-
- imgdat->mosaic = status;
-
- /* save status */
- KConfig cfg( Cache::getImgIdxPath( url ) );
- cfg.writeEntry( "Mosaic", status );
-}
-
-
-/* private */
-void ImgManager::createImgDat( const KURL& url, int code )
-{
- IMGDAT * imgdat = getImgDat( url );
- if ( !imgdat ) {
- imgdat = new IMGDAT;
- m_imgDatDict.insert( url.prettyURL(), imgdat );
- }
-
- KConfig cfg( Cache::getImgIdxPath( url ) );
- if ( code == 200 ) cfg.writeEntry( "URL", url.prettyURL() );
-
- imgdat->mosaic = cfg.readBoolEntry( "Mosaic", Kita::Config::useMosaic() );
- imgdat->height = cfg.readNumEntry( "Height", 0 );
- imgdat->width = cfg.readNumEntry( "Width", 0 );
- imgdat->size = cfg.readUnsignedNumEntry( "Size", 0 );
- imgdat->datURL = cfg.readEntry( "datURL", QString::null );
- imgdat->code = code;
-}
-
-
-/* private */
-IMGDAT* ImgManager::getImgDat( const KURL& url )
-{
- return m_imgDatDict.find( url.prettyURL() );
-}
-
-
-/* private */
-void ImgManager::deleteImgDat( const KURL& url )
-{
- IMGDAT * imgdat = getImgDat( url );
- if ( !imgdat ) return ;
-
- if ( m_imgDatDict.remove( url.prettyURL() ) ) {
- delete imgdat;
- }
-}
-
-
-/* private */
-void ImgManager::getSize( const KURL& url )
-{
- IMGDAT * imgdat = getImgDat( url );
- if ( !imgdat ) return ;
- if ( imgdat->code != 200 ) return ;
-
- QString path = Cache::getImgPath( url );
- QImage img = QImage( path );
-
- if ( !img.isNull() ) {
-
- imgdat->width = img.width();
- imgdat->height = img.height();
-
- /* save size */
- KConfig cfg( Cache::getImgIdxPath( url ) );
- cfg.writeEntry( "Width", imgdat->width );
- cfg.writeEntry( "Height", imgdat->height );
- }
-}
-
-
-/* private */
-bool ImgManager::cacheExists( const KURL& url )
-{
- if ( DownloadManager::isLoadingNow( url ) ) return FALSE;
-
- bool ret;
- QString path = Cache::getImgPath( url );
-
- ret = KIO::NetAccess::exists( path, TRUE, m_mainwidget );
-
- if ( ret && !getImgDat( url ) ) createImgDat( url, 200 );
-
- return ret;
-}
-
-
-
-/* This slot is called when loader received the data. */ /* private slot */
-void ImgManager::slotData( const Kita::LoaderData& data, const QByteArray& barray )
-{
- /* check BMP header */
- if ( barray.size() > 2 && data.size == barray.size()
- && barray[ 0 ] == 'B' && barray[ 1 ] == 'M' ) {
- DownloadManager::stopLoading( data.url );
- return ;
- }
-
- /* I assume that file size is smaller than 2^32 byte */
- emit receiveImgData( data.url, data.size, data.totalsize );
-}
-
-
-/* This slot is called when loading is done. */ /* private slot */
-void ImgManager::slotResult( const Kita::LoaderData& data )
-{
- m_urlList.remove( data.url.prettyURL() );
- createImgDat( data.url, data.code );
-
- /* save size, datURL, etc */
- if ( data.code == 200 ) {
- unsigned int totalsize = data.totalsize;
- KURL datURL = data.option.usrurl;
- KConfig cfg( Cache::getImgIdxPath( data.url ) );
- cfg.writeEntry( "Size", totalsize );
- cfg.writeEntry( "datURL", datURL.prettyURL() );
- IMGDAT* imgdat = instance->getImgDat( data.url );
- imgdat->size = totalsize;
- imgdat->datURL = datURL;
- }
-
- emit finishImgLoad( data.url );
-}
-
-
-/* protected */ /* virtual */
-void ImgManager::customEvent( QCustomEvent * e )
-{
- /* emit finishImgLoad SIGNAL */
- if ( e->type() == EVENT_EmitFinigh ) {
- KURL url = static_cast< EmitFinishEvent* >( e ) ->url();
- emit finishImgLoad( url );
- }
-}
-
-
+++ /dev/null
-/***************************************************************************
-* Copyright (C) 2004 by Kita Developers *
-* ikemo@users.sourceforge.jp *
-* *
-* This program is free software; you can redistribute it and/or modify *
-* it under the terms of the GNU General Public License as published by *
-* the Free Software Foundation; either version 2 of the License, or *
-* (at your option) any later version. *
-***************************************************************************/
-
-#ifndef KITAIMGMANAGER_H
-#define KITAIMGMANAGER_H
-
-#include "event.h"
-
-#include <kurl.h>
-
-#include <qobject.h>
-#include <qdict.h>
-#include <qmutex.h>
-#include <qevent.h>
-#include <qstringlist.h>
-
-struct IMGDAT
-{
- int code;
- bool mosaic;
- int width;
- int height;
- unsigned int size;
- KURL datURL;
-};
-
-
-/*----------------------------------------------------------*/
-
-namespace Kita
-{
- class LoaderData;
-
- class ImgManager : public QObject
- {
- Q_OBJECT
-
- static ImgManager* instance;
- static QMutex m_mutex;
- QDict< IMGDAT > m_imgDatDict;
- QWidget* m_mainwidget;
- QStringList m_urlList;
-
- public:
- ImgManager( QWidget* mainwidget );
- ~ImgManager();
-
- static void setup( QWidget* mainwidget );
- static void deleteInstance();
- static ImgManager* getInstance();
- static bool isImgFile( const KURL& url, bool use_mimetype );
- static bool isAnimationGIF( const KURL& url );
- static bool isBMP( const KURL& url );
-
- static bool load( const KURL& url, const KURL& datURL );
- static void stop( const KURL& url );
- static QString getPath( const KURL& url );
- static bool isLoadingNow( const KURL& url );
- static bool deleteCache( const KURL& url, QWidget* parent );
- static bool copyCache( const KURL& url, QWidget* parent );
-
- static bool mosaic( const KURL& url );
- static void setMosaic( const KURL& url, bool status );
- static int code( const KURL& url );
- static int width( const KURL& url );
- static int height( const KURL& url );
- static unsigned int size( const KURL& url );
- static QPixmap icon( const KURL& url );
- static KURL datURL( const KURL& url );
-
- private:
- bool isImgFilePrivate( const KURL& url, bool use_mimetype );
- bool loadPrivate( const KURL& url, const KURL& datURL );
- bool deleteCachePrivate( const KURL& url, QWidget* parent );
- bool copyCachePrivate( const KURL& url, QWidget* parent );
- void setMosaicPrivate( const KURL& url, bool status );
-
- void createImgDat( const KURL& url, int code );
- IMGDAT* getImgDat( const KURL& url );
- void deleteImgDat( const KURL& url );
- void getSize( const KURL& url );
- bool cacheExists( const KURL& url );
-
- private slots:
- void slotData( const Kita::LoaderData&, const QByteArray& );
- void slotResult( const Kita::LoaderData& );
-
- protected:
- virtual void customEvent( QCustomEvent * e );
-
- signals:
- void receiveImgData( const KURL&, unsigned int, unsigned int );
- void finishImgLoad( const KURL& );
- void cacheDeleted( const KURL& );
- };
-
-
- /* finish event */
- class EmitFinishEvent : public QCustomEvent
- {
- KURL m_url;
-
- public:
- EmitFinishEvent( KURL url ) : QCustomEvent( EVENT_EmitFinigh ), m_url( url ) {}
-
- KURL url() const { return m_url; }
- };
-
-}
-
-#endif
#include "libkita/datinfo.h"
#include "libkita/kita_misc.h"
#include "libkita/signalcollection.h"
-#include "libkita/imgmanager.h"
#include "libkita/config_xt.h"
#include "libkita/abone.h"
connect( this, SIGNAL( closeWriteTab( const KURL& ) ),
signalCollection, SIGNAL( closeWriteTab( const KURL& ) ) );
- /* image viewer */
- connect( this, SIGNAL( redrawImage( const KURL& ) ),
- signalCollection, SIGNAL( redrawImage( const KURL& ) ) );
-
/* subject tab */
connect( this, SIGNAL( updateSubjectTab( const KURL& ) ),
signalCollection, SIGNAL( updateSubjectTab( const KURL& ) ) );
popupMenu->clear();
-
- /*-------------*/
- /* image menu */
- if ( Kita::Config::useImagePopup() ) {
-
- if ( Kita::ImgManager::isImgFile( kurl, FALSE )
- && !Kita::ImgManager::isLoadingNow( kurl )
- ) {
-
- if ( Kita::ImgManager::code( kurl ) == 200 && Kita::ImgManager::mosaic( kurl ) )
- popupMenu->insertItem( i18n( "Cancel mosaic" ), ID_Mosaic );
-
- popupMenu->insertItem( i18n( "Open with Image viewer" ), ID_Show_Imgview );
-
- if ( Kita::ImgManager::code( kurl ) == 200 )
- popupMenu->insertItem( i18n( "Delete" ) , ID_Del_Image );
-
- popupMenu->insertSeparator();
- }
- }
-
/*------*/
/* jump */
if ( m_domtree &&
int ret = popupMenu->exec( point );
switch ( ret ) {
-
- case ID_Mosaic:
- Kita::ImgManager::setMosaic( kurl, FALSE );
- emit redrawImage( kurl );
- showPopup( kurl, QString::null );
- break;
-
- case ID_Del_Image:
- Kita::ImgManager::deleteCache( kurl, view() );
- break;
-
- case ID_Show_Imgview:
- emit openURLRequestExt( url, KParts::URLArgs(), QString::null, 1 );
- break;
-
case ID_COPY_Link:
clipboard->setText( url , QClipboard::Clipboard );
clipboard->setText( url , QClipboard::Selection );
/* right click */
if ( m_pushrightbt ) {
- /* show image menu */
- if ( Kita::Config::useImagePopup()
- && Kita::ImgManager::isImgFile( urlin, FALSE ) ) showPopupMenu( urlin );
-
/* start multi-popup mode or show popup menu */
- else if ( !startMultiPopup() ) showPopupMenu( urlin );
+ if ( !startMultiPopup() ) showPopupMenu( urlin );
return ;
}
/* right click */
-
- /* bmp file */
- if ( Kita::ImgManager::isBMP( urlin ) ) {
- QMessageBox::warning( view(),
- "Kita",
- i18n( "This is a BMP file. It might contain a Troy." ) );
- return ;
- }
- /* bmp file */
-
-
- /* image */
- if ( Kita::ImgManager::isImgFile( urlin, FALSE ) ) {
-
- int active = 1;
-
- if ( m_pushctrl || m_pushmidbt ) {
-
- /* stop loading */
- if ( Kita::ImgManager::isLoadingNow( urlin ) ) {
-
- if ( QMessageBox::information( view(),
- "Kita",
- i18n( "Do you want to stop loading ?" ),
- QMessageBox::Ok,
- QMessageBox::Cancel | QMessageBox::Default )
- == QMessageBox::Ok ) Kita::ImgManager::stop( urlin );
-
- return ;
- }
-
- if ( Kita::ImgManager::code( urlin ) != 200 ) showPopup( urlin, "<DIV>loading image...</DIV>" );
- active = 0;
- }
-
- QString id = getCurrentIDofNode();
- QString tmpurl = m_datURL.prettyURL();
- if ( id != QString::null ) tmpurl += "#" + id;
-
- emit openURLRequestExt( urlin, KParts::URLArgs(), QString::null, active, tmpurl );
- return ;
- }
- /* image */
-
emit openURLRequestExt( urlin );
return ;
}
return ;
}
- /*------------------------*/
- /* image popup */
- if ( Kita::Config::useImagePopup() ) {
-
- if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
-
- /* now loading */
- if ( Kita::ImgManager::isLoadingNow( url ) ) {
- showPopup( url, "<DIV>loading image...</DIV>" );
- return ;
- }
-
- /* show error code */
- int code = Kita::ImgManager::code( url );
- if ( code == -1 ) return ;
- if ( code != 200 ) {
- QString tmpstr = QString( "<DIV>error %1 </DIV>" ).arg( code );
- showPopup( url, tmpstr );
- return ;
- }
-
- /* show image */
- showPopup( url, QString::null );
- return ;
- }
- }
-
-
/*-------------------------*/
/* popup for anchor */
m_url = url;
m_htmlPart = NULL;
- /* image extension */
- if ( Kita::Config::useImagePopup() ) {
-
- if ( Kita::ImgManager::isImgFile( url, FALSE ) ) {
-
- connect( Kita::ImgManager::getInstance(),
- SIGNAL( receiveImgData( const KURL&, unsigned int, unsigned int ) ),
- SLOT( slotReceiveImgData( const KURL&, unsigned int, unsigned int ) ) );
- connect( Kita::ImgManager::getInstance(), SIGNAL( finishImgLoad( const KURL& ) ),
- SLOT( slotFinishImgLoad( const KURL& ) ) );
-
- /* show image */
- if ( !Kita::ImgManager::isLoadingNow( url ) && Kita::ImgManager::code( url ) == 200 ) {
- showImage( url );
- return ;
- }
- }
- }
-
m_htmlPart = new KitaHTMLPart( this );
m_htmlPart->setup( HTMLPART_MODE_POPUP , url );
connect( m_htmlPart, SIGNAL( hideChildPopup() ), SIGNAL( hideChildPopup() ) );
QCursor::setPos( cx, cy );
}
-
-
- /*----------------------------------------------------------*/
- /* image extension */
-
- /* private */
- void ResPopup::showImage( const KURL& url )
- {
- /* size of image popup */
- const int wd = 320;
- const int ht = 240;
-
- /*---------------------------*/
-
- if ( m_htmlPart ) m_htmlPart->hide();
- }
-
-
- /* private slot */
- void ResPopup::slotReceiveImgData( const KURL& url, unsigned int size, unsigned int total )
- {
- if ( url != m_url ) return ;
-
- QString tmpstr = QString( "<DIV>loading image...<br>%1k/%2k</DIV>" )
- .arg( size / 1024 ).arg( total / 1024 );
- setText( tmpstr );
- }
-
- /* private slot */
- void ResPopup::slotFinishImgLoad( const KURL& url )
- {
- if ( url != m_url ) return ;
- if ( m_htmlPart == NULL ) return ;
-
- int code = Kita::ImgManager::code( url );
-
- if ( code == 200 ) {
- showImage( url );
- } else {
- QString tmpstr = QString( "<DIV>error %1</DIV>" ).arg( code );
- setText( tmpstr );
- }
- }
-
}