mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
kdepasswd KCM: add option to remove the user image
REVIEW: 104054
This commit is contained in:
parent
3d5fe5b774
commit
402b98b4ce
3 changed files with 27 additions and 13 deletions
|
@ -54,10 +54,11 @@ ChFaceDlg::ChFaceDlg(const QString& picsdir, QWidget *parent)
|
|||
: KDialog( parent )
|
||||
{
|
||||
setCaption( i18nc("@title:window", "Change your Face") );
|
||||
setButtons( Ok|Cancel|User1 );
|
||||
setButtons( Ok|Cancel|User1|User2 );
|
||||
setDefaultButton( Ok );
|
||||
|
||||
setButtonText( User1, "Custom image" );
|
||||
setButtonText( User1, i18n("Custom Image...") );
|
||||
setButtonText( User2, i18n("Remove Image") );
|
||||
|
||||
QWidget *faceDlg = new QWidget;
|
||||
ui.setupUi(faceDlg);
|
||||
|
@ -71,6 +72,8 @@ ChFaceDlg::ChFaceDlg(const QString& picsdir, QWidget *parent)
|
|||
|
||||
connect( this, SIGNAL(user1Clicked()), this, SLOT(slotGetCustomImage()) );
|
||||
|
||||
connect( this, SIGNAL(user2Clicked()), this, SLOT(slotRemoveImage()) );
|
||||
|
||||
#if 0
|
||||
QPushButton *acquireBtn = new QPushButton( i18n("&Acquire Image..."), page );
|
||||
acquireBtn->setEnabled( false );
|
||||
|
@ -97,7 +100,7 @@ ChFaceDlg::ChFaceDlg(const QString& picsdir, QWidget *parent)
|
|||
}
|
||||
|
||||
|
||||
enableButtonOk( false );
|
||||
enableButtonOk( false ); // since no item is pre-selected, we must only enable the Ok button once a selection is done!
|
||||
//connect( this, SIGNAL(okClicked()), SLOT(slotSaveCustomImage()) );
|
||||
|
||||
resize( 420, 400 );
|
||||
|
@ -155,6 +158,12 @@ void ChFaceDlg::slotGetCustomImage( )
|
|||
addCustomPixmap( dlg.selectedFile(), checkWidget->isChecked() );
|
||||
}
|
||||
|
||||
void ChFaceDlg::slotRemoveImage()
|
||||
{
|
||||
ui.m_FacesWidget->clearSelection();
|
||||
accept();
|
||||
}
|
||||
|
||||
#if 0
|
||||
void ChFaceDlg::slotSaveCustomImage()
|
||||
{
|
||||
|
|
|
@ -43,10 +43,13 @@ class ChFaceDlg : public KDialog
|
|||
public:
|
||||
|
||||
|
||||
explicit ChFaceDlg(const QString& picsdirs,
|
||||
explicit ChFaceDlg(const QString& picsdirs,
|
||||
QWidget *parent=0);
|
||||
|
||||
|
||||
/**
|
||||
* Will return the currently selected face, or a null pixmap if the user hit the "remove image" button
|
||||
*/
|
||||
QPixmap getFaceImage() const
|
||||
{
|
||||
if(ui.m_FacesWidget->currentItem())
|
||||
|
@ -57,10 +60,11 @@ public:
|
|||
|
||||
private Q_SLOTS:
|
||||
void slotFaceWidgetSelectionChanged( QListWidgetItem *item )
|
||||
{ enableButton( Ok, !item->icon().isNull() ); }
|
||||
{ enableButton( Ok, !item->icon().isNull() ); }
|
||||
|
||||
void slotGetCustomImage();
|
||||
//void slotSaveCustomImage();
|
||||
void slotRemoveImage();
|
||||
|
||||
private:
|
||||
void addCustomPixmap( const QString &imPath, bool saveCopy );
|
||||
|
|
|
@ -211,7 +211,12 @@ void KCMUserAccount::save()
|
|||
{
|
||||
KMessageBox::error( this, i18n("There was an error saving the image: %1" ,
|
||||
KCFGUserAccount::faceFile()) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
else { // delete existing image
|
||||
if ( !KIO::NetAccess::del(KCFGUserAccount::faceFile(), this) ) {
|
||||
KMessageBox::error( this, i18n("There was an error deleting the image: %1" ,
|
||||
KCFGUserAccount::faceFile()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,14 +229,10 @@ void KCMUserAccount::save()
|
|||
|
||||
void KCMUserAccount::changeFace(const QPixmap &pix)
|
||||
{
|
||||
if ( pix.isNull() ) {
|
||||
KMessageBox::sorry( this, i18n("There was an error loading the image.") );
|
||||
return;
|
||||
}
|
||||
|
||||
_facePixmap = pix;
|
||||
_mw->btnChangeFace->setIcon( KIcon(_facePixmap) );
|
||||
_mw->btnChangeFace->setIconSize(_facePixmap.size());
|
||||
if ( !_facePixmap.isNull() )
|
||||
_mw->btnChangeFace->setIconSize(_facePixmap.size());
|
||||
emit changed( true );
|
||||
}
|
||||
|
||||
|
@ -240,7 +241,7 @@ void KCMUserAccount::slotFaceButtonClicked()
|
|||
ChFaceDlg* pDlg = new ChFaceDlg( KGlobal::dirs()->resourceDirs("data").last() +
|
||||
"/kdm/pics/users/", this );
|
||||
|
||||
if ( pDlg->exec() == QDialog::Accepted && !pDlg->getFaceImage().isNull() )
|
||||
if ( pDlg->exec() == QDialog::Accepted )
|
||||
changeFace( pDlg->getFaceImage() );
|
||||
|
||||
delete pDlg;
|
||||
|
|
Loading…
Reference in a new issue