Merge branch '0.7.0-dev' of ssh://github.com/Nheko-Reborn/nheko into 0.7.0-dev

This commit is contained in:
Joseph Donofry 2019-07-21 21:58:48 -04:00
commit 49ec388c1d
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
5 changed files with 28 additions and 7 deletions

View file

@ -306,8 +306,9 @@ FilteredTextEdit::insertFromMimeData(const QMimeData *source)
const auto audio = formats.filter("audio/", Qt::CaseInsensitive); const auto audio = formats.filter("audio/", Qt::CaseInsensitive);
const auto video = formats.filter("video/", Qt::CaseInsensitive); const auto video = formats.filter("video/", Qt::CaseInsensitive);
if (!image.empty()) { if (source->hasImage()) {
showPreview(source, image); QImage img = qvariant_cast<QImage>(source->imageData());
previewDialog_.setPreview(img, image.front());
} else if (!audio.empty()) { } else if (!audio.empty()) {
showPreview(source, audio); showPreview(source, audio);
} else if (!video.empty()) { } else if (!video.empty()) {

View file

@ -34,10 +34,6 @@
#include "popups/ReplyPopup.h" #include "popups/ReplyPopup.h"
#include "popups/SuggestionsPopup.h" #include "popups/SuggestionsPopup.h"
namespace dialogs {
class PreviewUploadOverlay;
}
struct SearchResult; struct SearchResult;
class FlatButton; class FlatButton;

View file

@ -134,6 +134,28 @@ PreviewUploadOverlay::setLabels(const QString &type, const QString &mime, uint64
} }
} }
void
PreviewUploadOverlay::setPreview(const QImage &src, const QString &mime)
{
auto const &split = mime.split('/');
auto const &type = split[1];
QBuffer buffer(&data_);
buffer.open(QIODevice::WriteOnly);
if (src.save(&buffer, type.toStdString().c_str()))
titleLabel_.setText(QString{tr(DEFAULT)}.arg("image"));
else
titleLabel_.setText(QString{tr(ERR_MSG)}.arg(type));
mediaType_ = split[0];
filePath_ = "clipboard." + type;
image_.convertFromImage(src);
isImage_ = true;
titleLabel_.setText(QString{tr(DEFAULT)}.arg("image"));
init();
}
void void
PreviewUploadOverlay::setPreview(const QByteArray data, const QString &mime) PreviewUploadOverlay::setPreview(const QByteArray data, const QString &mime)
{ {

View file

@ -17,6 +17,7 @@
#pragma once #pragma once
#include <QImage>
#include <QLabel> #include <QLabel>
#include <QLineEdit> #include <QLineEdit>
#include <QPixmap> #include <QPixmap>
@ -33,6 +34,7 @@ class PreviewUploadOverlay : public QWidget
public: public:
PreviewUploadOverlay(QWidget *parent = nullptr); PreviewUploadOverlay(QWidget *parent = nullptr);
void setPreview(const QImage &src, const QString &mime);
void setPreview(const QByteArray data, const QString &mime); void setPreview(const QByteArray data, const QString &mime);
void setPreview(const QString &path); void setPreview(const QString &path);

View file

@ -118,12 +118,12 @@ main(int argc, char *argv[])
} }
#endif #endif
QApplication app(argc, argv);
QCoreApplication::setApplicationName("nheko"); QCoreApplication::setApplicationName("nheko");
QCoreApplication::setApplicationVersion(nheko::version); QCoreApplication::setApplicationVersion(nheko::version);
QCoreApplication::setOrganizationName("nheko"); QCoreApplication::setOrganizationName("nheko");
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QCommandLineParser parser; QCommandLineParser parser;
parser.addHelpOption(); parser.addHelpOption();