mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added the possibility to clear the avatar when editing
This commit is contained in:
parent
5274a060e5
commit
fd5766a5fb
@ -89,6 +89,11 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
|
||||
connect(ui->toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
||||
connect(ui->avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
||||
|
||||
connect(ui->avatarLabel,SIGNAL(cleared()),this,SLOT(avatarCleared()));
|
||||
|
||||
ui->avatarLabel->setEnableClear(true);
|
||||
ui->avatarLabel->setToolTip(tr("No Avatar chosen. A default image will be automatically displayed from your new identity."));
|
||||
|
||||
/* Initialize ui */
|
||||
ui->lineEdit_Nickname->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE);
|
||||
|
||||
@ -126,7 +131,7 @@ void IdEditDialog::changeAvatar()
|
||||
|
||||
ui->avatarLabel->setPicture(QPixmap::fromImage(img));
|
||||
ui->avatarLabel->setEnableZoom(true);
|
||||
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar."));
|
||||
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar. Hit Del to remove it."));
|
||||
mAvatarIsSet = true;
|
||||
|
||||
// shows the tooltip for a while
|
||||
@ -207,6 +212,11 @@ void IdEditDialog::updateIdType(bool pseudo)
|
||||
}
|
||||
}
|
||||
|
||||
void IdEditDialog::avatarCleared()
|
||||
{
|
||||
setAvatar(QPixmap());
|
||||
}
|
||||
|
||||
void IdEditDialog::setAvatar(const QPixmap &avatar)
|
||||
{
|
||||
mAvatar = avatar;
|
||||
@ -214,10 +224,12 @@ void IdEditDialog::setAvatar(const QPixmap &avatar)
|
||||
if (!mAvatar.isNull()) {
|
||||
ui->avatarLabel->setPicture(avatar);
|
||||
mAvatarIsSet = true;
|
||||
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar. Hit Del to remove it."));
|
||||
} else {
|
||||
// we need to use the default pixmap here, generated from the ID
|
||||
ui->avatarLabel->setText(tr("No avatar chosen\ndefault will\nbe used"));
|
||||
ui->avatarLabel->setText(tr("No avatar chosen")); // This clears up the image
|
||||
mAvatarIsSet = false;
|
||||
ui->avatarLabel->setToolTip(tr("No Avatar chosen. A default image will be automatically displayed from your new identity."));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@ public:
|
||||
private slots:
|
||||
void idTypeToggled(bool checked);
|
||||
void submit();
|
||||
void avatarCleared();
|
||||
|
||||
void changeAvatar();
|
||||
|
||||
|
@ -310,6 +310,9 @@
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::Box</enum>
|
||||
</property>
|
||||
|
@ -217,6 +217,25 @@ float ChannelPostThumbnailView::thumbnail_h() const
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomableLabel::keyPressEvent(QKeyEvent *e)
|
||||
{
|
||||
switch(e->key())
|
||||
{
|
||||
case Qt::Key_Delete:
|
||||
|
||||
if(mClearEnabled)
|
||||
{
|
||||
mFullImage = QPixmap();
|
||||
emit cleared();
|
||||
e->accept();
|
||||
updateView();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
QLabel::keyPressEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomableLabel::reset()
|
||||
{
|
||||
mCenterX = mFullImage.width()/2.0;
|
||||
|
@ -40,18 +40,22 @@ class ZoomableLabel: public QLabel
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ZoomableLabel(QWidget *parent): QLabel(parent),mUseStyleSheet(true),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true) {}
|
||||
ZoomableLabel(QWidget *parent): QLabel(parent),mUseStyleSheet(true),mZoomFactor(1.0),mCenterX(0.0),mCenterY(0.0),mZoomEnabled(true),mClearEnabled(false) {}
|
||||
|
||||
void setPicture(const QPixmap& pix);
|
||||
void setEnableZoom(bool b) { mZoomEnabled = b; }
|
||||
void setEnableClear(bool b) { mClearEnabled = b; }
|
||||
void reset();
|
||||
QPixmap extractCroppedScaledPicture() const;
|
||||
void updateView();
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *ev) override;
|
||||
|
||||
const QPixmap& originalImage() const { return mFullImage ; }
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void cleared();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *ev) override;
|
||||
@ -73,6 +77,7 @@ protected:
|
||||
int mLastX,mLastY;
|
||||
bool mMoving;
|
||||
bool mZoomEnabled;
|
||||
bool mClearEnabled;
|
||||
};
|
||||
|
||||
// Class to paint the thumbnails with title
|
||||
|
Loading…
Reference in New Issue
Block a user