223 lines
8.6 KiB
Diff
223 lines
8.6 KiB
Diff
From 97df00beb618898b290ca2a633d5043c3d58e3db Mon Sep 17 00:00:00 2001
|
|
From: peijiankang <peijiankang@kylinos.cn>
|
|
Date: Wed, 29 Jun 2022 09:31:14 +0800
|
|
Subject: [PATCH] change text property in time
|
|
|
|
---
|
|
src/tools/AbstractActionToolWithWidget.cpp | 4 ++++
|
|
src/tools/AbstractActionToolWithWidget.h | 1 +
|
|
src/tools/abstractactiontool.cpp | 4 ++++
|
|
src/tools/abstractactiontool.h | 1 +
|
|
src/tools/abstractpathtool.cpp | 4 ++++
|
|
src/tools/abstractpathtool.h | 2 +-
|
|
src/tools/abstracttwopointtool.cpp | 4 ++++
|
|
src/tools/abstracttwopointtool.h | 1 +
|
|
src/tools/capturetool.h | 2 +-
|
|
src/tools/text/texttool.cpp | 11 +++++++++++
|
|
src/tools/text/texttool.h | 1 +
|
|
src/widgets/capture/capturewidget.cpp | 9 +++++++--
|
|
src/widgets/capture/capturewidget.h | 1 +
|
|
13 files changed, 41 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/tools/AbstractActionToolWithWidget.cpp b/src/tools/AbstractActionToolWithWidget.cpp
|
|
index bd07d86..9289683 100644
|
|
--- a/src/tools/AbstractActionToolWithWidget.cpp
|
|
+++ b/src/tools/AbstractActionToolWithWidget.cpp
|
|
@@ -86,3 +86,7 @@ void AbstractActionToolWithWidget::colorChanged(const QColor &c) {
|
|
void AbstractActionToolWithWidget::thicknessChanged(const int th) {
|
|
Q_UNUSED(th);
|
|
}
|
|
+
|
|
+void AbstractActionToolWithWidget::textChanged(const CaptureContext &context) {
|
|
+ Q_UNUSED(context);
|
|
+}
|
|
diff --git a/src/tools/AbstractActionToolWithWidget.h b/src/tools/AbstractActionToolWithWidget.h
|
|
index d92e7cd..feb2fbe 100644
|
|
--- a/src/tools/AbstractActionToolWithWidget.h
|
|
+++ b/src/tools/AbstractActionToolWithWidget.h
|
|
@@ -44,4 +44,5 @@ public slots:
|
|
void drawStart(const CaptureContext &context) override;
|
|
void colorChanged(const QColor &c) override;
|
|
void thicknessChanged(const int th) override;
|
|
+ void textChanged(const CaptureContext &context) override;
|
|
};
|
|
diff --git a/src/tools/abstractactiontool.cpp b/src/tools/abstractactiontool.cpp
|
|
index 2d0c886..df19020 100755
|
|
--- a/src/tools/abstractactiontool.cpp
|
|
+++ b/src/tools/abstractactiontool.cpp
|
|
@@ -84,3 +84,7 @@ void AbstractActionTool::colorChanged(const QColor &c) {
|
|
void AbstractActionTool::thicknessChanged(const int th) {
|
|
Q_UNUSED(th);
|
|
}
|
|
+
|
|
+void AbstractActionTool::textChanged(const CaptureContext &context) {
|
|
+ Q_UNUSED(context);
|
|
+}
|
|
diff --git a/src/tools/abstractactiontool.h b/src/tools/abstractactiontool.h
|
|
index 8b8b9c3..3cf57ac 100755
|
|
--- a/src/tools/abstractactiontool.h
|
|
+++ b/src/tools/abstractactiontool.h
|
|
@@ -42,4 +42,5 @@ public slots:
|
|
void drawStart(const CaptureContext &context) override;
|
|
void colorChanged(const QColor &c) override;
|
|
void thicknessChanged(const int th) override;
|
|
+ void textChanged(const CaptureContext &context) override;
|
|
};
|
|
diff --git a/src/tools/abstractpathtool.cpp b/src/tools/abstractpathtool.cpp
|
|
index 89ab28f..e678c4f 100755
|
|
--- a/src/tools/abstractpathtool.cpp
|
|
+++ b/src/tools/abstractpathtool.cpp
|
|
@@ -82,3 +82,7 @@ void AbstractPathTool::addPoint(const QPoint &point) {
|
|
}
|
|
m_points.append(point);
|
|
}
|
|
+
|
|
+void AbstractPathTool::textChanged(const CaptureContext &context) {
|
|
+ Q_UNUSED(context);
|
|
+}
|
|
diff --git a/src/tools/abstractpathtool.h b/src/tools/abstractpathtool.h
|
|
index 172dab8..842fcb1 100755
|
|
--- a/src/tools/abstractpathtool.h
|
|
+++ b/src/tools/abstractpathtool.h
|
|
@@ -35,7 +35,7 @@ public slots:
|
|
void drawMove(const QPoint &p) override;
|
|
void colorChanged(const QColor &c) override;
|
|
void thicknessChanged(const int th) override;
|
|
-
|
|
+ void textChanged(const CaptureContext &context) override;
|
|
protected:
|
|
void updateBackup(const QPixmap &pixmap);
|
|
void addPoint(const QPoint &point);
|
|
diff --git a/src/tools/abstracttwopointtool.cpp b/src/tools/abstracttwopointtool.cpp
|
|
index d968dea..6403190 100755
|
|
--- a/src/tools/abstracttwopointtool.cpp
|
|
+++ b/src/tools/abstracttwopointtool.cpp
|
|
@@ -133,3 +133,7 @@ QPoint AbstractTwoPointTool::adjustedVector(QPoint v) const {
|
|
}
|
|
return v;
|
|
}
|
|
+
|
|
+void AbstractTwoPointTool::textChanged(const CaptureContext &context) {
|
|
+ Q_UNUSED(context);
|
|
+}
|
|
diff --git a/src/tools/abstracttwopointtool.h b/src/tools/abstracttwopointtool.h
|
|
index 65ee630..4c684d2 100755
|
|
--- a/src/tools/abstracttwopointtool.h
|
|
+++ b/src/tools/abstracttwopointtool.h
|
|
@@ -39,6 +39,7 @@ public slots:
|
|
void drawMoveWithAdjustment(const QPoint &p) override;
|
|
void colorChanged(const QColor &c) override;
|
|
void thicknessChanged(const int th) override;
|
|
+ void textChanged(const CaptureContext &context) override;
|
|
|
|
protected:
|
|
void updateBackup(const QPixmap &pixmap);
|
|
diff --git a/src/tools/capturetool.h b/src/tools/capturetool.h
|
|
index f1eff27..8531aeb 100755
|
|
--- a/src/tools/capturetool.h
|
|
+++ b/src/tools/capturetool.h
|
|
@@ -191,7 +191,7 @@ public slots:
|
|
virtual void colorChanged(const QColor &c) = 0;
|
|
// Called when the thickness of the tool is updated in the editor.
|
|
virtual void thicknessChanged(const int th) = 0;
|
|
-
|
|
+ virtual void textChanged(const CaptureContext &context) = 0;
|
|
#ifdef ENABLE_RECORD
|
|
virtual void pressCalled() {
|
|
m_isPressed = !m_isPressed;
|
|
diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp
|
|
index 43ac557..b70889e 100755
|
|
--- a/src/tools/text/texttool.cpp
|
|
+++ b/src/tools/text/texttool.cpp
|
|
@@ -201,6 +201,17 @@ void TextTool::thicknessChanged(const int th) {
|
|
}
|
|
}
|
|
|
|
+void TextTool::textChanged(const CaptureContext &context)
|
|
+{
|
|
+ m_font.setUnderline(context.underline);
|
|
+ m_font.setStrikeOut(context.deleteline);
|
|
+ m_font.setItalic(context.italic);
|
|
+ m_font.setBold(context.bold);
|
|
+ if (m_widget) {
|
|
+ m_widget->setFont(m_font);
|
|
+ }
|
|
+}
|
|
+
|
|
void TextTool::updateText(const QString &s) {
|
|
m_text = s;
|
|
}
|
|
diff --git a/src/tools/text/texttool.h b/src/tools/text/texttool.h
|
|
index 8981bff..c97a87e 100755
|
|
--- a/src/tools/text/texttool.h
|
|
+++ b/src/tools/text/texttool.h
|
|
@@ -58,6 +58,7 @@ public slots:
|
|
void pressed(const CaptureContext &context) override;
|
|
void colorChanged(const QColor &c) override;
|
|
void thicknessChanged(const int th) override;
|
|
+ void textChanged(const CaptureContext &context) override;
|
|
|
|
private slots:
|
|
void updateText(const QString &s);
|
|
diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp
|
|
index 178d7da..b93e08c 100755
|
|
--- a/src/widgets/capture/capturewidget.cpp
|
|
+++ b/src/widgets/capture/capturewidget.cpp
|
|
@@ -631,6 +631,8 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) {
|
|
m_activeTool, &CaptureTool::thicknessChanged);
|
|
connect(m_activeTool, &CaptureTool::requestAction,
|
|
this, &CaptureWidget::handleButtonSignal);
|
|
+ connect(this,&CaptureWidget::textchanged,
|
|
+ m_activeTool, &CaptureTool::textChanged);
|
|
m_activeTool->drawStart(m_context);
|
|
return;
|
|
}
|
|
@@ -1266,7 +1268,7 @@ void CaptureWidget::setState(CaptureButton *b) {
|
|
new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Left), this, SLOT(leftResize()));
|
|
new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Up), this, SLOT(upResize()));
|
|
new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_Down), this, SLOT(downResize()));
|
|
- // new QShortcut(Qt::Key_Space, this, SLOT(togglePanel()));
|
|
+ new QShortcut(Qt::Key_Space, this, SLOT(togglePanel()));
|
|
new QShortcut(Qt::Key_Escape, this, SLOT(deleteToolwidgetOrClose()));
|
|
new QShortcut(Qt::Key_Return, this, SLOT(copyScreenshot()));
|
|
new QShortcut(Qt::Key_Enter, this, SLOT(copyScreenshot()));
|
|
@@ -1480,19 +1482,22 @@ void CaptureWidget::setState(CaptureButton *b) {
|
|
void CaptureWidget::font_bold_clicked(bool b)
|
|
{
|
|
m_context.bold = b;
|
|
+ emit textchanged(m_context);
|
|
}
|
|
void CaptureWidget::font_delete_clicked(bool b)
|
|
{
|
|
m_context.deleteline = b;
|
|
+ emit textchanged(m_context);
|
|
}
|
|
void CaptureWidget::font_underline_clicked(bool b)
|
|
{
|
|
m_context.underline =b;
|
|
-
|
|
+ emit textchanged(m_context);
|
|
}
|
|
void CaptureWidget::font_italic_clicked(bool b)
|
|
{
|
|
m_context.italic =b;
|
|
+ emit textchanged(m_context);
|
|
}
|
|
void CaptureWidget::ClickedSaveType(int i)
|
|
{
|
|
diff --git a/src/widgets/capture/capturewidget.h b/src/widgets/capture/capturewidget.h
|
|
index 1d011d3..ce04f5d 100755
|
|
--- a/src/widgets/capture/capturewidget.h
|
|
+++ b/src/widgets/capture/capturewidget.h
|
|
@@ -88,6 +88,7 @@ signals:
|
|
void captureFailed(uint id);
|
|
void colorChanged(const QColor &c);
|
|
void thicknessChanged(const int thickness);
|
|
+ void textchanged(CaptureContext m_context);
|
|
|
|
private slots:
|
|
// TODO replace with tools
|
|
--
|
|
2.33.0
|
|
|