2021-12-19 18:30:41 +00:00
|
|
|
#include "TextInput.hpp"
|
|
|
|
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
namespace Bloom::Widgets
|
|
|
|
|
{
|
|
|
|
|
TextInput::TextInput(QWidget* parent): QLineEdit(parent) {}
|
2021-12-19 18:30:41 +00:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
void TextInput::contextMenuEvent(QContextMenuEvent* event) {
|
|
|
|
|
if (QMenu* menu = this->createStandardContextMenu()) {
|
|
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
2021-12-19 18:30:41 +00:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
// Remove default icons
|
|
|
|
|
for (auto& action : menu->actions()) {
|
|
|
|
|
action->setIcon(QIcon());
|
|
|
|
|
}
|
2021-12-19 18:30:41 +00:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
menu->popup(event->globalPos());
|
2021-12-19 18:30:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-27 03:55:32 +00:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
void TextInput::focusInEvent(QFocusEvent* event) {
|
|
|
|
|
QLineEdit::focusInEvent(event);
|
|
|
|
|
emit this->focusChanged();
|
|
|
|
|
}
|
2021-12-27 03:55:32 +00:00
|
|
|
|
2022-02-05 15:32:08 +00:00
|
|
|
void TextInput::focusOutEvent(QFocusEvent* event) {
|
|
|
|
|
QLineEdit::focusOutEvent(event);
|
|
|
|
|
emit this->focusChanged();
|
|
|
|
|
}
|
2021-12-27 03:55:32 +00:00
|
|
|
}
|