diff options
Diffstat (limited to 'src/chfacedlg.cpp')
| -rw-r--r-- | src/chfacedlg.cpp | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/src/chfacedlg.cpp b/src/chfacedlg.cpp index bea316c..1b1293a 100644 --- a/src/chfacedlg.cpp +++ b/src/chfacedlg.cpp @@ -41,11 +41,9 @@ #include <kimagefilepreview.h> #include <kimageio.h> #include <tdemessagebox.h> -#include <konq_operations.h> #include <kurl.h> #include "chfacedlg.h" -#include "settings.h" // TDEConfigXT @@ -55,6 +53,9 @@ ChFaceDlg::ChFaceDlg(const TQString& picsdir, TQWidget *parent, const char *name, bool modal) : KDialogBase( parent, name, modal, i18n("Change your Face"), Ok|Cancel, Ok, true ) { + // Global settings + m_maxFaceSize = 64; + TQWidget *page = new TQWidget(this); setMainWidget( page ); @@ -95,15 +96,6 @@ ChFaceDlg::ChFaceDlg(const TQString& picsdir, TQWidget *parent, const char *name for ( TQStringList::Iterator it = picslist.begin(); it != picslist.end(); ++it ) new TQIconViewItem( m_FacesWidget, (*it).section(".",0,0), TQPixmap( picsdir + *it ) ); } - facesDir.setPath( KCFGUserAccount::userFaceDir() ); - if ( facesDir.exists() ) - { - TQStringList picslist = facesDir.entryList( TQDir::Files ); - for ( TQStringList::Iterator it = picslist.begin(); it != picslist.end(); ++it ) - new TQIconViewItem( m_FacesWidget, "/"+(*it) == KCFGUserAccount::customFaceFile() ? - i18n("(Custom)") : (*it).section(".",0,0), - TQPixmap( KCFGUserAccount::userFaceDir() + *it ) ); - } m_FacesWidget->setResizeMode( TQIconView::Adjust ); //m_FacesWidget->setGridX( FACE_PIX_SIZE - 10 ); @@ -115,7 +107,7 @@ ChFaceDlg::ChFaceDlg(const TQString& picsdir, TQWidget *parent, const char *name resize( 420, 400 ); } -void ChFaceDlg::addCustomPixmap( TQString imPath, bool saveCopy ) +void ChFaceDlg::addCustomPixmap( TQString imPath ) { TQImage pix( imPath ); // TODO: save pix to TMPDIR/userinfo-tmp, @@ -126,37 +118,19 @@ void ChFaceDlg::addCustomPixmap( TQString imPath, bool saveCopy ) KMessageBox::sorry( this, i18n("There was an error loading the image.") ); return; } - if ( (pix.width() > KCFGUserAccount::faceSize()) - || (pix.height() > KCFGUserAccount::faceSize()) ) - pix = pix.scale( KCFGUserAccount::faceSize(), KCFGUserAccount::faceSize(), TQImage::ScaleMin );// Should be no bigger than certain size. - - if ( saveCopy ) - { - // If we should save a copy: - TQDir userfaces( KCFGUserAccount::userFaceDir() ); - if ( !userfaces.exists( ) ) - userfaces.mkdir( userfaces.absPath() ); - - pix.save( userfaces.absPath() + "/.userinfo-tmp" , "PNG" ); - KonqOperations::copy( this, KonqOperations::COPY, KURL::List( KURL( userfaces.absPath() + "/.userinfo-tmp" ) ), KURL( userfaces.absPath() + "/" + TQFileInfo(imPath).fileName().section(".",0,0) ) ); -#if 0 - if ( !pix.save( userfaces.absPath() + "/" + imPath , "PNG" ) ) - KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1").arg( userfaces.absPath() ) ); -#endif - } + if ( (pix.width() > m_maxFaceSize) + || (pix.height() > m_maxFaceSize) ) + pix = pix.scale( m_maxFaceSize, m_maxFaceSize, TQImage::ScaleMin );// Should be no bigger than certain size. TQIconViewItem* newface = new TQIconViewItem( m_FacesWidget, TQFileInfo(imPath).fileName().section(".",0,0) , pix ); - newface->setKey( KCFGUserAccount::customKey() );// Add custom items to end m_FacesWidget->ensureItemVisible( newface ); m_FacesWidget->setCurrentItem( newface ); } void ChFaceDlg::slotGetCustomImage( ) { - TQCheckBox* checkWidget = new TQCheckBox( i18n("&Save copy in custom faces folder for future use"), 0 ); - KFileDialog *dlg = new KFileDialog( TQDir::homeDirPath(), KImageIO::pattern( KImageIO::Reading ), - this, 0, true, checkWidget); + this, 0, true); dlg->setOperationMode( KFileDialog::Opening ); dlg->setCaption( i18n("Choose Image") ); @@ -165,24 +139,9 @@ void ChFaceDlg::slotGetCustomImage( ) KImageFilePreview *ip = new KImageFilePreview( dlg ); dlg->setPreviewWidget( ip ); if (dlg->exec() == TQDialog::Accepted) - addCustomPixmap( dlg->selectedFile(), checkWidget->isChecked() ); + addCustomPixmap( dlg->selectedFile() ); // Because we give it a parent we have to close it ourselves. dlg->close(true); } -#if 0 -void ChFaceDlg::slotSaveCustomImage() -{ - if ( m_FacesWidget->currentItem()->key() == USER_CUSTOM_KEY) - { - TQDir userfaces( TQDir::homeDirPath() + USER_FACES_DIR ); - if ( !userfaces.exists( ) ) - userfaces.mkdir( userfaces.absPath() ); - - if ( !m_FacesWidget->currentItem()->pixmap()->save( userfaces.absPath() + USER_CUSTOM_FILE , "PNG" ) ) - KMessageBox::sorry(this, i18n("There was an error saving the image:\n%1").arg( userfaces.absPath() ) ); - } -} -#endif - #include "chfacedlg.moc" |
