From f06fa656b81ab5039cc0fe9b1e0f6b7cb4ab0476 Mon Sep 17 00:00:00 2001 From: PYRET1C <88980503+PYRET1C@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:32:17 +0530 Subject: [PATCH] This commit added a browse button the wire for image addition functionality. --- .../src/gui/TheWire/PulseAddDialog.cpp | 32 +++- .../src/gui/TheWire/PulseAddDialog.h | 1 + .../src/gui/TheWire/PulseAddDialog.ui | 150 +++++++++++------- 3 files changed, 123 insertions(+), 60 deletions(-) diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index 15fe997a6..84a8e322c 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "PulseReply.h" #include "gui/gxs/GxsIdDetails.h" @@ -42,9 +43,15 @@ PulseAddDialog::PulseAddDialog(QWidget *parent) connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) ); connect(ui.pushButton_picture, SIGNAL(clicked()), this, SLOT( toggle())); + // this connection is from browse push button to the slot function onBrowseButtonClicked() + connect(ui.pushButton_Browse, SIGNAL(clicked()), this, SLOT( onBrowseButtonClicked())); + ui.pushButton_picture->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/photo.png"))); ui.frame_picture->hide(); + // initially hiding the browse button as the attach image button is not pressed + ui.frame_PictureBrowse->hide(); + setAcceptDrops(true); } @@ -153,8 +160,12 @@ void PulseAddDialog::cleanup() ui.label_image4->clear(); ui.label_image4->setText(tr("Drag and Drop Image")); - // Hide Drag & Drop Frame - ui.frame_picture->hide(); + ui.lineEdit_FilePath->clear(); + + // Hide Drag & Drop Frame and the browse frame + ui.frame_picture->hide(); + ui.frame_PictureBrowse->hide(); + ui.pushButton_picture->setChecked(false); } @@ -510,12 +521,29 @@ void PulseAddDialog::toggle() { if (ui.pushButton_picture->isChecked()) { + // Show the input methods (drag and drop field and the browse button) ui.frame_picture->show(); + ui.frame_PictureBrowse->show(); + ui.pushButton_picture->setToolTip(tr("Hide Pictures")); } else { + // Hide the input methods (drag and drop field and the browse button) ui.frame_picture->hide(); + ui.frame_PictureBrowse->hide(); + ui.pushButton_picture->setToolTip(tr("Add Pictures")); } } + +// Function to get the file dialog for the browse button +void PulseAddDialog::onBrowseButtonClicked() +{ + QString filePath = QFileDialog::getOpenFileName(this, tr("Select image file"), QString(), tr("Image files (*.png *.jpg *.jpeg *.bmp *.gif)")); + if (!filePath.isEmpty()) { + ui.lineEdit_FilePath->setText(filePath); + addImage(filePath); + } +} + diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h index 258efb736..69007b025 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h @@ -53,6 +53,7 @@ private slots: void clearDialog(); void pulseTextChanged(); void toggle(); + void onBrowseButtonClicked(); private: // OLD VERSIONs, private now. diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui index a731ec3b0..5ef30ef19 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui @@ -7,20 +7,20 @@ 0 0 720 - 449 + 513 - - - 0 - + 6 - + + 0 + + @@ -52,7 +52,6 @@ 12 - 75 true @@ -118,7 +117,7 @@ - + @@ -232,18 +231,9 @@ - + - - - 0 - - - 0 - - - 0 - + @@ -262,7 +252,7 @@ 0 - 100 + 80 @@ -271,29 +261,13 @@ QFrame::Raised - - - - - - 80 - 80 - - - - Drag and Drop Image - - - Qt::AlignCenter - - - + - 80 - 80 + 40 + 40 @@ -308,8 +282,24 @@ - 80 - 80 + 40 + 40 + + + + Drag and Drop Image + + + Qt::AlignCenter + + + + + + + + 40 + 40 @@ -324,8 +314,8 @@ - 80 - 80 + 40 + 40 @@ -340,15 +330,49 @@ - - - - - - URL + + + + 0 + 50 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 541 + 25 + + + + + + 101 + 25 + + + + Browse... + + + + + + + + + @@ -359,13 +383,6 @@ - - - - Display As - - - @@ -376,13 +393,31 @@ + + + + Display As + + + + + + + URL + + + + frame_URL + frame_picture + frame_PictureBrowse + textEdit_Pulse - + 6 @@ -421,7 +456,6 @@ 12 - 75 true