Screenshots: Optimize image loading and memory use, fix list and button layout.
This commit is contained in:
		| @@ -465,6 +465,7 @@ logic/lists/JavaVersionList.cpp | |||||||
|  |  | ||||||
| # the screenshots feature | # the screenshots feature | ||||||
| logic/screenshots/Screenshot.h | logic/screenshots/Screenshot.h | ||||||
|  | logic/screenshots/Screenshot.cpp | ||||||
| logic/screenshots/ScreenshotList.h | logic/screenshots/ScreenshotList.h | ||||||
| logic/screenshots/ScreenshotList.cpp | logic/screenshots/ScreenshotList.cpp | ||||||
| logic/screenshots/ImgurUpload.h | logic/screenshots/ImgurUpload.h | ||||||
|   | |||||||
| @@ -38,6 +38,9 @@ | |||||||
|      <property name="isWrapping" stdset="0"> |      <property name="isWrapping" stdset="0"> | ||||||
|       <bool>true</bool> |       <bool>true</bool> | ||||||
|      </property> |      </property> | ||||||
|  |      <property name="resizeMode"> | ||||||
|  |       <enum>QListView::Adjust</enum> | ||||||
|  |      </property> | ||||||
|      <property name="viewMode"> |      <property name="viewMode"> | ||||||
|       <enum>QListView::IconMode</enum> |       <enum>QListView::IconMode</enum> | ||||||
|      </property> |      </property> | ||||||
| @@ -45,6 +48,20 @@ | |||||||
|    </item> |    </item> | ||||||
|    <item> |    <item> | ||||||
|     <layout class="QHBoxLayout" name="horizontalLayout"> |     <layout class="QHBoxLayout" name="horizontalLayout"> | ||||||
|  |      <item> | ||||||
|  |       <widget class="QPushButton" name="uploadBtn"> | ||||||
|  |        <property name="text"> | ||||||
|  |         <string>Upload</string> | ||||||
|  |        </property> | ||||||
|  |       </widget> | ||||||
|  |      </item> | ||||||
|  |      <item> | ||||||
|  |       <widget class="QPushButton" name="deleteBtn"> | ||||||
|  |        <property name="text"> | ||||||
|  |         <string>Delete</string> | ||||||
|  |        </property> | ||||||
|  |       </widget> | ||||||
|  |      </item> | ||||||
|      <item> |      <item> | ||||||
|       <spacer name="horizontalSpacer"> |       <spacer name="horizontalSpacer"> | ||||||
|        <property name="orientation"> |        <property name="orientation"> | ||||||
| @@ -65,20 +82,6 @@ | |||||||
|        </property> |        </property> | ||||||
|       </widget> |       </widget> | ||||||
|      </item> |      </item> | ||||||
|      <item> |  | ||||||
|       <widget class="QPushButton" name="uploadBtn"> |  | ||||||
|        <property name="text"> |  | ||||||
|         <string>Upload</string> |  | ||||||
|        </property> |  | ||||||
|       </widget> |  | ||||||
|      </item> |  | ||||||
|      <item> |  | ||||||
|       <widget class="QPushButton" name="deleteBtn"> |  | ||||||
|        <property name="text"> |  | ||||||
|         <string>Delete</string> |  | ||||||
|        </property> |  | ||||||
|       </widget> |  | ||||||
|      </item> |  | ||||||
|     </layout> |     </layout> | ||||||
|    </item> |    </item> | ||||||
|   </layout> |   </layout> | ||||||
|   | |||||||
							
								
								
									
										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 <QDateTime> | ||||||
| #include <QString> | #include <QString> | ||||||
| #include <memory> | #include <memory> | ||||||
|  | #include <QIcon> | ||||||
|  |  | ||||||
| struct ScreenShot | struct ScreenShot | ||||||
| { | { | ||||||
|  | 	QIcon getImage(); | ||||||
|  | 	QIcon m_image; | ||||||
|  | 	bool imageloaded = false; | ||||||
| 	QDateTime timestamp; | 	QDateTime timestamp; | ||||||
| 	QString file; | 	QString file; | ||||||
| 	QString url; | 	QString url; | ||||||
|   | |||||||
| @@ -25,7 +25,7 @@ QVariant ScreenshotList::data(const QModelIndex &index, int role) const | |||||||
| 	switch (role) | 	switch (role) | ||||||
| 	{ | 	{ | ||||||
| 	case Qt::DecorationRole: | 	case Qt::DecorationRole: | ||||||
| 		return QIcon(m_screenshots.at(index.row())->file); | 		return m_screenshots.at(index.row())->getImage(); | ||||||
| 	case Qt::DisplayRole: | 	case Qt::DisplayRole: | ||||||
| 		return m_screenshots.at(index.row())->timestamp.toString("yyyy-MM-dd HH:mm:ss"); | 		return m_screenshots.at(index.row())->timestamp.toString("yyyy-MM-dd HH:mm:ss"); | ||||||
| 	case Qt::ToolTipRole: | 	case Qt::ToolTipRole: | ||||||
| @@ -80,6 +80,7 @@ void ScreenshotLoadTask::executeTask() | |||||||
| 	m_list->loadShots(m_results); | 	m_list->loadShots(m_results); | ||||||
| 	emitSucceeded(); | 	emitSucceeded(); | ||||||
| } | } | ||||||
|  |  | ||||||
| void ScreenshotList::deleteSelected(ScreenshotDialog *dialog) | void ScreenshotList::deleteSelected(ScreenshotDialog *dialog) | ||||||
| { | { | ||||||
| 	auto screens = dialog->selected(); | 	auto screens = dialog->selected(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user