diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 20e169306..a77713e1e 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -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.")); } } diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.h b/retroshare-gui/src/gui/Identity/IdEditDialog.h index f3d49601f..8ee6b15c9 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.h +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.h @@ -51,6 +51,7 @@ public: private slots: void idTypeToggled(bool checked); void submit(); + void avatarCleared(); void changeAvatar(); diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.ui b/retroshare-gui/src/gui/Identity/IdEditDialog.ui index fee114a9d..e30c12d8a 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.ui @@ -310,6 +310,9 @@ 128 + + Qt::StrongFocus + QFrame::Box diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp index eb890b075..ee40e1465 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.cpp @@ -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; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h index d89fd5eca..7e8bab4b0 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostThumbnail.h @@ -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