summaryrefslogtreecommitdiff
path: root/src/mobile/qml/WindowManager.qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/mobile/qml/WindowManager.qml')
-rw-r--r--src/mobile/qml/WindowManager.qml227
1 files changed, 177 insertions, 50 deletions
diff --git a/src/mobile/qml/WindowManager.qml b/src/mobile/qml/WindowManager.qml
index 3a66219..f23a6c4 100644
--- a/src/mobile/qml/WindowManager.qml
+++ b/src/mobile/qml/WindowManager.qml
@@ -1,42 +1,129 @@
-import QtQuick 2.1
+/*********
+*
+* In the name of the Father, and of the Son, and of the Holy Spirit.
+*
+* This file is part of BibleTime's source code, http://www.bibletime.info/.
+*
+* Copyright 1999-2016 by the BibleTime developers.
+* The BibleTime source code is licensed under the GNU General Public License
+* version 2.0.
+*
+**********/
+
+import QtQuick 2.2
import BibleTime 1.0
Rectangle {
- id: windowArea
+ id: windowManager
+
+ objectName: "WindowManager"
property var windows: []
- property int single: 0
- property int tabLayout: 1
- property int autoTile: 2
- property int autoTileHor: 3
- property int autoTileVer: 4
- property int windowLayout: single
+
+ property int autoTileVer: 1
+ property int autoTileHor: 2
+ property int single: 3 // Tile in Desktop
+ // 4 is Manual in Desktop
+ property int autoTile: 5
+ property int tabLayout: 6
+
+ property int windowArrangement: single
+
+ signal setFontForLanguage(string language)
+
+ function getTopWindowIndex() {
+ if (windowArrangement == single || windowArrangement == tabLayout)
+ return tabbedWindows.current;
+ return 0;
+ }
+
+ function getLanguageForWindow(index) {
+ if (index < 0 || index >= windows.length)
+ return "";
+ return windows[index].getModuleLanguage();
+ }
+
+ function updateTextFont() {
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ var name = window.updateTextFonts();
+ }
+ }
+
+ function getWindowCount() {
+ return windows.length;
+ }
+
+ function saveWindowStateToConfig(windowIndex) {
+ var window = windows[windowIndex];
+ window.saveWindowStateToConfig(windowIndex);
+ }
+
+ function getModuleNames() {
+ var names = [];
+ for (var i=0; i<windows.length; ++i) {
+ var window = windows[i];
+ var name = window.getModule();
+ names.push(name);
+ }
+ return names;
+ }
+
+ function getUniqueModuleNames() {
+ var moduleNames = getModuleNames();
+ var uniqueNames = [];
+ for (var i=0; i<moduleNames.length; ++i) {
+ var name = moduleNames[i];
+ var index = uniqueNames.indexOf(name);
+ if (index < 0) {
+ uniqueNames.push(name);
+ }
+ }
+ return uniqueNames;
+ }
function setCurrentTabbedWindow(index) {
tabbedWindows.current = index;
}
+ function setNextWindow() {
+ var index = tabbedWindows.current + 1;
+ if (index >= windows.length)
+ index = 0;
+ setCurrentTabbedWindow(index);
+ }
+
+ function setPreviousWindow() {
+ var index = tabbedWindows.current - 1;
+ if (index < 0)
+ index = windows.length - 1;
+ setCurrentTabbedWindow(index);
+ }
+
+ function closeWindow(index) {
+ var window = windows[index];
+ windows.splice(index,1);
+ window.destroy();
+ layoutWindows();
+ }
+
function setWindowArrangement(arrangement) {
- if (arrangement < single || arrangement > autoTileVer)
+ if (arrangement < autoTileVer || arrangement > tabLayout)
return;
- windowLayout = arrangement;
- layoutWindows();
+ windowArrangement = arrangement;
}
- function createWindowMenus() {
- windowsModel.clear();
+ function createWindowMenus(model) {
+ model.clear();
for (var i=0; i<windows.length; ++i) {
var window = windows[i];
- windowsModel.append (
+ model.append (
{ title: window.title, action: i.toString() }
)
}
- windowTitlesMenus.model = windowsModel
- windowTitlesMenus.visible = true;
}
-
function newWindow() {
moduleChooser.moduleSelected.connect(openWindowSlot);
moduleChooser.visible = true;
@@ -44,15 +131,16 @@ Rectangle {
function openWindowSlot() {
moduleChooser.moduleSelected.disconnect(openWindowSlot);
- openWindow(moduleChooser.selectedCategory, moduleChooser.selectedModule)
+ openWindow(moduleChooser.selectedCategory, moduleChooser.selectedModule, "")
}
- function openWindow(category, module) {
- if (category == "Bibles")
- component = Qt.createComponent("Window.qml");
- else if (category == "Commentaries")
- component = Qt.createComponent("Window.qml");
- else if (category == "Books")
+ function openWindow(category, module, key) {
+ if (category == "Bibles"||
+ category == "Cults/Unorthodox" ||
+ category == "Commentaries" ||
+ category == "Books" ||
+ category == "Lexicons and Dictionaries" ||
+ category == "Daily Devotionals")
component = Qt.createComponent("Window.qml");
else {
console.log(category, " are not yet supported.");
@@ -60,20 +148,30 @@ Rectangle {
}
window = component.createObject(null, {"width": 250, "height": 200});
- window.setModule(module);
if (window == null) {
// Error Handling
console.log("Error creating object");
}
else {
+ window.setModule(module);
+ window.setModuleToBeginning();
+ window.swipeLeft.connect(windowManager,setPreviousWindow)
+ window.swipeRight.connect(windowManager,setNextWindow)
windows.push(window)
layoutWindows();
var curWindow = windows.length -1;
selectWindow(curWindow);
+ if (key !== "")
+ window.setKey(key);
+ window.setHistoryPoint();
}
}
+ function setFont(lang) {
+ windowManager.setFontForLanguage(lang)
+ }
+
function layoutTiles(rows, columns)
{
gridWindows.columns = columns;
@@ -87,6 +185,7 @@ Rectangle {
window.height = height;
window.width = width;
window.parent = gridWindows;
+ window.border.width = 1;
}
}
@@ -96,7 +195,8 @@ Rectangle {
for (var i=0; i<windows.length; ++i) {
var window = windows[i];
window.parent = tabbedWindowsStack;
- window.anchors.fill = tabbedWindowsStack
+ window.anchors.fill = tabbedWindowsStack;
+ window.border.width = 0;
}
}
@@ -107,6 +207,7 @@ Rectangle {
var window = windows[i];
window.parent = tabbedWindowsStack;
window.anchors.fill = tabbedWindowsStack
+ window.border.width = 0;
}
}
@@ -116,17 +217,17 @@ Rectangle {
var rows = 1;
var count = windows.length;
- if (windowLayout == autoTile) {
+ if (windowArrangement == autoTile) {
if (count > 1) {
columns = 2
rows = Math.floor((count+1)/2);
}
}
- else if (windowLayout == autoTileHor)
+ else if (windowArrangement == autoTileHor)
{
rows = count;
}
- else if (windowLayout == autoTileVer)
+ else if (windowArrangement == autoTileVer)
{
columns = count;
}
@@ -134,13 +235,15 @@ Rectangle {
}
function layoutWindows() {
+ tipText.visible = (windows.length == 0);
+
tabbedWindows.z = -2;
gridWindows.z = -3;
- if (windowLayout == single) {
+ if (windowArrangement == single) {
arrangeSingleWindow();
}
- else if (windowLayout == tabLayout) {
+ else if (windowArrangement == tabLayout) {
arrangeTabbedWindows();
}
else {
@@ -149,16 +252,28 @@ Rectangle {
}
function selectWindow(n) {
- if (windowLayout == tabLayout || windowLayout == single) {
+ if (windowArrangement == tabLayout || windowArrangement == single) {
tabbedWindows.current = n;
}
}
-// anchors.top: spacer.bottom
-// anchors.left: parent.left
-// anchors.right: parent.right
-// anchors.bottom: parent.bottom
-// color: "#646464"
+ onWindowArrangementChanged: layoutWindows()
+
+ Text {
+ id: tipText
+
+ text: qsTranslate("Welcome", "Use the \"New Window\" menu to open a document.")
+ anchors.left: windowManager.left
+ anchors.right: windowManager.right
+ anchors.verticalCenter: windowManager.verticalCenter
+ anchors.margins: btStyle.pixelsPerMillimeterX*6
+ horizontalAlignment: Text.AlignJustify
+ font.pointSize: btStyle.uiFontPointSize;
+ color: btStyle.textColor
+ visible: false
+ wrapMode: Text.Wrap
+ z: 10
+ }
Grid {
id: gridWindows
@@ -166,8 +281,14 @@ Rectangle {
objectName: "gridWindows"
anchors.fill: parent
columns: 2
- spacing: 2
+ spacing: 0
z: 2
+ onWidthChanged: {
+ layoutWindows();
+ }
+ onHeightChanged: {
+ layoutWindows();
+ }
}
Item {
@@ -217,22 +338,21 @@ Rectangle {
function calculateTabWidth() {
var tabWidth = (tabbedWindows.width) / tabbedWindowsStack.children.length;
+ tabWidth = Math.min(tabbedWindows.width/2, tabWidth)
return tabWidth;
}
visible: tabbedWindows.tabVisible
- //width: (tabbedWindows.width) / tabbedWindowsStack.children.length;
width: {
calculateTabWidth()
}
- height: 36
-
- Rectangle {
- id: tabBorder
- width: parent.width; height: 1
- anchors { bottom: parent.bottom; bottomMargin: 1 }
- color: "#acb2c2"
+ height: {
+ var pixel = btStyle.pixelsPerMillimeterY * 7.5;
+ var uiFont = btStyle.uiFontPointSize * 4.4;
+ var mix = pixel * 0.7 + uiFont * 0.3;
+ return Math.max(pixel, mix);
}
+ color: btStyle.toolbarColor
Rectangle {
id: tabImage
@@ -244,8 +364,15 @@ Rectangle {
else
return btStyle.windowTab
}
- border.color: btStyle.windowTab
- border.width: 2
+ radius: height/2
+
+ Rectangle {
+ color: tabImage.color
+ height: tabImage.height/2
+ width: tabImage.width
+ anchors.left: tabImage.left
+ anchors.bottom: tabImage.bottom
+ }
Text {
id: tabText
@@ -253,8 +380,8 @@ Rectangle {
horizontalAlignment: Qt.AlignHCenter;
verticalAlignment: Qt.AlignVCenter
anchors.fill: parent
- anchors.topMargin: 6
- font.pointSize: btStyle.uiFontPointSize -3
+ anchors.topMargin: 4
+ font.pointSize: btStyle.uiFontPointSize -1
text: tabbedWindowsStack.children[index].title
elide: Text.ElideLeft
color: {