Add text configuration in panel
@@ -51,5 +51,13 @@
|
||||
<file>img/buttonIconsWhite/text.png</file>
|
||||
<file>img/configBlack/colorize.png</file>
|
||||
<file>img/configWhite/colorize.png</file>
|
||||
<file>img/configWhite/format_bold.png</file>
|
||||
<file>img/configWhite/format_italic.png</file>
|
||||
<file>img/configWhite/format_strikethrough.png</file>
|
||||
<file>img/configWhite/format_underlined.png</file>
|
||||
<file>img/configBlack/format_bold.png</file>
|
||||
<file>img/configBlack/format_italic.png</file>
|
||||
<file>img/configBlack/format_strikethrough.png</file>
|
||||
<file>img/configBlack/format_underlined.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
BIN
img/configBlack/format_bold.png
Normal file
|
After Width: | Height: | Size: 327 B |
4
img/configBlack/format_bold.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"/>
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 379 B |
BIN
img/configBlack/format_italic.png
Normal file
|
After Width: | Height: | Size: 272 B |
4
img/configBlack/format_italic.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 198 B |
BIN
img/configBlack/format_strikethrough.png
Normal file
|
After Width: | Height: | Size: 194 B |
4
img/configBlack/format_strikethrough.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 204 B |
BIN
img/configBlack/format_underlined.png
Normal file
|
After Width: | Height: | Size: 292 B |
4
img/configBlack/format_underlined.svg
Executable file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
||||
<path d="M0 0h24v24H0z" fill="none"/>
|
||||
<path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 265 B |
BIN
img/configWhite/format_bold.png
Normal file
|
After Width: | Height: | Size: 332 B |
58
img/configWhite/format_bold.svg
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="format_bold.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="9.8333333"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z"
|
||||
id="path2"
|
||||
style="fill:#ffffff" />
|
||||
<path
|
||||
d="M0 0h24v24H0z"
|
||||
fill="none"
|
||||
id="path4" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
BIN
img/configWhite/format_italic.png
Normal file
|
After Width: | Height: | Size: 289 B |
58
img/configWhite/format_italic.svg
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="format_italic.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="9.8333333"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M0 0h24v24H0z"
|
||||
fill="none"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z"
|
||||
id="path4"
|
||||
style="fill:#ffffff" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
BIN
img/configWhite/format_strikethrough.png
Normal file
|
After Width: | Height: | Size: 205 B |
58
img/configWhite/format_strikethrough.svg
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="format_strikethrough.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="9.8333333"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M0 0h24v24H0z"
|
||||
fill="none"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M10 19h4v-3h-4v3zM5 4v3h5v3h4V7h5V4H5zM3 14h18v-2H3v2z"
|
||||
id="path4"
|
||||
style="fill:#ffffff" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
BIN
img/configWhite/format_underlined.png
Normal file
|
After Width: | Height: | Size: 294 B |
58
img/configWhite/format_underlined.svg
Executable file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="24"
|
||||
height="24"
|
||||
viewBox="0 0 24 24"
|
||||
version="1.1"
|
||||
id="svg6"
|
||||
sodipodi:docname="format_underlined.svg"
|
||||
inkscape:version="0.92.3 (2405546, 2018-03-11)">
|
||||
<metadata
|
||||
id="metadata12">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs10" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="640"
|
||||
inkscape:window-height="480"
|
||||
id="namedview8"
|
||||
showgrid="false"
|
||||
inkscape:zoom="9.8333333"
|
||||
inkscape:cx="12"
|
||||
inkscape:cy="12"
|
||||
inkscape:window-x="36"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg6" />
|
||||
<path
|
||||
d="M0 0h24v24H0z"
|
||||
fill="none"
|
||||
id="path2" />
|
||||
<path
|
||||
d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"
|
||||
id="path4"
|
||||
style="fill:#ffffff" />
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
@@ -16,9 +16,90 @@
|
||||
// along with Flameshot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "textconfig.h"
|
||||
#include "src/utils/colorutils.h"
|
||||
#include "src/utils/pathinfo.h"
|
||||
#include <QFontDatabase>
|
||||
#include <QComboBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
TextConfig::TextConfig(QWidget *parent) : QWidget(parent) {
|
||||
m_layout = new QVBoxLayout(this);
|
||||
|
||||
QFontDatabase fontDB;
|
||||
QComboBox *fontsCB = new QComboBox();
|
||||
connect(fontsCB, &QComboBox::currentTextChanged,
|
||||
this, &TextConfig::fontFamilyChanged);
|
||||
fontsCB->addItems(fontDB.families());
|
||||
// TODO save family in config
|
||||
int index = fontsCB->findData(QFont().family());
|
||||
if ( index != -1 ) {
|
||||
fontsCB->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
QColor bgColor(palette().background().color());
|
||||
QString iconPrefix = ColorUtils::colorIsDark(bgColor) ?
|
||||
PathInfo::whiteConfigIconPath() :
|
||||
PathInfo::blackConfigIconPath();
|
||||
|
||||
m_strikeOutButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_strikethrough.png"), "");
|
||||
m_strikeOutButton->setCheckable(true);
|
||||
connect(m_strikeOutButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontStrikeOutChanged);
|
||||
m_strikeOutButton->setToolTip(tr("StrikeOut"));
|
||||
|
||||
m_underlineButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_underlined.png"), "");
|
||||
m_underlineButton->setCheckable(true);
|
||||
connect(m_underlineButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontUnderlineChanged);
|
||||
m_underlineButton->setToolTip(tr("Underline"));
|
||||
|
||||
m_weightButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_bold.png"), "");
|
||||
m_weightButton->setCheckable(true);
|
||||
connect(m_weightButton, &QPushButton::clicked,
|
||||
this, &TextConfig::weightButtonPressed);
|
||||
m_weightButton->setToolTip(tr("Bold"));
|
||||
|
||||
m_italicButton = new QPushButton(
|
||||
QIcon(iconPrefix + "format_italic.png"), "");
|
||||
m_italicButton->setCheckable(true);
|
||||
connect(m_italicButton, &QPushButton::clicked,
|
||||
this, &TextConfig::fontItalicChanged);
|
||||
m_italicButton->setToolTip(tr("Italic"));
|
||||
QHBoxLayout *modifiersLayout = new QHBoxLayout();
|
||||
|
||||
m_layout->addWidget(fontsCB);
|
||||
modifiersLayout->addWidget(m_strikeOutButton);
|
||||
modifiersLayout->addWidget(m_underlineButton);
|
||||
modifiersLayout->addWidget(m_weightButton);
|
||||
modifiersLayout->addWidget(m_italicButton);
|
||||
m_layout->addLayout(modifiersLayout);
|
||||
}
|
||||
|
||||
// https://doc.qt.io/qt-5/qfontdatabase.html#details
|
||||
void TextConfig::setUnderline(const bool u) {
|
||||
m_underlineButton->setChecked(u);
|
||||
}
|
||||
|
||||
void TextConfig::setStrikeOut(const bool s) {
|
||||
m_strikeOutButton->setChecked(s);
|
||||
}
|
||||
|
||||
void TextConfig::setWeight(const int w) {
|
||||
m_weightButton->setChecked(static_cast<QFont::Weight>(w) == QFont::Bold);
|
||||
}
|
||||
|
||||
void TextConfig::setItalic(const bool i) {
|
||||
m_italicButton->setChecked(i);
|
||||
}
|
||||
|
||||
void TextConfig::weightButtonPressed(const bool w) {
|
||||
if (w) {
|
||||
emit fontWeightChanged(QFont::Bold);
|
||||
} else {
|
||||
emit fontWeightChanged(QFont::Normal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,35 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QVBoxLayout;
|
||||
class QPushButton;
|
||||
|
||||
class TextConfig : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TextConfig(QWidget *parent = nullptr);
|
||||
|
||||
void setUnderline(const bool u);
|
||||
void setStrikeOut(const bool s);
|
||||
void setWeight(const int w);
|
||||
void setItalic(const bool i);
|
||||
|
||||
signals:
|
||||
void fontFamilyChanged(const QString &f);
|
||||
void fontUnderlineChanged(const bool underlined);
|
||||
void fontStrikeOutChanged(const bool dashed);
|
||||
void fontWeightChanged(const QFont::Weight w);
|
||||
void fontItalicChanged(const bool italic);
|
||||
|
||||
public slots:
|
||||
|
||||
private slots:
|
||||
void weightButtonPressed(const bool w);
|
||||
|
||||
private:
|
||||
QVBoxLayout *m_layout;
|
||||
QPushButton *m_strikeOutButton;
|
||||
QPushButton *m_underlineButton;
|
||||
QPushButton *m_weightButton;
|
||||
QPushButton *m_italicButton;
|
||||
};
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
|
||||
#define BASE_POINT_SIZE 8
|
||||
|
||||
TextTool::TextTool(QObject *parent) : CaptureTool(parent) {
|
||||
|
||||
TextTool::TextTool(QObject *parent) : CaptureTool(parent) {
|
||||
}
|
||||
|
||||
bool TextTool::isValid() const {
|
||||
@@ -70,13 +70,38 @@ QWidget *TextTool::widget() {
|
||||
}
|
||||
|
||||
QWidget *TextTool::configurationWidget() {
|
||||
TextConfig *w = nullptr;//new TextConfig();
|
||||
// TODO CONNECT
|
||||
return w;
|
||||
m_confW = new TextConfig();
|
||||
connect(m_confW, &TextConfig::fontFamilyChanged,
|
||||
this, &TextTool::updateFamily);
|
||||
connect(m_confW, &TextConfig::fontItalicChanged,
|
||||
this, &TextTool::updateFontItalic);
|
||||
connect(m_confW, &TextConfig::fontStrikeOutChanged,
|
||||
this, &TextTool::updateFontStrikeOut);
|
||||
connect(m_confW, &TextConfig::fontUnderlineChanged,
|
||||
this, &TextTool::updateFontUnderline);
|
||||
connect(m_confW, &TextConfig::fontWeightChanged,
|
||||
this, &TextTool::updateFontWeight);
|
||||
m_confW->setItalic(m_font.italic());
|
||||
m_confW->setUnderline(m_font.underline());
|
||||
m_confW->setStrikeOut(m_font.strikeOut());
|
||||
m_confW->setWeight(m_font.weight());
|
||||
return m_confW;
|
||||
}
|
||||
|
||||
CaptureTool *TextTool::copy(QObject *parent) {
|
||||
return new TextTool(parent);
|
||||
TextTool *tt = new TextTool(parent);
|
||||
connect(m_confW, &TextConfig::fontFamilyChanged,
|
||||
tt, &TextTool::updateFamily);
|
||||
connect(m_confW, &TextConfig::fontItalicChanged,
|
||||
tt, &TextTool::updateFontItalic);
|
||||
connect(m_confW, &TextConfig::fontStrikeOutChanged,
|
||||
tt, &TextTool::updateFontStrikeOut);
|
||||
connect(m_confW, &TextConfig::fontUnderlineChanged,
|
||||
tt, &TextTool::updateFontUnderline);
|
||||
connect(m_confW, &TextConfig::fontWeightChanged,
|
||||
tt, &TextTool::updateFontWeight);
|
||||
tt->m_font = m_font;
|
||||
return tt;
|
||||
}
|
||||
|
||||
void TextTool::undo(QPixmap &pixmap) {
|
||||
@@ -85,7 +110,6 @@ void TextTool::undo(QPixmap &pixmap) {
|
||||
}
|
||||
|
||||
void TextTool::process(QPainter &painter, const QPixmap &pixmap, bool recordUndo) {
|
||||
// TODO updateBackup() of others
|
||||
if (m_text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -149,3 +173,38 @@ void TextTool::setFont(const QFont &f) {
|
||||
m_widget->setFont(f);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFamily(const QString &s) {
|
||||
m_font.setFamily(s);
|
||||
if (m_widget) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontUnderline(const bool underlined) {
|
||||
m_font.setUnderline(underlined);
|
||||
if (m_widget) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontStrikeOut(const bool s) {
|
||||
m_font.setStrikeOut(s);
|
||||
if (m_widget) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontWeight(const QFont::Weight w) {
|
||||
m_font.setWeight(w);
|
||||
if (m_widget) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
void TextTool::updateFontItalic(const bool italic) {
|
||||
m_font.setItalic(italic);
|
||||
if (m_widget) {
|
||||
m_widget->setFont(m_font);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <QPointer>
|
||||
|
||||
class TextWidget;
|
||||
class TextConfig;
|
||||
|
||||
class TextTool : public CaptureTool {
|
||||
public:
|
||||
@@ -57,13 +58,19 @@ public slots:
|
||||
private slots:
|
||||
void updateText(const QString &s);
|
||||
void setFont(const QFont &f);
|
||||
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);
|
||||
|
||||
private:
|
||||
QString m_text;
|
||||
QFont m_font;
|
||||
QString m_text;
|
||||
int m_size;
|
||||
QColor m_color;
|
||||
QPixmap m_pixmapBackup;
|
||||
QRect m_backupArea;
|
||||
QPointer<TextWidget> m_widget;
|
||||
QPointer<TextConfig> m_confW;
|
||||
};
|
||||
|
||||
@@ -291,6 +291,7 @@ void CaptureWidget::mousePressEvent(QMouseEvent *e) {
|
||||
}
|
||||
}
|
||||
m_activeTool = m_activeButton->tool()->copy(this);
|
||||
|
||||
connect(this, &CaptureWidget::colorChanged,
|
||||
m_activeTool, &CaptureTool::colorChanged);
|
||||
connect(this, &CaptureWidget::thicknessChanged,
|
||||
@@ -573,13 +574,12 @@ void CaptureWidget::setState(CaptureButton *b) {
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
if (m_activeTool->isValid()) {
|
||||
auto mod = new ModificationCommand(
|
||||
&m_context.screenshot, m_activeTool);
|
||||
m_undoStack.push(mod);
|
||||
m_activeTool = nullptr;
|
||||
pushToolToStack();
|
||||
}
|
||||
}
|
||||
if (m_activeButton != b) {
|
||||
processTool(b->tool());
|
||||
}
|
||||
// Only close activated from button
|
||||
if (b->tool()->closeOnButtonPressed()) {
|
||||
close();
|
||||
@@ -587,12 +587,15 @@ void CaptureWidget::setState(CaptureButton *b) {
|
||||
|
||||
if (b->tool()->isSelectable()) {
|
||||
if (m_activeButton != b) {
|
||||
QWidget *confW = b->tool()->configurationWidget();
|
||||
m_panel->addToolWidget(confW);
|
||||
if (m_activeButton) {
|
||||
m_activeButton->setColor(m_uiColor);
|
||||
}
|
||||
m_activeButton = b;
|
||||
m_activeButton->setColor(m_contrastUiColor);
|
||||
} else if (m_activeButton) {
|
||||
m_panel->clearToolWidget();
|
||||
m_activeButton->setColor(m_uiColor);
|
||||
m_activeButton = nullptr;
|
||||
}
|
||||
@@ -606,10 +609,6 @@ void CaptureWidget::processTool(CaptureTool *t) {
|
||||
m_activeTool = t;
|
||||
t->pressed(m_context);
|
||||
m_activeTool = backup;
|
||||
QWidget *cw = t->configurationWidget();
|
||||
if (cw) {
|
||||
m_panel->addToolWidget(t->configurationWidget());
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureWidget::handleButtonSignal(CaptureTool::Request r) {
|
||||
@@ -797,11 +796,14 @@ void CaptureWidget::updateCursor() {
|
||||
void CaptureWidget::pushToolToStack() {
|
||||
auto mod = new ModificationCommand(
|
||||
&m_context.screenshot, m_activeTool);
|
||||
m_undoStack.push(mod);
|
||||
disconnect(this, &CaptureWidget::colorChanged,
|
||||
m_activeTool, &CaptureTool::colorChanged);
|
||||
disconnect(this, &CaptureWidget::thicknessChanged,
|
||||
m_activeTool, &CaptureTool::thicknessChanged);
|
||||
if (m_panel->toolWidget()) {
|
||||
disconnect(m_panel->toolWidget(), nullptr, m_activeTool, nullptr);
|
||||
}
|
||||
m_undoStack.push(mod);
|
||||
m_activeTool = nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,3 +60,7 @@ void NotifierBox::showMessage(const QString &msg) {
|
||||
show();
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
void NotifierBox::showColor(const QColor &color) {
|
||||
m_message = "";
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ protected:
|
||||
|
||||
public slots:
|
||||
void showMessage(const QString &msg);
|
||||
void showColor(const QColor &color);
|
||||
|
||||
private:
|
||||
QTimer *m_timer;
|
||||
|
||||
@@ -45,14 +45,26 @@ UtilityPanel::UtilityPanel(QWidget *parent) : QWidget(parent) {
|
||||
m_internalPanel, &QWidget::hide);
|
||||
}
|
||||
|
||||
QWidget *UtilityPanel::toolWidget() const {
|
||||
return m_toolWidget;
|
||||
}
|
||||
|
||||
void UtilityPanel::addToolWidget(QWidget *w) {
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
if (w) {
|
||||
m_toolWidget = w;
|
||||
m_upLayout->addWidget(w);
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityPanel::clearToolWidget() {
|
||||
if (m_toolWidget) {
|
||||
m_toolWidget->deleteLater();
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityPanel::pushWidget(QWidget *w) {
|
||||
m_layout->addWidget(w);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,9 @@ class UtilityPanel : public QWidget {
|
||||
public:
|
||||
explicit UtilityPanel(QWidget *parent = nullptr);
|
||||
|
||||
QWidget* toolWidget() const;
|
||||
void addToolWidget(QWidget *w);
|
||||
void clearToolWidget();
|
||||
void pushWidget(QWidget *w);
|
||||
|
||||
signals:
|
||||
|
||||