diff --git a/CMakeLists.txt b/CMakeLists.txt index da7b0e0bd..ee836cd26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -465,6 +465,7 @@ logic/lists/JavaVersionList.cpp # the screenshots feature logic/screenshots/Screenshot.h +logic/screenshots/Screenshot.cpp logic/screenshots/ScreenshotList.h logic/screenshots/ScreenshotList.cpp logic/screenshots/ImgurUpload.h diff --git a/gui/dialogs/ScreenshotDialog.ui b/gui/dialogs/ScreenshotDialog.ui index 4e42a5489..eb3dafba5 100644 --- a/gui/dialogs/ScreenshotDialog.ui +++ b/gui/dialogs/ScreenshotDialog.ui @@ -38,6 +38,9 @@ true + + QListView::Adjust + QListView::IconMode @@ -45,6 +48,20 @@ + + + + Upload + + + + + + + Delete + + + @@ -65,20 +82,6 @@ - - - - Upload - - - - - - - Delete - - - diff --git a/logic/screenshots/Screenshot.cpp b/logic/screenshots/Screenshot.cpp new file mode 100644 index 000000000..882e491ff --- /dev/null +++ b/logic/screenshots/Screenshot.cpp @@ -0,0 +1,14 @@ +#include "Screenshot.h" +#include +#include +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; +} diff --git a/logic/screenshots/Screenshot.h b/logic/screenshots/Screenshot.h index 194e70e5d..815c0d47b 100644 --- a/logic/screenshots/Screenshot.h +++ b/logic/screenshots/Screenshot.h @@ -3,9 +3,13 @@ #include #include #include +#include struct ScreenShot { + QIcon getImage(); + QIcon m_image; + bool imageloaded = false; QDateTime timestamp; QString file; QString url; diff --git a/logic/screenshots/ScreenshotList.cpp b/logic/screenshots/ScreenshotList.cpp index def1bdf7a..8a64dc36d 100644 --- a/logic/screenshots/ScreenshotList.cpp +++ b/logic/screenshots/ScreenshotList.cpp @@ -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();