diff --git a/src/config/configwindow.cpp b/src/config/configwindow.cpp index 528b5250..a4dda9a1 100644 --- a/src/config/configwindow.cpp +++ b/src/config/configwindow.cpp @@ -23,7 +23,7 @@ ConfigWindow::ConfigWindow(QWidget* parent) { setAttribute(Qt::WA_DeleteOnClose); setMinimumSize(GlobalValues::buttonBaseSize() * 15, - GlobalValues::buttonBaseSize() * 12); + GlobalValues::buttonBaseSize() * 18); setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowTitle(tr("Configuration")); diff --git a/src/config/generalconf.cpp b/src/config/generalconf.cpp index b7df6f03..033622d5 100644 --- a/src/config/generalconf.cpp +++ b/src/config/generalconf.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -33,6 +34,7 @@ GeneralConf::GeneralConf(QWidget* parent) initCopyPathAfterSave(); initUseJpgForClipboard(); initSaveAfterCopy(); + initUploadHistoryMaxSize(); // this has to be at the end initConfigButtons(); @@ -178,6 +180,7 @@ void GeneralConf::setActualFormData() m_screenshotPathFixedCheck->setChecked(config.savePathFixed()); m_historyConfirmationToDelete->setChecked( config.historyConfirmationToDelete()); + m_uploadHistoryMaxSize->setValue(config.uploadHistoryMaxSizeValue()); m_useJpgForClipboard->setChecked(config.useJpgForClipboard()); } @@ -401,6 +404,38 @@ void GeneralConf::historyConfirmationToDelete(bool checked) ConfigHandler().setHistoryConfirmationToDelete(checked); } +void GeneralConf::initUploadHistoryMaxSize() +{ + QGroupBox* box = new QGroupBox(tr("Latest Uploads Max Size")); + box->setFlat(true); + m_layout->addWidget(box); + m_layout->addStretch(); + + QVBoxLayout* vboxLayout = new QVBoxLayout(); + box->setLayout(vboxLayout); + + int max = ConfigHandler().uploadHistoryMaxSizeValue(); + + m_uploadHistoryMaxSize = new QSpinBox(this); + m_uploadHistoryMaxSize->setMaximum(1000); + m_uploadHistoryMaxSize->setValue(max); + QString foreground = this->palette().windowText().color().name(); + m_uploadHistoryMaxSize->setStyleSheet( + QStringLiteral("color: %1").arg(foreground)); + + connect(m_uploadHistoryMaxSize, + SIGNAL(valueChanged(int)), + this, + SLOT(uploadHistoryMaxSizeChanged(int))); + + vboxLayout->addWidget(m_uploadHistoryMaxSize); +} + +void GeneralConf::uploadHistoryMaxSizeChanged(int max) +{ + ConfigHandler().setUploadHistoryMaxSize(max); +} + void GeneralConf::initUseJpgForClipboard() { m_useJpgForClipboard = diff --git a/src/config/generalconf.h b/src/config/generalconf.h index cddbe1eb..5e6fd0e1 100644 --- a/src/config/generalconf.h +++ b/src/config/generalconf.h @@ -10,6 +10,7 @@ class QCheckBox; class QPushButton; class QLabel; class QLineEdit; +class QSpinBox; class GeneralConf : public QWidget { @@ -28,6 +29,7 @@ private slots: void checkForUpdatesChanged(bool checked); void autostartChanged(bool checked); void historyConfirmationToDelete(bool checked); + void uploadHistoryMaxSizeChanged(int max); void saveAfterCopyChanged(bool checked); void changeSavePath(); void importConfiguration(); @@ -44,6 +46,7 @@ private: void initShowDesktopNotification(); void initShowTrayIcon(); void initHistoryConfirmationToDelete(); + void initUploadHistoryMaxSize(); void initConfigButtons(); void initCheckForUpdates(); void initAutostart(); @@ -75,4 +78,5 @@ private: QCheckBox* m_screenshotPathFixedCheck; QCheckBox* m_historyConfirmationToDelete; QCheckBox* m_useJpgForClipboard; + QSpinBox* m_uploadHistoryMaxSize; }; diff --git a/src/tools/imgur/imguruploadertool.h b/src/tools/imgur/imguruploadertool.h index 5aeb9752..48cffdbe 100644 --- a/src/tools/imgur/imguruploadertool.h +++ b/src/tools/imgur/imguruploadertool.h @@ -11,7 +11,7 @@ class ImgurUploaderTool : public AbstractActionTool public: explicit ImgurUploaderTool(QObject* parent = nullptr); - bool closeOnButtonPressed() const; + bool closeOnButtonPressed() const override; QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; diff --git a/src/tools/launcher/launcheritemdelegate.cpp b/src/tools/launcher/launcheritemdelegate.cpp index 0803bdef..fa368031 100644 --- a/src/tools/launcher/launcheritemdelegate.cpp +++ b/src/tools/launcher/launcheritemdelegate.cpp @@ -29,7 +29,8 @@ void LauncherItemDelegate::paint(QPainter* painter, const int halfWidth = rect.width() / 2; const int halfHeight = rect.height() / 2; QSize size(iconSide, iconSide); - QPixmap pixIcon = icon.pixmap(size).scaled(size, Qt::KeepAspectRatio); + QPixmap pixIcon = icon.pixmap(size).scaled( + size, Qt::KeepAspectRatio, Qt::SmoothTransformation); painter->drawPixmap(rect.x() + (halfWidth - halfIcon), rect.y() + (halfHeight / 2 - halfIcon), iconSide, diff --git a/src/tools/sizedecrease/sizedecreasetool.h b/src/tools/sizedecrease/sizedecreasetool.h index a2cf1346..07b8b8e5 100644 --- a/src/tools/sizedecrease/sizedecreasetool.h +++ b/src/tools/sizedecrease/sizedecreasetool.h @@ -25,7 +25,7 @@ class SizeDecreaseTool : public AbstractActionTool public: explicit SizeDecreaseTool(QObject* parent = nullptr); - bool closeOnButtonPressed() const; + bool closeOnButtonPressed() const override; QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; diff --git a/src/tools/sizeincrease/sizeincreasetool.h b/src/tools/sizeincrease/sizeincreasetool.h index e921cf33..80f0677f 100644 --- a/src/tools/sizeincrease/sizeincreasetool.h +++ b/src/tools/sizeincrease/sizeincreasetool.h @@ -25,7 +25,7 @@ class SizeIncreaseTool : public AbstractActionTool public: explicit SizeIncreaseTool(QObject* parent = nullptr); - bool closeOnButtonPressed() const; + bool closeOnButtonPressed() const override; QIcon icon(const QColor& background, bool inEditor) const override; QString name() const override; diff --git a/src/utils/confighandler.cpp b/src/utils/confighandler.cpp index 6786225a..bd2c69fd 100644 --- a/src/utils/confighandler.cpp +++ b/src/utils/confighandler.cpp @@ -490,6 +490,20 @@ void ConfigHandler::setHistoryConfirmationToDelete(const bool check) m_settings.setValue(QStringLiteral("historyConfirmationToDelete"), check); } +int ConfigHandler::uploadHistoryMaxSizeValue() +{ + int max = 25; + if (m_settings.contains(QStringLiteral("uploadHistoryMax"))) { + max = m_settings.value(QStringLiteral("uploadHistoryMax")).toInt(); + } + return max; +} + +void ConfigHandler::setUploadHistoryMaxSize(const int max) +{ + m_settings.setValue(QStringLiteral("uploadHistoryMax"), max); +} + bool ConfigHandler::saveAfterCopyValue() { return m_settings.value(QStringLiteral("saveAfterCopy")).toBool(); diff --git a/src/utils/confighandler.h b/src/utils/confighandler.h index 9bb9106a..5b4fcfa7 100644 --- a/src/utils/confighandler.h +++ b/src/utils/confighandler.h @@ -71,8 +71,13 @@ public: bool copyAndCloseAfterUploadEnabled(); void setCopyAndCloseAfterUploadEnabled(const bool); + bool historyConfirmationToDelete(); void setHistoryConfirmationToDelete(const bool save); + + int uploadHistoryMaxSizeValue(); + void setUploadHistoryMaxSize(const int); + bool saveAfterCopyValue(); void setSaveAfterCopy(const bool); diff --git a/src/utils/history.cpp b/src/utils/history.cpp index 83844a7f..9e20d6e1 100644 --- a/src/utils/history.cpp +++ b/src/utils/history.cpp @@ -34,9 +34,11 @@ void History::save(const QPixmap& pixmap, const QString& fileName) QPixmap pixmapScaled = QPixmap(pixmap); if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { - pixmapScaled = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + pixmapScaled = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT, + Qt::SmoothTransformation); } else { - pixmapScaled = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH); + pixmapScaled = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH, + Qt::SmoothTransformation); } // save preview @@ -55,9 +57,10 @@ const QList& History::history() QDir::Files, QDir::Time); int cnt = 0; + int max = ConfigHandler().uploadHistoryMaxSizeValue(); m_thumbs.clear(); foreach (QString fileName, images) { - if (++cnt <= HISTORY_MAX_SIZE) { + if (++cnt <= max) { m_thumbs.append(fileName); } else { QFile file(path() + fileName); diff --git a/src/utils/history.h b/src/utils/history.h index a0d7266b..71ef3283 100644 --- a/src/utils/history.h +++ b/src/utils/history.h @@ -1,10 +1,8 @@ #ifndef HISTORY_H #define HISTORY_H -#define HISTORY_MAX_SIZE 25 - -#define HISTORYPIXMAP_MAX_PREVIEW_WIDTH 160 -#define HISTORYPIXMAP_MAX_PREVIEW_HEIGHT 90 +#define HISTORYPIXMAP_MAX_PREVIEW_WIDTH 250 +#define HISTORYPIXMAP_MAX_PREVIEW_HEIGHT 100 #include #include diff --git a/src/widgets/historywidget.cpp b/src/widgets/historywidget.cpp index f5d7f17b..68ad27ae 100644 --- a/src/widgets/historywidget.cpp +++ b/src/widgets/historywidget.cpp @@ -24,9 +24,13 @@ HistoryWidget::HistoryWidget(QWidget* parent) setWindowIcon(QIcon(":img/app/flameshot.svg")); setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); setWindowTitle(tr("Latest Uploads")); - setFixedSize(800, this->height()); + resize(QDesktopWidget().availableGeometry(this).size() * 0.5); m_notification = new NotificationWidget(); + QGridLayout* layout = new QGridLayout(this); + layout->setContentsMargins(QMargins(0, 0, 0, 0)); + setLayout(layout); + m_pVBox = new QVBoxLayout(this); m_pVBox->setAlignment(Qt::AlignTop); @@ -38,6 +42,7 @@ HistoryWidget::HistoryWidget(QWidget* parent) QWidget* widget = new QWidget(); scrollArea->setWidget(widget); widget->setLayout(m_pVBox); + layout->addWidget(scrollArea); } HistoryWidget::~HistoryWidget() @@ -106,15 +111,17 @@ void HistoryWidget::addLine(const QString& path, const QString& fileName) // fine if (pixmap.height() / HISTORYPIXMAP_MAX_PREVIEW_HEIGHT >= pixmap.width() / HISTORYPIXMAP_MAX_PREVIEW_WIDTH) { - pixmap = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); + pixmap = pixmap.scaledToHeight(HISTORYPIXMAP_MAX_PREVIEW_HEIGHT, + Qt::SmoothTransformation); } else { - pixmap = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH); + pixmap = pixmap.scaledToWidth(HISTORYPIXMAP_MAX_PREVIEW_WIDTH, + Qt::SmoothTransformation); } // get file info QFileInfo* pFileInfo = new QFileInfo(fullFileName); QString lastModified = - pFileInfo->lastModified().toString(" yyyy-MM-dd\nhh:mm:ss"); + pFileInfo->lastModified().toString("yyyy-MM-dd\nhh:mm:ss"); // screenshot preview QLabel* pScreenshot = new QLabel();