Fix more c++ 20 deprecations

This commit is contained in:
Jeremy Borgman
2025-06-06 14:35:04 -05:00
parent b504b9eda1
commit 2c99e97ed7
13 changed files with 44 additions and 39 deletions

View File

@@ -97,7 +97,7 @@ ColorPickerEditor::ColorPickerEditor(QWidget* parent)
connect(m_colorWheel, connect(m_colorWheel,
&color_widgets::ColorWheel::colorSelected, &color_widgets::ColorWheel::colorSelected,
this, this,
[=](QColor c) { [=, this](QColor c) {
m_color = c; m_color = c;
m_colorInput->setText(m_color.name(QColor::HexRgb)); m_colorInput->setText(m_color.name(QColor::HexRgb));
}); });

View File

@@ -112,7 +112,7 @@ void ConfigResolver::populate()
auto* resolveAll = new QPushButton(tr("Resolve all")); auto* resolveAll = new QPushButton(tr("Resolve all"));
resolveAll->setToolTip(tr("Resolve all listed errors.")); resolveAll->setToolTip(tr("Resolve all listed errors."));
buttons->addButton(resolveAll, BBox::ResetRole); buttons->addButton(resolveAll, BBox::ResetRole);
connect(resolveAll, &QPushButton::clicked, this, [=]() { connect(resolveAll, &QPushButton::clicked, this, [=, this]() {
for (const auto& key : semanticallyWrong) { for (const auto& key : semanticallyWrong) {
ConfigHandler().resetValue(key); ConfigHandler().resetValue(key);
} }

View File

@@ -145,11 +145,12 @@ void ConfigWindow::initErrorIndicator(QWidget* tab, QWidget* widget)
} }
// Sigslots // Sigslots
connect(ConfigHandler::getInstance(), &ConfigHandler::error, widget, [=]() { connect(
widget->setEnabled(false); ConfigHandler::getInstance(), &ConfigHandler::error, widget, [=, this]() {
label->show(); widget->setEnabled(false);
btnResolve->show(); label->show();
}); btnResolve->show();
});
connect(ConfigHandler::getInstance(), connect(ConfigHandler::getInstance(),
&ConfigHandler::errorResolved, &ConfigHandler::errorResolved,
widget, widget,

View File

@@ -402,7 +402,7 @@ void Flameshot::exportCapture(const QPixmap& capture,
// NOTE: lambda can't capture 'this' because it might be destroyed later // NOTE: lambda can't capture 'this' because it might be destroyed later
CR::ExportTask tasks = tasks; CR::ExportTask tasks = tasks;
QObject::connect( QObject::connect(
widget, &ImgUploaderBase::uploadOk, [=](const QUrl& url) { widget, &ImgUploaderBase::uploadOk, [=, this](const QUrl& url) {
if (ConfigHandler().copyURLAfterUpload()) { if (ConfigHandler().copyURLAfterUpload()) {
if (!(tasks & CR::COPY)) { if (!(tasks & CR::COPY)) {
FlameshotDaemon::copyToClipboard( FlameshotDaemon::copyToClipboard(

View File

@@ -261,7 +261,7 @@ void FlameshotDaemon::attachPin(const QPixmap& pixmap, QRect geometry)
{ {
auto* pinWidget = new PinWidget(pixmap, geometry); auto* pinWidget = new PinWidget(pixmap, geometry);
m_widgets.append(pinWidget); m_widgets.append(pinWidget);
connect(pinWidget, &QObject::destroyed, this, [=]() { connect(pinWidget, &QObject::destroyed, this, [=, this]() {
m_widgets.removeOne(pinWidget); m_widgets.removeOne(pinWidget);
quitIfIdle(); quitIfIdle();
}); });

View File

@@ -152,14 +152,14 @@ void PinWidget::mouseDoubleClickEvent(QMouseEvent*)
void PinWidget::mousePressEvent(QMouseEvent* e) void PinWidget::mousePressEvent(QMouseEvent* e)
{ {
m_dragStart = e->globalPos(); m_dragStart = e->globalPosition();
m_offsetX = e->localPos().x() / width(); m_offsetX = e->position().x() / width();
m_offsetY = e->localPos().y() / height(); m_offsetY = e->position().y() / height();
} }
void PinWidget::mouseMoveEvent(QMouseEvent* e) 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 offsetW = width() * m_offsetX;
const int offsetH = height() * m_offsetY; const int offsetH = height() * m_offsetY;
move(m_dragStart.x() + delta.x() - offsetW, move(m_dragStart.x() + delta.x() - offsetW,

View File

@@ -45,7 +45,7 @@ private:
QPixmap m_pixmap; QPixmap m_pixmap;
QVBoxLayout* m_layout; QVBoxLayout* m_layout;
QLabel* m_label; QLabel* m_label;
QPoint m_dragStart; QPointF m_dragStart;
qreal m_offsetX{}, m_offsetY{}; qreal m_offsetX{}, m_offsetY{};
QGraphicsDropShadowEffect* m_shadowEffect; QGraphicsDropShadowEffect* m_shadowEffect;
QColor m_baseColor, m_hoverColor; QColor m_baseColor, m_hoverColor;

View File

@@ -240,17 +240,20 @@ CaptureWidget::CaptureWidget(const CaptureRequest& req,
if (m_config.hasError()) { if (m_config.hasError()) {
m_configError = true; m_configError = true;
} }
connect(ConfigHandler::getInstance(), &ConfigHandler::error, this, [=]() {
m_configError = true;
m_configErrorResolved = false;
OverlayMessage::instance()->update();
});
connect( connect(
ConfigHandler::getInstance(), &ConfigHandler::errorResolved, this, [=]() { ConfigHandler::getInstance(), &ConfigHandler::error, this, [=, this]() {
m_configError = false; m_configError = true;
m_configErrorResolved = true; m_configErrorResolved = false;
OverlayMessage::instance()->update(); OverlayMessage::instance()->update();
}); });
connect(ConfigHandler::getInstance(),
&ConfigHandler::errorResolved,
this,
[=, this]() {
m_configError = false;
m_configErrorResolved = true;
OverlayMessage::instance()->update();
});
OverlayMessage::init(this, OverlayMessage::init(this,
QGuiAppCurrentScreen().currentScreen()->geometry()); QGuiAppCurrentScreen().currentScreen()->geometry());
@@ -333,7 +336,7 @@ void CaptureWidget::initButtons()
if (!shortcut.isNull()) { if (!shortcut.isNull()) {
auto shortcuts = newShortcut(shortcut, this, nullptr); auto shortcuts = newShortcut(shortcut, this, nullptr);
for (auto* sc : shortcuts) { for (auto* sc : shortcuts) {
connect(sc, &QShortcut::activated, this, [=]() { connect(sc, &QShortcut::activated, this, [=, this]() {
setState(b); setState(b);
}); });
} }

View File

@@ -26,7 +26,7 @@ bool DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
m_isDragging = false; m_isDragging = false;
if (mouseEvent->button() == Qt::LeftButton) { if (mouseEvent->button() == Qt::LeftButton) {
m_isPressing = true; m_isPressing = true;
m_mousePressPos = mouseEvent->globalPos(); m_mousePressPos = mouseEvent->globalPosition();
m_mouseMovePos = m_mousePressPos; m_mouseMovePos = m_mousePressPos;
} }
} break; } break;
@@ -34,15 +34,15 @@ bool DraggableWidgetMaker::eventFilter(QObject* obj, QEvent* event)
auto* mouseEvent = static_cast<QMouseEvent*>(event); auto* mouseEvent = static_cast<QMouseEvent*>(event);
if (m_isPressing) { if (m_isPressing) {
QPoint widgetPos = widget->mapToGlobal(widget->pos()); QPointF widgetPos = widget->mapToGlobal(widget->pos());
QPoint eventPos = mouseEvent->globalPos(); QPointF eventPos = mouseEvent->globalPosition();
QPoint diff = eventPos - m_mouseMovePos; QPointF diff = eventPos - m_mouseMovePos;
QPoint newPos = widgetPos + diff; QPointF newPos = widgetPos + diff;
widget->move(widget->mapFromGlobal(newPos)); widget->move(widget->mapFromGlobal(newPos.toPoint()));
if (!m_isDragging) { if (!m_isDragging) {
QPoint totalMovedDiff = eventPos - m_mousePressPos; QPointF totalMovedDiff = eventPos - m_mousePressPos;
if (totalMovedDiff.manhattanLength() > 3) { if (totalMovedDiff.manhattanLength() > 3) {
m_isDragging = true; m_isDragging = true;
} }

View File

@@ -22,6 +22,6 @@ protected:
private: private:
bool m_isPressing = false; bool m_isPressing = false;
bool m_isDragging = false; bool m_isDragging = false;
QPoint m_mouseMovePos; QPointF m_mouseMovePos;
QPoint m_mousePressPos; QPointF m_mousePressPos;
}; };

View File

@@ -107,7 +107,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
this, this,
&SidePanelWidget::onToolSizeChanged); &SidePanelWidget::onToolSizeChanged);
// color hex editor sigslots // 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 QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
if (!QColor::isValidColor(m_colorHex->text())) { if (!QColor::isValidColor(m_colorHex->text())) {
#else #else
@@ -130,7 +130,7 @@ SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
this, this,
&SidePanelWidget::colorChanged); &SidePanelWidget::colorChanged);
// Grid feature // Grid feature
connect(m_gridCheck, &QCheckBox::clicked, this, [=](bool b) { connect(m_gridCheck, &QCheckBox::clicked, this, [=, this](bool b) {
this->m_gridSizeSpin->setEnabled(b); this->m_gridSizeSpin->setEnabled(b);
emit this->displayGridChanged(b); emit this->displayGridChanged(b);
}); });

View File

@@ -59,7 +59,8 @@ void UploadHistory::setEmptyMessage()
auto* buttonEmpty = new QPushButton; auto* buttonEmpty = new QPushButton;
buttonEmpty->setText(tr("Screenshots history is empty")); buttonEmpty->setText(tr("Screenshots history is empty"));
buttonEmpty->setMinimumSize(1, HISTORYPIXMAP_MAX_PREVIEW_HEIGHT); 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); ui->historyContainer->addWidget(buttonEmpty);
} }
@@ -85,7 +86,7 @@ void UploadHistory::addLine(const QString& path, const QString& fileName)
auto* line = new UploadLineItem( auto* line = new UploadLineItem(
this, pixmap, lastModified, url, fullFileName, unpackFileName); this, pixmap, lastModified, url, fullFileName, unpackFileName);
connect(line, &UploadLineItem::requestedDeletion, this, [=]() { connect(line, &UploadLineItem::requestedDeletion, this, [=, this]() {
if (ui->historyContainer->count() <= 1) { if (ui->historyContainer->count() <= 1) {
setEmptyMessage(); setEmptyMessage();
} }

View File

@@ -34,15 +34,15 @@ UploadLineItem::UploadLineItem(QWidget* parent,
ui->imagePreview->setPixmap(preview); ui->imagePreview->setPixmap(preview);
ui->uploadTimestamp->setText(timestamp); ui->uploadTimestamp->setText(timestamp);
connect(ui->copyUrl, &QPushButton::clicked, this, [=]() { connect(ui->copyUrl, &QPushButton::clicked, this, [=, this]() {
FlameshotDaemon::copyToClipboard(url); FlameshotDaemon::copyToClipboard(url);
}); });
connect(ui->openBrowser, &QPushButton::clicked, this, [=]() { connect(ui->openBrowser, &QPushButton::clicked, this, [=, this]() {
QDesktopServices::openUrl(QUrl(url)); QDesktopServices::openUrl(QUrl(url));
}); });
connect(ui->deleteImage, &QPushButton::clicked, this, [=]() { connect(ui->deleteImage, &QPushButton::clicked, this, [=, this]() {
if (ConfigHandler().historyConfirmationToDelete() && if (ConfigHandler().historyConfirmationToDelete() &&
QMessageBox::No == QMessageBox::No ==
QMessageBox::question( QMessageBox::question(