Commit 5dd0161a authored by Ronan Abhamon's avatar Ronan Abhamon

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

parent b59e8c29
...@@ -395,6 +395,7 @@ ...@@ -395,6 +395,7 @@
<file>ui/views/App/Calls/IncomingCall.qml</file> <file>ui/views/App/Calls/IncomingCall.qml</file>
<file>ui/views/App/Calls/OutgoingCall.qml</file> <file>ui/views/App/Calls/OutgoingCall.qml</file>
<file>ui/views/App/Calls/ZrtpTokenAuthentication.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/ActivateLinphoneSipAccountWithEmail.qml</file>
<file>ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml</file> <file>ui/views/App/Main/Assistant/ActivateLinphoneSipAccountWithPhoneNumber.qml</file>
<file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file> <file>ui/views/App/Main/Assistant/AssistantAbstractView.qml</file>
...@@ -419,6 +420,7 @@ ...@@ -419,6 +420,7 @@
<file>ui/views/App/Main/Dialogs/ManageAccounts.qml</file> <file>ui/views/App/Main/Dialogs/ManageAccounts.qml</file>
<file>ui/views/App/Main/Home.qml</file> <file>ui/views/App/Main/Home.qml</file>
<file>ui/views/App/Main/InviteFriends.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/MainWindow.js</file>
<file>ui/views/App/Main/MainWindowMenuBar.qml</file> <file>ui/views/App/Main/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/MainWindow.qml</file> <file>ui/views/App/Main/MainWindow.qml</file>
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QDir> #include <QDir>
#include <QFileSelector> #include <QFileSelector>
#include <QLibraryInfo>
#include <QMenu> #include <QMenu>
#include <QQmlFileSelector> #include <QQmlFileSelector>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
...@@ -197,8 +198,15 @@ void App::initContentApp () { ...@@ -197,8 +198,15 @@ void App::initContentApp () {
// Init engine content. // Init engine content.
mEngine = new QQmlApplicationEngine(); mEngine = new QQmlApplicationEngine();
// Provide `+custom` folders for custom components. // Provide `+custom` folders for custom components and `5.9` for old components.
(new QQmlFileSelector(mEngine, mEngine))->setExtraSelectors(QStringList("custom")); // 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(); qInfo() << QStringLiteral("Activated selectors:") << QQmlFileSelector::get(mEngine)->selector()->allSelectors();
// Set modules paths. // 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 import QtQuick 2.7
import QtQuick.Controls 2.3
// Experimental.
import Qt.labs.platform 1.0
import Linphone 1.0 import Linphone 1.0
...@@ -48,32 +46,25 @@ Item { ...@@ -48,32 +46,25 @@ Item {
// Menu. // Menu.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
MenuBar { Menu {
Menu { id: menu
id: menu
MenuItem { MenuItem {
role: MenuItem.PreferencesRole text: qsTr('settings')
shortcut: settingsShortcut.sequence
text: qsTr('settings')
onTriggered: settingsShortcut.onActivated() onTriggered: settingsShortcut.onActivated()
} }
MenuItem { MenuItem {
role: MenuItem.AboutRole text: qsTr('about')
text: qsTr('about')
onTriggered: aboutShortcut.onActivated() onTriggered: aboutShortcut.onActivated()
} }
MenuItem { MenuItem {
role: MenuItem.QuitRole text: qsTr('quit')
shortcut: quitShortcut.sequence
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