Picture attachments improved

* Added a remove button to clear pictures
* Improved picture attachments
This commit is contained in:
defnax 2023-04-20 23:26:57 +02:00
parent 6476cfa4e0
commit a71d6e2430
3 changed files with 91 additions and 60 deletions

View File

@ -42,15 +42,26 @@ PulseAddDialog::PulseAddDialog(QWidget *parent)
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) ); connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) );
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()));
connect(ui.pushButton_remove, SIGNAL(clicked()), this, SLOT( removePictures()));
// this connection is from browse push button to the slot function onBrowseButtonClicked() // this connection is from browse push button to the slot function onBrowseButtonClicked()
connect(ui.pushButton_Browse, SIGNAL(clicked()), this, SLOT( 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.pushButton_Browse->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/png/add-image.png")));
ui.pushButton_remove->setIcon(FilesDefs::getIconFromQtResourcePath(QString(":/icons/mail/delete.png")));
ui.frame_picture->hide(); ui.frame_picture->hide();
ui.pushButton_picture->hide();
// initially hiding the browse button as the attach image button is not pressed // initially hiding the browse button as the attach image button is not pressed
ui.frame_PictureBrowse->hide(); //ui.frame_PictureBrowse->hide();
ui.label_image1->hide();
ui.label_image2->hide();
ui.label_image3->hide();
ui.label_image4->hide();
setAcceptDrops(true); setAcceptDrops(true);
} }
@ -160,11 +171,10 @@ 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"));
ui.lineEdit_FilePath->clear();
// Hide Drag & Drop Frame and the browse frame // Hide Drag & Drop Frame and the browse frame
ui.frame_picture->hide(); ui.frame_picture->hide();
ui.frame_PictureBrowse->hide(); //ui.frame_PictureBrowse->hide();
ui.pushButton_picture->hide();
ui.pushButton_picture->setChecked(false); ui.pushButton_picture->setChecked(false);
} }
@ -489,24 +499,29 @@ void PulseAddDialog::addImage(const QString &path)
std::cerr << "PulseAddDialog::addImage() Installing in Image1"; std::cerr << "PulseAddDialog::addImage() Installing in Image1";
std::cerr << std::endl; std::cerr << std::endl;
ui.label_image1->setPixmap(icon); ui.label_image1->setPixmap(icon);
ui.label_image1->show();
ui.frame_picture->show();
mImage1.copy((uint8_t *) ba.data(), ba.size()); mImage1.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image1 Size: " << mImage1.mSize; std::cerr << "PulseAddDialog::addImage() Installing in Image1 Size: " << mImage1.mSize;
std::cerr << std::endl; std::cerr << std::endl;
} }
else if (mImage2.empty()) { else if (mImage2.empty()) {
ui.label_image2->setPixmap(icon); ui.label_image2->setPixmap(icon);
ui.label_image2->show();
mImage2.copy((uint8_t *) ba.data(), ba.size()); mImage2.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image2 Size: " << mImage2.mSize; std::cerr << "PulseAddDialog::addImage() Installing in Image2 Size: " << mImage2.mSize;
std::cerr << std::endl; std::cerr << std::endl;
} }
else if (mImage3.empty()) { else if (mImage3.empty()) {
ui.label_image3->setPixmap(icon); ui.label_image3->setPixmap(icon);
ui.label_image3->show();
mImage3.copy((uint8_t *) ba.data(), ba.size()); mImage3.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image3 Size: " << mImage3.mSize; std::cerr << "PulseAddDialog::addImage() Installing in Image3 Size: " << mImage3.mSize;
std::cerr << std::endl; std::cerr << std::endl;
} }
else if (mImage4.empty()) { else if (mImage4.empty()) {
ui.label_image4->setPixmap(icon); ui.label_image4->setPixmap(icon);
ui.label_image4->show();
mImage4.copy((uint8_t *) ba.data(), ba.size()); mImage4.copy((uint8_t *) ba.data(), ba.size());
std::cerr << "PulseAddDialog::addImage() Installing in Image4 Size: " << mImage4.mSize; std::cerr << "PulseAddDialog::addImage() Installing in Image4 Size: " << mImage4.mSize;
std::cerr << std::endl; std::cerr << std::endl;
@ -523,7 +538,6 @@ void PulseAddDialog::toggle()
{ {
// Show the input methods (drag and drop field and the browse button) // 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"));
} }
@ -531,7 +545,6 @@ void PulseAddDialog::toggle()
{ {
// Hide the input methods (drag and drop field and the browse button) // 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"));
} }
@ -543,8 +556,27 @@ void PulseAddDialog::onBrowseButtonClicked()
QString filePath; QString filePath;
misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg *.gif *.webp )", filePath); misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg *.jpeg *.gif *.webp )", filePath);
if (!filePath.isEmpty()) { if (!filePath.isEmpty()) {
ui.lineEdit_FilePath->setText(filePath); //ui.lineEdit_FilePath->setText(filePath);
addImage(filePath); addImage(filePath);
} }
} }
void PulseAddDialog::removePictures()
{
mImage1.clear();
ui.label_image1->clear();
mImage2.clear();
ui.label_image2->clear();
mImage3.clear();
ui.label_image3->clear();
mImage4.clear();
ui.label_image4->clear();
ui.label_image1->hide();
ui.label_image2->hide();
ui.label_image3->hide();
ui.label_image4->hide();
ui.frame_picture->hide();
}

View File

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

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>720</width> <width>735</width>
<height>513</height> <height>513</height>
</rect> </rect>
</property> </property>
@ -52,6 +52,7 @@
<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>
@ -249,6 +250,12 @@
</item> </item>
<item> <item>
<widget class="QFrame" name="frame_picture"> <widget class="QFrame" name="frame_picture">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>0</width> <width>0</width>
@ -278,6 +285,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1">
<widget class="QLabel" name="label_image4">
<property name="minimumSize">
<size>
<width>40</width>
<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="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_image3"> <widget class="QLabel" name="label_image3">
<property name="minimumSize"> <property name="minimumSize">
@ -310,63 +333,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="0" column="2" rowspan="2">
<widget class="QLabel" name="label_image4"> <widget class="QToolButton" name="pushButton_remove">
<property name="minimumSize"> <property name="toolTip">
<size> <string>Remove all images</string>
<width>40</width>
<height>40</height>
</size>
</property> </property>
<property name="text"> <property name="text">
<string>Drag and Drop Image</string> <string/>
</property> </property>
<property name="alignment"> <property name="iconSize">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_PictureBrowse">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</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> <size>
<width>541</width> <width>24</width>
<height>25</height> <height>24</height>
</size> </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> </layout>
</widget> </widget>
</item> </item>
@ -413,7 +395,6 @@
</layout> </layout>
<zorder>frame_URL</zorder> <zorder>frame_URL</zorder>
<zorder>frame_picture</zorder> <zorder>frame_picture</zorder>
<zorder>frame_PictureBrowse</zorder>
<zorder>textEdit_Pulse</zorder> <zorder>textEdit_Pulse</zorder>
</widget> </widget>
</item> </item>
@ -423,7 +404,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QPushButton" name="pushButton_picture"> <widget class="QToolButton" name="pushButton_picture">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
@ -438,6 +419,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="pushButton_Browse">
<property name="toolTip">
<string>Add Picture</string>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item> <item>
<spacer name="buttonHSpacer"> <spacer name="buttonHSpacer">
<property name="orientation"> <property name="orientation">
@ -456,6 +453,7 @@
<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>