Screenshots: Optimize image loading and memory use, fix list and button layout.
This commit is contained in:
14
logic/screenshots/Screenshot.cpp
Normal file
14
logic/screenshots/Screenshot.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "Screenshot.h"
|
||||
#include <QImage>
|
||||
#include <QIcon>
|
||||
QIcon ScreenShot::getImage()
|
||||
{
|
||||
if(!imageloaded)
|
||||
{
|
||||
QImage image(file);
|
||||
QImage thumbnail = image.scaledToWidth(256, Qt::SmoothTransformation);
|
||||
m_image = QIcon(QPixmap::fromImage(thumbnail));
|
||||
imageloaded = true;
|
||||
}
|
||||
return m_image;
|
||||
}
|
@ -3,9 +3,13 @@
|
||||
#include <QDateTime>
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
#include <QIcon>
|
||||
|
||||
struct ScreenShot
|
||||
{
|
||||
QIcon getImage();
|
||||
QIcon m_image;
|
||||
bool imageloaded = false;
|
||||
QDateTime timestamp;
|
||||
QString file;
|
||||
QString url;
|
||||
|
@ -25,7 +25,7 @@ QVariant ScreenshotList::data(const QModelIndex &index, int role) const
|
||||
switch (role)
|
||||
{
|
||||
case Qt::DecorationRole:
|
||||
return QIcon(m_screenshots.at(index.row())->file);
|
||||
return m_screenshots.at(index.row())->getImage();
|
||||
case Qt::DisplayRole:
|
||||
return m_screenshots.at(index.row())->timestamp.toString("yyyy-MM-dd HH:mm:ss");
|
||||
case Qt::ToolTipRole:
|
||||
@ -80,6 +80,7 @@ void ScreenshotLoadTask::executeTask()
|
||||
m_list->loadShots(m_results);
|
||||
emitSucceeded();
|
||||
}
|
||||
|
||||
void ScreenshotList::deleteSelected(ScreenshotDialog *dialog)
|
||||
{
|
||||
auto screens = dialog->selected();
|
||||
|
Reference in New Issue
Block a user