diff --git a/gemini/Settings.cpp b/gemini/Settings.cpp index b9e5400d348..4e11dc3772e 100644 --- a/gemini/Settings.cpp +++ b/gemini/Settings.cpp @@ -1,194 +1,193 @@ /* This file is part of the KDE project * Copyright (C) 2012 Arjen Hiemstra * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "Settings.h" #include "DocumentListModel.h" #include #include #include #include #include #include "Theme.h" #include "PropertyContainer.h" // #include #include #include #include class Settings::Private { public: Private() : temporaryFile(false), focusItem(0) { } QString currentFile; QString currentFileClass; bool temporaryFile; QQuickItem *focusItem; Theme* theme; }; Settings::Settings( QObject* parent ) : QObject( parent ), d( new Private ) { QString theme = KSharedConfig::openConfig()->group("General").readEntry("theme", "default"); d->theme = Theme::load(theme, this); connect(d->theme, SIGNAL(fontCacheRebuilt()), SIGNAL(themeChanged())); } Settings::~Settings() { delete d; } QString Settings::currentFile() const { - QUrl url = QUrl::fromLocalFile(d->currentFile); - return url.toString(); + return d->currentFile; } QString Settings::currentFileClass() const { return d->currentFileClass; } void Settings::setCurrentFile(const QString& fileName) { qApp->processEvents(); if(fileName.isEmpty()) { d->currentFile = fileName; d->currentFileClass = "No document set, consequently no class. This is expected behaviour, do not report."; emit currentFileChanged(); } else if (fileName != d->currentFile) { QUrl url(fileName); if(url.scheme() == "newfile") { d->currentFileClass = url.queryItemValue("mimetype"); } else { QMimeDatabase db; QMimeType mimeType = db.mimeTypeForUrl(url); KoDocumentEntry documentEntry = KoDocumentEntry::queryByMimeType(mimeType.name()); if(documentEntry.supportsMimeType(WORDS_MIME_TYPE)) { d->currentFileClass = WORDS_MIME_TYPE; } else if(documentEntry.supportsMimeType(STAGE_MIME_TYPE)) { d->currentFileClass = STAGE_MIME_TYPE; } else { d->currentFileClass = QString("Unsupported document! Reported mimetype is %1").arg(mimeType.name()); } } d->currentFile = fileName; emit currentFileChanged(); } } bool Settings::isTemporaryFile() const { return d->temporaryFile; } void Settings::setTemporaryFile(bool temp) { if (temp != d->temporaryFile) { d->temporaryFile = temp; emit temporaryFileChanged(); } } QQuickItem* Settings::focusItem() { return d->focusItem; } void Settings::setFocusItem(QQuickItem* item) { if (item != d->focusItem) { d->focusItem = item; emit focusItemChanged(); } } QObject* Settings::theme() const { return d->theme; } QString Settings::themeID() const { if(d->theme) return d->theme->id(); return QString(); } void Settings::setThemeID(const QString& id) { if(!d->theme || id != d->theme->id()) { if(d->theme) { delete d->theme; d->theme = 0; } d->theme = Theme::load(id, this); KSharedConfig::openConfig()->group("General").writeEntry("theme", id); emit themeChanged(); } } int Settings::mimeTypeToDocumentClass(QString mimeType) const { DocumentListModel::DocumentType documentClass = DocumentListModel::UnknownType; if(mimeType == QLatin1String("application/vnd.oasis.opendocument.text") || mimeType == QLatin1String("application/msword") || mimeType == QLatin1String("application/rtf") || mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.wordprocessingml.document") || mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.wordprocessingml.template") || mimeType == QLatin1String("application/vnd.ms-word.document.macroEnabled.12") || mimeType == QLatin1String("application/vnd.ms-word.template.macroEnabled.12")) { documentClass = DocumentListModel::TextDocumentType; } else if(mimeType == QLatin1String("application/vnd.oasis.opendocument.presentation") || mimeType == QLatin1String("application/vnd.ms-powerpoint") || mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.presentationml.presentation") || mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.presentationml.template") || mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.presentationml.slideshow") || mimeType == QLatin1String("application/vnd.ms-powerpoint.presentation.macroEnabled.12") || mimeType == QLatin1String("application/vnd.ms-powerpoint.template.macroEnabled.12") || mimeType == QLatin1String("application/vnd.ms-powerpoint.slideshow.macroEnabled.12") ) { documentClass = DocumentListModel::PresentationType; } // else // if(mimeType == QLatin1String("application/vnd.oasis.opendocument.spreadsheet") || // mimeType == QLatin1String("application/vnd.ms-excel") || // mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") || // mimeType == QLatin1String("application/vnd.openxmlformats-officedocument.spreadsheetml.template") || // mimeType == QLatin1String("application/vnd.ms-excel.sheet.macroEnabled") || // mimeType == QLatin1String("application/vnd.ms-excel.sheet.macroEnabled.12") || // mimeType == QLatin1String("application/vnd.ms-excel.template.macroEnabled.12") ) // { // documentClass = DocumentListModel::SpreadSheetType; // } return documentClass; } diff --git a/gemini/qml/MainPage.qml b/gemini/qml/MainPage.qml index 9de3f597701..71e7833920b 100644 --- a/gemini/qml/MainPage.qml +++ b/gemini/qml/MainPage.qml @@ -1,521 +1,525 @@ /* This file is part of the KDE project * Copyright (C) 2014 Dan Leinir Turthra Jensen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import "components" import "panels" import org.calligra 1.0 import org.kde.calligra 1.0 as Calligra Page { id: base; property string pageName: "MainPage"; Connections { target: Settings; onCurrentFileChanged: { if(Settings.currentFileClass === WORDS_MIME_TYPE) { viewLoader.sourceComponent = wordsView; } else if(Settings.currentFileClass === STAGE_MIME_TYPE) { viewLoader.sourceComponent = stageView; } else { if(Settings.currentFile !== "") { console.debug("BANG!"); } } if(viewLoader.item) { - viewLoader.item.source = Settings.currentFile; + if(Settings.currentFile.indexOf("://") > 0) { + viewLoader.item.source = Settings.currentFile; + } else { + viewLoader.item.source = "file://" + Settings.currentFile; + } } } } ToolManager { id: toolManager; onCurrentToolChanged: console.debug("Current tool is now " + currentTool.toolId()); } Loader { id: viewLoader; anchors { top: toolbar.top; left: parent.left; right: parent.right; bottom: parent.bottom; } } Connections { target: viewLoader.item; // ok, so this looks weird, but we explicitly want to keep the notes // panel open unless they're interacting with the other gui bits, not // if they're moving through the document onCanvasInteractionStarted: closeToolbarMenus(notesButton); } Component { id: stageView; StageDocumentPage {} } Component { id: wordsView; WordsDocumentPage {} } function closeToolbarMenus(sender) { if(sender !== textStyleButton) { textStyleButton.checked = false; } if(sender !== imageToolsButton) { imageToolsButton.checked = false; } if(sender !== optionsButton1) { optionsButton1.checked = false; } if(sender !== notesButton) { notesButton.checked = false; } if(sender !== optionsButton2) { optionsButton2.checked = false; } } Item { id: toolbar; anchors { top: parent.top; left: parent.left; right: parent.right; } opacity: viewLoader.item ? viewLoader.item.toolbarOpacity : 1; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } height: Settings.theme.adjustedPixel(86); MouseArea { anchors.fill: parent; // same logic as on canvas interaction - close menus, leave notes menu open onClicked: closeToolbarMenus(notesButton); } Rectangle { anchors.fill: parent; color: Settings.theme.color("components/toolbar/base"); opacity: 0.96; } Rectangle { anchors { left: parent.left; right: parent.right; bottom: parent.bottom; } height: 1; color: "black"; opacity: 0.1; } Item { id: appButton; height: parent.height; width: Settings.theme.adjustedPixel(110); Rectangle { anchors.fill: parent; color: "#f2b200"; } Image { anchors { left: parent.left; verticalCenter: parent.verticalCenter; } height: Settings.theme.adjustedPixel(32); width: height; source: Settings.theme.icon("Arrow-Back-FileBrowse-1"); sourceSize.width: width > height ? height : width; sourceSize.height: width > height ? height : width; } Image { anchors { right: parent.right; rightMargin: Constants.DefaultMargin; verticalCenter: parent.verticalCenter; } height: Settings.theme.adjustedPixel(86) - Constants.DefaultMargin * 2; width: height; source: Settings.theme.icon("Calligra-MockIcon-1"); sourceSize.width: width > height ? height : width; sourceSize.height: width > height ? height : width; } MouseArea { anchors.fill: parent; onClicked: { closeToolbarMenus(); if(viewLoader.item.canvas.document.document.isModified()) { saveBeforeExitDialog.show(); } else { mainPageStack.pop(); } } } } Row { anchors { left: appButton.right; leftMargin: 20; verticalCenter: parent.verticalCenter; } height: Settings.theme.adjustedPixel(66); spacing: Settings.theme.adjustedPixel(8); CohereButton { anchors.verticalCenter: parent.verticalCenter; text: "SAVE"; textColor: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); onClicked: { closeToolbarMenus(); viewLoader.item.canvas.document.save(); } } CohereButton { anchors.verticalCenter: parent.verticalCenter; text: "UNDO"; textColor: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); enabled: typeof(undoaction) !== "undefined" ? undoaction.enabled : false; onClicked: { closeToolbarMenus(); undoaction.trigger(); } } Button { height: parent.height; width: height * 2; text: "REDO"; textColor: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); enabled: typeof(redoaction) !== "undefined" ? redoaction.enabled : false; onClicked: { closeToolbarMenus(); redoaction.trigger(); } } Item { height: parent.height; width: Settings.theme.adjustedPixel(8); } CohereButton { anchors.verticalCenter: parent.verticalCenter; text: "DONE" textColor: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); visible: viewLoader.item ? !viewLoader.item.navigateMode : false; onClicked: { closeToolbarMenus(); viewLoader.item.navigateMode = true; } } } Row { id: toolbarTextTool anchors.centerIn: parent; height: Settings.theme.adjustedPixel(54); spacing: Settings.theme.adjustedPixel(4); opacity: (toolManager.currentTool !== null && toolManager.currentTool.toolId() === "TextToolFactory_ID") ? 1 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } Button { id: textStyleButton; image: Settings.theme.icon("SVG-Icon-TextStyle-1"); imageMargin: 2; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); checkable: true; checkedMargin: 0; radius: 4; onClicked: closeToolbarMenus(textStyleButton); Rectangle { anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.bottom; height: Constants.DefaultMargin; width: height; color: "#e8e9ea"; rotation: 45; opacity: parent.checked ? 1 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } } TextStylePanel { id: textStylePanel; document: viewLoader.item ? viewLoader.item.document : null; textEditor: viewLoader.item ? viewLoader.item.textEditor : null; zoomLevel: viewLoader.item && viewLoader.item.canvas && viewLoader.item.canvas.zoomAction ? viewLoader.item.canvas.zoomAction.effectiveZoom : 1; } } Item { height: parent.height; width: 1; } Rectangle { color: Settings.theme.color("components/toolbar/text"); opacity: 0.3; height: parent.height; width: 1; } Item { height: parent.height; width: 1; } Label { text: textStylePanel.cursorFont.family; height: parent.height; width: Constants.GridWidth; color: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); horizontalAlignment: Text.AlignLeft; } Label { text: textStylePanel.cursorFont.pointSize; height: parent.height; width: Constants.GridWidth / 2; color: Settings.theme.color("components/toolbar/text"); font: Settings.theme.font("toolbar"); horizontalAlignment: Text.AlignRight verticalAlignment: Text.AlignVCenter; } Item { height: parent.height; width: 1; } Rectangle { color: Settings.theme.color("components/toolbar/text"); opacity: 0.3; height: parent.height; width: 1; } Item { height: parent.height; width: 1; } Button { image: Settings.theme.icon("SVG-Icon-Bold-1"); imageMargin: 4; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); radius: 4; checkedMargin: 0; checked: textStylePanel.cursorFont ? textStylePanel.cursorFont.bold : false; onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-Italic-1"); imageMargin: 4; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); radius: 4; checkedMargin: 0; checked: textStylePanel.cursorFont ? textStylePanel.cursorFont.italic : false; onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-Underline-1"); imageMargin: 4; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); radius: 4; checkedMargin: 0; checked: textStylePanel.cursorFont ? textStylePanel.cursorFont.underline : false; onClicked: closeToolbarMenus(); } Item { height: parent.height; width: 1; } Rectangle { color: Settings.theme.color("components/toolbar/text"); opacity: 0.3; height: parent.height; width: 1; } Item { height: parent.height; width: 1; } Button { image: Settings.theme.icon("SVG-Icon-BulletList-1"); imageMargin: 4; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-TextAlignment-1"); imageMargin: 4; height: parent.height; width: height; textColor: Settings.theme.color("components/toolbar/text"); onClicked: closeToolbarMenus(); } } Row { id: toolbarImageTool anchors.centerIn: parent; height: Settings.theme.adjustedPixel(54); spacing: Settings.theme.adjustedPixel(4); opacity: (toolManager.currentTool !== null && toolManager.currentTool.toolId() === "InteractionTool") ? 1 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } Button { image: Settings.theme.icon("SVG-Icon-Image"); imageMargin: 4; height: parent.height; width: height; onClicked: closeToolbarMenus(); } Item { height: parent.height; width: 1; } Rectangle { color: Settings.theme.color("components/toolbar/text"); opacity: 0.3; height: parent.height; width: 1; } Item { height: parent.height; width: 1; } Button { image: Settings.theme.icon("SVG-Icon-Pen"); imageMargin: 4; height: parent.height; width: height; onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-Fill"); imageMargin: 4; height: parent.height; width: height; onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-Lines"); imageMargin: 4; height: parent.height; width: height; onClicked: closeToolbarMenus(); } Button { image: Settings.theme.icon("SVG-Icon-Shadow"); imageMargin: 4; height: parent.height; width: height; onClicked: closeToolbarMenus(); } Item { height: parent.height; width: 1; } Rectangle { color: Settings.theme.color("components/toolbar/text"); opacity: 0.3; height: parent.height; width: 1; } Item { height: parent.height; width: 1; } Button { id: imageToolsButton; height: parent.height; width: height; image: Settings.theme.icon("SVG-Icon-ImageAdjustment-1"); imageMargin: 4; checkable: true; checkedMargin: 0; radius: 4; onClicked: closeToolbarMenus(imageToolsButton); Rectangle { anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.bottom; height: Constants.DefaultMargin; width: height; color: "#22282f"; rotation: 45; opacity: parent.checked ? 0.96 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } } ImageToolsPanel { canvas: viewLoader.item && viewLoader.item.canvas ? viewLoader.item.canvas : null; } } } Row { anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: Settings.theme.adjustedPixel(10); } height: Settings.theme.adjustedPixel(66); spacing: Settings.theme.adjustedPixel(10); visible: notesPanel.canvas ? false : true; // Button { // height: parent.height; width: height; // image: Settings.theme.icon("SVG-Icon-AddShape-1"); // onClicked: closeToolbarMenus(); // } // Button { // height: parent.height; width: height; // image: Settings.theme.icon("SVG-Icon-Animations-1"); // onClicked: closeToolbarMenus(); // } Button { height: parent.height; width: height; image: Settings.theme.icon("SVG-Icon-PlayPresentation-1"); onClicked: { mainPageStack.push(presentationDJMode); closeToolbarMenus(); if(mainWindow.lastScreen() > 0) { // don't do the whole song and dance with presenting unless we've got a useful // external screen to do the presentation on. For on-device presentations, we // need desktop controls anyway, so heuristics say - presentation in touch need // external screen. mainWindow.fullScreen = true; DocumentManager.doc().setPresentationMonitor(mainWindow.lastScreen()); DocumentManager.doc().setPresenterViewEnabled(false); mainWindow.desktopKoView.startPresentationFromBeginning(); } } Calligra.ContentsModel { id: presentationModel document: viewLoader.item ? viewLoader.item.document : null; thumbnailSize: Qt.size(base.width, base.height); } Component { id: presentationDJMode; PresentationDJMode { }}//canvas: viewLoader.item ? viewLoader.item.canvas : null; } } } Button { id: optionsButton1; height: parent.height; width: height; image: Settings.theme.icon("SVG-Icon-Options-1"); checkable: true; radius: 4; checkedColor: "#00adf5"; checkedOpacity: 0.6; onClicked: closeToolbarMenus(optionsButton1); Rectangle { anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.bottom; height: Constants.DefaultMargin; width: height; color: "#4e5359"; rotation: 45; opacity: parent.checked ? 0.96 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } } OptionsPanel { onInteractionStarted: closeToolbarMenus(); } } } Row { anchors { right: parent.right; verticalCenter: parent.verticalCenter; rightMargin: Settings.theme.adjustedPixel(10); } height: Settings.theme.adjustedPixel(66); spacing: Settings.theme.adjustedPixel(10); visible: notesPanel.canvas ? true : false; // Button { // height: parent.height; width: height; // image: Settings.theme.icon("SVG-Icon-AddShape-1"); // onClicked: closeToolbarMenus(); // } Button { id: notesButton; height: parent.height; width: height; image: Settings.theme.icon("SVG-Icon-AddNote-1"); checkable: true; radius: 4; checkedColor: "#00adf5"; checkedOpacity: 0.6; onClicked: closeToolbarMenus(notesButton); Rectangle { anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.bottom; height: Constants.DefaultMargin; width: height; color: "#e8e9ea"; rotation: 45; opacity: parent.checked ? 1 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } } NotesPanel { id: notesPanel; anchors { top: parent.bottom; right: parent.right; rightMargin: - (parent.width + 20); topMargin: 4; } opacity: parent.checked ? 1 : 0; canvas: viewLoader.item && viewLoader.item.canvas && viewLoader.item.canvas.notes ? viewLoader.item.canvas : null; } } Button { id: optionsButton2; height: parent.height; width: height; image: Settings.theme.icon("SVG-Icon-Options-1"); checkable: true; radius: 4; checkedColor: "#00adf5"; checkedOpacity: 0.6; onClicked: closeToolbarMenus(optionsButton2); OptionsPanel { onInteractionStarted: closeToolbarMenus(); } Rectangle { anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.bottom; height: Constants.DefaultMargin + 2; width: height; color: "#4e5359"; rotation: 45; opacity: parent.checked ? 0.96 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } } } } } Dialog { id: saveBeforeExitDialog; title: "Save?"; message: "The document was modified. Would you like to save it before closing it?"; buttons: [ "Save", "Discard", "Cancel" ] onButtonClicked: { if(button === 0) { viewLoader.item.canvas.document.save(); } else if(button === 1) { viewLoader.item.canvas.document.setModified(false); mainPageStack.pop(); } } } } diff --git a/gemini/qml/welcomepages/VariantSelector.qml b/gemini/qml/welcomepages/VariantSelector.qml index 3ad3c8bb5b8..bf4ca3049fe 100644 --- a/gemini/qml/welcomepages/VariantSelector.qml +++ b/gemini/qml/welcomepages/VariantSelector.qml @@ -1,188 +1,186 @@ /* This file is part of the KDE project * Copyright (C) 2014 Dan Leinir Turthra Jensen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import org.calligra 1.0 import "../components" Item { id: base; property alias model: variantView.model; property string selectorType: "stage"; anchors.fill: parent; enabled: (visible && opacity > 0.0); opacity: 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } MouseArea { anchors.fill: parent; onClicked: {} } SimpleTouchArea { anchors.fill: parent; onTouched: {} } Rectangle { anchors.fill: parent; color: "#e8e9ea" opacity: 0.6; } Item { anchors { centerIn: parent; topMargin: -(height/2); } height: Settings.theme.adjustedPixel(475); width: Settings.theme.adjustedPixel(1600); Rectangle { anchors.fill: parent; color: "#22282f"; opacity: 0.7; radius: 8; } BorderImage { anchors { fill: parent; topMargin: -28; leftMargin: -36; rightMargin: -36; bottomMargin: -44; } border { left: 36; top: 28; right: 36; bottom: 44; } horizontalTileMode: BorderImage.Stretch; verticalTileMode: BorderImage.Stretch; source: Settings.theme.image("drop-shadows.png"); BorderImage { anchors { fill: parent; topMargin: 28; leftMargin: 36; rightMargin: 36; bottomMargin: 44; } border { left: 8; top: 8; right: 8; bottom: 8; } horizontalTileMode: BorderImage.Stretch; verticalTileMode: BorderImage.Stretch; source: Settings.theme.image("drop-corners.png"); } } Label { anchors { top: parent.top; left: parent.left; right: parent.right; } height: Settings.theme.adjustedPixel(120); horizontalAlignment: Text.AlignHCenter; verticalAlignment: Text.AlignVCenter; color: "white"; font: Settings.theme.font("title"); text: "Select a Style Option"; } Button { anchors { top: parent.top; right: parent.right; margins: Settings.theme.adjustedPixel(20); } height: Settings.theme.adjustedPixel(40); width: height; image: Settings.theme.icon("SVG-Icon-SmallX"); onClicked: base.opacity = 0; } Flickable { id: variantFlickable; anchors { fill: parent; topMargin: Settings.theme.adjustedPixel(120); leftMargin: Settings.theme.adjustedPixel(50); rightMargin: Settings.theme.adjustedPixel(50); bottomMargin: Settings.theme.adjustedPixel(40); } clip: true; contentHeight: variantFlow.height; contentWidth: variantFlow.width; Flow { id: variantFlow; width: variantFlickable.width; Repeater { id: variantView; delegate: Item { height: Settings.theme.adjustedPixel(310); width: Settings.theme.adjustedPixel(375); MouseArea { anchors.fill: parent; onClicked: { base.opacity = 0; var file = ""; - if(base.selectorType === "stage") { - file = model.url; - } else if(base.selectorType === "words") { + if(base.selectorType === "stage" || base.selectorType === "words") { file = "template://" + model.url; } if(file.slice(-1) === "/" || file === "") { return; } baseLoadingDialog.visible = true; openFile(file); } Rectangle { anchors.fill: parent; opacity: parent.pressed ? 0.6 : 0; Behavior on opacity { PropertyAnimation { duration: Constants.AnimationDuration; } } radius: Settings.theme.adjustedPixel(8); color: "#00adf5"; } } Image { anchors { top: parent.top; left: parent.left; right: parent.right; margins: Settings.theme.adjustedPixel(16); } height: Settings.theme.adjustedPixel(192); source: model.thumbnail; fillMode: Image.PreserveAspectFit smooth: true; } Image { anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; margins: Settings.theme.adjustedPixel(16); } height: Settings.theme.adjustedPixel(64); width: Settings.theme.adjustedPixel(190); source: model.swatch !== "" ? Settings.theme.icon(model.swatch) : ""; fillMode: Image.PreserveAspectFit smooth: true; } Label { anchors { horizontalCenter: parent.horizontalCenter; bottom: parent.bottom; margins: Settings.theme.adjustedPixel(16); } height: Settings.theme.adjustedPixel(64); width: Settings.theme.adjustedPixel(190); horizontalAlignment: Text.AlignHCenter; text: model.text; font: Settings.theme.font("templateLabel"); color: "white"; } } } } } ScrollDecorator { flickableItem: variantFlickable; anchors.fill: variantFlickable; } } } diff --git a/gemini/qml/welcomepages/WelcomePageStage.qml b/gemini/qml/welcomepages/WelcomePageStage.qml index b49a97cfd42..883b9692c61 100644 --- a/gemini/qml/welcomepages/WelcomePageStage.qml +++ b/gemini/qml/welcomepages/WelcomePageStage.qml @@ -1,179 +1,179 @@ /* This file is part of the KDE project * Copyright (C) 2014 Dan Leinir Turthra Jensen * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import org.calligra 1.0 import "../components" Page { id: base; objectName: "WelcomePageStage"; function activateTemplate(templateFile) { console.debug(templateFile); if(templateFile.slice(-1) === "/" || templateFile === "") { return; } baseLoadingDialog.visible = true; - openFile(templateFile); + openFile("template://" + templateFile); } TemplatesModel { id: stageTemplates; templateType: STAGE_MIME_TYPE; showWide: true; } TemplatesModel { id: stageTemplatesClassic; templateType: STAGE_MIME_TYPE; showWide: false; } // templates to make: // ListElement { text: "Metropolitan"; thumbnail: ""; color: "#E8EFF1"; templateFile: ""; variants: [ ] } // ListElement { text: "Elegant"; thumbnail: ""; color: "#A9B3B6"; templateFile: ""; variants: [ ] } // ListElement { text: "Vintage"; thumbnail: ""; color: "#828C8F"; templateFile: ""; variants: [ ] } // ListElement { text: "Modernist"; thumbnail: ""; color: "#A9B3B6"; templateFile: ""; variants: [ ] } // ListElement { text: "Distraught"; thumbnail: ""; color: "#828C8F"; templateFile: ""; variants: [ ] } // ListElement { text: "Fabric"; thumbnail: ""; color: "#E8EFF1"; templateFile: ""; variants: [ ] } // ListElement { text: "Metallic"; thumbnail: ""; color: "#A9B3B6"; templateFile: ""; variants: [ ] } // ListElement { text: "Luna Rising"; thumbnail: ""; color: "#828C8F"; templateFile: ""; variants: [ ] } // ListElement { text: "Galactic Voyage"; thumbnail: ""; color: "#E8EFF1"; templateFile: ""; variants: [] } Label { anchors { top: parent.top; left: parent.left; right: parent.right; } height: Constants.GridHeight * 1.5; verticalAlignment: Text.AlignVCenter; horizontalAlignment: Text.AlignHCenter; font: Settings.theme.font("pageHeader"); text: "Select a template"; color: "#22282f"; Row { anchors { right: parent.right; rightMargin: Settings.theme.adjustedPixel(20); verticalCenter: parent.verticalCenter; } height: parent.height - Constants.DefaultMargin * 2; spacing: Settings.theme.adjustedPixel(4); CohereButton { anchors.verticalCenter: parent.verticalCenter; checked: stageTemplatesRepeater.model === stageTemplatesClassic; text: "Classic"; textColor: "#5b6573"; textSize: Settings.theme.adjustedPixel(18); checkedColor: "#D2D4D5"; onClicked: { if(!checked) { stageTemplatesRepeater.model = stageTemplatesClassic; } } } CohereButton { anchors.verticalCenter: parent.verticalCenter; checked: stageTemplatesRepeater.model === stageTemplates; text: "Wide"; textColor: "#5b6573"; textSize: Settings.theme.adjustedPixel(18); checkedColor: "#D2D4D5"; onClicked: { if(!checked) { stageTemplatesRepeater.model = stageTemplates; } } } } } Flickable { id: stageFlickable; anchors { fill: parent; margins: Constants.DefaultMargin; topMargin: Constants.GridHeight * 1.5; bottomMargin: 0; } contentWidth: templatesFlow.width; contentHeight: templatesFlow.height; clip: true; Flow { id: templatesFlow; width: base.width - Constants.DefaultMargin * 2; spacing: Constants.DefaultMargin * 3; Repeater { id: stageTemplatesRepeater; model: stageTemplates; Column { width: (templatesFlow.width / 4) - Constants.DefaultMargin * 3; height: width * 0.7; spacing: Constants.DefaultMargin; Image { source: model.thumbnail ? model.thumbnail : ""; width: parent.width; height: parent.height - templateName.height - Constants.DefaultMargin; fillMode: Image.PreserveAspectFit; smooth: true; Rectangle { anchors.fill: parent; color: model.thumbnail ? "transparent" : model.color; border { width: 1; color: "#c1cdd1"; } opacity: 0.6; } Row { anchors { bottom: parent.bottom; right: parent.right; margins: Constants.DefaultMargin; } height: Constants.DefaultMargin * 2; spacing: Constants.DefaultMargin; property QtObject colorModel: model.variants; Repeater { model: parent.colorModel; Rectangle { height: Constants.DefaultMargin * 2; width: height; radius: Constants.DefaultMargin; color: model.color; } } } MouseArea { anchors.fill: parent; onClicked: { if(model.variantCount === 0) { activateTemplate(model.url); } else { // then there are variants to choose between, let the user see! variantSelector.model = model.variants; variantSelector.opacity = 1; } } } } Label { id: templateName; width: parent.width; horizontalAlignment: Text.AlignHCenter; text: model.text; font: Settings.theme.font("templateLabel"); color: "#5b6573"; } } } } } ScrollDecorator { flickableItem: stageFlickable; anchors.fill: stageFlickable; } }