From dcaa2e321f01fd022738e510a0f5c5fabf9379c8 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Sat, 26 May 2018 17:59:44 +0200 Subject: [PATCH] Add text configuration in panel --- graphics.qrc | 8 +++ img/configBlack/format_bold.png | Bin 0 -> 327 bytes img/configBlack/format_bold.svg | 4 ++ img/configBlack/format_italic.png | Bin 0 -> 272 bytes img/configBlack/format_italic.svg | 4 ++ img/configBlack/format_strikethrough.png | Bin 0 -> 194 bytes img/configBlack/format_strikethrough.svg | 4 ++ img/configBlack/format_underlined.png | Bin 0 -> 292 bytes img/configBlack/format_underlined.svg | 4 ++ img/configWhite/format_bold.png | Bin 0 -> 332 bytes img/configWhite/format_bold.svg | 58 ++++++++++++++++ img/configWhite/format_italic.png | Bin 0 -> 289 bytes img/configWhite/format_italic.svg | 58 ++++++++++++++++ img/configWhite/format_strikethrough.png | Bin 0 -> 205 bytes img/configWhite/format_strikethrough.svg | 58 ++++++++++++++++ img/configWhite/format_underlined.png | Bin 0 -> 294 bytes img/configWhite/format_underlined.svg | 58 ++++++++++++++++ src/tools/text/textconfig.cpp | 83 ++++++++++++++++++++++- src/tools/text/textconfig.h | 22 ++++++ src/tools/text/texttool.cpp | 77 ++++++++++++++++++--- src/tools/text/texttool.h | 9 ++- src/widgets/capture/capturewidget.cpp | 22 +++--- src/widgets/capture/notifierbox.cpp | 4 ++ src/widgets/capture/notifierbox.h | 1 + src/widgets/panel/utilitypanel.cpp | 12 ++++ src/widgets/panel/utilitypanel.h | 2 + 26 files changed, 467 insertions(+), 21 deletions(-) create mode 100644 img/configBlack/format_bold.png create mode 100755 img/configBlack/format_bold.svg create mode 100644 img/configBlack/format_italic.png create mode 100755 img/configBlack/format_italic.svg create mode 100644 img/configBlack/format_strikethrough.png create mode 100755 img/configBlack/format_strikethrough.svg create mode 100644 img/configBlack/format_underlined.png create mode 100755 img/configBlack/format_underlined.svg create mode 100644 img/configWhite/format_bold.png create mode 100755 img/configWhite/format_bold.svg create mode 100644 img/configWhite/format_italic.png create mode 100755 img/configWhite/format_italic.svg create mode 100644 img/configWhite/format_strikethrough.png create mode 100755 img/configWhite/format_strikethrough.svg create mode 100644 img/configWhite/format_underlined.png create mode 100755 img/configWhite/format_underlined.svg diff --git a/graphics.qrc b/graphics.qrc index c51a80cf..5169b369 100644 --- a/graphics.qrc +++ b/graphics.qrc @@ -51,5 +51,13 @@ img/buttonIconsWhite/text.png img/configBlack/colorize.png img/configWhite/colorize.png + img/configWhite/format_bold.png + img/configWhite/format_italic.png + img/configWhite/format_strikethrough.png + img/configWhite/format_underlined.png + img/configBlack/format_bold.png + img/configBlack/format_italic.png + img/configBlack/format_strikethrough.png + img/configBlack/format_underlined.png diff --git a/img/configBlack/format_bold.png b/img/configBlack/format_bold.png new file mode 100644 index 0000000000000000000000000000000000000000..540150d8a43cd53ad946f3375473d9c8d0d3e59a GIT binary patch literal 327 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1T!c)B=- zcyzvwDxWgjb zXh*_Cezr7;Pxl<;T>j0CSs`7(a4b~vMis+mqsCe7jj0d6*d}D%i$7DtZ}I2sfv|~F zH%ogmmG-`7Uw3Jdq=HfTFGT~xzkC*2eN6l6KS{pGI$Fz9ln|-5z&DWDqjBHN;Dp!J zr57E%E*`kKR<$vHsm4UHTOwO4mU1M>S4}+ne6qj8ZmwpY8w|2*D^wmG7k16}^R}5h Rod@V222WQ%mvv4FO#tSzcy0gy literal 0 HcmV?d00001 diff --git a/img/configBlack/format_bold.svg b/img/configBlack/format_bold.svg new file mode 100755 index 00000000..ca6b4b63 --- /dev/null +++ b/img/configBlack/format_bold.svg @@ -0,0 +1,4 @@ + + + + diff --git a/img/configBlack/format_italic.png b/img/configBlack/format_italic.png new file mode 100644 index 0000000000000000000000000000000000000000..394aaf632c87f812dd62f765ac80c8f426e37d7b GIT binary patch literal 272 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1TgJzX3_ zJUZWAImmg)LBQ>y{=LPa9cw#ME4E8=Z|I&7c0}vS?qkkkLOdF~b3Q!S_xarK^!7xJ zKeMzRl?#4f10>7L8dQ@>K-ds^|t^EHHwdFEpj`tRx)NL;l z*>F}j{;}W_apRo(7ccx(+`i}7)eW;&&v@j&T + + + diff --git a/img/configBlack/format_strikethrough.png b/img/configBlack/format_strikethrough.png new file mode 100644 index 0000000000000000000000000000000000000000..6c3c226e12cd7a3c99bec9afa05324ed67b63741 GIT binary patch literal 194 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1U-JzX3_ zJUWvTBv_ewB?>$KFP~QFlOp9}vS26cjwTLi2Y$0fU-vSFx0WI2q%4-Sqe0Y!PC{xWt~$(696AxI5GeL literal 0 HcmV?d00001 diff --git a/img/configBlack/format_strikethrough.svg b/img/configBlack/format_strikethrough.svg new file mode 100755 index 00000000..15151054 --- /dev/null +++ b/img/configBlack/format_strikethrough.svg @@ -0,0 +1,4 @@ + + + + diff --git a/img/configBlack/format_underlined.png b/img/configBlack/format_underlined.png new file mode 100644 index 0000000000000000000000000000000000000000..5a0da6c63d1b9f205a4b01ede6b186b651549e74 GIT binary patch literal 292 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1SRdb&7< zcyzv<;>gwPz~dSpdt+zQx3;Bwo1YgfUM^^UNjT*Fg|hp4YDofHO>$Wi?P}O2O%P|2 zc3|d1uWrF3 zj7v|+>o(XH1o}oPh?i^KW7x>bPsx1!r2qf! h|NHOXNzM0Ov2J>$5izT^HVNoh22WQ%mvv4FO#s(4Z0G<0 literal 0 HcmV?d00001 diff --git a/img/configBlack/format_underlined.svg b/img/configBlack/format_underlined.svg new file mode 100755 index 00000000..8615187f --- /dev/null +++ b/img/configBlack/format_underlined.svg @@ -0,0 +1,4 @@ + + + + diff --git a/img/configWhite/format_bold.png b/img/configWhite/format_bold.png new file mode 100644 index 0000000000000000000000000000000000000000..e16a9f2e0245462ca8dad968b9b7c02e5cc122ca GIT binary patch literal 332 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1S}db&7< zcyzv78NxViR11gqUojxC#Q>}nVFEy=vrc0nXm_2{Hs zp0cxV{(AedDCkP@lcnb$M{8#NYPleC^{dxJm0adFttm + + + + + image/svg+xml + + + + + + + + + diff --git a/img/configWhite/format_italic.png b/img/configWhite/format_italic.png new file mode 100644 index 0000000000000000000000000000000000000000..1a6422c91f95c0c2b0a507fe04df5c9fef186f05 GIT binary patch literal 289 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1U%dAc}; zcyzv#$fq+Z;PUlq)TbeYQt*;g==bjQK5UNnD*3Yahs3=r- zE<0A#%COiiEq<@qMYq6b!Vi=qJiYdnOusVYb9uw&?*g7yGb5#h+ZlLvd|1S6cJz#G z!tvR~fyMk8)r_|9xQ?eo56q{Z%dDsVt(N9Au8lZk(uzkk2J{^8`G ed!BfuTFqNyn0T?u@Ln3wr3{{~elF{r5}E)#ylzbZ literal 0 HcmV?d00001 diff --git a/img/configWhite/format_italic.svg b/img/configWhite/format_italic.svg new file mode 100755 index 00000000..14cbd711 --- /dev/null +++ b/img/configWhite/format_italic.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/img/configWhite/format_strikethrough.png b/img/configWhite/format_strikethrough.png new file mode 100644 index 0000000000000000000000000000000000000000..c4f641c953fb94bf69dd4bf4c7d7f7cb4308e7eb GIT binary patch literal 205 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1UNJY5_^ zJUZWAw&r3`;9M?2Mh7R5JsZDt{{~f}Xtl7HK uYRWIstLD5~yZ=YO*uXIF;6(njJTD$y6%Z~-*nS;oDubu1pUXO@geCw6sY9^< literal 0 HcmV?d00001 diff --git a/img/configWhite/format_strikethrough.svg b/img/configWhite/format_strikethrough.svg new file mode 100755 index 00000000..812c02be --- /dev/null +++ b/img/configWhite/format_strikethrough.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/img/configWhite/format_underlined.png b/img/configWhite/format_underlined.png new file mode 100644 index 0000000000000000000000000000000000000000..ca485a68fee922d3063ca27fbc769f564e406d61 GIT binary patch literal 294 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjEX7WqAsj$Z!;#Vf4nJ z@ErkR#;MwT(m+AU64!{5;QX|b^2DN4hVt@qz0ADq;^f4FRK5J7^x5xhq=1SRd%8G= zcyzv<;>gwPz~d?_eoZ?fU*oN;P5bO`CeG%UgjbYj?5@vK;=Sf)xFBE#f1<+AKhu5H zJQuBbwASjuO7+X;{<}_=2?{XoW{mqJ#^|s4KG{@q$4TB&hkXX;8{=&5F}SRR literal 0 HcmV?d00001 diff --git a/img/configWhite/format_underlined.svg b/img/configWhite/format_underlined.svg new file mode 100755 index 00000000..f0cc574e --- /dev/null +++ b/img/configWhite/format_underlined.svg @@ -0,0 +1,58 @@ + + + + + + image/svg+xml + + + + + + + + + diff --git a/src/tools/text/textconfig.cpp b/src/tools/text/textconfig.cpp index 6f586aae..078124e1 100644 --- a/src/tools/text/textconfig.cpp +++ b/src/tools/text/textconfig.cpp @@ -16,9 +16,90 @@ // along with Flameshot. If not, see . #include "textconfig.h" +#include "src/utils/colorutils.h" +#include "src/utils/pathinfo.h" +#include +#include +#include +#include +#include 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(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); + } +} diff --git a/src/tools/text/textconfig.h b/src/tools/text/textconfig.h index c5854eda..c9f15932 100644 --- a/src/tools/text/textconfig.h +++ b/src/tools/text/textconfig.h @@ -19,13 +19,35 @@ #include +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; }; diff --git a/src/tools/text/texttool.cpp b/src/tools/text/texttool.cpp index e933a667..e5066abc 100644 --- a/src/tools/text/texttool.cpp +++ b/src/tools/text/texttool.cpp @@ -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 { @@ -66,17 +66,42 @@ QWidget *TextTool::widget() { connect(w, &TextWidget::textUpdated, this, &TextTool::updateText); m_widget = w; - return w; -} - -QWidget *TextTool::configurationWidget() { - TextConfig *w = nullptr;//new TextConfig(); - // TODO CONNECT return w; } +QWidget *TextTool::configurationWidget() { + 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); + } +} diff --git a/src/tools/text/texttool.h b/src/tools/text/texttool.h index 2f78dc0d..66cca95c 100644 --- a/src/tools/text/texttool.h +++ b/src/tools/text/texttool.h @@ -21,6 +21,7 @@ #include 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 m_widget; + QPointer m_confW; }; diff --git a/src/widgets/capture/capturewidget.cpp b/src/widgets/capture/capturewidget.cpp index 6fd44a26..49958802 100644 --- a/src/widgets/capture/capturewidget.cpp +++ b/src/widgets/capture/capturewidget.cpp @@ -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(); } } - processTool(b->tool()); + 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; } diff --git a/src/widgets/capture/notifierbox.cpp b/src/widgets/capture/notifierbox.cpp index d38fef71..b018449d 100644 --- a/src/widgets/capture/notifierbox.cpp +++ b/src/widgets/capture/notifierbox.cpp @@ -60,3 +60,7 @@ void NotifierBox::showMessage(const QString &msg) { show(); m_timer->start(); } + +void NotifierBox::showColor(const QColor &color) { + m_message = ""; +} diff --git a/src/widgets/capture/notifierbox.h b/src/widgets/capture/notifierbox.h index b67be07f..06b5a594 100644 --- a/src/widgets/capture/notifierbox.h +++ b/src/widgets/capture/notifierbox.h @@ -32,6 +32,7 @@ protected: public slots: void showMessage(const QString &msg); + void showColor(const QColor &color); private: QTimer *m_timer; diff --git a/src/widgets/panel/utilitypanel.cpp b/src/widgets/panel/utilitypanel.cpp index fac598ed..48b4a7aa 100644 --- a/src/widgets/panel/utilitypanel.cpp +++ b/src/widgets/panel/utilitypanel.cpp @@ -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); } diff --git a/src/widgets/panel/utilitypanel.h b/src/widgets/panel/utilitypanel.h index 0228a67a..e3edce59 100644 --- a/src/widgets/panel/utilitypanel.h +++ b/src/widgets/panel/utilitypanel.h @@ -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: