mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fix more c++ 20 deprecations
This commit is contained in:
@@ -97,7 +97,7 @@ ColorPickerEditor::ColorPickerEditor(QWidget* parent)
|
||||
connect(m_colorWheel,
|
||||
&color_widgets::ColorWheel::colorSelected,
|
||||
this,
|
||||
[=](QColor c) {
|
||||
[=, this](QColor c) {
|
||||
m_color = c;
|
||||
m_colorInput->setText(m_color.name(QColor::HexRgb));
|
||||
});
|
||||
|
||||
@@ -112,7 +112,7 @@ void ConfigResolver::populate()
|
||||
auto* resolveAll = new QPushButton(tr("Resolve all"));
|
||||
resolveAll->setToolTip(tr("Resolve all listed errors."));
|
||||
buttons->addButton(resolveAll, BBox::ResetRole);
|
||||
connect(resolveAll, &QPushButton::clicked, this, [=]() {
|
||||
connect(resolveAll, &QPushButton::clicked, this, [=, this]() {
|
||||
for (const auto& key : semanticallyWrong) {
|
||||
ConfigHandler().resetValue(key);
|
||||
}
|
||||
|
||||
@@ -145,7 +145,8 @@ void ConfigWindow::initErrorIndicator(QWidget* tab, QWidget* widget)
|
||||
}
|
||||
|
||||
// Sigslots
|
||||
connect(ConfigHandler::getInstance(), &ConfigHandler::error, widget, [=]() {
|
||||
connect(
|
||||
ConfigHandler::getInstance(), &ConfigHandler::error, widget, [=, this]() {
|
||||
widget->setEnabled(false);
|
||||
label->show();
|
||||
btnResolve->show();
|
||||
|
||||
@@ -402,7 +402,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
|
||||
// NOTE: lambda can't capture 'this' because it might be destroyed later
|
||||
CR::ExportTask tasks = tasks;
|
||||
QObject::connect(
|
||||
widget, &ImgUploaderBase::uploadOk, [=](const QUrl& url) {
|
||||
widget, &ImgUploaderBase::uploadOk, [=, this](const QUrl& url) {
|
||||
if (ConfigHandler().copyURLAfterUpload()) {
|
||||
if (!(tasks & CR::COPY)) {
|
||||
FlameshotDaemon::copyToClipboard(
|
||||
|
||||
@@ -261,7 +261,7 @@ void FlameshotDaemon::attachPin(const QPixmap& pixmap, QRect geometry)
|
||||
{
|
||||
auto* pinWidget = new PinWidget(pixmap, geometry);
|
||||
m_widgets.append(pinWidget);
|
||||
connect(pinWidget, &QObject::destroyed, this, [=]() {
|
||||
connect(pinWidget, &QObject::destroyed, this, [=, this]() {
|
||||
m_widgets.removeOne(pinWidget);
|
||||
quitIfIdle();
|
||||
});
|
||||
|
||||
@@ -152,14 +152,14 @@ void PinWidget::mouseDoubleClickEvent(QMouseEvent*)
|
||||
|
||||
void PinWidget::mousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
m_dragStart = e->globalPos();
|
||||
m_offsetX = e->localPos().x() / width();
|
||||
m_offsetY = e->localPos().y() / height();
|
||||
m_dragStart = e->globalPosition();
|
||||
m_offsetX = e->position().x() / width();
|
||||
m_offsetY = e->position().y() / height();
|
||||
}
|
||||
|
||||
void PinWidget::mouseMoveEvent(QMouseEvent* e)
|
||||
{
|
||||
const QPoint delta = e->globalPos() - m_dragStart;
|
||||
const QPointF delta = e->globalPosition() - m_dragStart;
|
||||
const int offsetW = width() * m_offsetX;
|
||||
const int offsetH = height() * m_offsetY;
|
||||
move(m_dragStart.x() + delta.x() - offsetW,
|
||||
|
||||
@@ -45,7 +45,7 @@ private:
|
||||
QPixmap m_pixmap;
|
||||
QVBoxLayout* m_layout;
|
||||
QLabel* m_label;
|
||||
QPoint m_dragStart;
|
||||
QPointF m_dragStart;
|
||||
qreal m_offsetX{}, m_offsetY{};
|
||||
QGraphicsDropShadowEffect* m_shadowEffect;
|
||||
QColor m_baseColor, m_hoverColor;
|
||||
|
||||
@@ -240,13 +240,16 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
|
||||
if (m_config.hasError()) {
|
||||
m_configError = true;
|
||||
}
|
||||
connect(ConfigHandler::getInstance(), &ConfigHandler::error, this, [=]() {
|
||||
connect(
|
||||
ConfigHandler::getInstance(), &ConfigHandler::error, this, [=, this]() {
|
||||
m_configError = true;
|
||||
m_configErrorResolved = false;
|
||||
OverlayMessage::instance()->update();
|
||||
});
|
||||
connect(
|
||||
ConfigHandler::getInstance(), &ConfigHandler::errorResolved, this, [=]() {
|
||||
connect(ConfigHandler::getInstance(),
|
||||
&ConfigHandler::errorResolved,
|
||||
this,
|
||||
[=, this]() {
|
||||
m_configError = false;
|
||||
m_configErrorResolved = true;
|
||||
OverlayMessage::instance()->update();
|
||||
@@ -333,7 +336,7 @@ void CaptureWidget::initButtons()
|
||||
if (!shortcut.isNull()) {
|
||||
auto shortcuts = newShortcut(shortcut, this, nullptr);
|
||||
for (auto* sc : shortcuts) {
|
||||
connect(sc, &QShortcut::activated, this, [=]() {
|
||||
connect(sc, &QShortcut::activated, this, [=, this]() {
|
||||
setState(b);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ bool DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
|
||||
m_isDragging = false;
|
||||
if (mouseEvent->button() == Qt::LeftButton) {
|
||||
m_isPressing = true;
|
||||
m_mousePressPos = mouseEvent->globalPos();
|
||||
m_mousePressPos = mouseEvent->globalPosition();
|
||||
m_mouseMovePos = m_mousePressPos;
|
||||
}
|
||||
} break;
|
||||
@@ -34,15 +34,15 @@ bool DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
|
||||
auto* mouseEvent = static_cast<QMouseEvent*>(event);
|
||||
|
||||
if (m_isPressing) {
|
||||
QPoint widgetPos = widget->mapToGlobal(widget->pos());
|
||||
QPoint eventPos = mouseEvent->globalPos();
|
||||
QPoint diff = eventPos - m_mouseMovePos;
|
||||
QPoint newPos = widgetPos + diff;
|
||||
QPointF widgetPos = widget->mapToGlobal(widget->pos());
|
||||
QPointF eventPos = mouseEvent->globalPosition();
|
||||
QPointF diff = eventPos - m_mouseMovePos;
|
||||
QPointF newPos = widgetPos + diff;
|
||||
|
||||
widget->move(widget->mapFromGlobal(newPos));
|
||||
widget->move(widget->mapFromGlobal(newPos.toPoint()));
|
||||
|
||||
if (!m_isDragging) {
|
||||
QPoint totalMovedDiff = eventPos - m_mousePressPos;
|
||||
QPointF totalMovedDiff = eventPos - m_mousePressPos;
|
||||
if (totalMovedDiff.manhattanLength() > 3) {
|
||||
m_isDragging = true;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ protected:
|
||||
private:
|
||||
bool m_isPressing = false;
|
||||
bool m_isDragging = false;
|
||||
QPoint m_mouseMovePos;
|
||||
QPoint m_mousePressPos;
|
||||
QPointF m_mouseMovePos;
|
||||
QPointF m_mousePressPos;
|
||||
};
|
||||
|
||||
@@ -107,7 +107,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
|
||||
this,
|
||||
&SidePanelWidget::onToolSizeChanged);
|
||||
// color hex editor sigslots
|
||||
connect(m_colorHex, &QLineEdit::editingFinished, this, [=]() {
|
||||
connect(m_colorHex, &QLineEdit::editingFinished, this, [=, this]() {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
if (!QColor::isValidColor(m_colorHex->text())) {
|
||||
#else
|
||||
@@ -130,7 +130,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
|
||||
this,
|
||||
&SidePanelWidget::colorChanged);
|
||||
// Grid feature
|
||||
connect(m_gridCheck, &QCheckBox::clicked, this, [=](bool b) {
|
||||
connect(m_gridCheck, &QCheckBox::clicked, this, [=, this](bool b) {
|
||||
this->m_gridSizeSpin->setEnabled(b);
|
||||
emit this->displayGridChanged(b);
|
||||
});
|
||||
|
||||
@@ -59,7 +59,8 @@ void UploadHistory::setEmptyMessage()
|
||||
auto* buttonEmpty = new QPushButton;
|
||||
buttonEmpty->setText(tr("Screenshots history is empty"));
|
||||
buttonEmpty->setMinimumSize(1, HISTORYPIXMAP_MAX_PREVIEW_HEIGHT);
|
||||
connect(buttonEmpty, &QPushButton::clicked, this, [=]() { this->close(); });
|
||||
connect(
|
||||
buttonEmpty, &QPushButton::clicked, this, [=, this]() { this->close(); });
|
||||
ui->historyContainer->addWidget(buttonEmpty);
|
||||
}
|
||||
|
||||
@@ -85,7 +86,7 @@ void UploadHistory::addLine(const QString& path, const QString& fileName)
|
||||
auto* line = new UploadLineItem(
|
||||
this, pixmap, lastModified, url, fullFileName, unpackFileName);
|
||||
|
||||
connect(line, &UploadLineItem::requestedDeletion, this, [=]() {
|
||||
connect(line, &UploadLineItem::requestedDeletion, this, [=, this]() {
|
||||
if (ui->historyContainer->count() <= 1) {
|
||||
setEmptyMessage();
|
||||
}
|
||||
|
||||
@@ -34,15 +34,15 @@ UploadLineItem::UploadLineItem(QWidget* parent,
|
||||
ui->imagePreview->setPixmap(preview);
|
||||
ui->uploadTimestamp->setText(timestamp);
|
||||
|
||||
connect(ui->copyUrl, &QPushButton::clicked, this, [=]() {
|
||||
connect(ui->copyUrl, &QPushButton::clicked, this, [=, this]() {
|
||||
FlameshotDaemon::copyToClipboard(url);
|
||||
});
|
||||
|
||||
connect(ui->openBrowser, &QPushButton::clicked, this, [=]() {
|
||||
connect(ui->openBrowser, &QPushButton::clicked, this, [=, this]() {
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
});
|
||||
|
||||
connect(ui->deleteImage, &QPushButton::clicked, this, [=]() {
|
||||
connect(ui->deleteImage, &QPushButton::clicked, this, [=, this]() {
|
||||
if (ConfigHandler().historyConfirmationToDelete() &&
|
||||
QMessageBox::No ==
|
||||
QMessageBox::question(
|
||||
|
||||
Reference in New Issue
Block a user