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:
|
||||
|
||||
Reference in New Issue
Block a user