mirror of
https://github.com/fergalmoran/flameshot.git
synced 2025-12-26 03:39:34 +00:00
NC/Edit text objects on double click (#1578)
* Edit existing text objects (cherry picked from commit 3d6edca21b5615481d0ab409801baeafb523ce72) * Add 'info' to the panel for the text tool object (cherry picked from commit 2b633f560e46a0112d70653f6c55da5e97ce4cc8) * Add 'info' to the panel for the CircleCount tool object (cherry picked from commit 5ff5b667c1d6c534fe447618f9938a4581f0c9f2) * Set text settings active in the Tool Settings panel on edit text (cherry picked from commit a020a3504c0d02bbca4bb870e12e80ee87d64f75) * Set font family in the Tool Settings panel on edit text object (cherry picked from commit 70fe9bd5e79f39d544ed2d7848d05492da9b52bd) Co-authored-by: Yuriy Puchkov <yuriy.puchkov@namecheap.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "textwidget.h"
|
||||
|
||||
#define BASE_POINT_SIZE 8
|
||||
#define MAX_INFO_LENGTH 24
|
||||
|
||||
TextTool::TextTool(QObject* parent)
|
||||
: CaptureTool(parent)
|
||||
@@ -59,6 +60,20 @@ QString TextTool::name() const
|
||||
return tr("Text");
|
||||
}
|
||||
|
||||
QString TextTool::info()
|
||||
{
|
||||
if (m_text.length() > 0) {
|
||||
m_tempString = QString("%1 - %2").arg(name()).arg(m_text.trimmed());
|
||||
m_tempString = m_tempString.split("\n").at(0);
|
||||
if (m_tempString.length() > MAX_INFO_LENGTH) {
|
||||
m_tempString.truncate(MAX_INFO_LENGTH);
|
||||
m_tempString += "…";
|
||||
}
|
||||
return m_tempString;
|
||||
}
|
||||
return name();
|
||||
}
|
||||
|
||||
ToolType TextTool::nameID() const
|
||||
{
|
||||
return ToolType::TEXT;
|
||||
@@ -76,6 +91,8 @@ QWidget* TextTool::widget()
|
||||
m_widget->setTextColor(m_color);
|
||||
m_font.setPointSize(m_size + BASE_POINT_SIZE);
|
||||
m_widget->setFont(m_font);
|
||||
m_widget->setText(m_text);
|
||||
m_widget->selectAll();
|
||||
connect(m_widget, &TextWidget::textUpdated, this, &TextTool::updateText);
|
||||
return m_widget;
|
||||
}
|
||||
@@ -115,6 +132,7 @@ QWidget* TextTool::configurationWidget()
|
||||
&TextConfig::fontWeightChanged,
|
||||
this,
|
||||
&TextTool::updateFontWeight);
|
||||
m_confW->setFontFamily(m_font.family());
|
||||
m_confW->setItalic(m_font.italic());
|
||||
m_confW->setUnderline(m_font.underline());
|
||||
m_confW->setStrikeOut(m_font.strikeOut());
|
||||
@@ -164,7 +182,9 @@ void TextTool::process(QPainter& painter, const QPixmap& pixmap)
|
||||
// draw text
|
||||
painter.setFont(m_font);
|
||||
painter.setPen(m_color);
|
||||
painter.drawText(m_textArea + QMargins(-val, -val, val, val), m_text);
|
||||
if (!editMode()) {
|
||||
painter.drawText(m_textArea + QMargins(-val, -val, val, val), m_text);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::drawObjectSelection(QPainter& painter)
|
||||
|
||||
Reference in New Issue
Block a user