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