|
|
|
|
@ -2,6 +2,7 @@
|
|
|
|
|
#include "avatarmanager.h" |
|
|
|
|
#include "../imageviewer_window.h" |
|
|
|
|
#include <QDialog> |
|
|
|
|
#include <QCoreApplication> |
|
|
|
|
#include <QHBoxLayout> |
|
|
|
|
#include <QLabel> |
|
|
|
|
#include <QPointer> |
|
|
|
|
@ -10,10 +11,11 @@
|
|
|
|
|
#include <QVBoxLayout> |
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
QString text(const char* source) { return QCoreApplication::translate("ChatGui",source); } |
|
|
|
|
class Gallery : public QDialog { |
|
|
|
|
public: |
|
|
|
|
explicit Gallery(AvatarManager* source) : manager(source) { |
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose); resize(850,720); setWindowTitle(tr("Avatars")); |
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose); resize(850,720); setWindowTitle(text("Avatars")); |
|
|
|
|
auto* layout = new QVBoxLayout(this); viewer = new ImageViewerWindow(this); layout->addWidget(viewer,1); |
|
|
|
|
status = new QLabel(this); status->setAlignment(Qt::AlignCenter); layout->addWidget(status); |
|
|
|
|
auto* strip = new QHBoxLayout; strip->addStretch(); previous = new QPushButton("←",this); strip->addWidget(previous); |
|
|
|
|
@ -49,7 +51,7 @@ public:
|
|
|
|
|
const bool full=!image.isNull(); if (!full) image=manager->galleryImage(selected); |
|
|
|
|
if (image.cacheKey()!=displayed) { viewer->loadImage(image); displayed=image.cacheKey(); } |
|
|
|
|
if (full) status->setText(QString("%1 / %2").arg(index+1).arg(files.size())); |
|
|
|
|
else if (!image.isNull()) status->setText(tr("Loading original…")); |
|
|
|
|
else if (!image.isNull()) status->setText(text("Loading original…")); |
|
|
|
|
for (int i=0;i<5;i++) { |
|
|
|
|
const int item=index+i-2; const bool valid=item>=0 && item<files.size(); previews[i]->setEnabled(valid); |
|
|
|
|
previews[i]->setIcon(valid ? QIcon(QPixmap::fromImage(manager->galleryImage(files[item]))) : QIcon()); |
|
|
|
|
|