ui: Window focus event sent when application changes state instead of main window
* Fixes tooltip disappearing when clicked on Windows
This commit is contained in:
@@ -4,12 +4,15 @@
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/messaging/type/MessageLoadProject.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
#include "utility/logging/LogManager.h"
|
||||
|
||||
#include "component/controller/LogController.h"
|
||||
|
||||
QtApplication::QtApplication(int& argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
{
|
||||
connect(this, &QGuiApplication::applicationStateChanged, this, &QtApplication::onApplicationStateChanged);
|
||||
}
|
||||
|
||||
int QtApplication::exec()
|
||||
@@ -41,3 +44,8 @@ bool QtApplication::event(QEvent *event)
|
||||
|
||||
return QApplication::event(event);
|
||||
}
|
||||
|
||||
void QtApplication::onApplicationStateChanged(Qt::ApplicationState state)
|
||||
{
|
||||
MessageWindowFocus(state == Qt::ApplicationActive).dispatch();
|
||||
}
|
||||
|
||||
@@ -6,11 +6,16 @@
|
||||
class QtApplication
|
||||
: public QApplication
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtApplication(int& argc, char** argv);
|
||||
|
||||
bool event(QEvent *event);
|
||||
int exec();
|
||||
|
||||
private slots:
|
||||
void onApplicationStateChanged(Qt::ApplicationState state);
|
||||
};
|
||||
|
||||
#endif // QT_APPLICATION_H
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "utility/messaging/type/MessageSearch.h"
|
||||
#include "utility/messaging/type/MessageUndo.h"
|
||||
#include "utility/messaging/type/MessageWindowClosed.h"
|
||||
#include "utility/messaging/type/MessageWindowFocus.h"
|
||||
#include "utility/messaging/type/MessageZoom.h"
|
||||
#include "utility/ResourcePaths.h"
|
||||
#include "utility/tracing.h"
|
||||
@@ -346,20 +345,6 @@ void QtMainWindow::setContentEnabled(bool enabled)
|
||||
}
|
||||
}
|
||||
|
||||
bool QtMainWindow::event(QEvent* event)
|
||||
{
|
||||
if (event->type() == QEvent::WindowActivate)
|
||||
{
|
||||
MessageWindowFocus(true).dispatch();
|
||||
}
|
||||
else if (event->type() == QEvent::WindowDeactivate)
|
||||
{
|
||||
MessageWindowFocus(false).dispatch();
|
||||
}
|
||||
|
||||
return QMainWindow::event(event);
|
||||
}
|
||||
|
||||
void QtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
{
|
||||
switch (event->key())
|
||||
|
||||
@@ -79,7 +79,6 @@ public:
|
||||
void setContentEnabled(bool enabled);
|
||||
|
||||
protected:
|
||||
bool event(QEvent* event);
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void contextMenuEvent(QContextMenuEvent* event);
|
||||
void closeEvent(QCloseEvent* event);
|
||||
|
||||
Reference in New Issue
Block a user