applied some clang modernize (#2435)
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
|
||||
#include "commandargument.h"
|
||||
|
||||
CommandArgument::CommandArgument() {}
|
||||
#include <utility>
|
||||
|
||||
CommandArgument::CommandArgument(const QString& name,
|
||||
const QString& description)
|
||||
: m_name(name)
|
||||
, m_description(description)
|
||||
CommandArgument::CommandArgument() = default;
|
||||
|
||||
CommandArgument::CommandArgument(QString name, QString description)
|
||||
: m_name(std::move(name))
|
||||
, m_description(std::move(description))
|
||||
{}
|
||||
|
||||
void CommandArgument::setName(const QString& name)
|
||||
|
||||
@@ -9,7 +9,7 @@ class CommandArgument
|
||||
{
|
||||
public:
|
||||
CommandArgument();
|
||||
explicit CommandArgument(const QString& name, const QString& description);
|
||||
explicit CommandArgument(QString name, QString description);
|
||||
|
||||
void setName(const QString& name);
|
||||
QString name() const;
|
||||
|
||||
@@ -67,10 +67,10 @@ QString optionsToString(const QList<CommandOption>& options,
|
||||
if (!arguments.isEmpty()) {
|
||||
result += QObject::tr("Arguments") + ":\n";
|
||||
}
|
||||
for (int i = 0; i < arguments.length(); ++i) {
|
||||
for (const auto& argument : arguments) {
|
||||
result += QStringLiteral(" %1 %2\n")
|
||||
.arg(arguments.at(i).name().leftJustified(size, ' '))
|
||||
.arg(arguments.at(i).description());
|
||||
.arg(argument.name().leftJustified(size, ' '))
|
||||
.arg(argument.description());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -363,9 +363,8 @@ CommandLineParser::Node* CommandLineParser::findParent(
|
||||
}
|
||||
// find the parent in the subNodes recursively
|
||||
Node* res = nullptr;
|
||||
for (auto i = m_parseTree.subNodes.begin(); i != m_parseTree.subNodes.end();
|
||||
++i) {
|
||||
res = recursiveParentSearch(parent, *i);
|
||||
for (auto& subNode : m_parseTree.subNodes) {
|
||||
res = recursiveParentSearch(parent, subNode);
|
||||
if (res != nullptr) {
|
||||
break;
|
||||
}
|
||||
@@ -381,8 +380,8 @@ CommandLineParser::Node* CommandLineParser::recursiveParentSearch(
|
||||
if (node.argument == parent) {
|
||||
res = &node;
|
||||
} else {
|
||||
for (auto i = node.subNodes.begin(); i != node.subNodes.end(); ++i) {
|
||||
res = recursiveParentSearch(parent, *i);
|
||||
for (auto& subNode : node.subNodes) {
|
||||
res = recursiveParentSearch(parent, subNode);
|
||||
if (res != nullptr) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3,26 +3,28 @@
|
||||
|
||||
#include "commandoption.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
CommandOption::CommandOption(const QString& name,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
QString description,
|
||||
QString valueName,
|
||||
QString defaultValue)
|
||||
: m_names(name)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
, m_description(std::move(description))
|
||||
, m_valueName(std::move(valueName))
|
||||
, m_value(std::move(defaultValue))
|
||||
{
|
||||
m_checker = [](QString const&) { return true; };
|
||||
}
|
||||
|
||||
CommandOption::CommandOption(const QStringList& names,
|
||||
const QString& description,
|
||||
const QString& valueName,
|
||||
const QString& defaultValue)
|
||||
: m_names(names)
|
||||
, m_description(description)
|
||||
, m_valueName(valueName)
|
||||
, m_value(defaultValue)
|
||||
CommandOption::CommandOption(QStringList names,
|
||||
QString description,
|
||||
QString valueName,
|
||||
QString defaultValue)
|
||||
: m_names(std::move(names))
|
||||
, m_description(std::move(description))
|
||||
, m_valueName(std::move(valueName))
|
||||
, m_value(std::move(defaultValue))
|
||||
{
|
||||
m_checker = [](QString const&) -> bool { return true; };
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@ class CommandOption
|
||||
{
|
||||
public:
|
||||
CommandOption(const QString& name,
|
||||
const QString& description,
|
||||
const QString& valueName = QString(),
|
||||
const QString& defaultValue = QString());
|
||||
QString description,
|
||||
QString valueName = QString(),
|
||||
QString defaultValue = QString());
|
||||
|
||||
CommandOption(const QStringList& names,
|
||||
const QString& description,
|
||||
const QString& valueName = QString(),
|
||||
const QString& defaultValue = QString());
|
||||
CommandOption(QStringList names,
|
||||
QString description,
|
||||
QString valueName = QString(),
|
||||
QString defaultValue = QString());
|
||||
|
||||
void setName(const QString& name);
|
||||
void setNames(const QStringList& names);
|
||||
|
||||
@@ -14,15 +14,16 @@
|
||||
#include <QDateTime>
|
||||
#include <QVector>
|
||||
#include <stdexcept>
|
||||
#include <utility>
|
||||
|
||||
CaptureRequest::CaptureRequest(CaptureRequest::CaptureMode mode,
|
||||
const uint delay,
|
||||
const QVariant& data,
|
||||
QVariant data,
|
||||
CaptureRequest::ExportTask tasks)
|
||||
: m_mode(mode)
|
||||
, m_delay(delay)
|
||||
, m_tasks(tasks)
|
||||
, m_data(data)
|
||||
, m_data(std::move(data))
|
||||
{}
|
||||
|
||||
CaptureRequest::CaptureMode CaptureRequest::captureMode() const
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
CaptureRequest(CaptureMode mode,
|
||||
const uint delay = 0,
|
||||
const QVariant& data = QVariant(),
|
||||
QVariant data = QVariant(),
|
||||
ExportTask tasks = NO_TASK);
|
||||
|
||||
void setStaticID(uint id);
|
||||
|
||||
@@ -8,7 +8,7 @@ FlameshotDBusAdapter::FlameshotDBusAdapter(QObject* parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{}
|
||||
|
||||
FlameshotDBusAdapter::~FlameshotDBusAdapter() {}
|
||||
FlameshotDBusAdapter::~FlameshotDBusAdapter() = default;
|
||||
|
||||
void FlameshotDBusAdapter::attachScreenshotToClipboard(const QByteArray& data)
|
||||
{
|
||||
|
||||
@@ -126,8 +126,8 @@ void AbstractPathTool::move(const QPoint& mousePos)
|
||||
}
|
||||
QPoint basePos = *pos();
|
||||
QPoint offset = mousePos - basePos;
|
||||
for (int index = 0; index < m_points.size(); ++index) {
|
||||
m_points[index] += offset;
|
||||
for (auto& m_point : m_points) {
|
||||
m_point += offset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,8 +50,9 @@ QLine getShorterLine(QPoint p1, QPoint p2, const int thickness)
|
||||
// looks not very bad
|
||||
val = thickness / 4;
|
||||
l.setLength(val);
|
||||
} else
|
||||
} else {
|
||||
l.setLength(l.length() + thickness * 2 - val);
|
||||
}
|
||||
return l.toLine();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,10 +46,10 @@ QRect CircleCountTool::boundingRect() const
|
||||
return {};
|
||||
}
|
||||
int bubble_size = size() + THICKNESS_OFFSET + PADDING_VALUE;
|
||||
return QRect(points().first.x() - bubble_size,
|
||||
points().first.y() - bubble_size,
|
||||
bubble_size * 2,
|
||||
bubble_size * 2);
|
||||
return { points().first.x() - bubble_size,
|
||||
points().first.y() - bubble_size,
|
||||
bubble_size * 2,
|
||||
bubble_size * 2 };
|
||||
}
|
||||
|
||||
QString CircleCountTool::name() const
|
||||
|
||||
@@ -49,5 +49,5 @@ QSize LauncherItemDelegate::sizeHint(const QStyleOptionViewItem& option,
|
||||
Q_UNUSED(option)
|
||||
Q_UNUSED(index)
|
||||
const int size = GlobalValues::buttonBaseSize();
|
||||
return QSize(static_cast<int>(size * 3.2), static_cast<int>(size * 3.7));
|
||||
return { static_cast<int>(size * 3.2), static_cast<int>(size * 3.7) };
|
||||
}
|
||||
|
||||
@@ -32,17 +32,17 @@ AbstractLogger::~AbstractLogger()
|
||||
|
||||
AbstractLogger AbstractLogger::info(int targets)
|
||||
{
|
||||
return AbstractLogger(Info, targets);
|
||||
return { Info, targets };
|
||||
}
|
||||
|
||||
AbstractLogger AbstractLogger::warning(int targets)
|
||||
{
|
||||
return AbstractLogger(Warning, targets);
|
||||
return { Warning, targets };
|
||||
}
|
||||
|
||||
AbstractLogger AbstractLogger::error(int targets)
|
||||
{
|
||||
return AbstractLogger(Error, targets);
|
||||
return { Error, targets };
|
||||
}
|
||||
|
||||
AbstractLogger& AbstractLogger::sendMessage(QString msg, Channel channel)
|
||||
|
||||
@@ -18,7 +18,7 @@ QColor ColorUtils::contrastColor(const QColor& c)
|
||||
{
|
||||
int change = colorIsDark(c) ? 30 : -45;
|
||||
|
||||
return QColor(qBound(0, c.red() + change, 255),
|
||||
qBound(0, c.green() + change, 255),
|
||||
qBound(0, c.blue() + change, 255));
|
||||
return { qBound(0, c.red() + change, 255),
|
||||
qBound(0, c.green() + change, 255),
|
||||
qBound(0, c.blue() + change, 255) };
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ QString GlobalValues::iconPath()
|
||||
#if USE_MONOCHROME_ICON
|
||||
return QString(":img/app/flameshot.monochrome.svg");
|
||||
#else
|
||||
return QString(":img/app/flameshot.svg");
|
||||
return { ":img/app/flameshot.svg" };
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ QString GlobalValues::iconPathPNG()
|
||||
#if USE_MONOCHROME_ICON
|
||||
return QString(":img/app/flameshot.monochrome.png");
|
||||
#else
|
||||
return QString(":img/app/flameshot.png");
|
||||
return { ":img/app/flameshot.png" };
|
||||
#endif
|
||||
}
|
||||
@@ -18,4 +18,5 @@ OrgFreedesktopPortalRequestInterface::OrgFreedesktopPortalRequestInterface(
|
||||
parent)
|
||||
{}
|
||||
|
||||
OrgFreedesktopPortalRequestInterface::~OrgFreedesktopPortalRequestInterface() {}
|
||||
OrgFreedesktopPortalRequestInterface::~OrgFreedesktopPortalRequestInterface() =
|
||||
default;
|
||||
|
||||
@@ -23,7 +23,7 @@ QVariant ValueHandler::value(const QVariant& val)
|
||||
|
||||
QVariant ValueHandler::fallback()
|
||||
{
|
||||
return QVariant();
|
||||
return {};
|
||||
}
|
||||
|
||||
QVariant ValueHandler::representation(const QVariant& val)
|
||||
@@ -68,8 +68,8 @@ QString Bool::expected()
|
||||
|
||||
// STRING
|
||||
|
||||
String::String(const QString& def)
|
||||
: m_def(def)
|
||||
String::String(QString def)
|
||||
: m_def(std::move(def))
|
||||
{}
|
||||
|
||||
bool String::check(const QVariant&)
|
||||
@@ -89,8 +89,8 @@ QString String::expected()
|
||||
|
||||
// COLOR
|
||||
|
||||
Color::Color(const QColor& def)
|
||||
: m_def(def)
|
||||
Color::Color(QColor def)
|
||||
: m_def(std::move(def))
|
||||
{}
|
||||
|
||||
bool Color::check(const QVariant& val)
|
||||
@@ -512,6 +512,7 @@ bool Region::check(const QVariant& val)
|
||||
}
|
||||
|
||||
#include <QApplication> // TODO remove after FIXME (see below)
|
||||
#include <utility>
|
||||
|
||||
QVariant Region::process(const QVariant& val)
|
||||
{
|
||||
|
||||
@@ -99,7 +99,7 @@ private:
|
||||
class String : public ValueHandler
|
||||
{
|
||||
public:
|
||||
String(const QString& def);
|
||||
String(QString def);
|
||||
bool check(const QVariant&) override;
|
||||
QVariant fallback() override;
|
||||
QString expected() override;
|
||||
@@ -111,7 +111,7 @@ private:
|
||||
class Color : public ValueHandler
|
||||
{
|
||||
public:
|
||||
Color(const QColor& def);
|
||||
Color(QColor def);
|
||||
bool check(const QVariant& val) override;
|
||||
QVariant process(const QVariant& val) override;
|
||||
QVariant fallback() override;
|
||||
|
||||
@@ -1696,7 +1696,7 @@ void CaptureWidget::redo()
|
||||
QRect CaptureWidget::extendedSelection() const
|
||||
{
|
||||
if (!m_selection->isVisible()) {
|
||||
return QRect();
|
||||
return {};
|
||||
}
|
||||
QRect r = m_selection->geometry();
|
||||
return extendedRect(r);
|
||||
@@ -1705,10 +1705,10 @@ QRect CaptureWidget::extendedSelection() const
|
||||
QRect CaptureWidget::extendedRect(const QRect& r) const
|
||||
{
|
||||
auto devicePixelRatio = m_context.screenshot.devicePixelRatio();
|
||||
return QRect(r.left() * devicePixelRatio,
|
||||
r.top() * devicePixelRatio,
|
||||
r.width() * devicePixelRatio,
|
||||
r.height() * devicePixelRatio);
|
||||
return { static_cast<int>(r.left() * devicePixelRatio),
|
||||
static_cast<int>(r.top() * devicePixelRatio),
|
||||
static_cast<int>(r.width() * devicePixelRatio),
|
||||
static_cast<int>(r.height() * devicePixelRatio) };
|
||||
}
|
||||
|
||||
QRect CaptureWidget::paddedUpdateRect(const QRect& r) const
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
#include <QPainter>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QTimer>
|
||||
#include <utility>
|
||||
|
||||
#define MARGIN (m_THandle.width())
|
||||
|
||||
SelectionWidget::SelectionWidget(const QColor& c, QWidget* parent)
|
||||
SelectionWidget::SelectionWidget(QColor c, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_color(c)
|
||||
, m_color(std::move(c))
|
||||
, m_activeSide(NO_SIDE)
|
||||
, m_ignoreMouse(false)
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
CENTER = 0b10000,
|
||||
};
|
||||
|
||||
explicit SelectionWidget(const QColor& c, QWidget* parent = nullptr);
|
||||
explicit SelectionWidget(QColor c, QWidget* parent = nullptr);
|
||||
|
||||
SideType getMouseSide(const QPoint& mousePos) const;
|
||||
QVector<QRect> handlerAreas();
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
LoadSpinner::LoadSpinner(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_startAngle(0)
|
||||
, m_span(0)
|
||||
, m_growing(true)
|
||||
{
|
||||
|
||||
@@ -12,14 +12,15 @@
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWheelEvent>
|
||||
#include <utility>
|
||||
|
||||
UpdateNotificationWidget::UpdateNotificationWidget(
|
||||
QWidget* parent,
|
||||
const QString& appLatestVersion,
|
||||
const QString& appLatestUrl)
|
||||
QString appLatestUrl)
|
||||
: QWidget(parent)
|
||||
, m_appLatestVersion(appLatestVersion)
|
||||
, m_appLatestUrl(appLatestUrl)
|
||||
, m_appLatestUrl(std::move(appLatestUrl))
|
||||
, m_layout(nullptr)
|
||||
{
|
||||
setMinimumSize(400, 100);
|
||||
|
||||
@@ -20,7 +20,7 @@ class UpdateNotificationWidget : public QWidget
|
||||
public:
|
||||
explicit UpdateNotificationWidget(QWidget* parent,
|
||||
const QString& appLatestVersion,
|
||||
const QString& appLatestUrl);
|
||||
QString appLatestUrl);
|
||||
void setAppLatestVersion(const QString& latestVersion);
|
||||
|
||||
void hide();
|
||||
|
||||
Reference in New Issue
Block a user