From a44e96afe61ccc6819d6f04e5e1066379adcff54 Mon Sep 17 00:00:00 2001 From: Nodir Temirkhodjaev Date: Sun, 22 Dec 2019 10:28:19 +0500 Subject: [PATCH] UI: TextArea2Splitter: Draw handle. --- .../opt/controls/textarea2splitterhandle.cpp | 27 ++++++++++--------- .../opt/controls/textarea2splitterhandle.h | 3 +-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/ui/form/opt/controls/textarea2splitterhandle.cpp b/src/ui/form/opt/controls/textarea2splitterhandle.cpp index f39fa7b4..a0f936dd 100644 --- a/src/ui/form/opt/controls/textarea2splitterhandle.cpp +++ b/src/ui/form/opt/controls/textarea2splitterhandle.cpp @@ -1,8 +1,10 @@ #include "textarea2splitterhandle.h" #include +#include #include #include +#include #include "../../../fortmanager.h" #include "../../../util/stringutil.h" @@ -144,20 +146,21 @@ FortManager *TextArea2SplitterHandle::fortManager() const return ctrl()->fortManager(); } -void TextArea2SplitterHandle::paintEvent(QPaintEvent *e) +void TextArea2SplitterHandle::paintEvent(QPaintEvent *) { - Q_UNUSED(e) -} + const int handlePaintedWidth = 4; + auto rect = contentsRect(); + const int margin = (rect.width() - handlePaintedWidth) / 2; + rect.adjust(margin, 0, -margin, 0); -void TextArea2SplitterHandle::mouseMoveEvent(QMouseEvent *e) -{ - // Avoid dragging by buttons - if (e->button() == Qt::LeftButton) { - if (e->isAccepted()) - return; - } - - QSplitterHandle::mouseMoveEvent(e); + QPainter p(this); + QStyleOption opt(0); + opt.rect = rect; + opt.palette = palette(); + opt.state = (orientation() == Qt::Horizontal + ? QStyle::State_Horizontal : QStyle::State_None) + | (isEnabled() ? QStyle::State_Enabled : QStyle::State_None); + parentWidget()->style()->drawControl(QStyle::CE_Splitter, &opt, &p, splitter()); } void TextArea2SplitterHandle::setupUi(bool selectFileEnabled) diff --git a/src/ui/form/opt/controls/textarea2splitterhandle.h b/src/ui/form/opt/controls/textarea2splitterhandle.h index 03141472..d1517190 100644 --- a/src/ui/form/opt/controls/textarea2splitterhandle.h +++ b/src/ui/form/opt/controls/textarea2splitterhandle.h @@ -37,8 +37,7 @@ public: FortManager *fortManager() const; protected: - void paintEvent(QPaintEvent *e) override; - void mouseMoveEvent(QMouseEvent *e) override; + void paintEvent(QPaintEvent *) override; private: void setupUi(bool selectFileEnabled);