Make latest uploads max size configurable. Make latest uploads window resizeable
This commit is contained in:
@@ -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"));
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QTextCodec>
|
||||
#include <QVBoxLayout>
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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<QString>& 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);
|
||||
|
||||
@@ -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 <QList>
|
||||
#include <QPixmap>
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user