| 1 |
/* |
| 2 |
* Copyright 2012-2015 Canonical Ltd. |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU Lesser General Public License as published by |
| 6 |
* the Free Software Foundation; version 3. |
| 7 |
* |
| 8 |
* This program is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
* GNU Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public License |
| 14 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
import QtQuick 2.4 |
| 18 |
import Lomiri.Components 1.2 as Toolkit |
| 19 |
import Lomiri.PerformanceMetrics 1.0 |
| 20 |
import QtQuick.Window 2.0 |
| 21 |
|
| 22 |
/*! \internal */ |
| 23 |
// Documentation is in MainView.qdoc |
| 24 |
PageTreeNode { |
| 25 |
id: mainView |
| 26 |
property string applicationName: "" |
| 27 |
property bool anchorToKeyboard: false |
| 28 |
property alias headerColor: background.headerColor |
| 29 |
property alias backgroundColor: background.backgroundColor |
| 30 |
property alias footerColor: background.footerColor |
| 31 |
|
| 32 |
// FIXME: Make sure that the theming is only in the background, and the style |
| 33 |
// should not occlude contents of the MainView. When making changes here, make |
| 34 |
// sure that bug https://bugs.launchpad.net/manhattan/+bug/1124076 does not come back. |
| 35 |
Toolkit.StyledItem { |
| 36 |
id: background |
| 37 |
anchors.fill: parent |
| 38 |
style: Theme.createStyleComponent("MainViewStyle.qml", background) |
| 39 |
|
| 40 |
property color headerColor: backgroundColor |
| 41 |
property color backgroundColor: Theme.palette.normal.background |
| 42 |
property color footerColor: backgroundColor |
| 43 |
|
| 44 |
/* |
| 45 |
As we don't know the order the property bindings and onXXXChanged signals are evaluated |
| 46 |
we should rely only on one property when changing the theme to avoid intermediate |
| 47 |
theme changes due to properties being evaluated separately. |
| 48 |
|
| 49 |
Qt bug: https://bugreports.qt-project.org/browse/QTBUG-11712 |
| 50 |
*/ |
| 51 |
property string themeName: (Toolkit.ColorUtils.luminance(backgroundColor) >= 0.85) ? |
| 52 |
"Ambiance" : "SuruDark" |
| 53 |
onThemeNameChanged: { |
| 54 |
// only change the theme if the current one is a system one. |
| 55 |
if (themeName !== "" && (Theme.name.search("Lomiri.Components.Themes") >= 0)) { |
| 56 |
Theme.name = "Lomiri.Components.Themes.%1".arg(themeName); |
| 57 |
} |
| 58 |
} |
| 59 |
} |
| 60 |
|
| 61 |
active: true |
| 62 |
property alias actions: lomiriActionManager.actions |
| 63 |
property alias actionManager: lomiriActionManager |
| 64 |
Toolkit.ActionManager { |
| 65 |
id: lomiriActionManager |
| 66 |
onQuit: { |
| 67 |
// FIXME Wire this up to the application lifecycle management API instead of quit(). |
| 68 |
Qt.quit() |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
onApplicationNameChanged: { |
| 73 |
if (applicationName !== "") { |
| 74 |
i18n.domain = applicationName; |
| 75 |
LomiriApplication.applicationName = applicationName |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
PerformanceOverlay { |
| 80 |
id: performanceOverlay |
| 81 |
active: false |
| 82 |
} |
| 83 |
} |