fix #LINQT-1641 main window steals focus on macos
This commit is contained in:
parent
37a0403c01
commit
a4809bbde5
5 changed files with 280 additions and 255 deletions
|
|
@ -866,6 +866,15 @@ void App::setMainWindow(QQuickWindow *data) {
|
|||
}
|
||||
}
|
||||
|
||||
QQuickWindow *App::getLastActiveWindow() const {
|
||||
return mLastActiveWindow;
|
||||
}
|
||||
void App::setLastActiveWindow(QQuickWindow *data) {
|
||||
if (mLastActiveWindow != data) {
|
||||
mLastActiveWindow = data;
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<AccountList> App::getAccountList() const {
|
||||
return mAccountList;
|
||||
}
|
||||
|
|
@ -1059,7 +1068,7 @@ bool App::event(QEvent *event) {
|
|||
receivedMessage(0, url.toLocal8Bit());
|
||||
} else if (event->type() == QEvent::ApplicationStateChange) {
|
||||
auto state = static_cast<QApplicationStateChangeEvent *>(event);
|
||||
if (state->applicationState() == Qt::ApplicationActive) Utils::smartShowWindow(getMainWindow());
|
||||
if (state->applicationState() == Qt::ApplicationActive) Utils::smartShowWindow(getLastActiveWindow());
|
||||
}
|
||||
|
||||
return SingleApplication::event(event);
|
||||
|
|
|
|||
|
|
@ -131,6 +131,9 @@ public:
|
|||
|
||||
QQuickWindow *getMainWindow() const;
|
||||
void setMainWindow(QQuickWindow *data);
|
||||
QQuickWindow *getLastActiveWindow() const;
|
||||
void setLastActiveWindow(QQuickWindow *data);
|
||||
|
||||
QSharedPointer<AccountList> getAccountList() const;
|
||||
void setAccountList(QSharedPointer<AccountList> data);
|
||||
Q_INVOKABLE AccountList *getAccounts() const;
|
||||
|
|
@ -182,6 +185,7 @@ private:
|
|||
QSystemTrayIcon *mSystemTrayIcon = nullptr;
|
||||
QQuickWindow *mMainWindow = nullptr;
|
||||
QQuickWindow *mCallsWindow = nullptr;
|
||||
QQuickWindow *mLastActiveWindow = nullptr;
|
||||
QSharedPointer<SettingsCore> mSettings;
|
||||
QSharedPointer<AccountList> mAccountList;
|
||||
QSharedPointer<CallList> mCallList;
|
||||
|
|
|
|||
|
|
@ -212,6 +212,13 @@ QQuickWindow *Utils::getMainWindow() {
|
|||
return win;
|
||||
}
|
||||
|
||||
QQuickWindow *Utils::getLastActiveWindow() {
|
||||
return App::getInstance()->getLastActiveWindow();
|
||||
}
|
||||
void Utils::setLastActiveWindow(QQuickWindow *data) {
|
||||
App::getInstance()->setLastActiveWindow(data);
|
||||
}
|
||||
|
||||
void Utils::showInformationPopup(const QString &title,
|
||||
const QString &description,
|
||||
bool isSuccess,
|
||||
|
|
@ -239,6 +246,7 @@ void Utils::smartShowWindow(QQuickWindow *window) {
|
|||
if (window->visibility() == QWindow::Maximized) // Avoid to change visibility mode
|
||||
window->showNormal();
|
||||
else window->show();
|
||||
App::getInstance()->setLastActiveWindow(window);
|
||||
window->raise(); // Raise ensure to get focus on Mac
|
||||
window->requestActivate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public:
|
|||
Q_INVOKABLE static void setupConference(ConferenceInfoGui *confGui);
|
||||
Q_INVOKABLE static QQuickWindow *getMainWindow();
|
||||
Q_INVOKABLE static void openCallsWindow(CallGui *call);
|
||||
Q_INVOKABLE static QQuickWindow *getLastActiveWindow();
|
||||
Q_INVOKABLE static void setLastActiveWindow(QQuickWindow *data);
|
||||
Q_INVOKABLE static void showInformationPopup(const QString &title,
|
||||
const QString &description,
|
||||
bool isSuccess = true,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ ApplicationWindow {
|
|||
width: Math.min(1512 * DefaultStyle.dp, Screen.desktopAvailableWidth)
|
||||
height: Math.min(982 * DefaultStyle.dp, Screen.desktopAvailableHeight)
|
||||
|
||||
onActiveChanged: UtilsCpp.setLastActiveWindow(this)
|
||||
|
||||
property bool isFullscreen: visibility == Window.FullScreen
|
||||
onIsFullscreenChanged: DesktopToolsCpp.screenSaverStatus = !isFullscreen
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue