summaryrefslogtreecommitdiffabout
path: root/kaddressbook
Side-by-side diff
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/imagewidget.cpp21
-rw-r--r--kaddressbook/imagewidget.h2
2 files changed, 4 insertions, 19 deletions
diff --git a/kaddressbook/imagewidget.cpp b/kaddressbook/imagewidget.cpp
index d0f52ea..eec5e08 100644
--- a/kaddressbook/imagewidget.cpp
+++ b/kaddressbook/imagewidget.cpp
@@ -92,221 +92,206 @@ ImageWidget::ImageWidget( QWidget *parent, const char *name )
mLogoLabel = new QLabel( logoBox );
mLogoLabel->setFixedSize( 50*9/fac, 70*9/fac );
mLogoLabel->setScaledContents( true );
mLogoLabel->setFrameStyle( QFrame::Panel | QFrame::Sunken );
boxLayout->addMultiCellWidget( mLogoLabel, 0, 3, 0, 0 );
mLogoUrl = new KURLRequester( logoBox );
#ifndef KAB_EMBEDDED
mLogoUrl->setFilter( KImageIO::pattern() );
#else //KAB_EMBEDDED
//US qDebug("ImageWidget::ImageWidget KImageIO not defined 2");
#endif //KAB_EMBEDDED
boxLayout->addWidget( mLogoUrl, 0, 1 );
QHBox *hb2 = new QHBox ( logoBox );
mUseLogoUrl = new QCheckBox( i18n( "Store as URL" ), hb2 );
mUseLogoUrl->setEnabled( false );
boxLayout->addWidget( hb2, 1, 1 );
pb = new QPushButton( i18n( "Remove" ), hb2 );
connect( pb, SIGNAL( clicked() ),this, SLOT( removeLogo() ) );
boxLayout->addWidget( new QLabel( logoBox ), 2, 1 );
topLayout->addWidget( logoBox, 1, 0 );
connect( mPhotoUrl, SIGNAL( textChanged( const QString& ) ),
SIGNAL( changed() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( loadPhoto() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SIGNAL( changed() ) );
connect( mPhotoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( updateGUI() ) );
connect( mUsePhotoUrl, SIGNAL( toggled( bool ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( textChanged( const QString& ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( loadLogo() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SIGNAL( changed() ) );
connect( mLogoUrl, SIGNAL( urlSelected( const QString& ) ),
SLOT( updateGUI() ) );
connect( mUseLogoUrl, SIGNAL( toggled( bool ) ),
SIGNAL( changed() ) );
#ifndef KAB_EMBEDDED
KAcceleratorManager::manage( this );
#endif //KAB_EMBEDDED
}
ImageWidget::~ImageWidget()
{
}
void ImageWidget::setPhoto( const KABC::Picture &photo )
{
bool blocked = signalsBlocked();
blockSignals( true );
if ( photo.isIntern() ) {
//US
//US mPhotoLabel->setPixmap( photo.data() );
if (photo.data().isNull() != true)
{
QPixmap pm;
pm.convertFromImage(photo.data());
mPhotoLabel->setPixmap( pm );
}
mUsePhotoUrl->setChecked( false );
} else {
mPhotoUrl->setURL( photo.url() );
if ( !photo.url().isEmpty() )
mUsePhotoUrl->setChecked( true );
loadPhoto();
}
blockSignals( blocked );
}
KABC::Picture ImageWidget::photo() const
{
KABC::Picture photo;
if ( mUsePhotoUrl->isChecked() )
photo.setUrl( mPhotoUrl->url() );
else {
QPixmap *px = mPhotoLabel->pixmap();
if ( px ) {
#ifndef KAB_EMBEDDED
if ( px->height() > px->width() )
photo.setData( px->convertToImage().scaleHeight( 140 ) );
else
photo.setData( px->convertToImage().scaleWidth( 100 ) );
#else //KAB_EMBEDDED
//US add teh nullcheck
if (px->isNull() != true )
photo.setData( px->convertToImage() );
#endif //KAB_EMBEDDED
photo.setType( "PNG" );
}
}
return photo;
}
void ImageWidget::setLogo( const KABC::Picture &logo )
{
bool blocked = signalsBlocked();
blockSignals( true );
if ( logo.isIntern() ) {
//US
//US mLogoLabel->setPixmap( logo.data() );
if (logo.data().isNull() != true)
{
QPixmap pm;
pm.convertFromImage(logo.data());
mLogoLabel->setPixmap( pm );
}
mUseLogoUrl->setChecked( false );
} else {
mLogoUrl->setURL( logo.url() );
if ( !logo.url().isEmpty() )
mUseLogoUrl->setChecked( true );
loadLogo();
}
blockSignals( blocked );
}
KABC::Picture ImageWidget::logo() const
{
KABC::Picture logo;
if ( mUseLogoUrl->isChecked() )
logo.setUrl( mLogoUrl->url() );
else {
QPixmap *px = mLogoLabel->pixmap();
if ( px ) {
#ifndef KAB_EMBEDDED
if ( px->height() > px->width() )
logo.setData( px->convertToImage().scaleHeight( 140 ) );
else
logo.setData( px->convertToImage().scaleWidth( 100 ) );
#else //KAB_EMBEDDED
if (px->isNull() != true )
logo.setData( px->convertToImage() );
#endif //KAB_EMBEDDED
logo.setType( "PNG" );
}
}
return logo;
}
void ImageWidget::removePhoto()
{
setPhoto(KABC::Picture() );
}
void ImageWidget::removeLogo()
{
setLogo(KABC::Picture() );
}
void ImageWidget::loadPhoto()
{
mPhotoLabel->setPixmap( loadPixmap( mPhotoUrl->url() ) );
}
void ImageWidget::loadLogo()
{
mLogoLabel->setPixmap( loadPixmap( mLogoUrl->url() ) );
}
void ImageWidget::updateGUI()
{
KURLRequester *ptr = (KURLRequester*)sender();
if ( ptr == mPhotoUrl )
mUsePhotoUrl->setEnabled( true );
else if ( ptr == mLogoUrl )
mUseLogoUrl->setEnabled( true );
}
-QPixmap ImageWidget::loadPixmap( const KURL &url )
+QPixmap ImageWidget::loadPixmap( const QString &url )
{
- QString tempFile;
+
QPixmap pixmap;
if ( url.isEmpty() )
return pixmap;
-
- if ( url.isLocalFile() )
- pixmap = QPixmap( url.path() );
- else
- {
-#ifndef KAB_EMBEDDED
- if ( KIO::NetAccess::download( url, tempFile ) ) {
- pixmap = QPixmap( tempFile );
- KIO::NetAccess::removeTempFile( tempFile );
- }
-#else //KAB_EMBEDDED
- qDebug("ImageWidget::loadPixmap : only local pixmaps are allowed");
-#endif //KAB_EMBEDDED
-
- }
-
+ pixmap.load( url );
return pixmap;
}
#ifndef KAB_EMBEDDED
#include "imagewidget.moc"
#endif //KAB_EMBEDDED
diff --git a/kaddressbook/imagewidget.h b/kaddressbook/imagewidget.h
index afb9aa7..bbfba58 100644
--- a/kaddressbook/imagewidget.h
+++ b/kaddressbook/imagewidget.h
@@ -1,88 +1,88 @@
/*
This file is part of KAddressBook.
Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef IMAGEWIDGET_H
#define IMAGEWIDGET_H
#include <qwidget.h>
#include <kabc/picture.h>
#include <kdialogbase.h>
class KURL;
class KURLRequester;
class QCheckBox;
class QLabel;
class ImageWidget : public QWidget
{
Q_OBJECT
public:
ImageWidget( QWidget *parent, const char *name = 0 );
~ImageWidget();
/**
Sets the photo object.
*/
void setPhoto( const KABC::Picture &photo );
/**
Returns a photo object.
*/
KABC::Picture photo() const;
/**
Sets the logo object.
*/
void setLogo( const KABC::Picture &photo );
/**
Returns a logo object.
*/
KABC::Picture logo() const;
signals:
void changed();
private slots:
void loadPhoto();
void loadLogo();
void removePhoto();
void removeLogo();
void updateGUI();
private:
- QPixmap loadPixmap( const KURL &url );
+ QPixmap loadPixmap( const QString &url );
KURLRequester *mPhotoUrl;
KURLRequester *mLogoUrl;
QCheckBox *mUsePhotoUrl;
QCheckBox *mUseLogoUrl;
QLabel *mPhotoLabel;
QLabel *mLogoLabel;
};
#endif