mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 01:04:06 +02:00
change display plugin to deactivate when window minimized
This commit is contained in:
parent
1b2887d5b1
commit
279997d905
4 changed files with 17 additions and 0 deletions
|
@ -1429,6 +1429,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
entityPacketSender->setMyAvatar(myAvatar.get());
|
||||
|
||||
connect(this, &Application::applicationStateChanged, this, &Application::activeChanged);
|
||||
connect(_window, SIGNAL(windowMinimizedChanged(bool)), this, SLOT(windowMinimizedChanged(bool)));
|
||||
qCDebug(interfaceapp, "Startup time: %4.2f seconds.", (double)startupTimer.elapsed() / 1000.0);
|
||||
|
||||
auto textureCache = DependencyManager::get<TextureCache>();
|
||||
|
@ -6476,6 +6477,15 @@ void Application::activeChanged(Qt::ApplicationState state) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::windowMinimizedChanged(bool minimized) {
|
||||
if (!minimized && !getActiveDisplayPlugin()->isActive()) {
|
||||
getActiveDisplayPlugin()->activate();
|
||||
} else if (minimized && getActiveDisplayPlugin()->isActive()) {
|
||||
getActiveDisplayPlugin()->deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Application::postLambdaEvent(std::function<void()> f) {
|
||||
if (this->thread() == QThread::currentThread()) {
|
||||
f();
|
||||
|
|
|
@ -416,6 +416,7 @@ private slots:
|
|||
void faceTrackerMuteToggled();
|
||||
|
||||
void activeChanged(Qt::ApplicationState state);
|
||||
void windowMinimizedChanged(bool minimized);
|
||||
|
||||
void notifyPacketVersionMismatch();
|
||||
|
||||
|
|
|
@ -105,12 +105,17 @@ void MainWindow::hideEvent(QHideEvent* event) {
|
|||
void MainWindow::changeEvent(QEvent* event) {
|
||||
if (event->type() == QEvent::WindowStateChange) {
|
||||
QWindowStateChangeEvent* stateChangeEvent = static_cast<QWindowStateChangeEvent*>(event);
|
||||
|
||||
if ((stateChangeEvent->oldState() == Qt::WindowNoState ||
|
||||
stateChangeEvent->oldState() == Qt::WindowMaximized) &&
|
||||
windowState() == Qt::WindowMinimized) {
|
||||
emit windowShown(false);
|
||||
emit windowMinimizedChanged(true);
|
||||
} else {
|
||||
emit windowShown(true);
|
||||
if (stateChangeEvent->oldState() == Qt::WindowMinimized) {
|
||||
emit windowMinimizedChanged(false);
|
||||
}
|
||||
}
|
||||
} else if (event->type() == QEvent::ActivationChange) {
|
||||
if (isActiveWindow()) {
|
||||
|
|
|
@ -29,6 +29,7 @@ public slots:
|
|||
signals:
|
||||
void windowGeometryChanged(QRect geometry);
|
||||
void windowShown(bool shown);
|
||||
void windowMinimizedChanged(bool minimized);
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent* event) override;
|
||||
|
|
Loading…
Reference in a new issue