mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-28 09:19:19 +00:00
feat(app): show correctly windows on mac/GNU Linux/windows
This commit is contained in:
parent
4d4bcf8558
commit
4dcb43092b
7 changed files with 37 additions and 14 deletions
|
|
@ -20,10 +20,18 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "Utils.hpp"
|
||||
#include <QQuickWindow>
|
||||
|
||||
#include "Utils.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
class QQuickWindow;
|
||||
|
||||
namespace Utils {
|
||||
inline QString linphoneStringToQString (const std::string &string) {
|
||||
return QString::fromLocal8Bit(string.c_str(), static_cast<int>(string.size()));
|
||||
|
|
@ -50,6 +52,11 @@ namespace Utils {
|
|||
return findParentType<T>(parent);
|
||||
}
|
||||
|
||||
// Bring a window to front.
|
||||
// See: http://stackoverflow.com/questions/6087887/bring-window-to-front-raise-show-activatewindow-don-t-work
|
||||
void smartShowWindow (QQuickWindow *window);
|
||||
|
||||
// Reverse function of strstr.
|
||||
char *rstrstr (const char *a, const char *b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ void App::initContentApp () {
|
|||
QObject::connect(
|
||||
this, &App::receivedMessage, this, [this](int, QByteArray message) {
|
||||
if (message == "show")
|
||||
getMainWindow()->showNormal();
|
||||
Utils::smartShowWindow(getMainWindow());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
@ -338,7 +338,9 @@ void App::setTrayIcon () {
|
|||
root->connect(quitAction, &QAction::triggered, this, &App::quit);
|
||||
|
||||
QAction *restoreAction = new QAction("Restore", root);
|
||||
root->connect(restoreAction, &QAction::triggered, root, &QQuickWindow::showNormal);
|
||||
root->connect(restoreAction, &QAction::triggered, root, [root] {
|
||||
Utils::smartShowWindow(root);
|
||||
});
|
||||
|
||||
// trayIcon: Left click actions.
|
||||
QMenu *menu = new QMenu();
|
||||
|
|
@ -348,7 +350,7 @@ void App::setTrayIcon () {
|
|||
) {
|
||||
if (reason == QSystemTrayIcon::Trigger) {
|
||||
if (root->visibility() == QWindow::Hidden)
|
||||
root->showNormal();
|
||||
Utils::smartShowWindow(root);
|
||||
else
|
||||
root->hide();
|
||||
}
|
||||
|
|
@ -404,9 +406,9 @@ void App::openAppAfterInit () {
|
|||
setTrayIcon();
|
||||
|
||||
if (!mParser.isSet("iconified"))
|
||||
getMainWindow()->showNormal();
|
||||
Utils::smartShowWindow(getMainWindow());
|
||||
#else
|
||||
getMainWindow()->showNormal();
|
||||
Utils::smartShowWindow(getMainWindow());
|
||||
#endif // ifndef __APPLE__
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void CallModel::accept () {
|
|||
params->enableVideo(false);
|
||||
setRecordFile(params);
|
||||
|
||||
App::getInstance()->getCallsWindow()->show();
|
||||
Utils::smartShowWindow(App::getInstance()->getCallsWindow());
|
||||
mLinphoneCall->acceptWithParams(params);
|
||||
}
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ void CallModel::acceptWithVideo () {
|
|||
params->enableVideo(true);
|
||||
setRecordFile(params);
|
||||
|
||||
App::getInstance()->getCallsWindow()->show();
|
||||
Utils::smartShowWindow(App::getInstance()->getCallsWindow());
|
||||
mLinphoneCall->acceptWithParams(params);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ bool CallsListModel::removeRows (int row, int count, const QModelIndex &parent)
|
|||
|
||||
void CallsListModel::addCall (const shared_ptr<linphone::Call> &linphoneCall) {
|
||||
if (linphoneCall->getDir() == linphone::CallDirOutgoing)
|
||||
App::getInstance()->getCallsWindow()->show();
|
||||
Utils::smartShowWindow(App::getInstance()->getCallsWindow());
|
||||
|
||||
CallModel *call = new CallModel(linphoneCall);
|
||||
|
||||
|
|
|
|||
|
|
@ -205,6 +205,16 @@ 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.
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -28,11 +28,7 @@ function unlockView () {
|
|||
|
||||
function setView (view, props) {
|
||||
function apply (view, props) {
|
||||
if (window.visibility === Window.Minimized) {
|
||||
window.visibility = Window.AutomaticVisibility
|
||||
} else {
|
||||
window.setVisible(true)
|
||||
}
|
||||
Utils.smartShowWindow(window)
|
||||
|
||||
var item = mainLoader.item
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue