Commit 368a4eb1 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(app): test another solution to show correctly windows...

parent 33d648c8
...@@ -26,12 +26,6 @@ ...@@ -26,12 +26,6 @@
// ============================================================================= // =============================================================================
void Utils::smartShowWindow (QQuickWindow *window) {
window->show();
window->raise();
window->requestActivate();
}
char *Utils::rstrstr (const char *a, const char *b) { char *Utils::rstrstr (const char *a, const char *b) {
size_t a_len = strlen(a); size_t a_len = strlen(a);
size_t b_len = strlen(b); size_t b_len = strlen(b);
......
...@@ -163,7 +163,7 @@ void App::initContentApp () { ...@@ -163,7 +163,7 @@ void App::initContentApp () {
QObject::connect( QObject::connect(
this, &App::receivedMessage, this, [this](int, QByteArray message) { this, &App::receivedMessage, this, [this](int, QByteArray message) {
if (message == "show") if (message == "show")
Utils::smartShowWindow(getMainWindow()); App::smartShowWindow(getMainWindow());
} }
); );
} }
...@@ -251,6 +251,18 @@ QQuickWindow *App::getSettingsWindow () { ...@@ -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 { bool App::hasFocus () const {
return getMainWindow()->isActive() || (mCallsWindow && mCallsWindow->isActive()); return getMainWindow()->isActive() || (mCallsWindow && mCallsWindow->isActive());
} }
...@@ -333,7 +345,7 @@ void App::setTrayIcon () { ...@@ -333,7 +345,7 @@ void App::setTrayIcon () {
QAction *restoreAction = new QAction("Restore", root); QAction *restoreAction = new QAction("Restore", root);
root->connect(restoreAction, &QAction::triggered, root, [root] { root->connect(restoreAction, &QAction::triggered, root, [root] {
Utils::smartShowWindow(root); App::smartShowWindow(root);
}); });
// trayIcon: Left click actions. // trayIcon: Left click actions.
...@@ -344,7 +356,7 @@ void App::setTrayIcon () { ...@@ -344,7 +356,7 @@ void App::setTrayIcon () {
) { ) {
if (reason == QSystemTrayIcon::Trigger) { if (reason == QSystemTrayIcon::Trigger) {
if (root->visibility() == QWindow::Hidden) if (root->visibility() == QWindow::Hidden)
Utils::smartShowWindow(root); App::smartShowWindow(root);
else else
root->hide(); root->hide();
} }
...@@ -400,9 +412,9 @@ void App::openAppAfterInit () { ...@@ -400,9 +412,9 @@ void App::openAppAfterInit () {
setTrayIcon(); setTrayIcon();
if (!mParser.isSet("iconified")) if (!mParser.isSet("iconified"))
Utils::smartShowWindow(getMainWindow()); App::smartShowWindow(getMainWindow());
#else #else
Utils::smartShowWindow(getMainWindow()); App::smartShowWindow(getMainWindow());
#endif // ifndef __APPLE__ #endif // ifndef __APPLE__
} }
......
...@@ -69,6 +69,8 @@ public: ...@@ -69,6 +69,8 @@ public:
return static_cast<App *>(QApplication::instance()); return static_cast<App *>(QApplication::instance());
} }
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
public slots: public slots:
void quit (); void quit ();
......
...@@ -148,7 +148,7 @@ void CallModel::accept () { ...@@ -148,7 +148,7 @@ void CallModel::accept () {
params->enableVideo(false); params->enableVideo(false);
setRecordFile(params); setRecordFile(params);
Utils::smartShowWindow(App::getInstance()->getCallsWindow()); App::smartShowWindow(App::getInstance()->getCallsWindow());
mLinphoneCall->acceptWithParams(params); mLinphoneCall->acceptWithParams(params);
} }
...@@ -160,7 +160,7 @@ void CallModel::acceptWithVideo () { ...@@ -160,7 +160,7 @@ void CallModel::acceptWithVideo () {
params->enableVideo(true); params->enableVideo(true);
setRecordFile(params); setRecordFile(params);
Utils::smartShowWindow(App::getInstance()->getCallsWindow()); App::smartShowWindow(App::getInstance()->getCallsWindow());
mLinphoneCall->acceptWithParams(params); mLinphoneCall->acceptWithParams(params);
} }
......
...@@ -172,7 +172,7 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent) ...@@ -172,7 +172,7 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphoneCall) { void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphoneCall) {
if (linphoneCall->getDir() == linphone::CallDirOutgoing) if (linphoneCall->getDir() == linphone::CallDirOutgoing)
Utils::smartShowWindow(App::getInstance()->getCallsWindow()); App::smartShowWindow(App::getInstance()->getCallsWindow());
CallModel *call = new CallModel(linphoneCall); CallModel *call = new CallModel(linphoneCall);
......
...@@ -205,16 +205,6 @@ function setTimeout (parent, delay, cb) { ...@@ -205,16 +205,6 @@ function setTimeout (parent, delay, cb) {
return timer 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. // GENERIC.
// ============================================================================= // =============================================================================
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
// `MainWindow.qml` Logic. // `MainWindow.qml` Logic.
// ============================================================================= // =============================================================================
.import Linphone 1.0 as Linphone
.import QtQuick.Window 2.2 as Window .import QtQuick.Window 2.2 as Window
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils .import 'qrc:/ui/scripts/Utils/utils.js' as Utils
...@@ -35,7 +36,7 @@ function unlockView () { ...@@ -35,7 +36,7 @@ function unlockView () {
function setView (view, props) { function setView (view, props) {
function apply (view, props) { function apply (view, props) {
Utils.smartShowWindow(window) Linphone.App.smartShowWindow(window)
var item = mainLoader.item var item = mainLoader.item
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment