Warning, /office/calligra/gemini/qml/WelcomePage.qml is written in an unsupported language. File is not indexed.

0001 /* This file is part of the KDE project
0002  * Copyright (C) 2014 Dan Leinir Turthra Jensen <admin@leinir.dk>
0003  *
0004  *  This program is free software; you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation; either version 2 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program; if not, write to the Free Software
0016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0017  */
0018 
0019 import QtQuick 2.0
0020 import QtQuick.Controls 1.3
0021 import org.calligra 1.0
0022 import org.kde.kirigami 2.1 as Kirigami
0023 import "welcomepages"
0024 import "components"
0025 
0026 Kirigami.ApplicationItem {
0027     id: base;
0028     onWidthChanged: Constants.setGridWidth( width / Constants.GridColumns );
0029     onHeightChanged: Constants.setGridHeight( height / Constants.GridRows );
0030     DocumentListModel { id: allDocumentsModel; }
0031     DocumentListModel { id: textDocumentsModel; filter: DocumentListModel.TextDocumentType; }
0032     DocumentListModel { id: presentationDocumentsModel; filter: DocumentListModel.PresentationType; }
0033 
0034     pageStack.initialPage: welcomePageFilebrowser;
0035     pageStack.defaultColumnWidth: pageStack.width
0036     pageStack.globalToolBar.style: Kirigami.ApplicationHeaderStyle.Auto
0037     pageStack.layers.onCurrentItemChanged: pageStack.layers.currentItem !== null ? mainWindow.currentTouchPage = (pageStack.layers.currentItem.pageName !== undefined) ? pageStack.layers.currentItem.pageName : pageStack.layers.currentItem.toString() : ""
0038     Component.onCompleted: {
0039         if(RecentFileManager.size() > 0) {
0040             pageStack.replace(welcomePageRecent);
0041         }
0042     }
0043 
0044     function openFile(fileName, alternativeSaveAction) {
0045         baseLoadingDialog.visible = true;
0046         loadInitiator.fileName = fileName;
0047         loadInitiator.alternativeSaveAction = alternativeSaveAction;
0048         loadInitiator.start();
0049     }
0050     Timer {
0051         id: loadInitiator
0052         running: false; repeat: false; interval: 1
0053         property string fileName
0054         property var alternativeSaveAction
0055         onTriggered: {
0056             pageStack.layers.push(mainPage);
0057             Settings.currentFile = "";
0058             Settings.currentFile = fileName;
0059             pageStack.layers.currentItem.openFileReal(fileName);
0060             RecentFileManager.addRecent(fileName);
0061             mainWindow.setAlternativeSaveAction(alternativeSaveAction);
0062         }
0063     }
0064 
0065     contextDrawer: Kirigami.ContextDrawer {
0066         id: contextDrawer
0067     }
0068     Connections {
0069         target: pageStack.layers
0070         onDepthChanged: {
0071             if (pageStack.layers.depth === 1) {
0072                 base.globalDrawer.drawerOpen = true
0073                 applicationWindow().controlsVisible = true
0074             } else {
0075                 base,globalDrawer.drawerOpen = false
0076                 base.contextDrawer.drawerOpen = false
0077                 applicationWindow().controlsVisible = false
0078             }
0079         }
0080     }
0081     globalDrawer: Kirigami.GlobalDrawer {
0082         title: "Calligra Gemini"
0083         titleIcon: Settings.theme.iconActual("Calligra-MockIcon-1");
0084         drawerOpen: true;
0085         modal: false;
0086         actions: [
0087             Kirigami.Action  {
0088                 text: "OPEN"
0089             },
0090             Kirigami.Action  {
0091                 text: "Recent Documents"
0092                 iconName: "document-open-recent"
0093                 onTriggered: if(pageStack.currentItem.objectName != "welcomePageRecent") pageStack.replace(welcomePageRecent);
0094                 checked: pageStack.currentItem !== null && pageStack.currentItem.objectName == "WelcomePageRecent";
0095             },
0096             Kirigami.Action  {
0097                 text: "Library"
0098                 iconName: "folder-documents"
0099                 onTriggered: if(pageStack.currentItem.objectName != "WelcomePageFilebrowser") pageStack.replace(welcomePageFilebrowser);
0100                 checked: pageStack.currentItem !== null && pageStack.currentItem.objectName == "WelcomePageFilebrowser";
0101             },
0102             Kirigami.Action  {
0103                 text: "Cloud"
0104                 iconName: "folder-cloud"
0105                 onTriggered: if(pageStack.currentItem.objectName != "WelcomePageCloud") pageStack.replace(welcomePageCloud);
0106                 checked: pageStack.currentItem !== null && pageStack.currentItem.objectName == "WelcomePageCloud";
0107             },
0108             Kirigami.Action  {
0109                 text: "CREATE NEW"
0110             },
0111             Kirigami.Action  {
0112                 text: "Document"
0113                 iconName: "x-office-document"
0114                 onTriggered: if(pageStack.currentItem.objectName != "WelcomePageWords") pageStack.replace(welcomePageWords);
0115                 checked: pageStack.currentItem !== null && pageStack.currentItem.objectName == "WelcomePageWords";
0116             },
0117             Kirigami.Action  {
0118                 text: "Presentation"
0119                 iconName: "x-office-presentation"
0120                 onTriggered: if(pageStack.currentItem.objectName != "WelcomePageStage") pageStack.replace(welcomePageStage);
0121                 checked: pageStack.currentItem !== null && pageStack.currentItem.objectName == "WelcomePageStage";
0122             }
0123         ]
0124     }
0125     Component { id: mainPage; MainPage { } }
0126     Component { id: welcomePageFilebrowser; WelcomePageFilebrowser { } }
0127     Component { id: welcomePageRecent; WelcomePageRecent { } }
0128     Component { id: welcomePageStage; WelcomePageStage { } }
0129     Component { id: welcomePageWords; WelcomePageWords { } }
0130     Component { id: welcomePageCustom; WelcomePageCustom { } }
0131     Component { id: welcomePageCloud; WelcomePageCloud { } }
0132 
0133     VariantSelector { id: variantSelector; }
0134     VariantSelector { id: wordsVariantSelector; selectorType: "words"; }
0135 
0136     // This component is used to get around the fact that MainPage takes a very long time to initialise in some cases
0137     Dialog {
0138         id: baseLoadingDialog;
0139         title: "Loading";
0140         message: "Please wait...";
0141         textAlign: Text.AlignHCenter;
0142         modalBackgroundColor: "#ffffff";
0143         opacity: 1;
0144         progress: 0;
0145         visible: false;
0146         function hideMe() { timer.start(); }
0147         Timer {
0148             id: timer;
0149             interval: 500; running: false; repeat: false;
0150             onTriggered: { parent.visible = false; baseLoadingDialog.progress = -1; }
0151         }
0152     }
0153 }