From f20050aa1560576e10d4a376d2c7768c10e49626 Mon Sep 17 00:00:00 2001 From: lixueman Date: Wed, 21 Dec 2022 11:36:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9wayland=E4=B8=8B=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E7=AA=97=E7=AE=A1=E5=B1=9E=E6=80=A7=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=AD=97=E6=AF=8D=E6=8F=90=E7=A4=BA=E7=AA=97?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Button/letter_classify_button.cpp | 27 ++++--------------- .../Button/letter_classify_button.h | 2 +- src/UserInterface/Other/lettertooltip.cpp | 4 +-- src/UserInterface/Other/lettertooltip.h | 4 +-- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/src/UserInterface/Button/letter_classify_button.cpp b/src/UserInterface/Button/letter_classify_button.cpp index 6577384..47cd21f 100755 --- a/src/UserInterface/Button/letter_classify_button.cpp +++ b/src/UserInterface/Button/letter_classify_button.cpp @@ -28,16 +28,7 @@ LetterClassifyButton::LetterClassifyButton(QWidget *parent, { this->setFlat(true); m_letter = letter; -// if (m_fullscreen) { -// QFont font; -// font.setPixelSize(Style::LeftLetterFontSize); -// this->setFont(font); -// QPalette pe = this->palette(); -// pe.setColor(QPalette::ButtonText, Qt::white); -// this->setPalette(pe); -// } - -// this->setText(letter); + m_tooltip = new LetterToolTip(this); this->setFocusPolicy(Qt::NoFocus); this->setCheckable(true); this->setStyleSheet("padding: 0px;"); @@ -147,16 +138,10 @@ void LetterClassifyButton::enterEvent(QEvent *e) Q_UNUSED(e); if (m_fullscreen) { - // QFont font; - // font.setPixelSize(Style::LeftLetterFontSize*3); - // this->setFont(font); - // this->setFixedSize(Style::LeftLetterBtnHeight*2,Style::LeftLetterBtnHeight*2); - tooltip = new LetterToolTip(); QPoint oPoint = this->mapToGlobal(QPoint(this->rect().x() + 35, this->rect().y() - 10)); - tooltip->setText(m_letter); - tooltip->raise(); - tooltip->move(oPoint); - tooltip->show(); + m_tooltip->setText(m_letter); + m_tooltip->move(oPoint); + m_tooltip->show(); } } @@ -169,9 +154,7 @@ void LetterClassifyButton::leaveEvent(QEvent *e) font.setPixelSize(Style::m_leftLetterFontSize); this->setFont(font); this->setFixedSize(Style::m_leftLetterBtnHeight, Style::m_leftLetterBtnHeight); - tooltip->close(); - delete tooltip; - tooltip = nullptr; + m_tooltip->hide(); } } diff --git a/src/UserInterface/Button/letter_classify_button.h b/src/UserInterface/Button/letter_classify_button.h index fded3eb..277fab8 100755 --- a/src/UserInterface/Button/letter_classify_button.h +++ b/src/UserInterface/Button/letter_classify_button.h @@ -37,7 +37,7 @@ public: QString m_letter = QString(); private: bool m_fullscreen = false; - LetterToolTip *tooltip = nullptr; + LetterToolTip *m_tooltip = nullptr; protected: void enterEvent(QEvent *e); diff --git a/src/UserInterface/Other/lettertooltip.cpp b/src/UserInterface/Other/lettertooltip.cpp index 030e544..00a28db 100755 --- a/src/UserInterface/Other/lettertooltip.cpp +++ b/src/UserInterface/Other/lettertooltip.cpp @@ -21,9 +21,9 @@ #include LetterToolTip::LetterToolTip(QWidget *parent): - QDialog(parent) + QWidget(parent) { - this->setWindowFlags(/*Qt::FramelessWindowHint *//*| */Qt::X11BypassWindowManagerHint); + this->setWindowFlag(Qt::ToolTip); this->setAttribute(Qt::WA_TranslucentBackground, true); this->setContentsMargins(0, 0, 0, 0); this->setAutoFillBackground(false); diff --git a/src/UserInterface/Other/lettertooltip.h b/src/UserInterface/Other/lettertooltip.h index 81c0411..854e69f 100755 --- a/src/UserInterface/Other/lettertooltip.h +++ b/src/UserInterface/Other/lettertooltip.h @@ -17,10 +17,10 @@ #ifndef LETTERTOOLTIP_H #define LETTERTOOLTIP_H -#include #include +#include -class LetterToolTip : public QDialog +class LetterToolTip : public QWidget { Q_OBJECT public: