Commit c3f2d693 authored by Jehan Monnier's avatar Jehan Monnier

Merge branch 'dev_linphone_qt' of git.linphone.org:linphone-desktop-private into dev_linphone_qt

parents a7bfae9c ba15723a
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>English</string> <string>English</string>
<key>CFBundleName</key>
<string>Linphone</string>
<key>CFBundleDisplayName</key>
<string>Linphone</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>linphone</string> <string>linphone</string>
<key>CFBundleGetInfoString</key> <key>CFBundleGetInfoString</key>
......
...@@ -76,6 +76,14 @@ ...@@ -76,6 +76,14 @@
<source>commandLineOptionCmdArg</source> <source>commandLineOptionCmdArg</source>
<translation>command line</translation> <translation>command line</translation>
</message> </message>
<message>
<source>commandLineOptionHelp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionVersion</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>AssistantAbstractView</name> <name>AssistantAbstractView</name>
......
...@@ -76,6 +76,14 @@ ...@@ -76,6 +76,14 @@
<source>commandLineOptionCmdArg</source> <source>commandLineOptionCmdArg</source>
<translation>ligne de commande</translation> <translation>ligne de commande</translation>
</message> </message>
<message>
<source>commandLineOptionHelp</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>commandLineOptionVersion</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>AssistantAbstractView</name> <name>AssistantAbstractView</name>
......
[Desktop Entry] [Desktop Entry]
Name=Linphone Name=Linphone
GenericName=Web-phone GenericName=SIP Phone
Comment=Linphone is a web-phone Comment=Linphone is a libre SIP client
Type=Application Type=Application
Exec=linphone %u Exec=linphone %u
Icon=linphone Icon=linphone
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include <QCommandLineParser>
#include <QDir> #include <QDir>
#include <QFileSelector> #include <QFileSelector>
#include <QMenu> #include <QMenu>
...@@ -74,44 +75,33 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) { ...@@ -74,44 +75,33 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) {
parseArgs(); parseArgs();
// Initialize logger. (Do not do this before this point because the
// application has to be created for the logs to be put in the correct
// directory.)
Logger::init();
if (mParser->isSet("verbose"))
Logger::getInstance()->setVerbose(true);
// List available locales. // List available locales.
for (const auto &locale : QDir(LANGUAGES_PATH).entryList()) for (const auto &locale : QDir(LANGUAGES_PATH).entryList())
mAvailableLocales << QLocale(locale); mAvailableLocales << QLocale(locale);
// Init locale.
mTranslator = new DefaultTranslator(this); mTranslator = new DefaultTranslator(this);
initLocale();
// Try to use preferred locale. parseArgs();
QString locale = ::Utils::coreStringToAppString(
linphone::Config::newWithFactory(
Paths::getConfigFilePath(mParser.value("config"), false), "")->getString(
SettingsModel::UI_SECTION, "locale", ""
)
);
if (!locale.isEmpty() && installLocale(*this, *mTranslator, QLocale(locale))) {
mLocale = locale;
qInfo() << QStringLiteral("Use preferred locale: %1").arg(locale);
return;
}
// Try to use system locale.
QLocale sysLocale = QLocale::system();
if (installLocale(*this, *mTranslator, sysLocale)) {
mLocale = sysLocale.name();
qInfo() << QStringLiteral("Use system locale: %1").arg(mLocale);
return;
}
// Use english. if (mParser->isSet("help"))
mLocale = DEFAULT_LOCALE; mParser->showHelp();
if (!installLocale(*this, *mTranslator, QLocale(mLocale))) if (mParser->isSet("version"))
qFatal("Unable to install default translator."); mParser->showVersion();
qInfo() << QStringLiteral("Use default locale: %1").arg(mLocale);
} }
App::~App () { App::~App () {
qInfo() << QStringLiteral("Destroying app..."); qInfo() << QStringLiteral("Destroying app...");
delete mEngine; delete mEngine;
delete mParser;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -167,7 +157,7 @@ void App::initContentApp () { ...@@ -167,7 +157,7 @@ void App::initContentApp () {
} }
// Init core. // Init core.
CoreManager::init(this, mParser.value("config")); CoreManager::init(this, mParser->value("config"));
// Init engine content. // Init engine content.
mEngine = new QQmlApplicationEngine(); mEngine = new QQmlApplicationEngine();
...@@ -193,7 +183,7 @@ void App::initContentApp () { ...@@ -193,7 +183,7 @@ void App::initContentApp () {
createNotifier(); createNotifier();
// Load splashscreen. // Load splashscreen.
bool selfTest = mParser.isSet("self-test"); bool selfTest = mParser->isSet("self-test");
if (!selfTest) if (!selfTest)
activeSplashScreen(this); activeSplashScreen(this);
// Set a self test limit. // Set a self test limit.
...@@ -218,7 +208,7 @@ void App::initContentApp () { ...@@ -218,7 +208,7 @@ void App::initContentApp () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString App::getCommandArgument () { QString App::getCommandArgument () {
return mParser.value("cmd"); return mParser->value("cmd");
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -282,10 +272,15 @@ bool App::hasFocus () const { ...@@ -282,10 +272,15 @@ bool App::hasFocus () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void App::parseArgs () { void App::parseArgs () {
mParser.setApplicationDescription(tr("applicationDescription")); if (mParser)
mParser.addHelpOption(); delete mParser;
mParser.addVersionOption();
mParser.addOptions({ mParser = new QCommandLineParser();
mParser->setApplicationDescription(tr("applicationDescription"));
mParser->addOptions({
{ { "h", "help" }, tr("commandLineOptionHelp") },
{ { "v", "version" }, tr("commandLineOptionVersion") },
{ "config", tr("commandLineOptionConfig"), tr("commandLineOptionConfigArg") }, { "config", tr("commandLineOptionConfig"), tr("commandLineOptionConfigArg") },
#ifndef Q_OS_MACOS #ifndef Q_OS_MACOS
{ "iconified", tr("commandLineOptionIconified") }, { "iconified", tr("commandLineOptionIconified") },
...@@ -295,15 +290,7 @@ void App::parseArgs () { ...@@ -295,15 +290,7 @@ void App::parseArgs () {
{ { "c", "cmd" }, tr("commandLineOptionCmd"), tr("commandLineOptionCmdArg") } { { "c", "cmd" }, tr("commandLineOptionCmd"), tr("commandLineOptionCmdArg") }
}); });
mParser.process(*this); mParser->process(*this);
// Initialize logger. (Do not do this before this point because the
// application has to be created for the logs to be put in the correct
// directory.)
Logger::init();
if (mParser.isSet("verbose")) {
Logger::getInstance()->setVerbose(true);
}
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -448,6 +435,36 @@ void App::createNotifier () { ...@@ -448,6 +435,36 @@ void App::createNotifier () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void App::initLocale () {
// Try to use preferred locale.
QString locale = ::Utils::coreStringToAppString(
linphone::Config::newWithFactory(
Paths::getConfigFilePath(mParser->value("config"), false), "")->getString(
SettingsModel::UI_SECTION, "locale", ""
)
);
if (!locale.isEmpty() && installLocale(*this, *mTranslator, QLocale(locale))) {
mLocale = locale;
qInfo() << QStringLiteral("Use preferred locale: %1").arg(locale);
return;
}
// Try to use system locale.
QLocale sysLocale = QLocale::system();
if (installLocale(*this, *mTranslator, sysLocale)) {
mLocale = sysLocale.name();
qInfo() << QStringLiteral("Use system locale: %1").arg(mLocale);
return;
}
// Use english.
mLocale = DEFAULT_LOCALE;
if (!installLocale(*this, *mTranslator, QLocale(mLocale)))
qFatal("Unable to install default translator.");
qInfo() << QStringLiteral("Use default locale: %1").arg(mLocale);
}
QString App::getConfigLocale () const { QString App::getConfigLocale () const {
return ::Utils::coreStringToAppString( return ::Utils::coreStringToAppString(
CoreManager::getInstance()->getCore()->getConfig()->getString( CoreManager::getInstance()->getCore()->getConfig()->getString(
...@@ -482,7 +499,7 @@ void App::openAppAfterInit () { ...@@ -482,7 +499,7 @@ void App::openAppAfterInit () {
else else
setTrayIcon(); setTrayIcon();
if (!mParser.isSet("iconified")) if (!mParser->isSet("iconified"))
smartShowWindow(mainWindow); smartShowWindow(mainWindow);
#else #else
smartShowWindow(mainWindow); smartShowWindow(mainWindow);
...@@ -508,7 +525,7 @@ void App::openAppAfterInit () { ...@@ -508,7 +525,7 @@ void App::openAppAfterInit () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void App::quit () { void App::quit () {
if (mParser.isSet("self-test")) if (mParser->isSet("self-test"))
cout << tr("selfTestResult").toStdString() << endl; cout << tr("selfTestResult").toStdString() << endl;
QApplication::quit(); QApplication::quit();
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#ifndef APP_H_ #ifndef APP_H_
#define APP_H_ #define APP_H_
#include <QCommandLineParser>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQuickWindow> #include <QQuickWindow>
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
class Cli; class Cli;
class DefaultTranslator; class DefaultTranslator;
class QCommandLineParser;
class App : public SingleApplication { class App : public SingleApplication {
Q_OBJECT; Q_OBJECT;
...@@ -96,6 +96,8 @@ private: ...@@ -96,6 +96,8 @@ private:
void setTrayIcon (); void setTrayIcon ();
void createNotifier (); void createNotifier ();
void initLocale ();
QString getConfigLocale () const; QString getConfigLocale () const;
void setConfigLocale (const QString &locale); void setConfigLocale (const QString &locale);
...@@ -111,7 +113,7 @@ private: ...@@ -111,7 +113,7 @@ private:
return qVersion(); return qVersion();
} }
QCommandLineParser mParser; QCommandLineParser *mParser = nullptr;
QVariantList mAvailableLocales; QVariantList mAvailableLocales;
QString mLocale; QString mLocale;
......
...@@ -69,8 +69,8 @@ Item { ...@@ -69,8 +69,8 @@ Item {
Keys.onEscapePressed: searchBox.closeMenu() Keys.onEscapePressed: searchBox.closeMenu()
Keys.onReturnPressed: { Keys.onReturnPressed: {
searchBox.closeMenu()
searchBox.enterPressed() searchBox.enterPressed()
searchBox.closeMenu()
} }
onActiveFocusChanged: { onActiveFocusChanged: {
......
...@@ -6,11 +6,11 @@ import Linphone.Styles 1.0 ...@@ -6,11 +6,11 @@ import Linphone.Styles 1.0
// ============================================================================= // =============================================================================
SearchBox { SearchBox {
id: searchBar id: searchBox
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
readonly property alias isOpen: searchBar._isOpen readonly property alias isOpen: searchBox._isOpen
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -29,7 +29,7 @@ SearchBox { ...@@ -29,7 +29,7 @@ SearchBox {
onEnterPressed: { onEnterPressed: {
var sipAddress = view.interpretableSipAddress var sipAddress = view.interpretableSipAddress
return sipAddress.length > 0 && searchBar.launchCall(sipAddress) return sipAddress.length > 0 && searchBox.launchCall(sipAddress)
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -40,37 +40,37 @@ SearchBox { ...@@ -40,37 +40,37 @@ SearchBox {
actions: [{ actions: [{
icon: 'video_call', icon: 'video_call',
handler: function (entry) { handler: function (entry) {
searchBar.closeMenu() searchBox.closeMenu()
searchBar.launchVideoCall(entry.sipAddress) searchBox.launchVideoCall(entry.sipAddress)
} }
}, { }, {
icon: 'call', icon: 'call',
handler: function (entry) { handler: function (entry) {
searchBar.closeMenu() searchBox.closeMenu()
searchBar.launchCall(entry.sipAddress) searchBox.launchCall(entry.sipAddress)
} }
}, { }, {
icon: 'chat', icon: 'chat',
handler: function (entry) { handler: function (entry) {
searchBar.closeMenu() searchBox.closeMenu()
searchBar.launchChat(entry.sipAddress) searchBox.launchChat(entry.sipAddress)
} }
}] }]
headerButtonDescription: qsTr('addContact') headerButtonDescription: qsTr('addContact')
headerButtonIcon: 'contact_add' headerButtonIcon: 'contact_add'
headerButtonAction: (function (sipAddress) { headerButtonAction: (function (sipAddress) {
searchBar.closeMenu() searchBox.closeMenu()
searchBar.addContact(sipAddress) searchBox.addContact(sipAddress)
}) })
genSipAddress: searchBar.filter genSipAddress: searchBox.filter
model: SipAddressesProxyModel {} model: SipAddressesProxyModel {}
onEntryClicked: { onEntryClicked: {
searchBar.closeMenu() searchBox.closeMenu()
searchBar.entryClicked(entry) searchBox.entryClicked(entry)
} }
} }
} }
linphone @ 4c291e2c
Subproject commit 3841f9c417019448118208291470232f7e20d60f Subproject commit 4c291e2c5a32711a1176459d74ed405cf225f706
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