mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Open downloaded image with mouse click on thumbnail
This commit is contained in:
parent
d614f74947
commit
857dfbcd4c
|
@ -53,7 +53,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
// hide the QWidget background (background-color: transparent doesn't seem to work)
|
// hide the QWidget background (background-color: transparent doesn't seem to work)
|
||||||
setAttribute(Qt::WA_TranslucentBackground, true);
|
setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
|
||||||
ui->previewLabel->hide();
|
ui->previewButton->hide();
|
||||||
ui->filenameLabel->setText(file.fileName);
|
ui->filenameLabel->setText(file.fileName);
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
ui->fileSizeLabel->setText(getHumanReadableSize(file.filesize));
|
ui->fileSizeLabel->setText(getHumanReadableSize(file.filesize));
|
||||||
|
@ -86,6 +86,7 @@ FileTransferWidget::FileTransferWidget(QWidget *parent, ToxFile file)
|
||||||
connect(Core::getInstance(), &Core::fileTransferBrokenUnbroken, this, &FileTransferWidget::fileTransferBrokenUnbroken);
|
connect(Core::getInstance(), &Core::fileTransferBrokenUnbroken, this, &FileTransferWidget::fileTransferBrokenUnbroken);
|
||||||
connect(ui->topButton, &QPushButton::clicked, this, &FileTransferWidget::onTopButtonClicked);
|
connect(ui->topButton, &QPushButton::clicked, this, &FileTransferWidget::onTopButtonClicked);
|
||||||
connect(ui->bottomButton, &QPushButton::clicked, this, &FileTransferWidget::onBottomButtonClicked);
|
connect(ui->bottomButton, &QPushButton::clicked, this, &FileTransferWidget::onBottomButtonClicked);
|
||||||
|
connect(ui->previewButton, &QPushButton::clicked, this, &FileTransferWidget::onPreviewButtonClicked);
|
||||||
|
|
||||||
setupButtons();
|
setupButtons();
|
||||||
|
|
||||||
|
@ -482,7 +483,7 @@ void FileTransferWidget::handleButton(QPushButton *btn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (btn->objectName() == "ok")
|
if (btn->objectName() == "ok" || btn->objectName() == "previewButton")
|
||||||
{
|
{
|
||||||
Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath));
|
Widget::confirmExecutableOpen(QFileInfo(fileInfo.filePath));
|
||||||
}
|
}
|
||||||
|
@ -501,13 +502,13 @@ void FileTransferWidget::showPreview(const QString &filename)
|
||||||
|
|
||||||
if (previewExtensions.contains(QFileInfo(filename).suffix()))
|
if (previewExtensions.contains(QFileInfo(filename).suffix()))
|
||||||
{
|
{
|
||||||
const int size = qMax(ui->previewLabel->width(), ui->previewLabel->height());
|
const int size = qMax(ui->previewButton->width(), ui->previewButton->height());
|
||||||
|
|
||||||
QPixmap pmap = QPixmap(filename).scaled(QSize(size, size),
|
QPixmap pmap = QPixmap(filename).scaled(QSize(size, size),
|
||||||
Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
ui->previewLabel->setPixmap(pmap);
|
ui->previewButton->setIcon(QIcon(pmap));
|
||||||
ui->previewLabel->show();
|
ui->previewButton->setIconSize(pmap.size());
|
||||||
ui->previewLabel->setCursor(Qt::PointingHandCursor);
|
ui->previewButton->show();
|
||||||
// Show mouseover preview, but make sure it's not larger than 50% of the screen width/height
|
// Show mouseover preview, but make sure it's not larger than 50% of the screen width/height
|
||||||
QRect desktopSize = QApplication::desktop()->screenGeometry();
|
QRect desktopSize = QApplication::desktop()->screenGeometry();
|
||||||
QImage image = QImage(filename).scaled(0.5 * desktopSize.width(),
|
QImage image = QImage(filename).scaled(0.5 * desktopSize.width(),
|
||||||
|
@ -518,7 +519,7 @@ void FileTransferWidget::showPreview(const QString &filename)
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
image.save(&buffer, "PNG");
|
image.save(&buffer, "PNG");
|
||||||
buffer.close();
|
buffer.close();
|
||||||
ui->previewLabel->setToolTip("<img src=data:image/png;base64," + imageData.toBase64() + "/>");
|
ui->previewButton->setToolTip("<img src=data:image/png;base64," + imageData.toBase64() + "/>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,3 +532,8 @@ void FileTransferWidget::onBottomButtonClicked()
|
||||||
{
|
{
|
||||||
handleButton(ui->bottomButton);
|
handleButton(ui->bottomButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FileTransferWidget::onPreviewButtonClicked()
|
||||||
|
{
|
||||||
|
handleButton(ui->previewButton);
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ protected:
|
||||||
private slots:
|
private slots:
|
||||||
void onTopButtonClicked();
|
void onTopButtonClicked();
|
||||||
void onBottomButtonClicked();
|
void onBottomButtonClicked();
|
||||||
|
void onPreviewButtonClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::FileTransferWidget *ui;
|
Ui::FileTransferWidget *ui;
|
||||||
|
|
|
@ -270,7 +270,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="previewLabel">
|
<widget class="QPushButton" name="previewButton">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -289,14 +289,21 @@
|
||||||
<height>60</height>
|
<height>60</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<property name="cursor">
|
||||||
<enum>QFrame::Box</enum>
|
<cursorShape>PointingHandCursor</cursorShape>
|
||||||
</property>
|
</property>
|
||||||
<property name="lineWidth">
|
<property name="icon">
|
||||||
<number>2</number>
|
<iconset resource="../../../res.qrc">
|
||||||
|
<normaloff>:/ui/fileTransferInstance/no.svg</normaloff>:/ui/fileTransferInstance/no.svg</iconset>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="iconSize">
|
||||||
<string>[preview]</string>
|
<size>
|
||||||
|
<width>32</width>
|
||||||
|
<height>18</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user