From 9d904d3a8cb6958de15a089f0cbf16634e285de5 Mon Sep 17 00:00:00 2001 From: Valentin Date: Wed, 29 May 2024 23:51:03 +0200 Subject: [PATCH] WIP - implementing question mark based tooltip helper --- .../include/tools/mdprep/ui/advanced_form.hpp | Bin 4774 -> 4694 bytes .../include/tools/mdprep/ui/basic_form.hpp | Bin 5038 -> 5412 bytes .../include/tools/mdprep/ui/form_data.hpp | Bin 6632 -> 5574 bytes .../tools/mdprep/src/ui/advanced_form.cpp | Bin 29794 -> 29746 bytes lib/tool/tools/mdprep/src/ui/basic_form.cpp | Bin 27992 -> 29590 bytes lib/ui/include/ui/qt/util.hpp | 16 ++- lib/ui/src/ui/qt/util.cpp | 93 ++++++++++++++++++ 7 files changed, 108 insertions(+), 1 deletion(-) diff --git a/lib/tool/tools/mdprep/include/tools/mdprep/ui/advanced_form.hpp b/lib/tool/tools/mdprep/include/tools/mdprep/ui/advanced_form.hpp index 4f77b0dc60365ddce06c2fdef2af10b4e7474111..9ac85e55863a81819def881452f6ef5c7d665d2e 100644 GIT binary patch delta 46 zcmZ3cdQD|R0Mq6KrZY^FZCEYXH5fD*6c{uouV;~-yo~kR<~3|t>_7>b%}#tNEC5-m B4jupi delta 126 zcmcbnvP^YD0299>LkdF~Ln1>SLo!1uL&|1%o6_&~OSS&Uxu&!g=e1pw`iJ6l@VKP6b{p1Hc7GQQGXFZgbpDf3v0TfqJ z4`3)|C}zlDa01dLK$y>v$DqKV1;p_TNeHpY^4zkbWkC60hE%Y+OrW}Spia)o_jxR# zrn*i(z-5JGg9?z(Hu({c5(%~_3gWXtbMicH36Q%dC-90O*~BqffCns2v`zdxqT(1f jF>nH*!el`X^~rghN}Ka|?3jT;Dl>TrtH$PE{9Bj-uuxP_ delta 157 zcmZ3YwN8D*6_&|78(Em delta 575 zcmX@6{la*I3YVZ0Ln1>lLncEq11|#?11CfEdz{UDS#G`$ICgcHeE)Z7%O)LS@`9KkfIkrHvih*Jf@nnX0plu*qOBiezO2Ily z7|a+>Qw2>g3b>x|8Se za83RrsHTaoDirLx5(YnpGN2tG)1WS!T*$6Ixj{f>at^luakdB$V@m<0wg^gcDlmY; z&6L4l@_RvJZCpMI0ER|BLkd#AJg2uE~7TGMhgI H7bpM#{Y((w delta 104 zcmdn=g7MJ{#tju5!j23n3}p<740#O645>i20)yIQK~Cw-(>UgE@S{m?HWUGxzmt;Ld?>g;0RWR^8$JL4 diff --git a/lib/tool/tools/mdprep/src/ui/basic_form.cpp b/lib/tool/tools/mdprep/src/ui/basic_form.cpp index 3a412910cdb355d19bf30838e6f1bd9ee23ef9ef..2cdfe2e4eeb1a41ac8bf6e7dcf961789eca9c08c 100644 GIT binary patch delta 1273 zcmbtU-Aj{U6hBMIO;=iL)4f^Fk@JJ;=tCVT<_DG^So<&u3C25p)xq4>oMI7(-38su z1KkBm;C1lcbrIMf5NJ2jMGy$yMO{VEMZf21d-rMj7$`xIhgu;X%1{iD0y<_sf}*6!;}VpjIa=gzE|ud~F7cz9`SJ)Q;G5@zniq!t zw06kQ-`DmVy4&4i=(pSt41G-*Tvr|!O?^%IYGFmGcAKtwm;>i8JL-?SNq6b4ys0?G z|A>GxdZ>lks27^J-Azi8inSU39A!}jO-39+T>W>%L11Kop2k<8hJkw>V)jSTOciz4 zSQT?B!Mrc}0O@WZv@`6GDbTgov00m82hZ>KuNEGth5hsSh zEBNq|vx<{Sb+LoIrd&P$mqPLOkW*i&dtJrv`js&a2a1|60J6E%KR}C)#6d(z61E?4 zUPPuLNm-=?2nosj+T}`rlfb+oFh#A0Ksiizu|{cvM(7URrg7@02#sMU1Um|EaYtk% zan>xWb2aR0^Kf17XgUsyB?jw3f9}fHwy^^e>UPUB4gOIq~)Nzz03XW&;c6JlhSp^3Q>PfLTP$x#;8EE*=7oRAnS+p^I NQohGU{ks~g{0Rz)9F_n8 delta 331 zcmbRCobkpj#tjjSn|m1TICz~H5*dmaG8vK?6d2Sd7lw#$e!{87Gnq%sWU`2az~mq? zwaHatR+G1h1pu+k2!}S6ERlrchkk61Z*&e9I!uH5yzhsWd z=X5wG`+0C|&azVy#0-SV%ly?g-|(NsF*(LnY4d`J93D=1KyBtuUCy-GAtQ_%0O1s6 AZ~y=R diff --git a/lib/ui/include/ui/qt/util.hpp b/lib/ui/include/ui/qt/util.hpp index 20e5b76c3..a0524a9be 100644 --- a/lib/ui/include/ui/qt/util.hpp +++ b/lib/ui/include/ui/qt/util.hpp @@ -121,7 +121,21 @@ namespace VTX::UI::QT::Util return QBitmap( QPixmap::fromImage( QImage( p_filepath ).createAlphaMask() ) ); } QLabel * createLabelWithHelpTooltip( const char * p_label, const char * p_helpTooltip ) noexcept; - void addLabeledHLineSeparator( QBoxLayout * p_dest, const char * p_label ) noexcept; + class LabelWithHelper + { + public: + enum class E_QUESTIONMARK_POSITION + { + left, + right + }; + LabelWithHelper( const char * p_label, const char * p_helper, const E_QUESTIONMARK_POSITION & p_postion ); + QWidget * container = nullptr; + QLabel * label = nullptr; + + private: + }; + void addLabeledHLineSeparator( QBoxLayout * p_dest, const char * p_label ) noexcept; // The idea is to create a lineEdit field with a validator that enforce the UInt64 size input QLineEdit * addUInt64Field( QFormLayout * p_dest, const char * p_label, const char * p_tooltip ) noexcept; diff --git a/lib/ui/src/ui/qt/util.cpp b/lib/ui/src/ui/qt/util.cpp index ed0cd43cd..8e4ab53f9 100644 --- a/lib/ui/src/ui/qt/util.cpp +++ b/lib/ui/src/ui/qt/util.cpp @@ -1,6 +1,9 @@ #include "ui/qt/util.hpp" #include "ui/qt/validator.hpp" #include +#include +#include +#include namespace VTX::UI::QT::Util { @@ -35,6 +38,96 @@ namespace VTX::UI::QT::Util p_menu.addAction( action ); } } + class QHoverableQuestionMark : public QPushButton + { + int m_count = 0; + QWidget * popup = nullptr; + + public: + QHoverableQuestionMark( const char * p_popupText ) : QPushButton() + { + setIcon( QIcon( ":/sprite/citations_icon_hovered.png" ) ); + setAttribute( Qt::WA_Hover ); + + auto label = new QLabel( p_popupText ); + label->setTextFormat( Qt::RichText ); + + popup = new QWidget; + popup->setWindowFlag( Qt::ToolTip ); + auto layout = new QHBoxLayout( popup ); + layout->addWidget( label ); + } + void enterEvent( QEnterEvent * event ) { QWidget::enterEvent( event ); } + + void leaveEvent( QEvent * event ) { QWidget::leaveEvent( event ); } + void hoverEnter( QHoverEvent * p_event ) + { + auto p = p_event->globalPosition().toPoint(); + if ( p.isNull() || ( p.x() == -1 && p.y() == -1 ) ) + return; + popup->move( p_event->globalPosition().toPoint() ); + setText( QString::asprintf( "{%d, %d}", p.x(), p.y() ) ); + popup->show(); + } + + void hoverLeave( QHoverEvent * event ) + { + popup->hide(); + setText( "leaved" ); + } + + void hoverMove( QHoverEvent * p_event ) + { + auto p = p_event->globalPosition().toPoint(); + if ( p.isNull() || ( p.x() == -1 && p.y() == -1 ) ) + return; + popup->move( p_event->globalPosition().toPoint() ); + setText( QString::asprintf( "{%d, %d}", p.x(), p.y() ) ); + } + bool event( QEvent * e ) + { + switch ( e->type() ) + { + case QEvent::HoverEnter: + hoverEnter( reinterpret_cast( e ) ); + return true; + break; + case QEvent::HoverLeave: + hoverLeave( reinterpret_cast( e ) ); + return true; + break; + case QEvent::HoverMove: + hoverMove( reinterpret_cast( e ) ); + return true; + break; + default: break; + } + return QWidget::event( e ); + } + }; + LabelWithHelper::LabelWithHelper( + const char * p_label, + const char * p_helper, + const E_QUESTIONMARK_POSITION & p_postion + ) : + container( new QWidget ), + label( new QLabel( p_label ) ) + { + QHBoxLayout * layout = new QHBoxLayout( container ); + QHoverableQuestionMark * questionMark = new QHoverableQuestionMark( p_helper ); + layout->setContentsMargins( { 0, 0, 0, 0 } ); + + if ( p_postion == E_QUESTIONMARK_POSITION::left ) + { + layout->addWidget( questionMark ); + layout->addWidget( label ); + } + else + { + layout->addWidget( label ); + layout->addWidget( questionMark ); + } + } QLabel * createLabelWithHelpTooltip( const char * p_label, const char * p_helpTooltip ) noexcept {