Improved the Image attach Page

This commit is contained in:
defnax 2020-01-06 17:02:17 +01:00
parent c210bf4b9e
commit 846767e83b
2 changed files with 194 additions and 101 deletions

View file

@ -50,7 +50,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *pos
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost())); connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->pushButton, SIGNAL(clicked() ), this , SLOT(addPicture())); connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture()));
ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/postedlinks.png")); ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/postedlinks.png"));
ui->headerFrame->setHeaderText(tr("Create a new Post")); ui->headerFrame->setHeaderText(tr("Create a new Post"));
@ -169,7 +169,7 @@ void PostedCreatePostDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
ui->linkEdit->setText(link.toString()); ui->linkEdit->setText(link.toString());
} }
ui->submitButton->setEnabled(true); ui->submitButton->setEnabled(true);
ui->pushButton->setEnabled(true); ui->addPicButton->setEnabled(true);
} }
void PostedCreatePostDialog::addPicture() void PostedCreatePostDialog::addPicture()
@ -192,6 +192,8 @@ void PostedCreatePostDialog::addPicture()
QImage opt; QImage opt;
if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt, 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt, 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff
ui->imageLabel->setPixmap(QPixmap::fromImage(opt)); ui->imageLabel->setPixmap(QPixmap::fromImage(opt));
ui->stackedWidgetPicture->setCurrentIndex(1);
ui->removeButton->show();
} else { } else {
imagefilename = ""; imagefilename = "";
imagebytes.clear(); imagebytes.clear();
@ -211,13 +213,13 @@ void PostedCreatePostDialog::addPicture()
//If still yes then link it //If still yes then link it
if(answer == QMessageBox::Yes) { if(answer == QMessageBox::Yes) {
ui->submitButton->setEnabled(false); ui->submitButton->setEnabled(false);
ui->pushButton->setEnabled(false); ui->addPicButton->setEnabled(false);
QStringList files; QStringList files;
files.append(imagefilename); files.append(imagefilename);
ui->hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING); ui->hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING);
} }
ui->removeButton->show();
} }
void PostedCreatePostDialog::on_postButton_clicked() void PostedCreatePostDialog::on_postButton_clicked()
@ -242,4 +244,5 @@ void PostedCreatePostDialog::on_removeButton_clicked()
QPixmap empty; QPixmap empty;
ui->imageLabel->setPixmap(empty); ui->imageLabel->setPixmap(empty);
ui->removeButton->hide(); ui->removeButton->hide();
ui->stackedWidgetPicture->setCurrentIndex(0);
} }

View file

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>575</width> <width>575</width>
<height>529</height> <height>518</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -77,19 +77,44 @@
<property name="leftMargin"> <property name="leftMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item row="2" column="0" colspan="4"> <item row="0" column="0" colspan="2">
<widget class="HashBox" name="hashBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QGroupBox" name="groupBox"> <widget class="QGroupBox" name="groupBox">
<property name="title"> <property name="title">
<string>Preview</string> <string>Preview</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0" rowspan="2"> <property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -102,14 +127,127 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="1" rowspan="2"> <item row="0" column="2">
<widget class="QLabel" name="imageLabel"> <spacer name="horizontalSpacer_3">
<property name="minimumSize"> <property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size> <size>
<width>250</width> <width>40</width>
<height>200</height> <height>20</height>
</size> </size>
</property> </property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QStackedWidget" name="stackedWidgetPicture">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="PageAttach">
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<property name="topMargin">
<number>9</number>
</property>
<item row="1" column="0">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="addPicButton">
<property name="text">
<string>Add Picture</string>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
<normaloff>:/icons/png/add-image.png</normaloff>:/icons/png/add-image.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QLabel" name="sizeWarningLabel">
<property name="text">
<string>Post size is limited to 32 KB, pictures will be downscaled.</string>
</property>
</widget>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>267</width>
<height>138</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="PageImage">
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<property name="horizontalSpacing">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="imageLabel">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>800</width> <width>800</width>
@ -124,33 +262,20 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="2" colspan="2"> <item row="1" column="0">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="2">
<spacer name="horizontalSpacer_5"> <spacer name="horizontalSpacer_5">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="sizeHint" stdset="0">
<size> <size>
<width>40</width> <width>188</width>
<height>20</height> <height>17</height>
</size> </size>
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="3"> <item row="1" column="1">
<widget class="QToolButton" name="removeButton"> <widget class="QToolButton" name="removeButton">
<property name="toolTip"> <property name="toolTip">
<string>Remove image</string> <string>Remove image</string>
@ -172,45 +297,9 @@
</item> </item>
</layout> </layout>
</widget> </widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>447</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QLabel" name="sizeWarningLabel">
<property name="text">
<string>Post size is limited to 32 KB, pictures will be downscaled.</string>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> </layout>
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>Add Picture</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="HashBox" name="hashBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -536,6 +625,7 @@
</customwidgets> </customwidgets>
<resources> <resources>
<include location="Posted_images.qrc"/> <include location="Posted_images.qrc"/>
<include location="../icons.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>