Skip to content

Commit

Permalink
reintroduced focus out on click outside
Browse files Browse the repository at this point in the history
  • Loading branch information
Odizinne committed Oct 17, 2024
1 parent 1cb364f commit e065835
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Panel/panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Panel::Panel(QWidget *parent)
ui->setupUi(this);
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint);
setFixedSize(size());
this->installEventFilter(this);

QRect screenGeometry = QGuiApplication::primaryScreen()->availableGeometry();
QPoint screenCenter = screenGeometry.bottomLeft();
Expand Down Expand Up @@ -52,7 +53,7 @@ Panel::Panel(QWidget *parent)

Panel::~Panel()
{
cleanup(); //clean audiomanager
cleanup();
delete ui;
}

Expand Down Expand Up @@ -211,3 +212,14 @@ void Panel::inputAudioMeter() {
int level = getRecordingAudioLevel();
ui->inputAudioMeter->setValue(level);
}

bool Panel::eventFilter(QObject *obj, QEvent *event)
{
if (event->type() == QEvent::MouseButtonPress) {
if (!this->underMouse()) {
emit lostFocus();
}
}

return QWidget::eventFilter(obj, event);
}
1 change: 1 addition & 0 deletions src/Panel/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Panel : public QWidget
void showEvent(QShowEvent *event) override;
void closeEvent(QCloseEvent *event) override;
void paintEvent(QPaintEvent *event) override;
bool eventFilter(QObject *obj, QEvent *event) override;

private:
Ui::Panel *ui;
Expand Down

0 comments on commit e065835

Please sign in to comment.