mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-22 09:51:06 +00:00
Fix alignment bug and applied many clang format warnings (#2448)
* Fix alignment bug and applied many clang format warnings * removed nodiscard from slot
This commit is contained in:
@@ -12,8 +12,8 @@
|
||||
|
||||
TextConfig::TextConfig(QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_layout(nullptr)
|
||||
, m_fontsCB(nullptr)
|
||||
, m_layout(new QVBoxLayout(this))
|
||||
, m_fontsCB(new QComboBox())
|
||||
, m_strikeOutButton(nullptr)
|
||||
, m_underlineButton(nullptr)
|
||||
, m_weightButton(nullptr)
|
||||
@@ -22,10 +22,9 @@ TextConfig::TextConfig(QWidget* parent)
|
||||
, m_centerAlignButton(nullptr)
|
||||
, m_rightAlignButton(nullptr)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
||||
QFontDatabase fontDB;
|
||||
m_fontsCB = new QComboBox();
|
||||
|
||||
connect(m_fontsCB,
|
||||
&QComboBox::currentTextChanged,
|
||||
this,
|
||||
@@ -121,29 +120,30 @@ void TextConfig::setFontFamily(const QString& fontFamily)
|
||||
m_fontsCB->findText(fontFamily.isEmpty() ? font().family() : fontFamily));
|
||||
}
|
||||
|
||||
void TextConfig::setUnderline(const bool u)
|
||||
void TextConfig::setUnderline(const bool underline)
|
||||
{
|
||||
m_underlineButton->setChecked(u);
|
||||
m_underlineButton->setChecked(underline);
|
||||
}
|
||||
|
||||
void TextConfig::setStrikeOut(const bool s)
|
||||
void TextConfig::setStrikeOut(const bool strikeout)
|
||||
{
|
||||
m_strikeOutButton->setChecked(s);
|
||||
m_strikeOutButton->setChecked(strikeout);
|
||||
}
|
||||
|
||||
void TextConfig::setWeight(const int w)
|
||||
void TextConfig::setWeight(const int weight)
|
||||
{
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(w) == QFont::Bold);
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(weight) ==
|
||||
QFont::Bold);
|
||||
}
|
||||
|
||||
void TextConfig::setItalic(const bool i)
|
||||
void TextConfig::setItalic(const bool italic)
|
||||
{
|
||||
m_italicButton->setChecked(i);
|
||||
m_italicButton->setChecked(italic);
|
||||
}
|
||||
|
||||
void TextConfig::weightButtonPressed(const bool w)
|
||||
void TextConfig::weightButtonPressed(const bool weight)
|
||||
{
|
||||
if (w) {
|
||||
if (weight) {
|
||||
emit fontWeightChanged(QFont::Bold);
|
||||
} else {
|
||||
emit fontWeightChanged(QFont::Normal);
|
||||
|
||||
@@ -16,10 +16,10 @@ public:
|
||||
explicit TextConfig(QWidget* parent = nullptr);
|
||||
|
||||
void setFontFamily(const QString& fontFamily);
|
||||
void setUnderline(const bool u);
|
||||
void setStrikeOut(const bool s);
|
||||
void setWeight(const int w);
|
||||
void setItalic(const bool i);
|
||||
void setUnderline(bool underline);
|
||||
void setStrikeOut(bool strikeout);
|
||||
void setWeight(int weight);
|
||||
void setItalic(bool italic);
|
||||
void setTextAlignment(Qt::AlignmentFlag alignment);
|
||||
|
||||
signals:
|
||||
@@ -32,7 +32,7 @@ signals:
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void weightButtonPressed(const bool w);
|
||||
void weightButtonPressed(bool weight);
|
||||
|
||||
private:
|
||||
QVBoxLayout* m_layout;
|
||||
|
||||
@@ -17,7 +17,7 @@ TextTool::TextTool(QObject* parent)
|
||||
if (!fontFamily.isEmpty()) {
|
||||
m_font.setFamily(ConfigHandler().fontFamily());
|
||||
}
|
||||
m_alignment = Qt::AlignRight;
|
||||
m_alignment = Qt::AlignLeft;
|
||||
}
|
||||
|
||||
TextTool::~TextTool()
|
||||
@@ -161,34 +161,36 @@ QWidget* TextTool::configurationWidget()
|
||||
|
||||
CaptureTool* TextTool::copy(QObject* parent)
|
||||
{
|
||||
auto* tt = new TextTool(parent);
|
||||
if (m_confW) {
|
||||
connect(
|
||||
m_confW, &TextConfig::fontFamilyChanged, tt, &TextTool::updateFamily);
|
||||
auto* textTool = new TextTool(parent);
|
||||
if (m_confW != nullptr) {
|
||||
connect(m_confW,
|
||||
&TextConfig::fontFamilyChanged,
|
||||
textTool,
|
||||
&TextTool::updateFamily);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontItalicChanged,
|
||||
tt,
|
||||
textTool,
|
||||
&TextTool::updateFontItalic);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontStrikeOutChanged,
|
||||
tt,
|
||||
textTool,
|
||||
&TextTool::updateFontStrikeOut);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontUnderlineChanged,
|
||||
tt,
|
||||
textTool,
|
||||
&TextTool::updateFontUnderline);
|
||||
connect(m_confW,
|
||||
&TextConfig::fontWeightChanged,
|
||||
tt,
|
||||
textTool,
|
||||
&TextTool::updateFontWeight);
|
||||
|
||||
connect(m_confW,
|
||||
&TextConfig::alignmentChanged,
|
||||
tt,
|
||||
textTool,
|
||||
&TextTool::updateAlignment);
|
||||
}
|
||||
copyParams(this, tt);
|
||||
return tt;
|
||||
copyParams(this, textTool);
|
||||
return textTool;
|
||||
}
|
||||
|
||||
void TextTool::process(QPainter& painter, const QPixmap& pixmap)
|
||||
@@ -215,7 +217,7 @@ void TextTool::process(QPainter& painter, const QPixmap& pixmap)
|
||||
painter.setFont(orig_font);
|
||||
painter.setPen(orig_pen);
|
||||
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setAlignment(m_alignment);
|
||||
}
|
||||
}
|
||||
@@ -235,14 +237,14 @@ void TextTool::paintMousePreview(QPainter& painter,
|
||||
Q_UNUSED(context)
|
||||
}
|
||||
|
||||
void TextTool::drawEnd(const QPoint& p)
|
||||
void TextTool::drawEnd(const QPoint& point)
|
||||
{
|
||||
m_textArea.moveTo(p);
|
||||
m_textArea.moveTo(point);
|
||||
}
|
||||
|
||||
void TextTool::drawMove(const QPoint& p)
|
||||
void TextTool::drawMove(const QPoint& point)
|
||||
{
|
||||
m_widget->move(p);
|
||||
m_widget->move(point);
|
||||
}
|
||||
|
||||
void TextTool::drawStart(const CaptureContext& context)
|
||||
@@ -257,11 +259,11 @@ void TextTool::pressed(CaptureContext& context)
|
||||
Q_UNUSED(context)
|
||||
}
|
||||
|
||||
void TextTool::onColorChanged(const QColor& c)
|
||||
void TextTool::onColorChanged(const QColor& color)
|
||||
{
|
||||
m_color = c;
|
||||
if (m_widget) {
|
||||
m_widget->setTextColor(c);
|
||||
m_color = color;
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setTextColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,23 +271,23 @@ void TextTool::onSizeChanged(int size)
|
||||
{
|
||||
m_size = size;
|
||||
m_font.setPointSize(m_size + BASE_POINT_SIZE);
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateText(const QString& s)
|
||||
void TextTool::updateText(const QString& newText)
|
||||
{
|
||||
m_text = s;
|
||||
m_text = newText;
|
||||
}
|
||||
|
||||
void TextTool::updateFamily(const QString& s)
|
||||
void TextTool::updateFamily(const QString& text)
|
||||
{
|
||||
m_font.setFamily(s);
|
||||
m_font.setFamily(text);
|
||||
if (m_textOld.isEmpty()) {
|
||||
ConfigHandler().setFontFamily(m_font.family());
|
||||
}
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
@@ -293,23 +295,23 @@ void TextTool::updateFamily(const QString& s)
|
||||
void TextTool::updateFontUnderline(const bool underlined)
|
||||
{
|
||||
m_font.setUnderline(underlined);
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontStrikeOut(const bool s)
|
||||
void TextTool::updateFontStrikeOut(const bool strikeout)
|
||||
{
|
||||
m_font.setStrikeOut(s);
|
||||
if (m_widget) {
|
||||
m_font.setStrikeOut(strikeout);
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontWeight(const QFont::Weight w)
|
||||
void TextTool::updateFontWeight(const QFont::Weight weight)
|
||||
{
|
||||
m_font.setWeight(w);
|
||||
if (m_widget) {
|
||||
m_font.setWeight(weight);
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
@@ -317,7 +319,7 @@ void TextTool::updateFontWeight(const QFont::Weight w)
|
||||
void TextTool::updateFontItalic(const bool italic)
|
||||
{
|
||||
m_font.setItalic(italic);
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
@@ -330,7 +332,7 @@ void TextTool::move(const QPoint& pos)
|
||||
void TextTool::updateAlignment(Qt::AlignmentFlag alignment)
|
||||
{
|
||||
m_alignment = alignment;
|
||||
if (m_widget) {
|
||||
if (m_widget != nullptr) {
|
||||
m_widget->setAlignment(m_alignment);
|
||||
}
|
||||
}
|
||||
@@ -341,12 +343,12 @@ const QPoint* TextTool::pos()
|
||||
return &m_currentPos;
|
||||
}
|
||||
|
||||
void TextTool::setEditMode(bool b)
|
||||
void TextTool::setEditMode(bool editMode)
|
||||
{
|
||||
if (b) {
|
||||
if (editMode) {
|
||||
m_textOld = m_text;
|
||||
}
|
||||
CaptureTool::setEditMode(b);
|
||||
CaptureTool::setEditMode(editMode);
|
||||
}
|
||||
|
||||
bool TextTool::isChanged()
|
||||
|
||||
@@ -15,17 +15,18 @@ class TextTool : public CaptureTool
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextTool(QObject* parent = nullptr);
|
||||
~TextTool();
|
||||
~TextTool() override;
|
||||
|
||||
bool isValid() const override;
|
||||
bool closeOnButtonPressed() const override;
|
||||
bool isSelectable() const override;
|
||||
bool showMousePreview() const override;
|
||||
QRect boundingRect() const override;
|
||||
[[nodiscard]] bool isValid() const override;
|
||||
[[nodiscard]] bool closeOnButtonPressed() const override;
|
||||
[[nodiscard]] bool isSelectable() const override;
|
||||
[[nodiscard]] bool showMousePreview() const override;
|
||||
[[nodiscard]] QRect boundingRect() const override;
|
||||
|
||||
QIcon icon(const QColor& background, bool inEditor) const override;
|
||||
QString name() const override;
|
||||
QString description() const override;
|
||||
[[nodiscard]] QIcon icon(const QColor& background,
|
||||
bool inEditor) const override;
|
||||
[[nodiscard]] QString name() const override;
|
||||
[[nodiscard]] QString description() const override;
|
||||
QString info() override;
|
||||
|
||||
QWidget* widget() override;
|
||||
@@ -39,29 +40,29 @@ public:
|
||||
const QPoint* pos() override;
|
||||
void drawObjectSelection(QPainter& painter) override;
|
||||
|
||||
void setEditMode(bool b) override;
|
||||
void setEditMode(bool editMode) override;
|
||||
bool isChanged() override;
|
||||
|
||||
protected:
|
||||
void copyParams(const TextTool* from, TextTool* to);
|
||||
CaptureTool::Type type() const override;
|
||||
[[nodiscard]] CaptureTool::Type type() const override;
|
||||
|
||||
public slots:
|
||||
void drawEnd(const QPoint& p) override;
|
||||
void drawMove(const QPoint& p) override;
|
||||
void drawEnd(const QPoint& point) override;
|
||||
void drawMove(const QPoint& point) override;
|
||||
void drawStart(const CaptureContext& context) override;
|
||||
void pressed(CaptureContext& context) override;
|
||||
void onColorChanged(const QColor& c) override;
|
||||
void onColorChanged(const QColor& color) override;
|
||||
void onSizeChanged(int size) override;
|
||||
virtual int size() const override { return m_size; };
|
||||
int size() const override { return m_size; };
|
||||
|
||||
private slots:
|
||||
void updateText(const QString& s);
|
||||
void updateFamily(const QString& s);
|
||||
void updateFontUnderline(const bool underlined);
|
||||
void updateFontStrikeOut(const bool s);
|
||||
void updateFontWeight(const QFont::Weight w);
|
||||
void updateFontItalic(const bool italic);
|
||||
void updateText(const QString& string);
|
||||
void updateFamily(const QString& string);
|
||||
void updateFontUnderline(bool underlined);
|
||||
void updateFontStrikeOut(bool strikeout);
|
||||
void updateFontWeight(QFont::Weight weight);
|
||||
void updateFontItalic(bool italic);
|
||||
void updateAlignment(Qt::AlignmentFlag alignment);
|
||||
|
||||
private:
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include "utilitypanel.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug> // TODO remove
|
||||
#include <QFormLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
@@ -23,9 +21,10 @@
|
||||
|
||||
SidePanelWidget::SidePanelWidget(QPixmap* p, QWidget* parent)
|
||||
: QWidget(parent)
|
||||
, m_layout(new QVBoxLayout(this))
|
||||
, m_pixmap(p)
|
||||
{
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
||||
if (parent) {
|
||||
parent->installEventFilter(this);
|
||||
}
|
||||
@@ -109,7 +108,7 @@ void SidePanelWidget::onColorChanged(const QColor& c)
|
||||
m_colorWheel->setColor(c);
|
||||
}
|
||||
|
||||
void SidePanelWidget::onToolSizeChanged(const int& t)
|
||||
void SidePanelWidget::onToolSizeChanged(int t)
|
||||
{
|
||||
m_toolSize = qBound(0, t, maxToolSize);
|
||||
m_toolSizeSlider->setValue(m_toolSize);
|
||||
|
||||
@@ -27,13 +27,13 @@ public:
|
||||
explicit SidePanelWidget(QPixmap* p, QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void colorChanged(const QColor& c);
|
||||
void toolSizeChanged(int t);
|
||||
void colorChanged(const QColor& color);
|
||||
void toolSizeChanged(int tootl);
|
||||
void togglePanel();
|
||||
|
||||
public slots:
|
||||
void onToolSizeChanged(const int& t);
|
||||
void onColorChanged(const QColor& c);
|
||||
void onToolSizeChanged(int tool);
|
||||
void onColorChanged(const QColor& color);
|
||||
|
||||
private slots:
|
||||
void startColorGrab();
|
||||
@@ -43,14 +43,14 @@ private slots:
|
||||
|
||||
private:
|
||||
void finalizeGrab();
|
||||
void updateColorNoWheel(const QColor& c);
|
||||
void updateColorNoWheel(const QColor& color);
|
||||
|
||||
bool eventFilter(QObject* obj, QEvent* event) override;
|
||||
void hideEvent(QHideEvent* event) override;
|
||||
|
||||
QVBoxLayout* m_layout;
|
||||
QPushButton* m_colorGrabButton;
|
||||
ColorGrabWidget* m_colorGrabber;
|
||||
ColorGrabWidget* m_colorGrabber{};
|
||||
color_widgets::ColorWheel* m_colorWheel;
|
||||
QLabel* m_colorLabel;
|
||||
QLineEdit* m_colorHex;
|
||||
@@ -58,5 +58,5 @@ private:
|
||||
QColor m_color;
|
||||
QColor m_revertColor;
|
||||
QSlider* m_toolSizeSlider;
|
||||
int m_toolSize;
|
||||
int m_toolSize{};
|
||||
};
|
||||
|
||||
@@ -53,31 +53,31 @@ QWidget* UtilityPanel::toolWidget() const
|
||||
return m_toolWidget;
|
||||
}
|
||||
|
||||
void UtilityPanel::setToolWidget(QWidget* w)
|
||||
void UtilityPanel::setToolWidget(QWidget* widget)
|
||||
{
|
||||
if (m_toolWidget) {
|
||||
if (m_toolWidget != nullptr) {
|
||||
m_toolWidget->hide();
|
||||
m_toolWidget->setParent(this);
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
if (w) {
|
||||
m_toolWidget = w;
|
||||
if (widget != nullptr) {
|
||||
m_toolWidget = widget;
|
||||
m_toolWidget->setSizePolicy(QSizePolicy::Ignored,
|
||||
QSizePolicy::Preferred);
|
||||
m_upLayout->addWidget(w);
|
||||
m_upLayout->addWidget(widget);
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityPanel::clearToolWidget()
|
||||
{
|
||||
if (m_toolWidget) {
|
||||
if (m_toolWidget != nullptr) {
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityPanel::pushWidget(QWidget* w)
|
||||
void UtilityPanel::pushWidget(QWidget* widget)
|
||||
{
|
||||
m_layout->insertWidget(m_layout->count() - 1, w);
|
||||
m_layout->insertWidget(m_layout->count() - 1, widget);
|
||||
}
|
||||
|
||||
void UtilityPanel::show()
|
||||
@@ -193,7 +193,7 @@ void UtilityPanel::initInternalPanel()
|
||||
}
|
||||
|
||||
void UtilityPanel::fillCaptureTools(
|
||||
QList<QPointer<CaptureTool>> captureToolObjects)
|
||||
const QList<QPointer<CaptureTool>>& captureToolObjects)
|
||||
{
|
||||
int currentSelection = m_captureTools->currentRow();
|
||||
m_captureTools->clear();
|
||||
|
||||
@@ -12,7 +12,6 @@ class QPropertyAnimation;
|
||||
class QScrollArea;
|
||||
class QPushButton;
|
||||
class QListWidget;
|
||||
class CaptureTool;
|
||||
class QPushButton;
|
||||
class CaptureWidget;
|
||||
|
||||
@@ -22,14 +21,14 @@ class UtilityPanel : public QWidget
|
||||
public:
|
||||
explicit UtilityPanel(CaptureWidget* captureWidget);
|
||||
|
||||
QWidget* toolWidget() const;
|
||||
void setToolWidget(QWidget* w);
|
||||
[[nodiscard]] QWidget* toolWidget() const;
|
||||
void setToolWidget(QWidget* weight);
|
||||
void clearToolWidget();
|
||||
void pushWidget(QWidget* w);
|
||||
void pushWidget(QWidget* widget);
|
||||
void hide();
|
||||
void show();
|
||||
void fillCaptureTools(
|
||||
QList<QPointer<CaptureTool>> captureToolObjectsHistory);
|
||||
const QList<QPointer<CaptureTool>>& captureToolObjectsHistory);
|
||||
void setActiveLayer(int index);
|
||||
int activeLayerIndex();
|
||||
bool isVisible() const;
|
||||
|
||||
Reference in New Issue
Block a user