mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
added the possibility to clear the avatar when editing
This commit is contained in:
parent
b4a3d67486
commit
9617ee5135
@ -89,6 +89,11 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
|
|||||||
connect(ui->toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
connect(ui->toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
||||||
connect(ui->avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
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 */
|
/* Initialize ui */
|
||||||
ui->lineEdit_Nickname->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE);
|
ui->lineEdit_Nickname->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE);
|
||||||
|
|
||||||
@ -126,7 +131,7 @@ void IdEditDialog::changeAvatar()
|
|||||||
|
|
||||||
ui->avatarLabel->setPicture(QPixmap::fromImage(img));
|
ui->avatarLabel->setPicture(QPixmap::fromImage(img));
|
||||||
ui->avatarLabel->setEnableZoom(true);
|
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;
|
mAvatarIsSet = true;
|
||||||
|
|
||||||
// shows the tooltip for a while
|
// 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)
|
void IdEditDialog::setAvatar(const QPixmap &avatar)
|
||||||
{
|
{
|
||||||
mAvatar = avatar;
|
mAvatar = avatar;
|
||||||
@ -214,10 +224,12 @@ void IdEditDialog::setAvatar(const QPixmap &avatar)
|
|||||||
if (!mAvatar.isNull()) {
|
if (!mAvatar.isNull()) {
|
||||||
ui->avatarLabel->setPicture(avatar);
|
ui->avatarLabel->setPicture(avatar);
|
||||||
mAvatarIsSet = true;
|
mAvatarIsSet = true;
|
||||||
|
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar. Hit Del to remove it."));
|
||||||
} else {
|
} else {
|
||||||
// we need to use the default pixmap here, generated from the ID
|
// 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;
|
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:
|
private slots:
|
||||||
void idTypeToggled(bool checked);
|
void idTypeToggled(bool checked);
|
||||||
void submit();
|
void submit();
|
||||||
|
void avatarCleared();
|
||||||
|
|
||||||
void changeAvatar();
|
void changeAvatar();
|
||||||
|
|
||||||
|
@ -310,6 +310,9 @@
|
|||||||
<height>128</height>
|
<height>128</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::StrongFocus</enum>
|
||||||
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Box</enum>
|
<enum>QFrame::Box</enum>
|
||||||
</property>
|
</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()
|
void ZoomableLabel::reset()
|
||||||
{
|
{
|
||||||
mCenterX = mFullImage.width()/2.0;
|
mCenterX = mFullImage.width()/2.0;
|
||||||
|
@ -40,18 +40,22 @@ class ZoomableLabel: public QLabel
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
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 setPicture(const QPixmap& pix);
|
||||||
void setEnableZoom(bool b) { mZoomEnabled = b; }
|
void setEnableZoom(bool b) { mZoomEnabled = b; }
|
||||||
|
void setEnableClear(bool b) { mClearEnabled = b; }
|
||||||
void reset();
|
void reset();
|
||||||
QPixmap extractCroppedScaledPicture() const;
|
QPixmap extractCroppedScaledPicture() const;
|
||||||
void updateView();
|
void updateView();
|
||||||
|
|
||||||
|
virtual void keyPressEvent(QKeyEvent *ev) override;
|
||||||
|
|
||||||
const QPixmap& originalImage() const { return mFullImage ; }
|
const QPixmap& originalImage() const { return mFullImage ; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void clicked();
|
void clicked();
|
||||||
|
void cleared();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QMouseEvent *ev) override;
|
void mousePressEvent(QMouseEvent *ev) override;
|
||||||
@ -73,6 +77,7 @@ protected:
|
|||||||
int mLastX,mLastY;
|
int mLastX,mLastY;
|
||||||
bool mMoving;
|
bool mMoving;
|
||||||
bool mZoomEnabled;
|
bool mZoomEnabled;
|
||||||
|
bool mClearEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Class to paint the thumbnails with title
|
// Class to paint the thumbnails with title
|
||||||
|
Loading…
Reference in New Issue
Block a user