feat: clear input, round corners

This commit is contained in:
parker
2025-07-15 18:02:03 +01:00
parent e44f5fdc92
commit 7be504cc62
2 changed files with 12 additions and 1 deletions

View File

@@ -8,12 +8,13 @@
#include <qnamespace.h> #include <qnamespace.h>
#include <qwidget.h> #include <qwidget.h>
#include <QEvent> #include <QEvent>
#include <QPainterPath>
enzo::ui::TabMenu::TabMenu(QWidget *parent, Qt::WindowFlags f) enzo::ui::TabMenu::TabMenu(QWidget *parent, Qt::WindowFlags f)
: QWidget(parent, f) : QWidget(parent, f)
{ {
std::cout << "ctor\n"; std::cout << "ctor\n";
searchBar_ = new QLineEdit("hello world"); searchBar_ = new QLineEdit();
auto box = new QVBoxLayout(this); auto box = new QVBoxLayout(this);
box->addWidget(searchBar_); box->addWidget(searchBar_);
@@ -28,6 +29,7 @@ void enzo::ui::TabMenu::showOnMouse(float dx, float dy)
std::cout << "showing\n"; std::cout << "showing\n";
QPoint cursorPos = mapToParent(mapFromGlobal(QCursor::pos())); QPoint cursorPos = mapToParent(mapFromGlobal(QCursor::pos()));
std::cout << "tab menu pos: " << cursorPos.x() << " " << cursorPos.y() << "\n"; std::cout << "tab menu pos: " << cursorPos.x() << " " << cursorPos.y() << "\n";
searchBar_->clear();
move(cursorPos + QPoint(dx, dy)); move(cursorPos + QPoint(dx, dy));
show(); show();
setFocus(); setFocus();
@@ -74,3 +76,11 @@ bool enzo::ui::TabMenu::event(QEvent *event)
} }
void enzo::ui::TabMenu::resizeEvent(QResizeEvent *event)
{
QPainterPath path;
constexpr float radius = 10;
path.addRoundedRect(contentsRect(), radius, radius);
QRegion region = QRegion(path.toFillPolygon().toPolygon());
this->setMask(region);
}

View File

@@ -24,5 +24,6 @@ private:
protected: protected:
void focusOutEvent(QFocusEvent *event) override; void focusOutEvent(QFocusEvent *event) override;
bool event(QEvent *event) override; bool event(QEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
}; };
} }