diff --git a/linphone-desktop/src/Utils.cpp b/linphone-desktop/src/Utils.cpp index 511e1826f..6d807ff1c 100644 --- a/linphone-desktop/src/Utils.cpp +++ b/linphone-desktop/src/Utils.cpp @@ -26,12 +26,6 @@ // ============================================================================= -void Utils::smartShowWindow (QQuickWindow *window) { - window->show(); - window->raise(); - window->requestActivate(); -} - char *Utils::rstrstr (const char *a, const char *b) { size_t a_len = strlen(a); size_t b_len = strlen(b); diff --git a/linphone-desktop/src/app/App.cpp b/linphone-desktop/src/app/App.cpp index e64225618..168c933f2 100644 --- a/linphone-desktop/src/app/App.cpp +++ b/linphone-desktop/src/app/App.cpp @@ -163,7 +163,7 @@ void App::initContentApp () { QObject::connect( this, &App::receivedMessage, this, [this](int, QByteArray message) { if (message == "show") - Utils::smartShowWindow(getMainWindow()); + App::smartShowWindow(getMainWindow()); } ); } @@ -251,6 +251,18 @@ QQuickWindow *App::getSettingsWindow () { // ----------------------------------------------------------------------------- +void App::smartShowWindow (QQuickWindow *window) { + window->setVisible(true); + + if (window->visibility() == QWindow::Minimized) + window->show(); + + window->raise(); + window->requestActivate(); +} + +// ----------------------------------------------------------------------------- + bool App::hasFocus () const { return getMainWindow()->isActive() || (mCallsWindow && mCallsWindow->isActive()); } @@ -333,7 +345,7 @@ void App::setTrayIcon () { QAction *restoreAction = new QAction("Restore", root); root->connect(restoreAction, &QAction::triggered, root, [root] { - Utils::smartShowWindow(root); + App::smartShowWindow(root); }); // trayIcon: Left click actions. @@ -344,7 +356,7 @@ void App::setTrayIcon () { ) { if (reason == QSystemTrayIcon::Trigger) { if (root->visibility() == QWindow::Hidden) - Utils::smartShowWindow(root); + App::smartShowWindow(root); else root->hide(); } @@ -400,9 +412,9 @@ void App::openAppAfterInit () { setTrayIcon(); if (!mParser.isSet("iconified")) - Utils::smartShowWindow(getMainWindow()); + App::smartShowWindow(getMainWindow()); #else - Utils::smartShowWindow(getMainWindow()); + App::smartShowWindow(getMainWindow()); #endif // ifndef __APPLE__ } diff --git a/linphone-desktop/src/app/App.hpp b/linphone-desktop/src/app/App.hpp index 2c4fca871..153a058c7 100644 --- a/linphone-desktop/src/app/App.hpp +++ b/linphone-desktop/src/app/App.hpp @@ -69,6 +69,8 @@ public: return static_cast(QApplication::instance()); } + Q_INVOKABLE static void smartShowWindow (QQuickWindow *window); + public slots: void quit (); diff --git a/linphone-desktop/src/components/call/CallModel.cpp b/linphone-desktop/src/components/call/CallModel.cpp index 2fec38a7c..ce10d68d0 100644 --- a/linphone-desktop/src/components/call/CallModel.cpp +++ b/linphone-desktop/src/components/call/CallModel.cpp @@ -148,7 +148,7 @@ void CallModel::accept () { params->enableVideo(false); setRecordFile(params); - Utils::smartShowWindow(App::getInstance()->getCallsWindow()); + App::smartShowWindow(App::getInstance()->getCallsWindow()); mLinphoneCall->acceptWithParams(params); } @@ -160,7 +160,7 @@ void CallModel::acceptWithVideo () { params->enableVideo(true); setRecordFile(params); - Utils::smartShowWindow(App::getInstance()->getCallsWindow()); + App::smartShowWindow(App::getInstance()->getCallsWindow()); mLinphoneCall->acceptWithParams(params); } diff --git a/linphone-desktop/src/components/calls/CallsListModel.cpp b/linphone-desktop/src/components/calls/CallsListModel.cpp index 62534372f..38727b344 100644 --- a/linphone-desktop/src/components/calls/CallsListModel.cpp +++ b/linphone-desktop/src/components/calls/CallsListModel.cpp @@ -172,7 +172,7 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) void CallsListModel::addCall (const shared_ptr &linphoneCall) { if (linphoneCall->getDir() == linphone::CallDirOutgoing) - Utils::smartShowWindow(App::getInstance()->getCallsWindow()); + App::smartShowWindow(App::getInstance()->getCallsWindow()); CallModel *call = new CallModel(linphoneCall); diff --git a/linphone-desktop/ui/scripts/Utils/utils.js b/linphone-desktop/ui/scripts/Utils/utils.js index 5e5fbebbf..af8f1249c 100644 --- a/linphone-desktop/ui/scripts/Utils/utils.js +++ b/linphone-desktop/ui/scripts/Utils/utils.js @@ -205,16 +205,6 @@ function setTimeout (parent, delay, cb) { return timer } -// ----------------------------------------------------------------------------- - -// Bring a window to front. -// See: http://stackoverflow.com/questions/6087887/bring-window-to-front-raise-show-activatewindow-don-t-work -function smartShowWindow (window) { - window.show() - window.raise() - window.requestActivate() -} - // ============================================================================= // GENERIC. // ============================================================================= diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.js b/linphone-desktop/ui/views/App/Main/MainWindow.js index 5325abca2..71f955aef 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.js +++ b/linphone-desktop/ui/views/App/Main/MainWindow.js @@ -2,6 +2,7 @@ // `MainWindow.qml` Logic. // ============================================================================= +.import Linphone 1.0 as Linphone .import QtQuick.Window 2.2 as Window .import 'qrc:/ui/scripts/Utils/utils.js' as Utils @@ -35,7 +36,7 @@ function unlockView () { function setView (view, props) { function apply (view, props) { - Utils.smartShowWindow(window) + Linphone.App.smartShowWindow(window) var item = mainLoader.item