42 lines
1.0 KiB
C++
42 lines
1.0 KiB
C++
#include "PhotoDisplay.h"
|
|
|
|
#include <QPixmap>
|
|
#include <QGridLayout>
|
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "ui_PhotoDisplay.h"
|
|
|
|
PhotoDisplay::PhotoDisplay(QWidget* parent) : QWidget(parent)
|
|
, ui(new Ui::PhotoDisplay) {
|
|
ui->setupUi(this);
|
|
|
|
setWindowFlags( Qt::FramelessWindowHint | Qt::Tool | Qt::WindowStaysOnTopHint);
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
ui->label->setAlignment(Qt::AlignCenter);
|
|
}
|
|
|
|
void PhotoDisplay::ShowPhoto(const QString& path) {
|
|
qDebug() << __FUNCTION__ << path;
|
|
m_pixmap.load(path);
|
|
QPixmap showPixmap = m_pixmap.scaled(size(), Qt::KeepAspectRatio);
|
|
|
|
ui->label->setPixmap(showPixmap);
|
|
|
|
show();
|
|
}
|
|
|
|
void PhotoDisplay::MoveCenter() {
|
|
const QSize& size = MainWindow::Get().size();
|
|
move((size.width() - width()) / 2, (size.height() - height()) / 2);
|
|
}
|
|
|
|
void PhotoDisplay::resizeEvent(QResizeEvent* event) {
|
|
if (!m_pixmap.isNull()) {
|
|
QPixmap showPixmap = m_pixmap.scaledToWidth(size().width() , Qt::SmoothTransformation);
|
|
ui->label->setPixmap(showPixmap);
|
|
}
|
|
|
|
}
|