Fix Settings GUI and App Nap

This commit is contained in:
Julien Wadel 2020-02-04 17:56:59 +01:00
parent d6efd66d20
commit 691db8c081
12 changed files with 53 additions and 8 deletions

View file

@ -235,6 +235,7 @@ if (APPLE)
src/components/core/event-count-notifier/EventCountNotifierMacOs.m
src/components/other/desktop-tools/DesktopToolsMacOs.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverMacOs.m
src/components/other/desktop-tools/state-process/StateProcessMacOs.mm
)
list(APPEND HEADERS
src/app/single-application/SingleApplicationPrivate.hpp
@ -326,6 +327,15 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_CURRENT_SOURCE_DIR}/tools/private/pre-commit"
"${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit"
)
set(_QML_IMPORT_PATHS "")
list(APPEND _QML_IMPORT_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui/modules")
list(APPEND _QML_IMPORT_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui/dev-modules")
list(APPEND _QML_IMPORT_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui/scripts")
list(APPEND _QML_IMPORT_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/ui/views")
set(QML_IMPORT_PATH ${_QML_IMPORT_PATHS} CACHE STRING "Path used to locate CMake modules by Qt Creator" FORCE)
# ------------------------------------------------------------------------------
# Create config.h file
@ -432,7 +442,7 @@ if (UNIX AND NOT APPLE)
RENAME "${EXECUTABLE_NAME}.svg"
)
set(ICON_DIRS 16x16 22x22 24x24 32x32 64x64 128x128)
set(ICON_DIRS 16x16 22x22 24x24 32x32 64x64 128x128 256x256)
foreach (DIR ${ICON_DIRS})
install(FILES "${ASSETS_DIR}/icons/hicolor/${DIR}/apps/icon.png"
DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/${DIR}/apps/"

View file

@ -404,7 +404,6 @@
<file>ui/views/App/Calls/IncomingCall.qml</file>
<file>ui/views/App/Calls/OutgoingCall.qml</file>
<file>ui/views/App/Calls/ZrtpTokenAuthentication.qml</file>
<file>ui/views/App/Main/+5.9/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/Assistant/ActivateAppSipAccountWithEmail.qml</file>
<file>ui/views/App/Main/Assistant/ActivateAppSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file>
@ -430,7 +429,6 @@
<file>ui/views/App/Main/Dialogs/ManageAccounts.qml</file>
<file>ui/views/App/Main/Home.qml</file>
<file>ui/views/App/Main/InviteFriends.qml</file>
<file>ui/views/App/Main/+mac/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/MainWindow.js</file>
<file>ui/views/App/Main/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/MainWindow.qml</file>
@ -479,5 +477,6 @@
<file>ui/views/App/Styles/Settings/SettingsAudioStyle.qml</file>
<file>ui/views/App/Styles/Settings/SettingsWindowStyle.qml</file>
<file>assets/images/linphone_logo.svg</file>
<file>ui/views/App/Main/MainWindowTopMenuBar.qml</file>
</qresource>
</RCC>

View file

@ -47,6 +47,7 @@
#include "translator/DefaultTranslator.hpp"
#include "utils/LinphoneUtils.hpp"
#include "utils/Utils.hpp"
#include "components/other/desktop-tools/DesktopTools.hpp"
#include "App.hpp"
@ -173,6 +174,9 @@ static inline shared_ptr<linphone::Config> getConfigIfExists (const QCommandLine
// -----------------------------------------------------------------------------
App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) {
connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChanged(Qt::ApplicationState)));
setWindowIcon(QIcon(LinphoneUtils::WindowIconPath));
createParser();
@ -405,11 +409,12 @@ void App::smartShowWindow (QQuickWindow *window) {
}
// -----------------------------------------------------------------------------
bool App::hasFocus () const {
return getMainWindow()->isActive() || (mCallsWindow && mCallsWindow->isActive());
}
void App::stateChanged(Qt::ApplicationState pState) {
DesktopTools::applicationStateChanged(pState);
}
// -----------------------------------------------------------------------------
void App::createParser () {

View file

@ -103,6 +103,9 @@ public:
Q_INVOKABLE static void smartShowWindow (QQuickWindow *window);
public slots:
void stateChanged(Qt::ApplicationState);
signals:
void configLocaleChanged (const QString &locale);

View file

@ -40,6 +40,8 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void applicationStateChanged(Qt::ApplicationState){};
signals:
void screenSaverStatusChanged (bool status);

View file

@ -24,7 +24,6 @@
#define DESKTOP_TOOLS_MAC_OS_H_
#include <QObject>
// =============================================================================
class DesktopTools : public QObject {
@ -39,6 +38,8 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void applicationStateChanged(Qt::ApplicationState currentState);
signals:
void screenSaverStatusChanged (bool status);

View file

@ -39,6 +39,8 @@ public:
bool getScreenSaverStatus () const;
void setScreenSaverStatus (bool status);
static void applicationStateChanged(Qt::ApplicationState){};
signals:
void screenSaverStatusChanged (bool status);

View file

@ -0,0 +1,20 @@
#include "../DesktopToolsMacOs.hpp"
#import <Foundation/NSString.h>
#import <Foundation/NSProcessInfo.h>
// Store a unique global instance of Activity to avoid App Nap of MacOs
static id g_backgroundActivity =0;
void DesktopTools::applicationStateChanged(Qt::ApplicationState p_currentState)
{
if( p_currentState == Qt::ApplicationActive && g_backgroundActivity != 0 )
{// Entering Foreground
[[NSProcessInfo processInfo] endActivity:g_backgroundActivity];
[g_backgroundActivity release];
g_backgroundActivity = 0;
}else if( g_backgroundActivity == 0 )
{// Doesn't begin activity if it is already started
g_backgroundActivity = [[NSProcessInfo processInfo] beginActivityWithOptions:NSActivityUserInitiatedAllowingIdleSystemSleep reason:@"Linphone : Continue to receive requests while in Background"];
[g_backgroundActivity retain];
}
}

0
src/native/mac.mm Normal file
View file

View file

@ -1,6 +1,7 @@
import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.0
import Common 1.0
import Linphone 1.0
@ -192,14 +193,14 @@ ApplicationWindow {
visible: Qt.platform.os !== 'osx'
onClicked: menuBar.open()
MainWindowMenuBar {
id: menuBar
}
}
}
}
MainWindowTopMenuBar{}
// -----------------------------------------------------------------------
// Content.
// -----------------------------------------------------------------------

View file

@ -1,5 +1,6 @@
import QtQuick 2.7
import QtQuick.Controls 2.3
import Qt.labs.platform 1.0
import Linphone 1.0
@ -48,6 +49,7 @@ Item {
Menu {
id: menu
title: qsTr('Settings')
MenuItem {
text: qsTr('settings')