Commit 5dd0161a authored by Ronan's avatar Ronan

feat(app): try to support menu bar between qt 5.9 and qt 5.10

parent b59e8c29
......@@ -395,6 +395,7 @@
<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/ActivateLinphoneSipAccountWithEmail.qml</file>
<file>ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file>
......@@ -419,6 +420,7 @@
<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>
......
......@@ -23,6 +23,7 @@
#include <QCommandLineParser>
#include <QDir>
#include <QFileSelector>
#include <QLibraryInfo>
#include <QMenu>
#include <QQmlFileSelector>
#include <QSystemTrayIcon>
......@@ -197,8 +198,15 @@ void App::initContentApp () {
// Init engine content.
mEngine = new QQmlApplicationEngine();
// Provide `+custom` folders for custom components.
(new QQmlFileSelector(mEngine, mEngine))->setExtraSelectors(QStringList("custom"));
// Provide `+custom` folders for custom components and `5.9` for old components.
// TODO: Remove 5.9 support in 6 months. (~ July 2018).
{
QStringList selectors("custom");
const QVersionNumber &version = QLibraryInfo::version();
if (version.majorVersion() == 5 && version.minorVersion() == 9)
selectors.push_back("5.9");
(new QQmlFileSelector(mEngine, mEngine))->setExtraSelectors(selectors);
}
qInfo() << QStringLiteral("Activated selectors:") << QQmlFileSelector::get(mEngine)->selector()->allSelectors();
// Set modules paths.
......
import QtQuick 2.7
// Experimental.
import Qt.labs.platform 1.0
import Linphone 1.0
// =============================================================================
Item {
function open () {
menu.open()
}
// ---------------------------------------------------------------------------
// Shortcuts.
// ---------------------------------------------------------------------------
Shortcut {
id: settingsShortcut
sequence: 'Ctrl+P'
onActivated: App.smartShowWindow(App.getSettingsWindow())
}
Shortcut {
id: quitShortcut
context: Qt.ApplicationShortcut
sequence: StandardKey.Quit
onActivated: Qt.quit()
}
Shortcut {
id: aboutShortcut
sequence: StandardKey.HelpContents
onActivated: {
window.detachVirtualWindow()
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/About.qml'))
}
}
// ---------------------------------------------------------------------------
// Menu.
// ---------------------------------------------------------------------------
MenuBar {
Menu {
id: menu
MenuItem {
role: MenuItem.PreferencesRole
shortcut: settingsShortcut.sequence
text: qsTr('settings')
onTriggered: settingsShortcut.onActivated()
}
MenuItem {
role: MenuItem.AboutRole
text: qsTr('about')
onTriggered: aboutShortcut.onActivated()
}
MenuItem {
role: MenuItem.QuitRole
shortcut: quitShortcut.sequence
text: qsTr('quit')
onTriggered: quitShortcut.onActivated()
}
}
}
}
import QtQuick 2.7
// Experimental.
import Qt.labs.platform 1.0
import Linphone 1.0
// =============================================================================
Item {
function open () {
menu.open()
}
// ---------------------------------------------------------------------------
// Shortcuts.
// ---------------------------------------------------------------------------
Shortcut {
id: settingsShortcut
sequence: 'Ctrl+P'
onActivated: App.smartShowWindow(App.getSettingsWindow())
}
Shortcut {
id: quitShortcut
context: Qt.ApplicationShortcut
sequence: StandardKey.Quit
onActivated: Qt.quit()
}
Shortcut {
id: aboutShortcut
sequence: StandardKey.HelpContents
onActivated: {
window.detachVirtualWindow()
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/About.qml'))
}
}
// ---------------------------------------------------------------------------
// Menu.
// ---------------------------------------------------------------------------
MenuBar {
Menu {
id: menu
MenuItem {
role: MenuItem.PreferencesRole
shortcut: settingsShortcut.sequence
text: qsTr('settings')
onTriggered: settingsShortcut.onActivated()
}
MenuItem {
role: MenuItem.AboutRole
text: qsTr('about')
onTriggered: aboutShortcut.onActivated()
}
MenuItem {
role: MenuItem.QuitRole
shortcut: quitShortcut.sequence
text: qsTr('quit')
onTriggered: quitShortcut.onActivated()
}
}
}
}
import QtQuick 2.7
// Experimental.
import Qt.labs.platform 1.0
import QtQuick.Controls 2.3
import Linphone 1.0
......@@ -48,32 +46,25 @@ Item {
// Menu.
// ---------------------------------------------------------------------------
MenuBar {
Menu {
id: menu
Menu {
id: menu
MenuItem {
role: MenuItem.PreferencesRole
shortcut: settingsShortcut.sequence
text: qsTr('settings')
MenuItem {
text: qsTr('settings')
onTriggered: settingsShortcut.onActivated()
}
onTriggered: settingsShortcut.onActivated()
}
MenuItem {
role: MenuItem.AboutRole
text: qsTr('about')
MenuItem {
text: qsTr('about')
onTriggered: aboutShortcut.onActivated()
}
onTriggered: aboutShortcut.onActivated()
}
MenuItem {
role: MenuItem.QuitRole
shortcut: quitShortcut.sequence
text: qsTr('quit')
MenuItem {
text: qsTr('quit')
onTriggered: quitShortcut.onActivated()
}
onTriggered: quitShortcut.onActivated()
}
}
}
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