feat: clear input, round corners
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user