This commit added a browse button the wire for image addition functionality.

This commit is contained in:
PYRET1C 2023-04-12 22:32:17 +05:30
parent c90ea518c5
commit f06fa656b8
3 changed files with 123 additions and 60 deletions

View File

@ -20,6 +20,7 @@
#include <iostream> #include <iostream>
#include <QtGui> #include <QtGui>
#include <QFileDialog>
#include "PulseReply.h" #include "PulseReply.h"
#include "gui/gxs/GxsIdDetails.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.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) );
connect(ui.pushButton_picture, SIGNAL(clicked()), this, SLOT( toggle())); 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.pushButton_picture->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/photo.png")));
ui.frame_picture->hide(); ui.frame_picture->hide();
// initially hiding the browse button as the attach image button is not pressed
ui.frame_PictureBrowse->hide();
setAcceptDrops(true); setAcceptDrops(true);
} }
@ -153,8 +160,12 @@ void PulseAddDialog::cleanup()
ui.label_image4->clear(); ui.label_image4->clear();
ui.label_image4->setText(tr("Drag and Drop Image")); ui.label_image4->setText(tr("Drag and Drop Image"));
// Hide Drag & Drop Frame ui.lineEdit_FilePath->clear();
ui.frame_picture->hide();
// Hide Drag & Drop Frame and the browse frame
ui.frame_picture->hide();
ui.frame_PictureBrowse->hide();
ui.pushButton_picture->setChecked(false); ui.pushButton_picture->setChecked(false);
} }
@ -510,12 +521,29 @@ void PulseAddDialog::toggle()
{ {
if (ui.pushButton_picture->isChecked()) if (ui.pushButton_picture->isChecked())
{ {
// Show the input methods (drag and drop field and the browse button)
ui.frame_picture->show(); ui.frame_picture->show();
ui.frame_PictureBrowse->show();
ui.pushButton_picture->setToolTip(tr("Hide Pictures")); ui.pushButton_picture->setToolTip(tr("Hide Pictures"));
} }
else else
{ {
// Hide the input methods (drag and drop field and the browse button)
ui.frame_picture->hide(); ui.frame_picture->hide();
ui.frame_PictureBrowse->hide();
ui.pushButton_picture->setToolTip(tr("Add Pictures")); 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);
}
}

View File

@ -53,6 +53,7 @@ private slots:
void clearDialog(); void clearDialog();
void pulseTextChanged(); void pulseTextChanged();
void toggle(); void toggle();
void onBrowseButtonClicked();
private: private:
// OLD VERSIONs, private now. // OLD VERSIONs, private now.

View File

@ -7,20 +7,20 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>720</width> <width>720</width>
<height>449</height> <height>513</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="PulseAddDialog_GL"> <layout class="QVBoxLayout" name="verticalLayout_2">
<property name="topMargin">
<number>0</number>
</property>
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0"> <property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QFrame" name="frame_from"> <widget class="QFrame" name="frame_from">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed"> <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@ -52,7 +52,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>
@ -118,7 +117,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QFrame" name="frame_reply"> <widget class="QFrame" name="frame_reply">
<layout class="QVBoxLayout" name="frame_reply_VL"> <layout class="QVBoxLayout" name="frame_reply_VL">
<property name="leftMargin"> <property name="leftMargin">
@ -232,18 +231,9 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0"> <item>
<widget class="QFrame" name="frame_input"> <widget class="QFrame" name="frame_input">
<layout class="QVBoxLayout" name="frame_input_VL"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item> <item>
<widget class="QTextEdit" name="textEdit_Pulse"> <widget class="QTextEdit" name="textEdit_Pulse">
<property name="font"> <property name="font">
@ -262,7 +252,7 @@
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
<height>100</height> <height>80</height>
</size> </size>
</property> </property>
<property name="frameShape"> <property name="frameShape">
@ -271,29 +261,13 @@
<property name="frameShadow"> <property name="frameShadow">
<enum>QFrame::Raised</enum> <enum>QFrame::Raised</enum>
</property> </property>
<layout class="QGridLayout" name="frame_picture_GL"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_image1">
<property name="minimumSize">
<size>
<width>80</width>
<height>80</height>
</size>
</property>
<property name="text">
<string>Drag and Drop Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLabel" name="label_image2"> <widget class="QLabel" name="label_image2">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>40</width>
<height>80</height> <height>40</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
@ -308,8 +282,24 @@
<widget class="QLabel" name="label_image3"> <widget class="QLabel" name="label_image3">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>40</width>
<height>80</height> <height>40</height>
</size>
</property>
<property name="text">
<string>Drag and Drop Image</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_image1">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
@ -324,8 +314,8 @@
<widget class="QLabel" name="label_image4"> <widget class="QLabel" name="label_image4">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>80</width> <width>40</width>
<height>80</height> <height>40</height>
</size> </size>
</property> </property>
<property name="text"> <property name="text">
@ -340,15 +330,49 @@
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QFrame" name="frame_URL"> <widget class="QFrame" name="frame_PictureBrowse">
<layout class="QGridLayout" name="frame_URL_GL"> <property name="minimumSize">
<item row="0" column="0"> <size>
<widget class="QLabel" name="label_URL"> <width>0</width>
<property name="text"> <height>50</height>
<string>URL</string> </size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLineEdit" name="lineEdit_FilePath">
<property name="minimumSize">
<size>
<width>541</width>
<height>25</height>
</size>
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="pushButton_Browse">
<property name="minimumSize">
<size>
<width>101</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>Browse...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_URL">
<layout class="QGridLayout" name="frame_URL_GL">
<item row="0" column="1"> <item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_URL"/> <widget class="QLineEdit" name="lineEdit_URL"/>
</item> </item>
@ -359,13 +383,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_DisplayAs">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_DisplayAs"/> <widget class="QLineEdit" name="lineEdit_DisplayAs"/>
</item> </item>
@ -376,13 +393,31 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="label_DisplayAs">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_URL">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
</layout> </layout>
<zorder>frame_URL</zorder>
<zorder>frame_picture</zorder>
<zorder>frame_PictureBrowse</zorder>
<zorder>textEdit_Pulse</zorder>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item>
<layout class="QHBoxLayout" name="butons_HL"> <layout class="QHBoxLayout" name="butons_HL">
<property name="leftMargin"> <property name="leftMargin">
<number>6</number> <number>6</number>
@ -421,7 +456,6 @@
<property name="font"> <property name="font">
<font> <font>
<pointsize>12</pointsize> <pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold> <bold>true</bold>
</font> </font>
</property> </property>