diff --git a/src/controls/AboutDialog.qml b/src/controls/AboutDialog.qml index b7e333d..9f27432 100644 --- a/src/controls/AboutDialog.qml +++ b/src/controls/AboutDialog.qml @@ -1,195 +1,197 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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 QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.13 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui Maui.Dialog { - id: control - - defaultButtons: false - widthHint: 0.9 - heightHint: 0.8 - - maxWidth: Maui.Style.unit * 400 - maxHeight: Maui.Style.unit * 250 - - page.padding: Maui.Style.space.small - - footBar.middleContent: ToolButton - { - icon.name: "link" - onClicked: Qt.openUrlExternally(Maui.App.webPage) - } - - footBar.rightContent: ToolButton - { - icon.name: "love" - onClicked: Qt.openUrlExternally(Maui.App.donationPage) - } - - footBar.leftContent: ToolButton - { - icon.name: "documentinfo" - onClicked: Qt.openUrlExternally(Maui.App.reportPage) - } - - RowLayout - { - id: layout - anchors.centerIn: parent - width: parent.width - height: parent.height * 0.7 - spacing: Maui.Style.space.big - -// Behavior on width -// { -// NumberAnimation -// { -// duration: Kirigami.Units.longDuration -// easing.type: Easing.InOutQuad -// } -// } - - Item - { - visible: parent.width > control.maxWidth * 0.7 - Layout.fillHeight: true - Layout.margins: Maui.Style.space.small - Layout.alignment: Qt.AlignVCenter - Layout.preferredWidth: visible ? Maui.Style.iconSizes.huge : 0 - - Image - { - id: _imgIcon - anchors.centerIn: parent - source: Maui.App.iconName - width: Math.max(Maui.Style.iconSizes.huge, parent.width) - height: width - sourceSize.width: width - sourceSize.height: height - asynchronous: true - fillMode: Image.PreserveAspectFit - } - - DropShadow - { - anchors.fill: _imgIcon - horizontalOffset: 0 - verticalOffset: 0 - radius: 8.0 - samples: 17 - color: "#80000000" - source: _imgIcon - } - } - - Kirigami.ScrollablePage - { - id: _descriptionItem - Layout.fillWidth: true - Layout.fillHeight: true - Layout.alignment: Qt.AlignLeft | Qt.AlignTop - Kirigami.Theme.backgroundColor: "transparent" - padding: 0 - leftPadding: padding - rightPadding: padding - topPadding: padding - bottomPadding: padding - - ColumnLayout - { - id: _columnInfo - spacing: Maui.Style.space.medium - - Label - { - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft - color: Kirigami.Theme.textColor - text: Maui.App.name - font.weight: Font.Bold - font.bold: true - font.pointSize: Maui.Style.fontSizes.huge - elide: Text.ElideRight - wrapMode: Text.NoWrap - } - - Label - { - Layout.fillWidth: true - Layout.alignment: Qt.AlignLeft - color: Qt.lighter(Kirigami.Theme.textColor, 1.2) - text: Maui.App.version - font.weight: Font.Light - font.pointSize: Maui.Style.fontSizes.default - elide: Text.ElideRight - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - } - - Label - { - id: body - Layout.fillWidth: true - text: Maui.App.description - color: Kirigami.Theme.textColor - font.pointSize: Maui.Style.fontSizes.default - elide: Text.ElideRight - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - } - - Label - { - color: Kirigami.Theme.textColor - Layout.fillWidth: true - - text: qsTr("By ") + Maui.App.org - font.pointSize: Maui.Style.fontSizes.default - elide: Text.ElideRight - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - } - - Kirigami.Separator - { - Layout.fillWidth: true - Layout.margins: Maui.Style.space.tiny - opacity: 0.4 - } - - Label - { - color: Kirigami.Theme.textColor - Layout.fillWidth: true - - text: qsTr("Powered by") + " MauiKit " + Maui.App.mauikitVersion + " and Kirigami." - font.pointSize: Maui.Style.fontSizes.default - elide: Text.ElideRight - wrapMode: Text.WrapAtWordBoundaryOrAnywhere - } - } - } - } + id: control + + defaultButtons: false + widthHint: 0.9 + heightHint: 0.8 + + maxWidth: Maui.Style.unit * 400 + maxHeight: Maui.Style.unit * 250 + + page.padding: Maui.Style.space.small + + footBar.middleContent: ToolButton + { + icon.name: "link" + onClicked: Qt.openUrlExternally(Maui.App.webPage) + } + + footBar.rightContent: ToolButton + { + icon.name: "love" + onClicked: Qt.openUrlExternally(Maui.App.donationPage) + } + + footBar.leftContent: ToolButton + { + icon.name: "documentinfo" + onClicked: Qt.openUrlExternally(Maui.App.reportPage) + } + + RowLayout + { + id: layout + anchors.centerIn: parent + width: parent.width + height: parent.height * 0.7 + spacing: Maui.Style.space.big + + // Behavior on width + // { + // NumberAnimation + // { + // duration: Kirigami.Units.longDuration + // easing.type: Easing.InOutQuad + // } + // } + + Item + { + visible: parent.width > control.maxWidth * 0.7 + Layout.fillHeight: true + Layout.margins: Maui.Style.space.small + Layout.alignment: Qt.AlignVCenter + Layout.preferredWidth: visible ? Maui.Style.iconSizes.huge : 0 + + + Image + { + id: _imgIcon + anchors.centerIn: parent + source: Maui.App.iconName + width: Math.max(Maui.Style.iconSizes.huge, parent.width) + height: width + sourceSize.width: width + sourceSize.height: height + asynchronous: true + fillMode: Image.PreserveAspectFit + } + + DropShadow + { + anchors.fill: _imgIcon + horizontalOffset: 0 + verticalOffset: 0 + radius: 8.0 + samples: 17 + color: "#80000000" + source: _imgIcon + } + } + + Kirigami.ScrollablePage + { + id: _descriptionItem + Layout.fillWidth: true + Layout.fillHeight: true + Layout.alignment: Qt.AlignLeft | Qt.AlignTop + Kirigami.Theme.backgroundColor: "transparent" + padding: 0 + leftPadding: padding + rightPadding: padding + topPadding: padding + bottomPadding: padding + + ColumnLayout + { + id: _columnInfo + spacing: Maui.Style.space.medium + + Label + { + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + color: Kirigami.Theme.textColor + text: Maui.App.name + font.weight: Font.Bold + font.bold: true + font.pointSize: Maui.Style.fontSizes.huge + elide: Text.ElideRight + wrapMode: Text.NoWrap + } + + Label + { + Layout.fillWidth: true + Layout.alignment: Qt.AlignLeft + color: Qt.lighter(Kirigami.Theme.textColor, 1.2) + text: Maui.App.version + font.weight: Font.Light + font.pointSize: Maui.Style.fontSizes.default + elide: Text.ElideRight + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + + Label + { + id: body + Layout.fillWidth: true + text: Maui.App.description + color: Kirigami.Theme.textColor + font.pointSize: Maui.Style.fontSizes.default + elide: Text.ElideRight + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + + Label + { + color: Kirigami.Theme.textColor + Layout.fillWidth: true + + text: qsTr("By ") + Maui.App.org + font.pointSize: Maui.Style.fontSizes.default + elide: Text.ElideRight + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + + Kirigami.Separator + { + Layout.fillWidth: true + Layout.margins: Maui.Style.space.tiny + opacity: 0.4 + } + + Label + { + color: Kirigami.Theme.textColor + Layout.fillWidth: true + + text: qsTr("Powered by") + " MauiKit " + + Maui.App.mauikitVersion + " and Kirigami." + font.pointSize: Maui.Style.fontSizes.default + elide: Text.ElideRight + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + } + } + } + } } diff --git a/src/controls/ActionGroup.qml b/src/controls/ActionGroup.qml index e5b964a..5a8c88c 100644 --- a/src/controls/ActionGroup.qml +++ b/src/controls/ActionGroup.qml @@ -1,187 +1,194 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.9 import QtQuick.Controls 2.5 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui Item { id: control default property list actions property list hiddenActions property int currentIndex : 0 + property bool strech: Kirigami.Settings.isMobile readonly property int count : control.actions.length + control.hiddenActions.length signal clicked(int index) signal pressAndHold(int index) signal doubleClicked(int index) property Component delegate : ToolButton { id: _delegate anchors.verticalCenter: parent.verticalCenter + Layout.fillWidth: control.strech action: modelData icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium autoExclusive: true checkable: true checked: index == control.currentIndex display: control.currentIndex === index ? ToolButton.TextBesideIcon : ToolButton.IconOnly Kirigami.Theme.backgroundColor: modelData.Kirigami.Theme.backgroundColor Kirigami.Theme.highlightColor: modelData.Kirigami.Theme.highlightColor Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } onClicked: { control.currentIndex = index control.clicked(index) } onPressAndHold: control.pressAndHold(index) onDoubleClicked: control.doubleClicked(index) } implicitHeight: parent.height - implicitWidth: _layout.implicitWidth + implicitWidth: strech ? parent.width : _layout.implicitWidth + Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } - Row + RowLayout { id: _layout height: parent.height + width: control.strech ? parent.width : undefined // width: Math.min(implicitWidth, parent.width) spacing: Maui.Style.space.medium clip: true Repeater { model: control.actions - delegate: control.delegate + delegate: control.delegate } ToolButton { id: _exposedHiddenActionButton visible: action + Layout.fillWidth: control.strech + action: control.currentIndex >= control.actions.length && control.currentIndex < control.count? control.hiddenActions[control.currentIndex - control.actions.length] : null checkable: true checked: visible anchors.verticalCenter: parent.verticalCenter icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium display: ToolButton.TextBesideIcon width: visible ? implicitWidth : 0 Behavior on width { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InOutQuad } } } ToolButton { id: _menuButton icon.name: "list-add" + visible: control.hiddenActions.length > 0 onClicked: { if(_menu.visible) _menu.close() else _menu.popup(_menuButton, 0, _menuButton.height) } anchors.verticalCenter: parent.verticalCenter text: qsTr("More") autoExclusive: false checkable: true checked: _menu.visible display: checked ? ToolButton.TextBesideIcon : ToolButton.IconOnly indicator: Kirigami.Icon { anchors { right: parent.right bottom: parent.bottom // verticalCenter: parent.verticalCenter } color: control.Kirigami.Theme.textColor source: "qrc://assets/arrow-down.svg" width: Maui.Style.iconSizes.small height: width isMask: true } Behavior on implicitWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } Menu { id: _menu closePolicy: Popup.CloseOnReleaseOutsideParent Repeater { model: control.hiddenActions MenuItem { action: modelData checkable: true autoExclusive: true checked: control.currentIndex === control.actions.length + index onTriggered: { control.currentIndex = control.actions.length + index control.clicked(control.currentIndex) } } } } } } } diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml index d58c4f4..eaddf75 100644 --- a/src/controls/ApplicationWindow.qml +++ b/src/controls/ApplicationWindow.qml @@ -1,435 +1,503 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.9 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.0 import QtQuick.Window 2.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtQuick.Controls.Material 2.1 import "private" Kirigami.AbstractApplicationWindow { id: root visible: true width: Screen.width * (Kirigami.Settings.isMobile ? 1 : 0.4) height: Screen.height * (Kirigami.Settings.isMobile ? 1 : 0.4) contentItem.anchors.leftMargin: root.sideBar && !root.globalDrawer ? ((root.sideBar.collapsible && root.sideBar.collapsed) ? root.sideBar.collapsedSize : (root.sideBar.modal ? 0 : root.sideBar.width * root.sideBar.position)) : (!root.sideBar && root.globalDrawer && (root.globalDrawer.modal === false) ? root.globalDrawer.width * root.globalDrawer.position : 0) property Maui.AbstractSideBar sideBar /***************************************************/ /******************** ALIASES *********************/ /*************************************************/ property alias headBar : _headBar property alias footBar: _footBar property alias dialog: dialogLoader.item property alias leftIcon : menuBtn property alias rightIcon : searchBtn property alias mainMenu : mainMenu.contentData property alias about : aboutDialog property alias accounts: _accountsDialogLoader.item property var currentAccount: Maui.App.accounts.currentAccount property alias notifyDialog: _notify property alias searchButton : searchBtn property alias menuButton : menuBtn wideScreen: isWide /***************************************************/ /*********************** UI ***********************/ /*************************************************/ property bool isWide : root.width >= Kirigami.Units.gridUnit * 30 property string colorSchemeName : Qt.application.name /***************************************************/ /********************* COLORS *********************/ /*************************************************/ property color headBarBGColor: Kirigami.Theme.backgroundColor property color headBarFGColor: Kirigami.Theme.textColor /***************************************************/ /**************** READONLY PROPS ******************/ /*************************************************/ readonly property bool isMobile : Kirigami.Settings.isMobile readonly property bool isAndroid: Qt.platform.os == "android" readonly property real screenWidth : Screen.width readonly property real screenHeight : Screen.height /***************************************************/ /******************** SIGNALS *********************/ /*************************************************/ signal menuButtonClicked(); signal searchButtonClicked(); onClosing: { if(!isMobile) { const height = root.height const width = root.width const x = root.x const y = root.y Maui.FM.saveSettings("GEOMETRY", Qt.rect(x, y, width, height), "WINDOW") } } property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation || Screen.primaryOrientation === Qt.InvertedPortraitOrientation onIsPortraitChanged: { if(isPortrait) { console.log("PORTARIT MODE CHANGED") width: Screen.width height: Screen.height } } // onHeadBarBGColorChanged: // { // if(!isMobile && colorSchemeName.length > 0) // Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) // else if(isAndroid && headBar.position === ToolBar.Header) // Maui.Android.statusbarColor(headBarBGColor, false) // else if(isAndroid && headBar.position === ToolBar.Footer) // Maui.Android.statusbarColor(Kirigami.Theme.viewBackgroundColor, true) // // } // // onHeadBarFGColorChanged: // { // if(!isAndroid && !isMobile && colorSchemeName.length > 0 && headBar.position === ToolBar.Header) // Maui.KDE.setColorScheme(colorSchemeName, headBarBGColor, headBarFGColor) // else if(isAndroid && headBar.position === ToolBar.Header) // Maui.Android.statusbarColor(headBarBGColor, false) // else if(isAndroid && headBar.position === ToolBar.Footer) // Maui.Android.statusbarColor(Kirigami.Theme.viewBackgroundColor, true) // } /* * background: Rectangle * { * color: bgColor } */ + + Component + { + id: _accountsComponent + + Column + { + width: parent.width +// height: Math.max( 300, implicitHeight + +// _accountsListing.contentHeight) + spacing: Maui.Style.space.medium + + Kirigami.Icon + { + source: "user-identity" + height: Maui.Style.iconSizes.huge + width: height + anchors.horizontalCenter: parent.horizontalCenter + + } + + Label + { + text: currentAccount.user + width: parent.width + horizontalAlignment: Qt.AlignHCenter + elide: Text.ElideMiddle + wrapMode: Text.NoWrap + font.bold: true + font.weight: Font.Bold + + } + + Kirigami.Separator + { + width: parent.width + } + + ListBrowser + { + id: _accountsListing + width: parent.width + height: Math.min(listView.contentHeight, 300) + Kirigami.Theme.backgroundColor: "transparent" + model: Maui.BaseModel + { + list: Maui.App.accounts + + } + + delegate: Maui.ListBrowserDelegate + { + iconSource: "amarok_artist" + iconSizeHint: Maui.Style.iconSizes.medium + label1.text: model.user + label2.text: model.server + width: _accountsListing.width + height: Maui.Style.rowHeight * 1.2 + leftPadding: Maui.Style.space.tiny + rightPadding: Maui.Style.space.tiny + + onClicked: + { + _accountsListing.currentIndex = index + Maui.App.accounts.currentAccountIndex = + index + } + } + + Component.onCompleted: + { + if(_accountsListing.count > 0) + { + _accountsListing.currentIndex = 0 + Maui.App.accounts.currentAccountIndex = + _accountsListing.currentIndex + } + } + } + + Kirigami.Separator + { + width: parent.width + } + + Button + { + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr("Manage accounts") + visible: Maui.App.handleAccounts + icon.name: "list-add-user" + onClicked: + { + if(root.accounts) + accounts.open() + + mainMenu.close() + } + } + + Kirigami.Separator + { + width: parent.width + } + + + } + } property Maui.ToolBar mheadBar : Maui.ToolBar { id: _headBar visible: count > 1 position: ToolBar.Header width: root.width height: implicitHeight // Kirigami.Theme.backgroundColor: headBarBGColor // Kirigami.Theme.textColor: headBarFGColor // Kirigami.Theme.inherit: true leftContent: [ ToolButton { id: menuBtn icon.name: "application-menu" icon.color: headBarFGColor icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium checked: mainMenu.visible onClicked: { - menuButtonClicked() mainMenu.visible ? mainMenu.close() : mainMenu.popup(parent, parent.x , parent.height+ Maui.Style.space.medium) } Menu { id: mainMenu modal: true z: 999 - width: Maui.Style.unit * 200 - - MenuItem + width: Maui.Style.unit * 250 + + Loader { - visible: (_accountCombobox.count > 0) && Maui.App.handleAccounts - height: visible ? _accountCombobox.implicitHeight + Maui.Style.space.big : 0 - - ComboBox - { - id: _accountCombobox - anchors.fill: parent - anchors.margins: Maui.Style.space.small - popup.z: 999 - width: parent.width - textRole: "user" - flat: true - model: Maui.BaseModel - { - list: Maui.App.accounts - } - onActivated: Maui.App.accounts.currentAccountIndex = index; - - Component.onCompleted: - { - if(_accountCombobox.count > 0) - { - _accountCombobox.currentIndex = 0 - Maui.App.accounts.currentAccountIndex = _accountCombobox.currentIndex - } - } - } + id: _accountsMenuLoader + width: parent.width + active: Maui.App.handleAccounts + sourceComponent: Maui.App.handleAccounts ? +_accountsComponent : null } - - MenuItem - { - text: qsTr("Accounts") - visible: Maui.App.handleAccounts - icon.name: "list-add-user" - onTriggered: - { - if(root.accounts) - accounts.open() - } - } - - MenuSeparator - { - visible: _accountCombobox.visible - } - + MenuItem { text: qsTr("About") icon.name: "documentinfo" onTriggered: aboutDialog.open() } } } ] rightContent: ToolButton { id: searchBtn icon.name: "edit-find" icon.color: headBarFGColor onClicked: searchButtonClicked() icon.width: Maui.Style.iconSizes.medium icon.height: Maui.Style.iconSizes.medium } } property Maui.ToolBar mfootBar : Maui.ToolBar { id: _footBar visible: count position: ToolBar.Footer width: root.width height: implicitHeight } header: headBar.count && headBar.position === ToolBar.Header ? headBar : null footer: Column { id: _footer visible : children children: { if(headBar.position === ToolBar.Footer && headBar.count && footBar.count) return [footBar , headBar] else if(headBar.position === ToolBar.Footer && headBar.count) return [headBar] else if(footBar.count) return [footBar] else return [] } } Maui.AboutDialog { id: aboutDialog } Loader { id: _accountsDialogLoader source: Maui.App.handleAccounts ? "private/AccountsHelper.qml" : "" } Maui.Dialog { id: _notify property var cb : ({}) verticalAlignment: Qt.AlignTop defaultButtons: _notify.cb !== null rejectButton.visible: false onAccepted: { if(_notify.cb) { _notify.cb() _notify.close() } } page.padding: Maui.Style.space.medium footBar.background: null maxHeight: Math.max(Maui.Style.iconSizes.large + Maui.Style.space.huge, (_notifyLayout.implicitHeight)) + Maui.Style.space.big + footBar.height maxWidth: Kirigami.Settings.isMobile ? parent.width * 0.9 : Maui.Style.unit * 500 widthHint: 0.8 Timer { id: _notifyTimer onTriggered: { if(_mouseArea.containsPress || _mouseArea.containsMouse) return; _notify.close() } } onClosed: _notifyTimer.stop() GridLayout { anchors.fill: parent columns: 2 rows: 1 Item { Layout.fillHeight: true Layout.preferredWidth: Maui.Style.iconSizes.large + Maui.Style.space.big Layout.row: 1 Layout.column: 1 Kirigami.Icon { id: _notifyIcon width: Maui.Style.iconSizes.large height: width anchors.centerIn: parent fallback : "dialog-warning" } } Item { Layout.fillHeight: true Layout.fillWidth: true Layout.margins: Maui.Style.space.medium Layout.row: 1 Layout.column: 2 ColumnLayout { id: _notifyLayout anchors.centerIn: parent width: parent.width Label { id: _notifyTitle Layout.fillHeight: true Layout.fillWidth: true font.weight: Font.Bold font.bold: true font.pointSize:Maui.Style.fontSizes.big elide: Qt.ElideRight wrapMode: Text.NoWrap } Label { id: _notifyBody Layout.fillHeight: true Layout.fillWidth: true font.pointSize:Maui.Style.fontSizes.default elide: Qt.ElideRight wrapMode: Text.Wrap } } } } MouseArea { id: _mouseArea anchors.fill: parent hoverEnabled: true } function show(callback) { _notify.cb = callback || null _notifyTimer.start() _notify.open() } } Loader { id: dialogLoader } Component.onCompleted: { if(isAndroid && headBar.position === ToolBar.Footer) Maui.Android.statusbarColor(Kirigami.Theme.backgroundColor, true) if(!isMobile) { const rect = Maui.FM.loadSettings("GEOMETRY", "WINDOW", Qt.rect(root.x, root.y, root.width, root.height)) root.x = rect.x root.y = rect.y root.width = rect.width root.height = rect.height } } function notify(icon, title, body, callback, timeout, buttonText) { _notifyIcon.source = icon || "emblem-warning" _notifyTitle.text = title _notifyBody.text = body _notifyTimer.interval = timeout ? timeout : 2500 _notify.acceptButton.text = buttonText || qsTr ("Accept") _notify.show(callback) } } diff --git a/src/controls/GridBrowser.qml b/src/controls/GridBrowser.qml index b88f221..ab9fb01 100644 --- a/src/controls/GridBrowser.qml +++ b/src/controls/GridBrowser.qml @@ -1,103 +1,104 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.9 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami Maui.GridView { id: control - + Kirigami.Theme.colorSet: Kirigami.Theme.View + itemSize : Maui.Style.iconSizes.large * 2 property bool showEmblem : true property bool keepEmblemOverlay : false property string rightEmblem property string leftEmblem centerContent: false adaptContent: true property bool showPreviewThumbnails: true signal itemClicked(int index) signal itemDoubleClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) signal itemRightClicked(int index) delegate: Maui.GridBrowserDelegate { id: delegate folderSize: height * 0.5 height: control.cellHeight width: control.cellWidth padding: Maui.Style.space.small showTooltip: true showEmblem: control.showEmblem keepEmblemOverlay: control.keepEmblemOverlay showThumbnails: control.showPreviewThumbnails rightEmblem: control.rightEmblem leftEmblem: control.leftEmblem Connections { target: delegate onClicked: { control.currentIndex = index itemClicked(index) } onDoubleClicked: { control.currentIndex = index itemDoubleClicked(index) } onPressAndHold: { control.currentIndex = index control.itemRightClicked(index) } onRightClicked: { control.currentIndex = index control.itemRightClicked(index) } onRightEmblemClicked: { control.currentIndex = index control.rightEmblemClicked(index) } onLeftEmblemClicked: { control.currentIndex = index control.leftEmblemClicked(index) } } } } diff --git a/src/controls/GridView.qml b/src/controls/GridView.qml index 6d01cc8..a51bfdf 100644 --- a/src/controls/GridView.qml +++ b/src/controls/GridView.qml @@ -1,188 +1,188 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.9 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import QtQuick.Controls.impl 2.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami import QtGraphicalEffects 1.0 Kirigami.ScrollablePage { id: control property int itemSize: 0 property int itemWidth : itemSize property int itemHeight : itemSize onItemWidthChanged : gridView.size_ = itemWidth property alias cellWidth: gridView.cellWidth property alias cellHeight: gridView.cellHeight property alias model : gridView.model property alias delegate : gridView.delegate property alias contentY: gridView.contentY property alias currentIndex : gridView.currentIndex property alias count : gridView.count property alias cacheBuffer : gridView.cacheBuffer property alias topMargin: gridView.topMargin property alias bottomMargin: gridView.bottomMargin property alias rightMargin: gridView.rightMargin property alias leftMarging: gridView.leftMargin property alias holder : _holder property alias gridView : gridView property bool centerContent: false //deprecrated property bool adaptContent: true signal areaClicked(var mouse) signal areaRightClicked() signal keyPress(var event) spacing: Maui.Style.space.medium - Kirigami.Theme.backgroundColor: "transparent" + Kirigami.Theme.colorSet: Kirigami.Theme.View padding: 0 leftPadding: control.ScrollBar.visible ? padding : control.ScrollBar.width rightPadding: padding topPadding: padding bottomPadding: padding focus: true Behavior on cellWidth { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InQuad } } GridView { id: gridView //nasty trick property int size_ Component.onCompleted: { gridView.size_ = control.itemWidth } flow: GridView.FlowLeftToRight clip: true focus: true cellWidth: control.itemWidth cellHeight: control.itemHeight boundsBehavior: !Kirigami.Settings.isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds flickableDirection: Flickable.AutoFlickDirection snapMode: GridView.NoSnap highlightMoveDuration: 0 interactive: true onWidthChanged: adaptContent? control.adaptGrid() : undefined keyNavigationEnabled : true keyNavigationWraps : true Keys.onPressed: control.keyPress(event) Maui.Holder { id: _holder anchors.fill : parent } PinchArea { anchors.fill: parent z: -1 onPinchStarted: { console.log("pinch started") } onPinchUpdated: { } onPinchFinished: { console.log("pinch finished") resizeContent(pinch.scale) } MouseArea { anchors.fill: parent propagateComposedEvents: true acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: { control.forceActiveFocus() control.areaClicked(mouse) } onPressAndHold: control.areaRightClicked() // scrollGestureEnabled : false onWheel: { if (wheel.modifiers & Qt.ControlModifier) { if (wheel.angleDelta.y != 0) { var factor = 1 + wheel.angleDelta.y / 600; control.resizeContent(factor) } }else wheel.accepted = false } } } } function resizeContent(factor) { if(factor > 1) { gridView.size_ = gridView.size_ + 10 control.cellHeight = control.cellHeight + 10 } else { gridView.size_ = gridView.size_ - 10 control.cellHeight = control.cellHeight - 10 } if(adaptContent) control.adaptGrid() } function adaptGrid() { var amount = parseInt(gridView.width / (gridView.size_), 10) var leftSpace = parseInt(gridView.width - ( amount * (gridView.size_) ), 10) var size = parseInt((gridView.size_) + (parseInt(leftSpace/amount, 10)), 10) // size = size > gridView.size_? size : gridView.size_ control.cellWidth = size } } diff --git a/src/controls/ListBrowser.qml b/src/controls/ListBrowser.qml index 9d22a25..0d1a780 100644 --- a/src/controls/ListBrowser.qml +++ b/src/controls/ListBrowser.qml @@ -1,176 +1,176 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.10 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami Kirigami.ScrollablePage { id: control property int itemSize : Maui.Style.iconSizes.big property bool showEmblem : true property bool keepEmblemOverlay : false property string rightEmblem property string leftEmblem property bool showDetailsInfo : false property bool showPreviewThumbnails: true property alias model : _listView.model - property alias delegate : _listView.delegate - property alias section : _listView.section - property alias contentY: _listView.contentY - property alias currentIndex : _listView.currentIndex - property alias currentItem : _listView.currentItem - property alias count : _listView.count - property alias cacheBuffer : _listView.cacheBuffer - + property alias delegate : _listView.delegate + property alias section : _listView.section + property alias contentY: _listView.contentY + property alias currentIndex : _listView.currentIndex + property alias currentItem : _listView.currentItem + property alias count : _listView.count + property alias cacheBuffer : _listView.cacheBuffer + property alias topMargin: _listView.topMargin property alias bottomMargin: _listView.bottomMargin property alias rightMargin: _listView.rightMargin property alias leftMarging: _listView.leftMargin property alias listView: _listView - property alias holder : _holder + property alias holder : _holder signal itemClicked(int index) signal itemDoubleClicked(int index) signal itemRightClicked(int index) signal rightEmblemClicked(int index) signal leftEmblemClicked(int index) signal areaClicked(var mouse) signal areaRightClicked() - signal keyPress(var event) - - spacing: 0 - focus: true - - Kirigami.Theme.backgroundColor: "transparent" - padding: 0 - leftPadding: padding - rightPadding: padding - topPadding: padding - bottomPadding: padding - - Keys.enabled: false - - ListView + signal keyPress(var event) + + spacing: 0 + focus: true + padding: 0 + leftPadding: padding + rightPadding: padding + topPadding: padding + bottomPadding: padding + + Keys.enabled: false + Kirigami.Theme.colorSet: Kirigami.Theme.View + + ListView { - id: _listView + id: _listView focus: true clip: true spacing: Maui.Style.space.tiny snapMode: ListView.NoSnap - boundsBehavior: !Kirigami.Settings.isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds - + boundsBehavior: !Kirigami.Settings.isMobile? Flickable.StopAtBounds : + Flickable.OvershootBounds + interactive: Kirigami.Settings.isMobile highlightFollowsCurrentItem: true highlightMoveDuration: 0 keyNavigationEnabled : bool keyNavigationWraps : bool Keys.onPressed: control.keyPress(event) - - Maui.Holder - { - id: _holder - anchors.fill : parent - } + + Maui.Holder + { + id: _holder + anchors.fill : parent + } delegate: Maui.ListBrowserDelegate { id: delegate width: parent.width height: itemSize + Maui.Style.space.big leftPadding: Maui.Style.space.small rightPadding: Maui.Style.space.small padding: 0 showDetailsInfo: control.showDetailsInfo folderSize : itemSize showTooltip: true showEmblem: control.showEmblem keepEmblemOverlay : control.keepEmblemOverlay showThumbnails: showPreviewThumbnails rightEmblem: control.rightEmblem leftEmblem: control.leftEmblem Connections { target: delegate onClicked: { control.currentIndex = index control.itemClicked(index) } onDoubleClicked: { control.currentIndex = index control.itemDoubleClicked(index) } onPressAndHold: { control.currentIndex = index control.itemRightClicked(index) } onRightClicked: { control.currentIndex = index control.itemRightClicked(index) } onRightEmblemClicked: { control.currentIndex = index control.rightEmblemClicked(index) } onLeftEmblemClicked: { control.currentIndex = index control.leftEmblemClicked(index) } } } - + MouseArea { anchors.fill: parent z: -1 acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: { - control.forceActiveFocus() - control.areaClicked(mouse) - } + control.forceActiveFocus() + control.areaClicked(mouse) + } onPressAndHold: control.areaRightClicked() } } } diff --git a/src/controls/Page.qml b/src/controls/Page.qml index 4978e4b..c3dffe0 100644 --- a/src/controls/Page.qml +++ b/src/controls/Page.qml @@ -1,125 +1,131 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.10 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.mauikit 1.0 as Maui import org.kde.kirigami 2.7 as Kirigami import QtQuick.Layouts 1.3 Page { id: control focus: true leftPadding: control.padding rightPadding: control.padding topPadding: control.padding - bottomPadding: control.padding + + Kirigami.Theme.colorSet: Kirigami.Theme.View signal goBackTriggered(); signal goForwardTriggered(); + background: Rectangle + { + color: Kirigami.Theme.backgroundColor + } + property alias headBar : _headBar property alias footBar: _footBar property Maui.ToolBar mheadBar : Maui.ToolBar { id: _headBar visible: count > 1 width: control.width height: implicitHeight position: ToolBar.Header Component { id: _titleComponent Label { text: control.title elide : Text.ElideRight font.bold : false font.weight: Font.Bold color : Kirigami.Theme.textColor font.pointSize: Maui.Style.fontSizes.big horizontalAlignment : Text.AlignHCenter verticalAlignment : Text.AlignVCenter } } middleContent: Loader { Layout.fillWidth: sourceComponent === _titleComponent Layout.fillHeight: sourceComponent === _titleComponent sourceComponent: control.title ? _titleComponent : undefined } } property Maui.ToolBar mfootBar : Maui.ToolBar { id: _footBar visible: count position: ToolBar.Footer width: control.width height: implicitHeight } header: headBar.count && headBar.position === ToolBar.Header ? headBar : null footer: Column { id: _footer visible : children children: { if(headBar.position === ToolBar.Footer && headBar.count && footBar.count) return [footBar , headBar] else if(headBar.position === ToolBar.Footer && headBar.count) return [headBar] else if(footBar.count) return [footBar] else return [] } } Keys.onBackPressed: { control.goBackTriggered(); event.accepted = true } Shortcut { sequence: "Forward" onActivated: control.goForwardTriggered(); } Shortcut { sequence: StandardKey.Forward onActivated: control.goForwardTriggered(); } Shortcut { sequence: StandardKey.Back onActivated: control.goBackTriggered(); } } diff --git a/src/controls/labs/SelectionBar.qml b/src/controls/labs/SelectionBar.qml index 5f0de61..83ca591 100644 --- a/src/controls/labs/SelectionBar.qml +++ b/src/controls/labs/SelectionBar.qml @@ -1,433 +1,432 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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.10 import QtQuick.Controls 2.10 import QtQuick.Layouts 1.3 import org.kde.kirigami 2.7 as Kirigami import org.kde.mauikit 1.0 as Maui import QtGraphicalEffects 1.0 Item { id: control focus: true default property list actions Kirigami.Theme.inherit: false Kirigami.Theme.colorSet: Kirigami.Theme.Complementary readonly property int barHeight : Maui.Style.iconSizes.large + Maui.Style.space.medium readonly property alias uris: _private._uris readonly property alias items: _private._items property alias selectionList : selectionList property alias count : selectionList.count readonly property QtObject m_private : QtObject { id: _private property var _uris : [] property var _items : [] } property Component listDelegate: Maui.ItemDelegate { id: delegate height: Maui.Style.rowHeight * 1.5 width: parent.width Kirigami.Theme.backgroundColor: "transparent" Kirigami.Theme.textColor: control.Kirigami.Theme.textColor onClicked: control.itemClicked(index) onPressAndHold: control.itemPressAndHold(index) RowLayout { anchors.fill: parent Item { Layout.fillHeight: true Layout.preferredWidth: _badge.height + Maui.Style.space.small Maui.Badge { id: _badge anchors.centerIn: parent size: Maui.Style.iconSizes.small iconName: "list-remove" onClicked: control.removeAtIndex(index) } } Maui.ListItemTemplate { id: _template Layout.fillWidth: true Layout.fillHeight: true iconVisible: false labelsVisible: true label1.text: model.uri } } } /** * if singleSelection is set to true then only a single item is selected * at time, and replaced with a newe item appended **/ property bool singleSelection: false signal iconClicked() signal cleared() signal exitClicked() signal itemClicked(int index) signal itemPressAndHold(int index) signal itemAdded(var item) signal itemRemoved(var item) signal uriAdded(string uri) signal uriRemoved(string uri) signal clicked(var mouse) signal rightClicked(var mouse) implicitHeight: barHeight implicitWidth: _layout.implicitWidth + Maui.Style.space.big visible: control.count > 0 DropShadow { id: rectShadow anchors.fill: _listContainer cached: true horizontalOffset: 0 verticalOffset: 0 radius: 8.0 samples: 16 color: "#333" smooth: true source: _listContainer } Rectangle { id: _listContainer property bool showList : false height: showList ? Math.min(Math.min(400, control.parent.parent.height), selectionList.contentHeight) + control.height + Maui.Style.space.medium : 0 width: showList ? parent.width : 0 color: Qt.lighter(Kirigami.Theme.backgroundColor) radius: Maui.Style.radiusV focus: true y: ((height) * -1) + control.height x: 0 opacity: showList ? 1 : .97 Behavior on height { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InOutQuad } } Behavior on width { NumberAnimation { duration: Kirigami.Units.longDuration easing.type: Easing.InOutQuad } } Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration easing.type: Easing.InOutQuad } } ListView { id: selectionList anchors.fill: parent anchors.margins: Maui.Style.space.medium anchors.bottomMargin: control.height visible: _listContainer.height > 10 highlightFollowsCurrentItem: true highlightMoveDuration: 0 keyNavigationEnabled: true interactive: Kirigami.Settings.isMobile boundsBehavior: !Kirigami.Settings.isMobile? Flickable.StopAtBounds : Flickable.OvershootBounds orientation: ListView.Vertical clip: true focus: true spacing: Maui.Style.space.small ScrollBar.vertical: ScrollBar { policy: Qt.ScrollBarAsNeeded } model: ListModel{} delegate: control.listDelegate } } Rectangle { id: bg anchors.fill: parent color: Kirigami.Theme.backgroundColor radius: Maui.Style.radiusV MouseArea { anchors.fill: parent acceptedButtons: Qt.RightButton | Qt.LeftButton onClicked: { if(!Kirigami.Settings.isMobile && mouse.button === Qt.RightButton) control.rightClicked(mouse) else control.clicked(mouse) } onPressAndHold : { if(Kirigami.Settings.isMobile) control.rightClicked(mouse) } } } RowLayout { anchors.fill: parent ToolButton { icon.name: "dialog-close" Layout.fillHeight: true Layout.preferredWidth: height onClicked: control.exitClicked() Kirigami.Theme.colorSet: control.Kirigami.Theme.colorSet } Maui.ToolBar { id: _layout background: null Layout.fillHeight: true Layout.fillWidth: true - leftContent: [ - Maui.Badge + middleContent: [ + + // Kirigami.ActionToolBar + // { + // display: control.width > Kirigami.Units.gridUnit * 25 ? ToolButton.TextUnderIcon : ToolButton.IconOnly + // actions: control.actions + // Layout.fillWidth: true + // Layout.fillHeight: true + // }, + + Repeater + { + model: control.actions + + ToolButton + { + action: modelData + // display: control.width > Kirigami.Units.gridUnit * 25 ? ToolButton.TextUnderIcon : ToolButton.IconOnly + Kirigami.Theme.colorSet: control.Kirigami.Theme.colorSet + display: ToolButton.TextUnderIcon + onClicked : _listContainer.showList = false + + } + } + ] + } + + Maui.Badge { id: _counter Layout.fillHeight: true Layout.preferredWidth: height Layout.margins: Maui.Style.space.medium text: selectionList.count radius: Maui.Style.radiusV - Kirigami.Theme.backgroundColor: _listContainer.showList ? Kirigami.Theme.highlightColor : Qt.darker(bg.color) + Kirigami.Theme.backgroundColor: _listContainer.showList ? +Kirigami.Theme.highlightColor : Qt.darker(bg.color) border.color: "transparent" onClicked: { _listContainer.showList = !_listContainer.showList } Component.onCompleted: { _counter.item.font.pointSize= Maui.Style.fontSizes.big } SequentialAnimation { id: anim // PropertyAnimation // { // target: _counter // property: "opacity" // easing.type: Easing.InOutQuad // from: 0.5 // to: 1 // duration: 600 // } // PropertyAnimation { target: _counter property: "radius" easing.type: Easing.InOutQuad from: target.height to: Maui.Style.radiusV duration: 200 } } } - ] - - rightContent: [ - - // Kirigami.ActionToolBar - // { - // display: control.width > Kirigami.Units.gridUnit * 25 ? ToolButton.TextUnderIcon : ToolButton.IconOnly - // actions: control.actions - // Layout.fillWidth: true - // Layout.fillHeight: true - // }, - - Repeater - { - model: control.actions - - ToolButton - { - action: modelData - // display: control.width > Kirigami.Units.gridUnit * 25 ? ToolButton.TextUnderIcon : ToolButton.IconOnly - Kirigami.Theme.colorSet: control.Kirigami.Theme.colorSet - display: ToolButton.TextUnderIcon - onClicked : _listContainer.showList = false - - } - } - ] - } } Keys.onEscapePressed: { control.exitClicked(); event.accepted = true } Keys.onBackPressed: { control.exitClicked(); event.accepted = true } function clear() { _private._uris = [] _private._items = [] selectionList.model.clear() control.cleared() } function itemAt(index) { if(index < 0 || index > selectionList.count) return return selectionList.model.get(index) } function removeAtIndex(index) { if(index < 0) return const item = selectionList.model.get(index) const uri = item.uri if(contains(uri)) { _private._uris.splice(index, 1) _private._items.splice(index, 1) selectionList.model.remove(index) control.itemRemoved(item) control.uriRemoved(uri) } } function removeAtUri(uri) { removeAtIndex(indexOf(uri)) } function indexOf(uri) { return _private._uris.indexOf(uri) } function append(uri, item) { const index = _private._uris.indexOf(uri) if(index < 0) { if(control.singleSelection) clear() _private._items.push(item) _private._uris.push(uri) item.uri = uri selectionList.model.append(item) selectionList.positionViewAtEnd() selectionList.currentIndex = selectionList.count - 1 control.itemAdded(item) control.uriAdded(uri) }else { selectionList.currentIndex = index // notify(item.icon, qsTr("Item already selected!"), String("The item '%1' is already in the selection box").arg(item.label), null, 4000) } animate() } function animate() { anim.running = true } function getSelectedUrisString() { return String(""+_private._uris.join(",")) } function contains(uri) { return _private._uris.includes(uri) } } diff --git a/src/mauikit.cpp b/src/mauikit.cpp index a6e6191..6a1f8de 100644 --- a/src/mauikit.cpp +++ b/src/mauikit.cpp @@ -1,231 +1,231 @@ /* * Copyright 2018 Camilo Higuita * * This program 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, 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 Library 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. */ #include "mauikit.h" #include #include "handy.h" #include "mauimodel.h" #include "mauilist.h" #include "pathlist.h" #include "mauiapp.h" #include "fmstatic.h" #ifdef COMPONENT_ACCOUNTS #include "mauiaccounts.h" #endif #ifdef COMPONENT_FM #include "fm.h" #include "placeslist.h" #include "fmlist.h" #endif #ifdef COMPONENT_TAGGING #include "tagsmodel.h" #include "tagslist.h" #endif #ifdef COMPONENT_STORE #include "storemodel.h" #include "storelist.h" #endif #ifdef COMPONENT_EDITOR #include "documenthandler.h" #include "syntaxhighlighterutil.h" #include "kquicksyntaxhighlighter/kquicksyntaxhighlighter.h" #endif #ifdef Q_OS_ANDROID #include "mauiandroid.h" #elif defined Q_OS_LINUX #include "mauikde.h" #endif #if defined MAUIKIT_STYLE #include #include #endif QUrl MauiKit::componentUrl(const QString &fileName) const { #ifdef MAUI_APP return QUrl(QStringLiteral("qrc:/maui/kit/") + fileName); #else return QUrl(resolveFileUrl(fileName)); #endif } void MauiKit::registerTypes(const char *uri) { Q_ASSERT(uri == QLatin1String("org.kde.mauikit")); qmlRegisterSingletonType(componentUrl(QStringLiteral("Style.qml")), uri, 1, 0, "Style"); qmlRegisterType(componentUrl(QStringLiteral("ToolBar.qml")), uri, 1, 0, "ToolBar"); qmlRegisterType(componentUrl(QStringLiteral("ApplicationWindow.qml")), uri, 1, 0, "ApplicationWindow"); qmlRegisterType(componentUrl(QStringLiteral("Page.qml")), uri, 1, 0, "Page"); qmlRegisterType(componentUrl(QStringLiteral("ShareDialog.qml")), uri, 1, 0, "ShareDialog"); qmlRegisterType(componentUrl(QStringLiteral("PieButton.qml")), uri, 1, 0, "PieButton"); qmlRegisterType(componentUrl(QStringLiteral("SideBar.qml")), uri, 1, 0, "SideBar"); qmlRegisterType(componentUrl(QStringLiteral("AbstractSideBar.qml")), uri, 1, 0, "AbstractSideBar"); qmlRegisterType(componentUrl(QStringLiteral("Holder.qml")), uri, 1, 0, "Holder"); qmlRegisterType(componentUrl(QStringLiteral("GlobalDrawer.qml")), uri, 1, 0, "GlobalDrawer"); qmlRegisterType(componentUrl(QStringLiteral("ListDelegate.qml")), uri, 1, 0, "ListDelegate"); qmlRegisterType(componentUrl(QStringLiteral("ListBrowserDelegate.qml")), uri, 1, 0, "ListBrowserDelegate"); qmlRegisterType(componentUrl(QStringLiteral("SwipeItemDelegate.qml")), uri, 1, 0, "SwipeItemDelegate"); qmlRegisterType(componentUrl(QStringLiteral("SwipeBrowserDelegate.qml")), uri, 1, 0, "SwipeBrowserDelegate"); qmlRegisterType(componentUrl(QStringLiteral("ItemDelegate.qml")), uri, 1, 0, "ItemDelegate"); qmlRegisterType(componentUrl(QStringLiteral("GridBrowserDelegate.qml")), uri, 1, 0, "GridBrowserDelegate"); qmlRegisterType(componentUrl(QStringLiteral("SelectionBar.qml")), uri, 1, 0, "SelectionBar"); qmlRegisterType(componentUrl(QStringLiteral("LabelDelegate.qml")), uri, 1, 0, "LabelDelegate"); qmlRegisterType(componentUrl(QStringLiteral("NewDialog.qml")), uri, 1, 0, "NewDialog"); qmlRegisterType(componentUrl(QStringLiteral("Dialog.qml")), uri, 1, 0, "Dialog"); qmlRegisterType(componentUrl(QStringLiteral("AboutDialog.qml")), uri, 1, 0, "AboutDialog"); qmlRegisterType(componentUrl(QStringLiteral("Popup.qml")), uri, 1, 0, "Popup"); qmlRegisterType(componentUrl(QStringLiteral("TextField.qml")), uri, 1, 0, "TextField"); qmlRegisterType(componentUrl(QStringLiteral("Badge.qml")), uri, 1, 0, "Badge"); qmlRegisterType(componentUrl(QStringLiteral("GridView.qml")), uri, 1, 0, "GridView"); qmlRegisterType(componentUrl(QStringLiteral("ColorsBar.qml")), uri, 1, 0, "ColorsBar"); qmlRegisterType(componentUrl(QStringLiteral("ImageViewer.qml")), uri, 1, 0, "ImageViewer"); qmlRegisterType(componentUrl(QStringLiteral("TabBar.qml")), uri, 1, 0, "TabBar"); qmlRegisterType(componentUrl(QStringLiteral("TabButton.qml")), uri, 1, 0, "TabButton"); qmlRegisterType(componentUrl(QStringLiteral("ActionGroup.qml")), uri, 1, 0, "ActionGroup"); qmlRegisterType(componentUrl(QStringLiteral("ActionSideBar.qml")), uri, 1, 0, "ActionSideBar"); qmlRegisterType(componentUrl(QStringLiteral("ToolActions.qml")), uri, 1, 0, "ToolActions"); qmlRegisterType(componentUrl(QStringLiteral("ToolButtonMenu.qml")), uri, 1, 0, "ToolButtonMenu"); qmlRegisterType(componentUrl(QStringLiteral("ListItemTemplate.qml")), uri, 1, 0, "ListItemTemplate"); qmlRegisterType(componentUrl(QStringLiteral("FloatingButton.qml")), uri, 1, 0, "FloatingButton"); qmlRegisterType(componentUrl(QStringLiteral("PathBar.qml")), uri, 1, 0, "PathBar"); qmlRegisterType(uri, 1, 0, "PathList"); /** 1.1 **/ qmlRegisterType(componentUrl(QStringLiteral("labs/SelectionBar.qml")), uri, 1, 1, "SelectionBar"); /** STORE CONTROLS, MODELS AND INTERFACES **/ #ifdef COMPONENT_STORE qmlRegisterType("StoreList", 1, 0, "StoreList"); qmlRegisterType("StoreModel", 1, 0, "StoreModel"); qmlRegisterType(componentUrl(QStringLiteral("private/StoreDelegate.qml")), uri, 1, 0, "StoreDelegate"); qmlRegisterType(componentUrl(QStringLiteral("Store.qml")), uri, 1, 0, "Store"); #endif /** BROWSING CONTROLS **/ qmlRegisterType(componentUrl(QStringLiteral("ListBrowser.qml")), uri, 1, 0, "ListBrowser"); qmlRegisterType(componentUrl(QStringLiteral("GridBrowser.qml")), uri, 1, 0, "GridBrowser"); /** FM CONTROLS, MODELS AND INTERFACES **/ #ifdef COMPONENT_FM qmlRegisterType(uri, 1, 0, "PlacesList"); qmlRegisterType(uri, 1, 0, "FMList"); qmlRegisterSingletonType(uri, 1, 0, "FM", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new FMStatic; }); // qmlRegisterSingletonType(componentUrl(QStringLiteral("private/FileBrowser.qml")), uri, 1, 0, "FileMenu"); qmlRegisterType(componentUrl(QStringLiteral("FileBrowser.qml")), uri, 1, 0, "FileBrowser"); qmlRegisterType(componentUrl(QStringLiteral("PlacesSidebar.qml")), uri, 1, 0, "PlacesSidebar"); qmlRegisterType(componentUrl(QStringLiteral("PlacesListBrowser.qml")), uri, 1, 0, "PlacesListBrowser"); qmlRegisterType(componentUrl(QStringLiteral("FilePreviewer.qml")), uri, 1, 0, "FilePreviewer"); qmlRegisterType(componentUrl(QStringLiteral("FileDialog.qml")), uri, 1, 0, "FileDialog"); #endif #ifdef COMPONENT_EDITOR /** EDITOR CONTROLS **/ qmlRegisterType(uri, 1, 0, "DocumentHandler"); qmlRegisterType(); qmlRegisterType(componentUrl(QStringLiteral("Editor.qml")), uri, 1, 0, "Editor"); qmlRegisterType(componentUrl(QStringLiteral("private/DocumentPreview.qml")), uri, 1, 0, "DocumentPreview"); qmlRegisterType("org.kde.kquicksyntaxhighlighter", 0, 1, "KQuickSyntaxHighlighter"); -#endif +#endif /** PLATFORMS SPECIFIC CONTROLS **/ #ifdef Q_OS_ANDROID qmlRegisterSingletonType(uri, 1, 0, "Android", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new MAUIAndroid; }); #elif defined Q_OS_LINUX qmlRegisterType(componentUrl(QStringLiteral("Terminal.qml")), uri, 1, 0, "Terminal"); qmlRegisterSingletonType(uri, 1, 0, "KDE", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new MAUIKDE; }); #elif defined Q_OS_WIN32 //here window platform integration interfaces #endif /** DATA MODELING TEMPLATED INTERFACES **/ qmlRegisterType(); //ABSTRACT BASE LIST qmlRegisterType(uri, 1, 0, "BaseModel"); //BASE MODEL /** TAGGING INTERFACES AND MODELS **/ qmlRegisterType("TagsList", 1, 0, "TagsList"); qmlRegisterType("TagsModel", 1, 0, "TagsModel"); qmlRegisterType(componentUrl(QStringLiteral("private/TagList.qml")), uri, 1, 0, "TagList"); qmlRegisterType(componentUrl(QStringLiteral("TagsBar.qml")), uri, 1, 0, "TagsBar"); qmlRegisterType(componentUrl(QStringLiteral("TagsDialog.qml")), uri, 1, 0, "TagsDialog"); /** MAUI APPLICATION SPECIFIC PROPS **/ #ifdef COMPONENT_ACCOUNTS qmlRegisterType(); qmlRegisterType(componentUrl(QStringLiteral("SyncDialog.qml")), uri, 1, 0, "SyncDialog"); //to be rename to accountsDialog #endif qmlRegisterUncreatableType(uri, 1, 0, "App", "Cannot be created App"); /** HELPERS **/ qmlRegisterSingletonType(uri, 1, 0, "Handy", [](QQmlEngine *engine, QJSEngine *scriptEngine) -> QObject* { Q_UNUSED(engine) Q_UNUSED(scriptEngine) return new Handy; }); #if defined MAUIKIT_STYLE this->initResources(); #endif qmlProtectModule(uri, 1); } void MauiKit::initResources() { #if defined QICON_H && defined QQUICKSTYLE_H Q_INIT_RESOURCE(mauikit); Q_INIT_RESOURCE(icons); Q_INIT_RESOURCE(style); QIcon::setThemeSearchPaths({":/icons/luv-icon-theme"}); QIcon::setThemeName("Luv"); QQuickStyle::setStyle(":/style"); #endif } //#include "moc_mauikit.cpp" diff --git a/src/utils/mauiapp.cpp b/src/utils/mauiapp.cpp index ee7739c..6642773 100644 --- a/src/utils/mauiapp.cpp +++ b/src/utils/mauiapp.cpp @@ -1,181 +1,185 @@ /* * * Copyright (C) 2019 camilo * * 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 3 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, see . */ #include "mauiapp.h" #include "utils.h" #include #include "fmh.h" #include "handy.h" #ifdef COMPONENT_ACCOUNTS #include "mauiaccounts.h" #endif MauiApp::MauiApp(QObject *parent) : QObject(parent) #ifdef COMPONENT_ACCOUNTS , m_accounts(MauiAccounts::instance(this)) #else , m_accounts(nullptr) #endif {} MauiApp::~MauiApp() {} MauiApp * MauiApp::m_instance = nullptr; MauiApp * MauiApp::instance() { if(MauiApp::m_instance == nullptr) MauiApp::m_instance = new MauiApp(); return MauiApp::m_instance; } QString MauiApp::getName() { - return Handy::appInfo().value("").toString(); + return +Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::NAME]).toString(); } QString MauiApp::getVersion() { - return Handy::appInfo().value("").toString(); + return +Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::VERSION]).toString(); } QString MauiApp::getOrg() { - return Handy::appInfo().value("").toString(); + return +Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::ORG]).toString(); } QString MauiApp::getDomain() { - return Handy::appInfo().value("").toString(); + return +Handy::appInfo().value(FMH::MODEL_NAME[FMH::MODEL_KEY::DOMAIN_M]).toString(); } QString MauiApp::getMauikitVersion() { return Handy::appInfo().value("mauikit_version").toString(); } QString MauiApp::getQtVersion() { return Handy::appInfo().value("qt_version").toString(); } QString MauiApp::getDescription() const { return description; } void MauiApp::setDescription(const QString &value) { if(description == value) return; description = value; emit this->descriptionChanged(description); } QString MauiApp::getIconName() const { return iconName; } void MauiApp::setIconName(const QString &value) { if(iconName == value) return; iconName = value; emit this->iconNameChanged(iconName); } QString MauiApp::getWebPage() const { return webPage; } void MauiApp::setWebPage(const QString &value) { if(webPage == value) return; webPage = value; emit this->webPageChanged(webPage); } QString MauiApp::getDonationPage() const { return donationPage; } void MauiApp::setDonationPage(const QString &value) { if(donationPage == value) return; donationPage = value; emit this->donationPageChanged(donationPage); } QString MauiApp::getReportPage() const { return reportPage; } void MauiApp::setReportPage(const QString &value) { if(reportPage == value) return; reportPage = value; emit this->reportPageChanged(reportPage); } bool MauiApp::getHandleAccounts() const { return this->handleAccounts; } void MauiApp::setHandleAccounts(const bool &value) { #ifdef COMPONENT_ACCOUNTS if(this->handleAccounts == value) return; this->handleAccounts = value; emit this->handleAccountsChanged(); #endif } #ifdef COMPONENT_ACCOUNTS MauiAccounts * MauiApp::getAccounts() const { return this->m_accounts; } #endif MauiApp * MauiApp::qmlAttachedProperties(QObject* object) { if(MauiApp::m_instance == nullptr) MauiApp::m_instance = new MauiApp(object); return MauiApp::m_instance; }